Update upgrade_map scripts to support new Text/ShieldSymbolizer syntax.
This commit is contained in:
parent
49f28cad40
commit
f08f8ce008
2 changed files with 24 additions and 9 deletions
|
@ -42,6 +42,7 @@ def indent(elem, level=0):
|
||||||
elem.tail = i
|
elem.tail = i
|
||||||
|
|
||||||
def name2expr(sym):
|
def name2expr(sym):
|
||||||
|
if 'name' not in sym.attrib: return
|
||||||
name = sym.attrib['name']
|
name = sym.attrib['name']
|
||||||
if re.match('^\[.*\]',name) is None \
|
if re.match('^\[.*\]',name) is None \
|
||||||
and '[' not in name \
|
and '[' not in name \
|
||||||
|
@ -50,8 +51,9 @@ def name2expr(sym):
|
||||||
and not name.endswith("'") \
|
and not name.endswith("'") \
|
||||||
and re.match("^\'.*\'",name) is None:
|
and re.match("^\'.*\'",name) is None:
|
||||||
print>>sys.stderr,"Fixing %s" % name
|
print>>sys.stderr,"Fixing %s" % name
|
||||||
expression = '[%s]' % name
|
name = '[%s]' % name
|
||||||
sym.attrib['name'] = expression
|
sym.attrib.pop('name')
|
||||||
|
sym.text = name
|
||||||
|
|
||||||
def handle_attr_changes(sym):
|
def handle_attr_changes(sym):
|
||||||
# http://www.w3schools.com/css/pr_text_text-transform.asp
|
# http://www.w3schools.com/css/pr_text_text-transform.asp
|
||||||
|
|
|
@ -29,11 +29,18 @@ dummy_map = """
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def name2expr(sym):
|
def name2expr(sym):
|
||||||
|
if 'name' not in sym.attrib: return
|
||||||
name = sym.attrib['name']
|
name = sym.attrib['name']
|
||||||
if re.match('^\[.*\]$',name) is None:
|
if re.match('^\[.*\]$',name) is None \
|
||||||
print >> sys.stderr,"Fixing %s" % name
|
and '[' not in name \
|
||||||
expression = '[%s]' % name
|
and ']' not in name \
|
||||||
sym.attrib['name'] = expression
|
and not name.startswith("'") \
|
||||||
|
and not name.endswith("'") \
|
||||||
|
and re.match("^\'.*\'",name) is None:
|
||||||
|
print >> sys.stderr,"Fixing %s" % name
|
||||||
|
name = '[%s]' % name
|
||||||
|
sym.attrib.pop('name')
|
||||||
|
sym._setText(name)
|
||||||
|
|
||||||
def fixup_pointsym(sym):
|
def fixup_pointsym(sym):
|
||||||
if sym.attrib.get('width'):
|
if sym.attrib.get('width'):
|
||||||
|
@ -76,7 +83,10 @@ if __name__ == "__main__":
|
||||||
file = open(xml, 'r')
|
file = open(xml, 'r')
|
||||||
xml_string = file.read()
|
xml_string = file.read()
|
||||||
file.close()
|
file.close()
|
||||||
good_doctype = re.match(r'(?ims).*DOCTYPE.*\[.*\]\>', xml_string).group()
|
match = re.match(r'(?ims).*DOCTYPE.*\[.*\]\>', xml_string)
|
||||||
|
good_doctype = ""
|
||||||
|
if match:
|
||||||
|
good_doctype = match.group()
|
||||||
|
|
||||||
# Two trees. One with the unresolved entities...
|
# Two trees. One with the unresolved entities...
|
||||||
parser = objectify.makeparser(resolve_entities=False)
|
parser = objectify.makeparser(resolve_entities=False)
|
||||||
|
@ -95,7 +105,10 @@ if __name__ == "__main__":
|
||||||
pretty_print=True,
|
pretty_print=True,
|
||||||
xml_declaration=True,
|
xml_declaration=True,
|
||||||
encoding="utf-8")
|
encoding="utf-8")
|
||||||
resolved_doctype = re.match(r'(?ims).*DOCTYPE.*\[.*\]\>', expanded_tree_string).group()
|
match = re.match(r'(?ims).*DOCTYPE.*\[.*\]\>', expanded_tree_string)
|
||||||
|
resolved_doctype = ""
|
||||||
|
if match:
|
||||||
|
resolved_doctype = match.group()
|
||||||
|
|
||||||
doctype_entities = {}
|
doctype_entities = {}
|
||||||
# e.g.:
|
# e.g.:
|
||||||
|
@ -178,4 +191,4 @@ if __name__ == "__main__":
|
||||||
output_file.write(fixed_updated_xml)
|
output_file.write(fixed_updated_xml)
|
||||||
output_file.close()
|
output_file.close()
|
||||||
|
|
||||||
# print fixed_updated_xml
|
# print fixed_updated_xml
|
||||||
|
|
Loading…
Reference in a new issue