mirror of
https://github.com/OMGeeky/pytiled_parser.git
synced 2025-12-29 07:40:11 +01:00
26 lines
596 B
Python
26 lines
596 B
Python
from pathlib import Path
|
|
from typing import Dict, List, NamedTuple, Optional, Union
|
|
|
|
from .common_types import Color
|
|
|
|
Property = Union[int, float, Path, str, bool, Color]
|
|
class
|
|
|
|
RawProperties = List[Dict[str, Property]]
|
|
|
|
|
|
Properties = Dict[str, Property]
|
|
|
|
|
|
def cast(raw: RawProperties) -> Dict[str, Property]:
|
|
final: Properties = {}
|
|
for prop in raw:
|
|
value = prop["value"]
|
|
if prop["type"] == "file":
|
|
value = Path(str(value))
|
|
elif prop["type"] == "color":
|
|
value = Color(str(value))
|
|
final[str(prop["name"])] = value
|
|
|
|
return final
|