From b8e1cc6dd717b3be0502240841dce8746fd049aa Mon Sep 17 00:00:00 2001 From: Laurent Monin Date: Mon, 21 Jan 2013 16:09:17 +0100 Subject: [PATCH] Handle _translate() case for new pyuic versions The code in setup.py replaces QtGui.QApplication.translate() with _(), but it does not handle _translate(), this patch is fixing that. --- setup.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 3ff8c7aae..b540ece4e 100755 --- a/setup.py +++ b/setup.py @@ -250,9 +250,14 @@ class picard_build_ui(Command): def run(self): from PyQt4 import uic - _translate_re = re.compile( - r'QtGui\.QApplication.translate\(.*?, (.*?), None, ' - r'QtGui\.QApplication\.UnicodeUTF8\)') + _translate_re = ( + re.compile( + r'QtGui\.QApplication.translate\(.*?, (.*?), None, ' + r'QtGui\.QApplication\.UnicodeUTF8\)'), + re.compile( + r'\b_translate\(.*?, (.*?), None\)') + ) + for uifile in glob.glob("ui/*.ui"): pyfile = "ui_%s.py" % os.path.splitext(os.path.basename(uifile))[0] pyfile = os.path.join("picard", "ui", pyfile) @@ -260,7 +265,8 @@ class picard_build_ui(Command): log.info("compiling %s -> %s", uifile, pyfile) tmp = StringIO() uic.compileUi(uifile, tmp) - source = _translate_re.sub(r'_(\1)', tmp.getvalue()) + for r in list(_translate_re): + source = r.sub(r'_(\1)', tmp.getvalue()) f = open(pyfile, "w") f.write(source) f.close()