From fa00718c23c17bb17c59494ac0c9ab0c0d16df8b Mon Sep 17 00:00:00 2001 From: Mark Ganson TheMarkster <39143564+mwganson@users.noreply.github.com> Date: Tue, 11 Sep 2018 13:11:43 -0500 Subject: [PATCH] fix python3 issues * fix attempts to remove readonly temp folder in windows, which was preventing addon manager window from closing * cleanup (unescape) macros manually if HTMLParser().unescape() fails * replace tabs in macros with 4 spaces --- src/Mod/AddonManager/AddonManager.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Mod/AddonManager/AddonManager.py b/src/Mod/AddonManager/AddonManager.py index 4a6516e112..c07a078986 100644 --- a/src/Mod/AddonManager/AddonManager.py +++ b/src/Mod/AddonManager/AddonManager.py @@ -220,7 +220,7 @@ class AddonsInstaller(QtGui.QDialog): if not thread.isFinished(): oktoclose = False if oktoclose: - shutil.rmtree(self.macro_repo_dir) + shutil.rmtree(self.macro_repo_dir,onerror=self.remove_readonly) QtGui.QDialog.reject(self) def retranslateUi(self): @@ -687,7 +687,12 @@ class Macro(object): code = code.encode('utf8') code = code.replace('\xc2\xa0', ' ') except: - FreeCAD.Console.PrintWarning(translate("AddonsInstaller", "Unable to clean macro code: ") + code + '\n') + #HTMLParser().unescape() didn't work, so try manually + try: + code = code.replace('>','>').replace('<','<').replace(' ','').replace('&','&').replace('\xc2\xa0', ' ') + code = code.replace('\t',' ')#some macros in the wiki have tabs interspersed, this might fix some of them + except: + FreeCAD.Console.PrintWarning(translate("AddonsInstaller", "Unable to clean macro code: ") + code + '\n') desc = re.findall("