From 4fb811d0392cff4203adcc75ea003863a657c26b Mon Sep 17 00:00:00 2001 From: Darren Eberly Date: Wed, 19 Aug 2020 23:11:59 -0400 Subject: [PATCH] refactor(tileset): Renamed TileSet class to Tileset --- pytiled_parser/__init__.py | 2 +- pytiled_parser/tiled_map.py | 4 ++-- pytiled_parser/tileset.py | 10 ++++------ tests/test_data/map_tests/embedded_tileset/expected.py | 2 +- tests/test_data/map_tests/hexagonal/expected.py | 2 +- .../map_tests/no_background_color/expected.py | 2 +- tests/test_data/map_tests/no_layers/expected.py | 2 +- tests/test_data/tilesets/image/expected.py | 2 +- .../tilesets/image_background_color/expected.py | 2 +- tests/test_data/tilesets/image_grid/expected.py | 2 +- tests/test_data/tilesets/image_properties/expected.py | 2 +- tests/test_data/tilesets/image_tile_offset/expected.py | 2 +- .../tilesets/image_transparent_color/expected.py | 2 +- tests/test_data/tilesets/individual_images/expected.py | 2 +- tests/test_data/tilesets/terrain/expected.py | 2 +- 15 files changed, 19 insertions(+), 21 deletions(-) diff --git a/pytiled_parser/__init__.py b/pytiled_parser/__init__.py index 258acdd..3ce0b53 100644 --- a/pytiled_parser/__init__.py +++ b/pytiled_parser/__init__.py @@ -6,4 +6,4 @@ from .common_types import OrderedPair, Size from .layer import Layer from .properties import Properties from .tiled_map import Map -from .tileset import TileSet +from .tileset import Tileset diff --git a/pytiled_parser/tiled_map.py b/pytiled_parser/tiled_map.py index 69158d8..61d9f89 100644 --- a/pytiled_parser/tiled_map.py +++ b/pytiled_parser/tiled_map.py @@ -12,9 +12,9 @@ from . import layer, properties, tileset from .common_types import Color, Size from .layer import Layer, RawLayer from .properties import Properties, RawProperty -from .tileset import RawTileSet, TileSet +from .tileset import RawTileSet, Tileset -TilesetDict = Dict[int, TileSet] +TilesetDict = Dict[int, Tileset] @attr.s(auto_attribs=True) diff --git a/pytiled_parser/tileset.py b/pytiled_parser/tileset.py index e7b211d..9fc3104 100644 --- a/pytiled_parser/tileset.py +++ b/pytiled_parser/tileset.py @@ -7,7 +7,6 @@ from typing_extensions import TypedDict from . import layer from . import properties as properties_ -from . import tiled_object from .common_types import Color, OrderedPair @@ -102,15 +101,14 @@ class Tile: image_width: Optional[int] = None image_height: Optional[int] = None properties: Optional[properties_.Properties] = None - tileset: Optional["TileSet"] = None + tileset: Optional["Tileset"] = None flipped_horizontally: bool = False flipped_diagonally: bool = False flipped_vertically: bool = False @attr.s(auto_attribs=True) -class TileSet: - # FIXME: rename to Tileset +class Tileset: """Object for storing a TSX with all associated collision data. Args: @@ -353,7 +351,7 @@ def _cast_grid(raw_grid: RawGrid) -> Grid: ) -def cast(raw_tileset: RawTileSet) -> TileSet: +def cast(raw_tileset: RawTileSet) -> Tileset: """ Cast the raw tileset into a pytiled_parser type Args: @@ -363,7 +361,7 @@ def cast(raw_tileset: RawTileSet) -> TileSet: TileSet: a properly typed TileSet. """ - tileset = TileSet( + tileset = Tileset( name=raw_tileset["name"], tile_count=raw_tileset["tilecount"], tile_width=raw_tileset["tilewidth"], diff --git a/tests/test_data/map_tests/embedded_tileset/expected.py b/tests/test_data/map_tests/embedded_tileset/expected.py index ebaaddc..c64d2fb 100644 --- a/tests/test_data/map_tests/embedded_tileset/expected.py +++ b/tests/test_data/map_tests/embedded_tileset/expected.py @@ -14,7 +14,7 @@ EXPECTED = tiled_map.Map( tile_size=common_types.Size(32, 32), version=1.4, tilesets={ - 1: tileset.TileSet( + 1: tileset.Tileset( columns=8, image=Path("../../images/tmw_desert_spacing.png"), image_width=265, diff --git a/tests/test_data/map_tests/hexagonal/expected.py b/tests/test_data/map_tests/hexagonal/expected.py index 3bf032e..05a7f13 100644 --- a/tests/test_data/map_tests/hexagonal/expected.py +++ b/tests/test_data/map_tests/hexagonal/expected.py @@ -127,7 +127,7 @@ EXPECTED = tiled_map.Map( tile_size=common_types.Size(14, 12), version=1.4, tilesets={ - 1: tileset.TileSet( + 1: tileset.Tileset( columns=5, image=Path("../../images/hexmini.png"), image_width=106, diff --git a/tests/test_data/map_tests/no_background_color/expected.py b/tests/test_data/map_tests/no_background_color/expected.py index 1df8bc2..831356c 100644 --- a/tests/test_data/map_tests/no_background_color/expected.py +++ b/tests/test_data/map_tests/no_background_color/expected.py @@ -14,7 +14,7 @@ EXPECTED = tiled_map.Map( tile_size=common_types.Size(32, 32), version=1.4, tilesets={ - 1: tileset.TileSet( + 1: tileset.Tileset( columns=8, image=Path("../../images/tmw_desert_spacing.png"), image_width=265, diff --git a/tests/test_data/map_tests/no_layers/expected.py b/tests/test_data/map_tests/no_layers/expected.py index bd7a222..febd8fa 100644 --- a/tests/test_data/map_tests/no_layers/expected.py +++ b/tests/test_data/map_tests/no_layers/expected.py @@ -15,7 +15,7 @@ EXPECTED = tiled_map.Map( version=1.4, background_color=common_types.Color("#ff0004"), tilesets={ - 1: tileset.TileSet( + 1: tileset.Tileset( columns=8, image=Path("../../images/tmw_desert_spacing.png"), image_width=265, diff --git a/tests/test_data/tilesets/image/expected.py b/tests/test_data/tilesets/image/expected.py index 29b1cfc..62577e5 100644 --- a/tests/test_data/tilesets/image/expected.py +++ b/tests/test_data/tilesets/image/expected.py @@ -2,7 +2,7 @@ from pathlib import Path from pytiled_parser import tileset -EXPECTED = tileset.TileSet( +EXPECTED = tileset.Tileset( columns=8, image=Path("../../images/tmw_desert_spacing.png"), image_height=199, diff --git a/tests/test_data/tilesets/image_background_color/expected.py b/tests/test_data/tilesets/image_background_color/expected.py index 23b0cee..389681a 100644 --- a/tests/test_data/tilesets/image_background_color/expected.py +++ b/tests/test_data/tilesets/image_background_color/expected.py @@ -3,7 +3,7 @@ from pathlib import Path from pytiled_parser import tileset from pytiled_parser.common_types import Color -EXPECTED = tileset.TileSet( +EXPECTED = tileset.Tileset( columns=8, image=Path("../../images/tmw_desert_spacing.png"), image_height=199, diff --git a/tests/test_data/tilesets/image_grid/expected.py b/tests/test_data/tilesets/image_grid/expected.py index 948bc13..1d58174 100644 --- a/tests/test_data/tilesets/image_grid/expected.py +++ b/tests/test_data/tilesets/image_grid/expected.py @@ -2,7 +2,7 @@ from pathlib import Path from pytiled_parser import tileset -EXPECTED = tileset.TileSet( +EXPECTED = tileset.Tileset( columns=8, image=Path("../../images/tmw_desert_spacing.png"), image_height=199, diff --git a/tests/test_data/tilesets/image_properties/expected.py b/tests/test_data/tilesets/image_properties/expected.py index ab6aa5a..a329942 100644 --- a/tests/test_data/tilesets/image_properties/expected.py +++ b/tests/test_data/tilesets/image_properties/expected.py @@ -3,7 +3,7 @@ from pathlib import Path from pytiled_parser import tileset from pytiled_parser.common_types import Color -EXPECTED = tileset.TileSet( +EXPECTED = tileset.Tileset( columns=8, image=Path("../../images/tmw_desert_spacing.png"), image_height=199, diff --git a/tests/test_data/tilesets/image_tile_offset/expected.py b/tests/test_data/tilesets/image_tile_offset/expected.py index 2ac339c..97e2777 100644 --- a/tests/test_data/tilesets/image_tile_offset/expected.py +++ b/tests/test_data/tilesets/image_tile_offset/expected.py @@ -3,7 +3,7 @@ from pathlib import Path from pytiled_parser import tileset from pytiled_parser.common_types import Color, OrderedPair -EXPECTED = tileset.TileSet( +EXPECTED = tileset.Tileset( columns=8, image=Path("../../images/tmw_desert_spacing.png"), image_height=199, diff --git a/tests/test_data/tilesets/image_transparent_color/expected.py b/tests/test_data/tilesets/image_transparent_color/expected.py index 56a45ea..7d69721 100644 --- a/tests/test_data/tilesets/image_transparent_color/expected.py +++ b/tests/test_data/tilesets/image_transparent_color/expected.py @@ -3,7 +3,7 @@ from pathlib import Path from pytiled_parser import tileset from pytiled_parser.common_types import Color -EXPECTED = tileset.TileSet( +EXPECTED = tileset.Tileset( columns=8, image=Path("../../images/tmw_desert_spacing.png"), image_height=199, diff --git a/tests/test_data/tilesets/individual_images/expected.py b/tests/test_data/tilesets/individual_images/expected.py index 54625d2..c6b354e 100644 --- a/tests/test_data/tilesets/individual_images/expected.py +++ b/tests/test_data/tilesets/individual_images/expected.py @@ -2,7 +2,7 @@ from pathlib import Path from pytiled_parser import common_types, layer, tiled_object, tileset -EXPECTED = tileset.TileSet( +EXPECTED = tileset.Tileset( columns=0, margin=0, spacing=0, diff --git a/tests/test_data/tilesets/terrain/expected.py b/tests/test_data/tilesets/terrain/expected.py index 89051ae..88db165 100644 --- a/tests/test_data/tilesets/terrain/expected.py +++ b/tests/test_data/tilesets/terrain/expected.py @@ -2,7 +2,7 @@ from pathlib import Path from pytiled_parser import common_types, layer, tileset -EXPECTED = tileset.TileSet( +EXPECTED = tileset.Tileset( columns=8, margin=1, spacing=1,