Two changes to wmlparser:

1) All data items collected by the parse now carry information about
   the text domain that was active when they were parsed.

2) Parser no longer ignores all #textdomain declarations other than
   'wesnoth'.

Note: the second change is potentially not backwards-compatible,
depending on how the parser client uses the data.
This commit is contained in:
Eric S. Raymond 2008-03-31 12:58:26 +00:00
parent 513921c01c
commit 515c68ce4c
3 changed files with 8 additions and 14 deletions

View file

@ -7,18 +7,19 @@ written in python.
###
__init__.py
Cause Python to executed any code in this directory on "import wesnoth".
Cause Python to execute any code in this directory on "import wesnoth".
campaignserver_client.py
textmode-client for uploading + downloding campaigns to the server.
libsvn.py
Library to provide an interface to svn,
the interface is build upon the command line svn tool.
The interface is built upon the command line svn tool.
wescamp.py
This utility provides two tools
* sync a campaign with the version on wescamp (using the packed campaign as base)
* sync a campaign with the version on wescamp (using the packed campaign
as base)
* update the translations in a campaign (in the packed campaign)
wmldata.py
@ -33,10 +34,6 @@ wmlparser.py
wmltools.py
Python routines for working with a Battle For Wesnoth WML tree
randomtraits.py (rev.21070)
Upconvert v1.3-1.3.7 saved replays to v1.3.8+ format.
Example for using wmliterator.py
###
From IRC #wesnoth-dev - 2007-11-27

View file

@ -122,11 +122,12 @@ class WMLException(Exception):
return self.text
class DataSub(Data):
def __init__(self, name, sub = []):
def __init__(self, name, sub = [], textdomain=None):
"""The sub parameter is a list of sub-elements."""
Data.__init__(self, name)
self.data = []
self.dict = {}
self.textdomain = textdomain
for element in sub:
self.insert(element)

View file

@ -617,11 +617,7 @@ class Parser:
elif self.check_for("textdomain"):
self.read_until(" ")
name = self.read_until("\n").strip()
if name == "wesnoth":
self.textdomain = "wesnoth"
else:
self.textdomain = ""
self.textdomain = self.read_until("\n").strip()
else: # comment
line = self.read_until("\n")
comment = c + line
@ -634,7 +630,7 @@ class Parser:
if state == name[1:] or state == "+" + name[1:]:
return
raise Error(self, "Mismatched closing tag [%s], expected [/%s]" % (name, state))
subdata = wmldata.DataSub(name)
subdata = wmldata.DataSub(name, textdomain=self.textdomain)
self.parse_top(subdata, name)
data.insert(subdata)
elif c == '{':