rf: change line length to 88 chars

This commit is contained in:
Benjamin Kirkbride
2020-04-18 01:24:56 -04:00
parent ec0c95ad06
commit 11ae5f1050
10 changed files with 1758 additions and 59 deletions

View File

@@ -469,7 +469,7 @@ indent-after-paren=4
indent-string=' '
# Maximum number of characters on a single line.
max-line-length=79
max-line-length=88
# Maximum number of lines in a module.
max-module-lines=1000

View File

@@ -20,11 +20,11 @@
import os
import sys
project = 'PyTiled Parser'
copyright = '2019, Beefy-Swain'
author = 'Beefy-Swain'
project = "PyTiled Parser"
copyright = "2019, Beefy-Swain"
author = "Beefy-Swain"
sys.path.insert(0, os.path.abspath('../..'))
sys.path.insert(0, os.path.abspath("../.."))
# -- General configuration ---------------------------------------------------
@@ -32,22 +32,22 @@ sys.path.insert(0, os.path.abspath('../..'))
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.ifconfig',
'sphinx.ext.viewcode',
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.todo",
"sphinx.ext.coverage",
"sphinx.ext.ifconfig",
"sphinx.ext.viewcode",
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]
source_suffix = '.rst'
source_suffix = ".rst"
master_doc = 'index'
master_doc = "index"
pygments_style = 'sphinx'
pygments_style = "sphinx"
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
@@ -60,9 +60,9 @@ exclude_patterns = []
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

View File

