143 |
for xmlns in ("http://thuban.intevation.org/dtds/thuban-0.8.dtd", |
for xmlns in ("http://thuban.intevation.org/dtds/thuban-0.8.dtd", |
144 |
"http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd", |
"http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd", |
145 |
"http://thuban.intevation.org/dtds/thuban-0.9.dtd", |
"http://thuban.intevation.org/dtds/thuban-0.9.dtd", |
146 |
"http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd"): |
"http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd", |
147 |
|
"http://thuban.intevation.org/dtds/thuban-1.0rc1.dtd"): |
148 |
for key, value in dispatchers.items(): |
for key, value in dispatchers.items(): |
149 |
dispatchers[(xmlns, key)] = value |
dispatchers[(xmlns, key)] = value |
150 |
|
|
187 |
If the attribute has a default value and it is not present in |
If the attribute has a default value and it is not present in |
188 |
attrs, use that default value as the value in the returned dict. |
attrs, use that default value as the value in the returned dict. |
189 |
|
|
190 |
If a conversion is specified, convert the value before putting |
The value is converted before putting it into the returned dict. |
191 |
it into the returned dict. The following conversions are |
The following conversions are available: |
|
available: |
|
192 |
|
|
193 |
'filename' -- The attribute is a filename. |
'filename' -- The attribute is a filename. |
194 |
|
|
212 |
ascii encoding. |
ascii encoding. |
213 |
|
|
214 |
a callable -- The attribute value is passed to the callable |
a callable -- The attribute value is passed to the callable |
215 |
and the return value is used a as the converted |
and the return value is used as the converted |
216 |
value |
value |
217 |
|
|
218 |
|
If no conversion is specified for an attribute it is converted |
219 |
|
with self.encode. |
220 |
""" |
""" |
221 |
normalized = {} |
normalized = {} |
222 |
|
|
250 |
elif d.conversion: |
elif d.conversion: |
251 |
# Assume it's a callable |
# Assume it's a callable |
252 |
value = d.conversion(value) |
value = d.conversion(value) |
253 |
|
else: |
254 |
|
value = self.encode(value) |
255 |
|
|
256 |
normalized[d.name] = value |
normalized[d.name] = value |
257 |
return normalized |
return normalized |
451 |
self.aLayer = None |
self.aLayer = None |
452 |
|
|
453 |
def start_classification(self, name, qname, attrs): |
def start_classification(self, name, qname, attrs): |
454 |
field = attrs.get((None, 'field'), None) |
attrs = self.check_attrs(name, attrs, |
455 |
|
[AttrDesc("field", True), |
456 |
|
AttrDesc("field_type", True)]) |
457 |
|
field = attrs["field"] |
458 |
|
fieldType = attrs["field_type"] |
459 |
|
|
|
fieldType = attrs.get((None, 'field_type'), None) |
|
460 |
dbFieldType = self.aLayer.GetFieldType(field) |
dbFieldType = self.aLayer.GetFieldType(field) |
461 |
|
|
462 |
if fieldType != dbFieldType: |
if fieldType != dbFieldType: |
546 |
self.aLayer = self.aMap.LabelLayer() |
self.aLayer = self.aMap.LabelLayer() |
547 |
|
|
548 |
def start_label(self, name, qname, attrs): |
def start_label(self, name, qname, attrs): |
549 |
x = float(attrs[(None, 'x')]) |
attrs = self.check_attrs(name, attrs, |
550 |
y = float(attrs[(None, 'y')]) |
[AttrDesc("x", True, conversion = float), |
551 |
text = self.encode(attrs[(None, 'text')]) |
AttrDesc("y", True, conversion = float), |
552 |
halign = attrs[(None, 'halign')] |
AttrDesc("text", True), |
553 |
valign = attrs[(None, 'valign')] |
AttrDesc("halign", True, |
554 |
|
conversion = "ascii"), |
555 |
|
AttrDesc("valign", True, |
556 |
|
conversion = "ascii")]) |
557 |
|
x = attrs['x'] |
558 |
|
y = attrs['y'] |
559 |
|
text = attrs['text'] |
560 |
|
halign = attrs['halign'] |
561 |
|
valign = attrs['valign'] |
562 |
|
if halign not in ("left", "center", "right"): |
563 |
|
raise LoadError("Unsupported halign value %r" % halign) |
564 |
|
if valign not in ("top", "center", "bottom"): |
565 |
|
raise LoadError("Unsupported valign value %r" % valign) |
566 |
self.aLayer.AddLabel(x, y, text, halign = halign, valign = valign) |
self.aLayer.AddLabel(x, y, text, halign = halign, valign = valign) |
567 |
|
|
568 |
def characters(self, chars): |
def characters(self, chars): |