Author: elias
Date: Wed Apr  9 21:38:40 2008
New Revision: 25715

URL: http://svn.gna.org/viewcvs/wesnoth?rev=25715&view=rev
Log:
Added option to specify the Wesnoth datadir to wmlunits, and fixed a bug where 
it was assumed to run from the wesnoth dir.

Modified:
    trunk/data/tools/wmlunits

Modified: trunk/data/tools/wmlunits
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/wmlunits?rev=25715&r1=25714&r2=25715&view=diff
==============================================================================
--- trunk/data/tools/wmlunits (original)
+++ trunk/data/tools/wmlunits Wed Apr  9 21:38:40 2008
@@ -65,7 +65,7 @@
             if c == "mainline": bases = ["core/images"]
            else: bases = ["campaigns/%s/images" % c, 
"campaigns/%s/images/units" % c, "core/images"]
            for base in bases:
-                ipath = os.path.join("data/%s" % base, i)
+                ipath = os.path.join(os.path.join(datadir, "%s" % base), i)
                if os.path.exists(ipath): break
             opath = os.path.join(target_path, "pics", c, i)
             try:
@@ -74,7 +74,7 @@
                 pass
             if os.path.exists(ipath):
                 #shutil.copy2(ipath, opath)
-                command = "data/tools/unit_tree/TeamColorizer %s %s" % (
+                command = os.path.join(datadir, 
"tools/unit_tree/TeamColorizer") + " %s %s" % (
                     ipath, opath)
                 os.system(command)
             else:
@@ -866,14 +866,19 @@
         help = "Specify output directory.")
     op.add_option("-n", "--nocopy", action = "store_true",
         help = "No copying of files.")
+    op.add_option("-d", "--datadir",
+        help = "Specify Wesnoth's data to use.")
     options, args = op.parse_args()
-    
+
     if not options.output:
         op.print_help()
         sys.exit(-1)
 
-    wmltools.pop_to_top("wmlunits")
-    datadir = os.getcwd() + "/data"
+    if not options.datadir:
+        wmltools.pop_to_top("wmlunits")
+        datadir = os.getcwd() + "/data"
+    else:
+        datadir = options.datadir
     
     if options.language == "all":
         languages = find_languages().keys()
@@ -890,7 +895,7 @@
     if not options.nocopy:
         print "Copying files."
         image_collector.copy_and_color_images(options.output)
-        shutil.copy2("data/tools/unit_tree/style.css", options.output)
+        shutil.copy2(os.path.join(datadir, "tools/unit_tree/style.css"), 
options.output)
         for grab in [
             "http://www.wesnoth.org/mw/skins/glamdrol/headerbg.jpg";,
             "http://www.wesnoth.org/mw/skins/glamdrol/wesnoth-logo.jpg";,


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to