[wmlunits] fixed some problems with latin1 filenames

This commit is contained in:
Elias Pschernig 2010-01-11 20:52:57 +00:00
parent e948226de7
commit 5431f82643
3 changed files with 14 additions and 6 deletions

View file

@ -139,7 +139,8 @@ class ImageCollector:
p.wait()
else:
sys.stderr.write(
"Warning: Required image %s: \"%s\" does not exist.\n" % (c, i))
"Warning: Required image %s: \"%s\" does not exist.\n" % (
repr(c), repr(i)))
if self.verbose:
sys.stderr.write("Warning: Looked at the following locations:\n")
sys.stderr.write("\n".join(bases) + "\n")
@ -352,7 +353,10 @@ class WesnothList:
except KeyError:
sys.stderr.write(
("Error: Era '%s' faction '%s' references " +
"non-existant unit id '%s'!\n") % (eid, fid, uid))
"non-existant unit id '%s'!\n") % (
eid,
fid,
repr(uid)))
continue
if not eid in unit.eras:
unit.eras.append(eid)

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python
# encoding: utf8
import wmldata, os, glob, sys
import re
@ -385,10 +385,14 @@ class Parser:
return None
# If it is a directory, parse all cfg files within.
if os.path.isdir(dirpath):
# Note: glob.glob will try to return unicode filenames
# if you pass it an unicode string - but to deal with
# non-unicode filenames as are allowed in linux we
# convert to a byte-string.
# Execute all WML files in the directory.
files = glob.glob(dirpath + "/*.cfg")
files = glob.glob(str(dirpath + "/*.cfg"))
# And also execute directories with a _main.cfg.
files += glob.glob(dirpath + "/*/_main.cfg")
files += glob.glob(str(dirpath + "/*/_main.cfg"))
files.sort()
mc = dirpath + "/_main.cfg"
fc = dirpath + "/_final.cfg"

View file

@ -111,7 +111,7 @@ class HTMLOutput:
except KeyError:
sys.stderr.write(
"Warning: Unit %s not found as advancement of %s\n" %
(auid, uid))
(auid, repr(uid)))
continue
forest.add_node(helpers.UnitNode(au))
new_units_added[auid] = au