@@ -49,9 +49,7 @@ def _get_tile_set_key(gid: int, tile_set_keys: List[int]) -> int:
return max([key for key in tile_set_keys if key <= gid])
def get_tile_by_gid(
gid: int, tile_sets: objects.TileSetDict
) -> Optional[objects.Tile]:
def get_tile_by_gid(gid: int, tile_sets: objects.TileSetDict) -> Optional[objects.Tile]:
"""Gets correct Tile for a given global ID.
Args:

View File

@@ -8,8 +8,8 @@ SCREEN_HEIGHT = 600
SPRITE_SCALING = 1
GRAVITY = 1.1
class BasicTestWindow(arcade.Window):
class BasicTestWindow(arcade.Window):
def __init__(self, width, height, title, map_name):
super().__init__(width, height, title)
file_path = os.path.dirname(os.path.abspath(__file__))
@@ -18,14 +18,18 @@ class BasicTestWindow(arcade.Window):
self.layers = []
my_map = arcade.tiled.read_tiled_map(map_name, 1)
for layer in my_map.layers:
self.layers.append(arcade.tiled.generate_sprites(
my_map, layer, 1, "../arcade/arcade/examples/"))
self.layers.append(
arcade.tiled.generate_sprites(
my_map, layer, 1, "../arcade/arcade/examples/"
)
)
def on_draw(self):
arcade.start_render()
for layer in self.layers:
layer.draw()
class CollisionTestWindow(BasicTestWindow):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@@ -33,13 +37,15 @@ class CollisionTestWindow(BasicTestWindow):
self.player_list = arcade.SpriteList()
self.player_sprite = arcade.Sprite(
"../arcade/arcade/examples/images/character.png", SPRITE_SCALING)
"../arcade/arcade/examples/images/character.png", SPRITE_SCALING
)
self.player_sprite.center_x = 400
self.player_sprite.center_y = 800
self.player_list.append(self.player_sprite)
self.physics_engine = arcade.PhysicsEnginePlatformer(
self.player_sprite, self.layers[0], gravity_constant=GRAVITY)
self.player_sprite, self.layers[0], gravity_constant=GRAVITY
)
def on_draw(self):
super().on_draw()
@@ -54,12 +60,10 @@ class CollisionTestWindow(BasicTestWindow):
self.physics_engine.update()
window = CollisionTestWindow(
SCREEN_WIDTH,
SCREEN_HEIGHT,
"Test Text",
"../arcade/arcade/examples/map_polyline_collision.tmx"
"../arcade/arcade/examples/map_polyline_collision.tmx",
)
arcade.run()

View File

@@ -1 +1 @@
MAP_NAME = 'assets/tiled_test_4.tmx'
MAP_NAME = "assets/tiled_test_4.tmx"

File diff suppressed because one or more lines are too long

View File

@@ -4,6 +4,7 @@ import config
from arcade.tiled import read_tiled_map
class MyTestWindow(arcade.Window):
def __init__(self, width, height, title):
super().__init__(width, height, title)
@@ -14,14 +15,15 @@ class MyTestWindow(arcade.Window):
self.map.draw()
MAP_NAME = 'assets/tiled_test_4.tmx'
MAP_NAME = "assets/tiled_test_4.tmx"
my_map = arcade.read_tiled_map(config.MAP_NAME, 1)
for row in my_map.layers["Tile Layer 1"]:
for grid_object in row:
print(grid_object)
print(
f"{grid_object.tile.local_id}, {grid_object.center_x}, {grid_object.center_y}")
test = MyTestWindow(640,800,"meme")
f"{grid_object.tile.local_id}, {grid_object.center_x}, {grid_object.center_y}"
)
test = MyTestWindow(640, 800, "meme")
test.test()
test.close()

View File

@@ -5,6 +5,7 @@ import pprint
pp = pprint.PrettyPrinter(indent=4, compact=True, width=200)
class MyTestWindow(arcade.Window):
def __init__(self, width, height, title, map_name):
super().__init__(width, height, title)
@@ -13,8 +14,11 @@ class MyTestWindow(arcade.Window):
my_map = arcade.tiled.read_tiled_map(map_name, 1)
pp.pprint(my_map.layers_int_data)
for layer in my_map.layers_int_data:
self.layers.append(arcade.tiled.generate_sprites(
my_map, layer, 1, "../arcade/arcade/examples/"))
self.layers.append(
arcade.tiled.generate_sprites(
my_map, layer, 1, "../arcade/arcade/examples/"
)
)
def on_draw(self):
arcade.start_render()
@@ -22,7 +26,7 @@ class MyTestWindow(arcade.Window):
layer.draw()
MAP_NAME = '../arcade/arcade/examples/map_base64_gzip.tmx'
MAP_NAME = "../arcade/arcade/examples/map_base64_gzip.tmx"
test = MyTestWindow(640, 800, "meme", MAP_NAME)
arcade.run()

View File

@@ -26,8 +26,7 @@ def _get_root_element(xml: str) -> etree.Element:
LAYER_DATA = [
(
'<layer id="1" name="Tile Layer 1" width="10" height="10">'
+ "</layer>",
'<layer id="1" name="Tile Layer 1" width="10" height="10">' + "</layer>",
(int(1), "Tile Layer 1", None, None, None),
),
(
@@ -40,13 +39,7 @@ LAYER_DATA = [
+ "<properties>"
+ "</properties>"
+ "</layer>",
(
int(5),
"Tile Layer 4",
objects.OrderedPair(49, -50),
None,
"properties",
),
(int(5), "Tile Layer 4", objects.OrderedPair(49, -50), None, "properties",),
),
]
@@ -58,7 +51,11 @@ def test_parse_layer(xml, expected, monkeypatch):
monkeypatch.setattr(xml_parser, "_parse_properties_element", mockreturn)
assert xml_parser._parse_layer(_get_root_element(xml)) == expected
result = xml_parser._parse_layer(_get_root_element(xml))
print(result)
assert result == expected
@pytest.mark.parametrize(
@@ -161,14 +158,11 @@ DATA_BASE64 = [
]
@pytest.mark.parametrize(
"data_base64,width,compression,expected,raises", DATA_BASE64
)
@pytest.mark.parametrize("data_base64,width,compression,expected,raises", DATA_BASE64)
def test_decode_base64_data(data_base64, width, compression, expected, raises):
with raises:
assert (
xml_parser._decode_base64_data(data_base64, width, compression)
== expected
xml_parser._decode_base64_data(data_base64, width, compression) == expected
)
@@ -201,11 +195,7 @@ tile_by_gid = [
(15, {1: create_tile_set(5), 6: create_tile_set(10)}, objects.Tile(id_=9)),
(
20,
{
1: create_tile_set(5),
6: create_tile_set(10),
16: create_tile_set(10),
},
{1: create_tile_set(5), 6: create_tile_set(10), 16: create_tile_set(10),},
objects.Tile(id_=4),
),
]

View File

@@ -56,9 +56,7 @@ def test_map_simple():
assert map.tile_sets[1].properties == None
# unsure how to get paths to compare propperly
assert str(map.tile_sets[1].image.source) == (
"images/tmw_desert_spacing.png"
)
assert str(map.tile_sets[1].image.source) == ("images/tmw_desert_spacing.png")
assert map.tile_sets[1].image.trans == None
assert map.tile_sets[1].image.size == (265, 199)