[python wmlparser] use a tempfile instead of a fixed path...

...to /tmp to make it work in windows
This commit is contained in:
Elias Pschernig 2010-07-21 16:15:00 +00:00
parent 503329da25
commit 5b181dd4d8

View file

@ -190,11 +190,11 @@ class Parser:
self.parse()
def parse_text(self, text, defines = ""):
self.file = tempfile.NamedTemporaryFile(prefix = "wmlparser_",
temp = tempfile.NamedTemporaryFile(prefix = "wmlparser_",
suffix = ".cfg")
self.file.write(text)
self.file.flush()
self.path = self.file.name
temp.write(text)
temp.flush()
self.path = temp.name
self.preprocess(defines)
self.parse()
@ -206,7 +206,8 @@ class Parser:
If this is not called then the .parse method will assume the
WML is already preprocessed.
"""
output = "/tmp/wmlparser"
output = tempfile.NamedTemporaryFile(prefix = "wmlparser_",
suffix = ".cfg").name
if not os.path.exists(output): os.mkdir(output)
p_option = "-p=" + defines if defines else "-p "
commandline = [self.wesnoth_exe, p_option, self.path,