Files
create/src/Mod/AddonManager/addonmanager_utilities.py
Gaël Écorchard bac786a8ea [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.
2018-10-25 11:04:43 -03:00

40 lines
881 B
Python

# -*- 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