Skip to content

Commit e57cfce

Browse files
Add Windows handling
1 parent 079aacd commit e57cfce

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

catalog/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from importlib.resources import as_file, files
23

34
import pandas as pd
@@ -17,6 +18,10 @@ def load(slug: str) -> gbt.Game:
1718
"""
1819
Load a game from the package catalog.
1920
"""
21+
# Handle backslashes for Windows
22+
if sys.platform == "win32":
23+
game_slug.replace("/", "\\") # noqa: F821
24+
2025
for suffix, reader in READERS.items():
2126
resource_path = _CATALOG_RESOURCE / f"{slug}{suffix}"
2227

@@ -45,6 +50,10 @@ def games() -> pd.DataFrame:
4550
rel_path = resource_path.relative_to(_CATALOG_RESOURCE)
4651
game_slug = str(rel_path.with_suffix(""))
4752

53+
# Replace backslashes for Windows
54+
if sys.platform == "win32":
55+
game_slug.replace("\\", "/") # noqa: F821
56+
4857
with as_file(resource_path) as path:
4958
game = reader(str(path))
5059
records.append(

0 commit comments

Comments
 (0)