Skip to content

Commit ae2ab80

Browse files
committed
Test case and fix for object template overrides
1 parent 481bf3e commit ae2ab80

File tree

5 files changed

+364
-350
lines changed

5 files changed

+364
-350
lines changed

.gitignore

Lines changed: 113 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,114 @@
1-
# Tiled Session file from using a project file
2-
*.tiled-session
3-
4-
# Byte-compiled / optimized / DLL files
5-
__pycache__/
6-
*.py[cod]
7-
*$py.class
8-
9-
# C extensions
10-
*.so
11-
12-
# Distribution / packaging
13-
.Python
14-
build/
15-
develop-eggs/
16-
dist/
17-
downloads/
18-
eggs/
19-
.eggs/
20-
lib/
21-
lib64/
22-
parts/
23-
sdist/
24-
var/
25-
wheels/
26-
*.egg-info/
27-
.installed.cfg
28-
*.egg
29-
MANIFEST
30-
31-
# PyInstaller
32-
# Usually these files are written by a python script from a template
33-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
34-
*.manifest
35-
*.spec
36-
37-
# Installer logs
38-
pip-log.txt
39-
pip-delete-this-directory.txt
40-
41-
# Unit test / coverage reports
42-
htmlcov/
43-
.tox/
44-
.coverage
45-
.coverage.*
46-
.cache
47-
nosetests.xml
48-
coverage.xml
49-
*.cover
50-
.hypothesis/
51-
.pytest_cache/
52-
53-
# Translations
54-
*.mo
55-
*.pot
56-
57-
# Django stuff:
58-
*.log
59-
local_settings.py
60-
db.sqlite3
61-
62-
# Flask stuff:
63-
instance/
64-
.webassets-cache
65-
66-
# Scrapy stuff:
67-
.scrapy
68-
69-
# Sphinx documentation
70-
docs/_build/
71-
72-
# PyBuilder
73-
target/
74-
75-
# Jupyter Notebook
76-
.ipynb_checkpoints
77-
78-
# pyenv
79-
.python-version
80-
81-
# celery beat schedule file
82-
celerybeat-schedule
83-
84-
# SageMath parsed files
85-
*.sage.py
86-
87-
# Environments
88-
.env
89-
.venv
90-
env/
91-
venv/
92-
ENV/
93-
env.bak/
94-
venv.bak/
95-
96-
# Spyder project settings
97-
.spyderproject
98-
.spyproject
99-
100-
# Rope project settings
101-
.ropeproject
102-
103-
# mkdocs documentation
104-
/site
105-
106-
# mypy
107-
.mypy_cache/
108-
.idea/
109-
110-
# VS Code Directory
1+
# Tiled Session file from using a project file
2+
*.tiled-session
3+
4+
# Byte-compiled / optimized / DLL files
5+
__pycache__/
6+
*.py[cod]
7+
*$py.class
8+
9+
# C extensions
10+
*.so
11+
12+
# Distribution / packaging
13+
.Python
14+
build/
15+
develop-eggs/
16+
dist/
17+
downloads/
18+
eggs/
19+
.eggs/
20+
lib/
21+
lib64/
22+
parts/
23+
sdist/
24+
var/
25+
wheels/
26+
*.egg-info/
27+
.installed.cfg
28+
*.egg
29+
MANIFEST
30+
31+
# PyInstaller
32+
# Usually these files are written by a python script from a template
33+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
34+
*.manifest
35+
*.spec
36+
37+
# Installer logs
38+
pip-log.txt
39+
pip-delete-this-directory.txt
40+
41+
# Unit test / coverage reports
42+
htmlcov/
43+
.tox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
.hypothesis/
51+
.pytest_cache/
52+
53+
# Translations
54+
*.mo
55+
*.pot
56+
57+
# Django stuff:
58+
*.log
59+
local_settings.py
60+
db.sqlite3
61+
62+
# Flask stuff:
63+
instance/
64+
.webassets-cache
65+
66+
# Scrapy stuff:
67+
.scrapy
68+
69+
# Sphinx documentation
70+
docs/_build/
71+
72+
# PyBuilder
73+
target/
74+
75+
# Jupyter Notebook
76+
.ipynb_checkpoints
77+
78+
# pyenv
79+
.python-version
80+
81+
# celery beat schedule file
82+
celerybeat-schedule
83+
84+
# SageMath parsed files
85+
*.sage.py
86+
87+
# Environments
88+
.env
89+
.venv
90+
env/
91+
venv/
92+
ENV/
93+
env.bak/
94+
venv.bak/
95+
96+
# Spyder project settings
97+
.spyderproject
98+
.spyproject
99+
100+
# Rope project settings
101+
.ropeproject
102+
103+
# mkdocs documentation
104+
/site
105+
106+
# mypy
107+
.mypy_cache/
108+
.idea/
109+
110+
# ruff
111+
.ruff_cache
112+
113+
# VS Code Directory
111114
.vscode

pytiled_parser/parsers/tmx/tiled_object.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,14 @@ def parse(raw_object: etree.Element, parent_dir: Optional[Path] = None) -> Tiled
272272
if isinstance(template, etree.Element):
273273
new_object = template.find("./object")
274274
if new_object is not None:
275-
if raw_object.attrib.get("id") is not None:
276-
new_object.attrib["id"] = raw_object.attrib["id"]
277-
278-
if raw_object.attrib.get("x") is not None:
279-
new_object.attrib["x"] = raw_object.attrib["x"]
280-
281-
if raw_object.attrib.get("y") is not None:
282-
new_object.attrib["y"] = raw_object.attrib["y"]
275+
for key, val in raw_object.attrib.items():
276+
if key == "template":
277+
continue
278+
new_object.attrib[key] = val
279+
280+
properties_element = raw_object.find("./properties")
281+
if properties_element is not None:
282+
new_object.append(properties_element)
283283

284284
raw_object = new_object
285285
elif isinstance(template, dict):

0 commit comments

Comments
 (0)