[AddonManager] separate the Macro class

Separate the Macro class of the AddonManager into addonmanager_macro.py
to prepare for future support for dependent files for macros from the
git repository.
This commit is contained in:
Gaël Écorchard
2018-08-29 22:35:27 +02:00
committed by Yorik van Havre
parent cef825c567
commit bac786a8ea
3 changed files with 194 additions and 192 deletions

View File

@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
import os
import sys
if sys.version_info.major < 3:
import urllib2
else:
import urllib.request as urllib2
from PySide import QtGui
# Qt tanslation handling
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def translate(context, text, disambig=None):
return QtGui.QApplication.translate(context, text, disambig)
ssl_ctx = None
try:
import ssl
except ImportError:
pass
else:
try:
ssl_ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
except AttributeError:
pass
def urlopen(url):
"""Opens an url with urllib2"""
if ssl_ctx:
u = urllib2.urlopen(url, context=ssl_ctx)
else:
u = urllib2.urlopen(url)
return u