mail[Wesnoth-commits] r25373 - in /trunk/data/tools: wesnoth/wmltools.py wmlmove


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by esr on March 31, 2008 - 13:17:
Author: esr
Date: Mon Mar 31 13:17:00 2008
New Revision: 25373

URL: http://svn.gna.org/viewcvs/wesnoth?rev=25373&view=rev
Log:
Define a function for popping to the top-level dist directory.

Modified:
    trunk/data/tools/wesnoth/wmltools.py
    trunk/data/tools/wmlmove

Modified: trunk/data/tools/wesnoth/wmltools.py
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/wesnoth/wmltools.py?rev=25373&r1=25372&r2=25373&view=diff
==============================================================================
--- trunk/data/tools/wesnoth/wmltools.py (original)
+++ trunk/data/tools/wesnoth/wmltools.py Mon Mar 31 13:17:00 2008
@@ -7,6 +7,20 @@
 
 resource_extensions = ("png", "jpg", "ogg", "wav", "map", "mask")
 image_reference = r"[A-Za-z0-9{}.][A-Za-z0-9_/+{}.-]*\.(png|jpg)(?=(~.*)?)"
+
+def pop_to_top(whoami):
+    "Pop upward to the top-level directory."
+    upwards = os.getcwd().split(os.sep)
+    upwards.reverse()
+    for pathpart in upwards:
+        if pathpart == "wesnoth":
+            break
+        else:
+            os.chdir("..")
+    else:
+        sys.stderr.write(whoami + ": must be run from within a Battle "
+                         "for Wesnoth source tree.\n")
+        sys.exit(1)
 
 def string_strip(value):
     "String-strip the value"

Modified: trunk/data/tools/wmlmove
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/wmlmove?rev=25373&r1=25372&r2=25373&view=diff
==============================================================================
--- trunk/data/tools/wmlmove (original)
+++ trunk/data/tools/wmlmove Mon Mar 31 13:17:00 2008
@@ -96,18 +96,7 @@
             else:
                 dst = arguments.pop()
 
-    # First, pop upward to the top-level directory.
-    upwards = os.getcwd().split(os.sep)
-    upwards.reverse()
-    for pathpart in upwards:
-        if pathpart == "wesnoth":
-            break
-        else:
-            os.chdir("..")
-    else:
-        sys.stderr.write("wmlmove: must be run from within a Battle "
-                         "for Wesnoth source tree.\n")
-        sys.exit(1)
+    pop_to_top("wmlmove")
 
     if listspaces:
         print "\n".join(map(os.path.basename, scopelist()))




Related Messages


Powered by MHonArc, Updated Mon Mar 31 15:02:37 2008