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
This commit is contained in:
Mark Ganson TheMarkster
2018-09-11 13:11:43 -05:00
committed by wmayer
parent 506f50788b
commit 68fb70ff3c

View File

@@ -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('&gt;','>').replace('&lt;','<').replace('&#160;','').replace('&amp;','&').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("<td class=\"ctEven left macro-description\">(.*?)<\/td>", p.replace('\n', ' '))
if desc:
desc = desc[0]