diff --git a/src/Mod/Start/StartPage/LoadCustom.py b/src/Mod/Start/StartPage/LoadCustom.py index 2cdaa1e0e6..dbd1aa396e 100644 --- a/src/Mod/Start/StartPage/LoadCustom.py +++ b/src/Mod/Start/StartPage/LoadCustom.py @@ -24,10 +24,7 @@ import sys import FreeCAD import FreeCADGui -if sys.version_info.major < 3: - from urllib import unquote -else: - from urllib.parse import unquote +from urllib.parse import unquote # filename will be given before this script is run diff --git a/src/Mod/Start/StartPage/StartPage.py b/src/Mod/Start/StartPage/StartPage.py index 74466276ce..0c73ebb64f 100644 --- a/src/Mod/Start/StartPage/StartPage.py +++ b/src/Mod/Start/StartPage/StartPage.py @@ -24,7 +24,6 @@ # contains the html code of the start page. # Note: It is built only once per FreeCAD session for now... -import six import sys import os import tempfile @@ -46,16 +45,6 @@ tempfolder = None # store icons inside a subfolder in temp dir defaulticon = None # store a default icon for problematic file types -def encode(text): - - "make sure we are always working with unicode in python2" - - if six.PY2: - if not isinstance(text,six.text_type): - return text.decode("utf8") - return text - - def gethexcolor(color): "returns a color hex value #000000" @@ -245,9 +234,9 @@ def buildCard(filename,method,arg=None): """builds an html
  • element representing a file. method is a script + a keyword, for ex. url.py?key=""" - result = encode("") + result = ("") if os.path.exists(filename) and isOpenableByFreeCAD(filename): - basename = encode(os.path.basename(filename)) + basename = os.path.basename(filename) if not arg: arg = basename finfo = getInfo(filename) @@ -255,17 +244,17 @@ def buildCard(filename,method,arg=None): image = finfo[0] size = finfo[1] author = finfo[2] - infostring = encode(TranslationTexts.T_CREATIONDATE+": "+finfo[3]+"\n") - infostring += encode(TranslationTexts.T_LASTMODIFIED+": "+finfo[4]) + infostring = TranslationTexts.T_CREATIONDATE+": "+finfo[3] + "\n" + infostring += TranslationTexts.T_LASTMODIFIED+": "+finfo[4] if finfo[5]: - infostring += "\n\n" + encode(finfo[5]) + infostring += "\n\n" + finfo[5] if size: result += '
  • ' result += '' - result += ''+encode(basename)+'' + result += ''+basename+'' result += '
    ' - result += '

    '+encode(basename)+'

    ' - result += '

    '+encode(author)+'

    ' + result += '

    '+basename+'

    ' + result += '

    '+author+'

    ' result += '

    '+size+'

    ' result += '
    ' result += '
    ' @@ -309,7 +298,6 @@ def handle(): CSS = f.read() HTML = HTML.replace("JS",JS) HTML = HTML.replace("CSS",CSS) - HTML = encode(HTML) # set the language @@ -340,11 +328,11 @@ def handle(): if res: f = QtCore.QFile(path) if f.open(QtCore.QIODevice.ReadOnly | QtCore.QFile.Text): - ALTCSS = encode(QtCore.QTextStream(f).readAll()) + ALTCSS = QtCore.QTextStream(f).readAll() HTML = HTML.replace("","") else: with open(path, 'r') as f: - ALTCSS = encode(f.read()) + ALTCSS = f.read() HTML = HTML.replace("","") # turn tips off if needed @@ -355,14 +343,14 @@ def handle(): # get FreeCAD version v = FreeCAD.Version() - VERSIONSTRING = encode(TranslationTexts.T_VERSION + " " + v[0] + "." + v[1] + " " + TranslationTexts.T_BUILD + " " + v[2]) + VERSIONSTRING = TranslationTexts.T_VERSION + " " + v[0] + "." + v[1] + " " + TranslationTexts.T_BUILD + " " + v[2] HTML = HTML.replace("VERSIONSTRING",VERSIONSTRING) # translate texts texts = [t for t in dir(TranslationTexts) if t.startswith("T_")] for text in texts: - HTML = HTML.replace(text,encode(getattr(TranslationTexts,text))) + HTML = HTML.replace(text,getattr(TranslationTexts,text)) # build a "create new" icon with the FreeCAD background color gradient @@ -385,43 +373,43 @@ def handle(): rf = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/RecentFiles") rfcount = rf.GetInt("RecentFiles",0) - SECTION_RECENTFILES = encode("

    "+TranslationTexts.T_RECENTFILES+"

    ") + SECTION_RECENTFILES = "

    "+TranslationTexts.T_RECENTFILES+"

    " SECTION_RECENTFILES += "' HTML = HTML.replace("SECTION_RECENTFILES",SECTION_RECENTFILES) # build SECTION_EXAMPLES - SECTION_EXAMPLES = encode("") + SECTION_EXAMPLES = "" if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start").GetBool("ShowExamples",True): - SECTION_EXAMPLES = encode("

    "+TranslationTexts.T_EXAMPLES+"

    ") + SECTION_EXAMPLES = "

    "+TranslationTexts.T_EXAMPLES+"

    " SECTION_EXAMPLES += "" HTML = HTML.replace("SECTION_EXAMPLES",SECTION_EXAMPLES) # build SECTION_CUSTOM - SECTION_CUSTOM = encode("") + SECTION_CUSTOM = "" cfolders = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Start").GetString("ShowCustomFolder","") if cfolders: dn = 0 @@ -431,11 +419,11 @@ def handle(): if not os.path.exists(cfolder): FreeCAD.Console.PrintWarning("Custom folder not found: %s" % cfolder) else: - SECTION_CUSTOM += encode("

    "+os.path.basename(os.path.normpath(cfolder))+"

    ") + SECTION_CUSTOM += "

    "+os.path.basename(os.path.normpath(cfolder))+"

    " SECTION_CUSTOM += "" # hide the custom section tooltip if custom section is set (users know about it if they enabled it) HTML = HTML.replace("id=\"customtip\" class","id=\"customtip\" style=\"display:none;\" class") @@ -514,7 +502,6 @@ def handle(): UL_WORKBENCHES += ''+wn.replace("ReverseEngineering","ReverseEng")+'' UL_WORKBENCHES += '
  • ' UL_WORKBENCHES += '' - HTML = HTML.replace("UL_WORKBENCHES",encode(UL_WORKBENCHES)) # Detect additional addons that are not a workbench @@ -554,7 +541,7 @@ def handle(): SHADOW = "#888888" if QtGui.QColor(BASECOLOR).valueF() < 0.5: # dark page - we need to make darker shadows SHADOW = "#000000" - FONTFAMILY = encode(p.GetString("FontFamily","Arial,Helvetica,sans")) + FONTFAMILY = p.GetString("FontFamily","Arial,Helvetica,sans") if not FONTFAMILY: FONTFAMILY = "Arial,Helvetica,sans" FONTSIZE = p.GetInt("FontSize",13) diff --git a/src/Mod/Start/StartPage/TranslationTexts.py b/src/Mod/Start/StartPage/TranslationTexts.py index edb0d98f13..ab4fbd3644 100644 --- a/src/Mod/Start/StartPage/TranslationTexts.py +++ b/src/Mod/Start/StartPage/TranslationTexts.py @@ -33,9 +33,6 @@ def translate(context,text): except AttributeError: u = QtGui.QApplication.translate(context, text, None) - if sys.version_info.major < 3: - u = u.encode("utf8") - return u.replace(chr(39), "’") T_TITLE = translate("StartPage", "Start")