← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/fix-bug-582561 into lp:widelands

 

David Allwicher has proposed merging lp:~widelands-dev/widelands/fix-bug-582561 into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)


Makes buildcat.py and buildlocale.py executable inside Xcode with installation of msgfmt, msgmerge and xgettext in /opt/local (macports default path)

Adds a strange preference towards the opt/local installation path.

Removes os.popen because it is deprecated.
-- 
https://code.launchpad.net/~widelands-dev/widelands/fix-bug-582561/+merge/31001
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/fix-bug-582561 into lp:widelands.
=== modified file 'utils/buildcat.py'
--- utils/buildcat.py	2010-04-16 22:48:20 +0000
+++ utils/buildcat.py	2010-07-26 22:18:48 +0000
@@ -21,6 +21,7 @@
 import re
 import string
 import sys
+import subprocess
 sys.path.append('build/scons-tools')
 from detect_revision import detect_revision
 from time import strftime,gmtime
@@ -93,7 +94,17 @@
 RE_NO_DOTFILE="^[^\.]"		# Matches everything but dot-leaded filenames.
 RE_ISO639="^[a-z]{2,2}(_[A-Z]{2,2})?$"	# Matches ISO-639 language codes
                                         # structure. Note that this doesn't
-                                        # garantees correctness of code.
+					# garantees correctness of code.
+
+#Mac OS X hack to support XCode and macports default path					
+MACPORTSPATH = "/opt/local/bin/"
+MSGMERGE = "msgmerge"
+if os.path.isfile(MACPORTSPATH + MSGMERGE) and os.access(MACPORTSPATH + MSGMERGE, os.X_OK):
+    MSGMERGE = MACPORTSPATH + MSGMERGE
+	
+XGETTEXT = "xgettext"
+if os.path.isfile(MACPORTSPATH + XGETTEXT) and os.access(MACPORTSPATH + XGETTEXT, os.X_OK):
+    XGETTEXT = MACPORTSPATH + XGETTEXT
 
 # Options passed to common external programs
 XGETTEXTOPTS ="-k_ --from-code=UTF-8"
@@ -182,8 +193,8 @@
 ##############################################################################
 def do_compile_src( potfile, srcfiles ):
         # call xgettext and supply source filenames via stdin
-        gettext_input = os.popen("xgettext %s --files-from=- --output=%s" % \
-                (XGETTEXTOPTS, potfile), "w")
+        gettext_input = subprocess.Popen(XGETTEXT + " %s --files-from=- --output=%s" % \
+                (XGETTEXTOPTS, potfile), shell=True, stdin=subprocess.PIPE).stdin
         try:
             for one_pattern in srcfiles:
                 # 'normpath' is necessary for windows ('/' vs. '\')
@@ -299,7 +310,7 @@
 #
 ##############################################################################
 def do_buildpo(po, pot, dst):
-        rv = os.system("msgmerge %s %s %s -o %s" % (MSGMERGEOPTS, po, pot, dst))
+        rv = os.system(MSGMERGE + " %s %s %s -o %s" % (MSGMERGEOPTS, po, pot, dst))
         if rv:
             raise RuntimeError("msgmerge exited with errorcode %i!" % rv)
         return rv

=== modified file 'utils/buildlocale.py'
--- utils/buildlocale.py	2010-03-24 12:26:58 +0000
+++ utils/buildlocale.py	2010-07-26 22:18:48 +0000
@@ -19,6 +19,12 @@
 
 import buildcat
 
+#Mac OS X hack to support XCode and macports default path					
+MACPORTSPATH = "/opt/local/bin/"
+MSGFMT = "msgfmt"
+if os.path.isfile(MACPORTSPATH + MSGFMT) and os.access(MACPORTSPATH + MSGFMT, os.X_OK):
+    MSGFMT = MACPORTSPATH + MSGFMT
+	
 ##############################################################################
 #
 # Merge & compile every .po file found in 'po/lang' directory
@@ -36,7 +42,7 @@
 
             if not buildcat.do_buildpo(po, pot, "tmp.po"):
                 buildcat.do_makedirs(os.path.dirname(mo))
-                err_code = os.system("msgfmt -o %s tmp.po" % mo)
+                err_code = os.system(MSGFMT + " -o %s tmp.po" % mo)
                 if not err_code: # Success
                     os.remove("tmp.po")
                     sys.stdout.write(".")


Follow ups