File tree 3 files changed +448
-111
lines changed 3 files changed +448
-111
lines changed Original file line number Diff line number Diff line change @@ -319,13 +319,20 @@ def load(filename, paths=None):
319
319
#
320
320
# XML PROPERTY PARSING
321
321
#
322
- _xml_to_python = {
323
- ' unicode' : unicode ,
324
- ' int' : int ,
325
- ' float' : float ,
326
- ' bool' : bool ,
327
- }
322
+ _xml_to_python = dict (
323
+ unicode = unicode ,
324
+ int = int ,
325
+ float = float ,
326
+ bool = bool ,
327
+ )
328
328
_python_to_xml = {
329
+ str : unicode ,
330
+ unicode : unicode ,
331
+ int : repr ,
332
+ float : repr ,
333
+ bool : repr ,
334
+ }
335
+ _xml_type = {
329
336
str : 'unicode' ,
330
337
unicode : 'unicode' ,
331
338
int : 'int' ,
@@ -747,8 +754,9 @@ def _as_xml(self, parent):
747
754
c .set ('tile' , self .tile .id )
748
755
for k in self .properties :
749
756
v = self .properties [k ]
757
+ v = _python_to_xml [type (v )](v )
750
758
ElementTree .SubElement (c , 'property' , value = v ,
751
- type = _python_to_xml [type (v )])
759
+ type = _xml_type [type (v )])
752
760
753
761
def __repr__ (self ):
754
762
return '<%s object at 0x%x (%g, %g) properties=%r tile=%r>' % (
Original file line number Diff line number Diff line change 1
- <?xml version =" 1.0" ?>
2
- <resource >
3
- <requires file =" road-tiles.xml" />
4
- <rectmap id =" map0" tile_size =" 128x128" origin =" 100,0,0" >
5
- <column >
6
- <cell tile =" bl" >
7
- <property type =" bool" name =" start" value =" True" />
8
- </cell >
9
- <cell tile =" vl" />
10
- <cell tile =" vl" />
11
- <cell tile =" vl" />
12
- <cell tile =" vl" />
13
- <cell tile =" tl" />
14
- </column >
15
- <column >
16
- <cell tile =" bh" />
17
- <cell tile =" bli" />
18
- <cell tile =" vr" />
19
- <cell tile =" vr" />
20
- <cell tile =" tli" />
21
- <cell tile =" th" />
22
- </column >
23
- <column >
24
- <cell tile =" bh" />
25
- <cell tile =" th" />
26
- <cell tile =" empty" />
27
- <cell tile =" empty" />
28
- <cell tile =" bh" />
29
- <cell tile =" th" />
30
- </column >
31
- <column >
32
- <cell tile =" bh" />
33
- <cell tile =" th" />
34
- <cell tile =" empty" />
35
- <cell tile =" empty" />
36
- <cell tile =" bh" />
37
- <cell tile =" th" />
38
- </column >
39
- <column >
40
- <cell tile =" bh" />
41
- <cell tile =" bri" />
42
- <cell tile =" vl" />
43
- <cell tile =" vl" />
44
- <cell tile =" tri" />
45
- <cell tile =" th" />
46
- </column >
47
- <column >
48
- <cell tile =" br" />
49
- <cell tile =" vr" />
50
- <cell tile =" vr" />
51
- <cell tile =" vr" />
52
- <cell tile =" vr" />
53
- <cell tile =" tr" />
54
- </column >
55
- <column >
56
- <cell tile =" bl" />
57
- <cell tile =" vl" />
58
- <cell tile =" vl" />
59
- <cell tile =" vl" />
60
- <cell tile =" vl" />
61
- <cell tile =" tl" />
62
- </column >
63
- <column >
64
- <cell tile =" bh" />
65
- <cell tile =" bli" />
66
- <cell tile =" vr" />
67
- <cell tile =" vr" />
68
- <cell tile =" tli" />
69
- <cell tile =" th" />
70
- </column >
71
- <column >
72
- <cell tile =" bh" />
73
- <cell tile =" th" />
74
- <cell tile =" empty" />
75
- <cell tile =" empty" />
76
- <cell tile =" bh" />
77
- <cell tile =" th" />
78
- </column >
79
- <column >
80
- <cell tile =" bh" />
81
- <cell tile =" th" />
82
- <cell tile =" empty" />
83
- <cell tile =" empty" />
84
- <cell tile =" bh" />
85
- <cell tile =" th" />
86
- </column >
87
- <column >
88
- <cell tile =" bh" />
89
- <cell tile =" bri" />
90
- <cell tile =" vl" />
91
- <cell tile =" vl" />
92
- <cell tile =" tri" />
93
- <cell tile =" th" />
94
- </column >
95
- <column >
96
- <cell tile =" br" />
97
- <cell tile =" vr" />
98
- <cell tile =" vr" />
99
- <cell tile =" vr" />
100
- <cell tile =" vr" />
101
- <cell tile =" tr" />
102
- </column >
103
- </rectmap >
104
- </resource >
1
+ <resource ><requires file =" ../test/road-tiles.xml" />
2
+ <rectmap id =" map0" origin =" 100,0,0" tile_size =" 128x128" ><column ><cell tile =" bl" ><property type =" unicode" value =" True" /></cell >
3
+ <cell tile =" vl" />
4
+ <cell tile =" vl" />
5
+ <cell tile =" vl" />
6
+ <cell tile =" vl" />
7
+ <cell tile =" tl" />
8
+ </column >
9
+ <column ><cell tile =" bh" />
10
+ <cell tile =" bli" />
11
+ <cell tile =" vr" />
12
+ <cell tile =" vr" />
13
+ <cell tile =" tli" />
14
+ <cell tile =" th" />
15
+ </column >
16
+ <column ><cell tile =" bh" />
17
+ <cell tile =" th" />
18
+ <cell tile =" empty" />
19
+ <cell tile =" empty" />
20
+ <cell tile =" bh" />
21
+ <cell tile =" th" />
22
+ </column >
23
+ <column ><cell tile =" bh" />
24
+ <cell tile =" th" />
25
+ <cell tile =" empty" />
26
+ <cell tile =" empty" />
27
+ <cell tile =" bh" />
28
+ <cell tile =" th" />
29
+ </column >
30
+ <column ><cell tile =" bh" />
31
+ <cell tile =" bri" />
32
+ <cell tile =" vl" />
33
+ <cell tile =" vl" />
34
+ <cell tile =" tri" />
35
+ <cell tile =" th" />
36
+ </column >
37
+ <column ><cell tile =" bh" />
38
+ <cell tile =" bli" />
39
+ <cell tile =" vr" />
40
+ <cell tile =" vr" />
41
+ <cell tile =" tli" />
42
+ <cell tile =" th" />
43
+ </column >
44
+ <column ><cell tile =" bh" />
45
+ <cell tile =" bri" />
46
+ <cell tile =" vl" />
47
+ <cell tile =" vl" />
48
+ <cell tile =" tri" />
49
+ <cell tile =" th" />
50
+ </column >
51
+ <column ><cell tile =" bh" />
52
+ <cell tile =" bli" />
53
+ <cell tile =" vr" />
54
+ <cell tile =" vr" />
55
+ <cell tile =" tli" />
56
+ <cell tile =" th" />
57
+ </column >
58
+ <column ><cell tile =" bh" />
59
+ <cell tile =" th" />
60
+ <cell tile =" empty" />
61
+ <cell tile =" empty" />
62
+ <cell tile =" bh" />
63
+ <cell tile =" th" />
64
+ </column >
65
+ <column ><cell tile =" bh" />
66
+ <cell tile =" th" />
67
+ <cell tile =" empty" />
68
+ <cell tile =" empty" />
69
+ <cell tile =" bh" />
70
+ <cell tile =" th" />
71
+ </column >
72
+ <column ><cell tile =" bh" />
73
+ <cell tile =" bri" />
74
+ <cell tile =" vl" />
75
+ <cell tile =" vl" />
76
+ <cell tile =" tri" />
77
+ <cell tile =" th" />
78
+ </column >
79
+ <column ><cell tile =" br" />
80
+ <cell tile =" vr" />
81
+ <cell tile =" vr" />
82
+ <cell tile =" vr" />
83
+ <cell tile =" vr" />
84
+ <cell tile =" tr" />
85
+ </column >
86
+ </rectmap ></resource >
You can’t perform that action at this time.
0 commit comments