Skip to content

Commit

Permalink
Issue pythonarcade#636, make sure file name is a string and not a pat…
Browse files Browse the repository at this point in the history
…h, before checking for :resources:
  • Loading branch information
pvcraven committed Apr 13, 2020
1 parent d212c7c commit fbc8fac
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion arcade/read_tiled_map.py
Expand Up @@ -141,7 +141,7 @@ def read_tiled_map(tmx_file: str, scaling: float = 1, tsx_file: str = None) -> T
my_map = TiledMap()

# If we should pull from local resources, replace with proper path
if tmx_file.startswith(":resources:"):
if isinstance(tmx_file, str) and str(tmx_file).startswith(":resources:"):
import os
path = os.path.dirname(os.path.abspath(__file__))
tmx_file = f"{path}/resources/{tmx_file[11:]}"
Expand Down
2 changes: 1 addition & 1 deletion arcade/sound.py
Expand Up @@ -30,7 +30,7 @@ def __init__(self, file_name: str, streaming: bool = False):
return

# If we should pull from local resources, replace with proper path
if file_name.startswith(":resources:"):
if isinstance(file_name, str) and str(file_name).startswith(":resources:"):
import os
path = os.path.dirname(os.path.abspath(__file__))
file_name = f"{path}/resources/{file_name[11:]}"
Expand Down
6 changes: 3 additions & 3 deletions arcade/texture.py
Expand Up @@ -212,7 +212,7 @@ def load_textures(file_name: str,
source_image = texture.image
else:
# If we should pull from local resources, replace with proper path
if str(file_name).startswith(":resources:"):
if isinstance(file_name, str) and str(file_name).startswith(":resources:"):
import os
path = os.path.dirname(os.path.abspath(__file__))
file_name = f"{path}/resources/{file_name[11:]}"
Expand Down Expand Up @@ -313,7 +313,7 @@ def load_texture(file_name: str,
source_image = texture.image
else:
# If we should pull from local resources, replace with proper path
if str(file_name).startswith(":resources:"):
if isinstance(file_name, str) and str(file_name).startswith(":resources:"):
import os
path = os.path.dirname(os.path.abspath(__file__))
file_name = f"{path}/resources/{file_name[11:]}"
Expand Down Expand Up @@ -390,7 +390,7 @@ def load_spritesheet(file_name: str,
texture_list = []

# If we should pull from local resources, replace with proper path
if str(file_name).startswith(":resources:"):
if isinstance(file_name, str) and str(file_name).startswith(":resources:"):
path = os.path.dirname(os.path.abspath(__file__))
file_name = f"{path}/resources/{file_name[11:]}"

Expand Down
2 changes: 1 addition & 1 deletion arcade/tilemap.py
Expand Up @@ -53,7 +53,7 @@ def read_tmx(tmx_file: str) -> pytiled_parser.objects.TileMap:
"""

# If we should pull from local resources, replace with proper path
if tmx_file.startswith(":resources:"):
if isinstance(tmx_file, str) and str(tmx_file).startswith(":resources:"):
import os
path = os.path.dirname(os.path.abspath(__file__))
tmx_file = f"{path}/resources/{tmx_file[11:]}"
Expand Down

0 comments on commit fbc8fac

Please sign in to comment.