mail[Wesnoth-commits] r44632 - /trunk/data/tools/wesnoth/wmlparser2.py


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

Header


Content

Posted by elias on July 24, 2010 - 12:58:
Author: elias
Date: Sat Jul 24 12:58:51 2010
New Revision: 44632

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44632&view=rev
Log:
[python WML parser]Add --config-dir option.

Modified:
    trunk/data/tools/wesnoth/wmlparser2.py

Modified: trunk/data/tools/wesnoth/wmlparser2.py
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/wesnoth/wmlparser2.py?rev=44632&r1=44631&r2=44632&view=diff
==============================================================================
--- trunk/data/tools/wesnoth/wmlparser2.py (original)
+++ trunk/data/tools/wesnoth/wmlparser2.py Sat Jul 24 12:58:51 2010
@@ -172,13 +172,14 @@
         return s
 
 class Parser:
-    def __init__(self, wesnoth_exe):
+    def __init__(self, wesnoth_exe, config_dir):
         """
         path - Path to the file to parse.
         wesnoth_exe - Wesnoth executable to use. This should have been
             configured to use the desired data and config directories.
         """
         self.wesnoth_exe = wesnoth_exe
+        self.config_dir = config_dir
         self.preprocessed = None
 
         self.last_wml_line = "?"
@@ -208,7 +209,10 @@
         """
         output = tempfile.mkdtemp(prefix="wmlparser_")
         p_option = "-p=" + defines if defines else "-p "
-        commandline = [self.wesnoth_exe, p_option, self.path,
+        commandline = [self.wesnoth_exe]
+        if self.config_dir:
+            commandline += ["--config_dir='%s'" % self.config_dir]
+        commandline += [p_option, self.path,
             output]
         p = subprocess.Popen(commandline,
             stdout = subprocess.PIPE, stderr = subprocess.PIPE)
@@ -484,10 +488,11 @@
     # Hack to make us not crash when we encounter characters that aren't 
ASCII
     sys.stdout = __import__("codecs").getwriter('utf-8')(sys.stdout)
     opt = optparse.OptionParser()
-    opt.add_option("-i", "--input")
-    opt.add_option("-t", "--text")
-    opt.add_option("-w", "--wesnoth")
-    opt.add_option("-d", "--defines")
+    opt.add_option("-c", "--config-dir", help = "directly passed on to 
wesnoth.exe")
+    opt.add_option("-i", "--input", help = "a WML file to parse")
+    opt.add_option("-t", "--text", help = "WML text to parse")
+    opt.add_option("-w", "--wesnoth", help = "path to wesnoth.exe")
+    opt.add_option("-d", "--defines", help = "comma separated list of WML 
defines")
     opt.add_option("-T", "--test", action = "store_true")
     opt.add_option("-j", "--to-json", action = "store_true")
     opt.add_option("-x", "--to-xml", action = "store_true")
@@ -635,7 +640,7 @@
 
         sys.exit(0)
 
-    p = Parser(options.wesnoth)
+    p = Parser(options.wesnoth, options.config_dir)
     if options.input: p.parse_file(options.input, options.defines)
     elif options.text: p.parse_text(options.text, options.defines)
     if options.to_json:




Related Messages


Powered by MHonArc, Updated Sat Jul 24 18:40:06 2010