fix: correct spelling of 'get_platform_fs_structure' in multiple files

This commit is contained in:
zurdi
2025-12-21 16:48:45 +00:00
parent cc63d19e5c
commit ecf4ae542f
4 changed files with 36 additions and 20 deletions

View File

@@ -53,14 +53,29 @@ class FSPlatformsHandler(FSHandler):
def get_platforms_directory(self) -> str:
cnfg = cm.get_config()
structure = self.detect_library_structure()
if structure == "A":
return cnfg.ROMS_FOLDER_NAME
if structure == "B":
return ""
# Fallback to config hint when detection is inconclusive
return (
cnfg.ROMS_FOLDER_NAME
if os.path.exists(cnfg.HIGH_PRIO_STRUCTURE_PATH)
else ""
)
def get_plaform_fs_structure(self, fs_slug: str) -> str:
def get_platform_fs_structure(self, fs_slug: str) -> str:
cnfg = cm.get_config()
structure = self.detect_library_structure()
if structure == "A":
return f"{cnfg.ROMS_FOLDER_NAME}/{fs_slug}"
if structure == "B":
return f"{fs_slug}/{cnfg.ROMS_FOLDER_NAME}"
# Fallback to config hint when detection is inconclusive
return (
f"{cnfg.ROMS_FOLDER_NAME}/{fs_slug}"
if os.path.exists(cnfg.HIGH_PRIO_STRUCTURE_PATH)
@@ -73,7 +88,7 @@ class FSPlatformsHandler(FSHandler):
Args:
fs_slug: platform slug
"""
platform_path = self.get_plaform_fs_structure(fs_slug)
platform_path = self.get_platform_fs_structure(fs_slug)
try:
await self.make_directory(platform_path)
@@ -94,7 +109,8 @@ class FSPlatformsHandler(FSHandler):
raise FolderStructureNotMatchException() from e
# For Structure B, only include directories that have a roms subfolder
if not os.path.exists(cnfg.HIGH_PRIO_STRUCTURE_PATH):
structure = self.detect_library_structure()
if structure == "B":
platforms = [
platform
for platform in platforms

View File

@@ -108,7 +108,7 @@ def _make_file_uri(platform_dir: str, raw_text: str) -> str:
def extract_media_from_gamelist_rom(
game: Element, platform: Platform
) -> GamelistMetadataMedia:
platform_dir = fs_platform_handler.get_plaform_fs_structure(platform.fs_slug)
platform_dir = fs_platform_handler.get_platform_fs_structure(platform.fs_slug)
gamelist_media = GamelistMetadataMedia(
box2d_url=None,
@@ -285,7 +285,7 @@ class GamelistHandler(MetadataHandler):
async def _find_gamelist_file(self, platform: Platform) -> Path | None:
"""Find the gamelist.xml file for a platform"""
platform_dir = fs_platform_handler.get_plaform_fs_structure(platform.fs_slug)
platform_dir = fs_platform_handler.get_platform_fs_structure(platform.fs_slug)
# Check for platform-level gamelist.xml
platform_gamelist = f"{platform_dir}/gamelist.xml"

View File

@@ -108,42 +108,42 @@ class TestFSPlatformsHandler:
result = handler.get_platforms_directory()
assert result == ""
def test_get_plaform_fs_structure_high_priority(
def test_get_platform_fs_structure_high_priority(
self, handler: FSPlatformsHandler, config
):
"""Test get_plaform_fs_structure with high priority structure"""
"""Test get_platform_fs_structure with high priority structure"""
fs_slug = "n64"
with patch(
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
):
with patch("os.path.exists", return_value=True):
result = handler.get_plaform_fs_structure(fs_slug)
result = handler.get_platform_fs_structure(fs_slug)
assert result == f"{config.ROMS_FOLDER_NAME}/{fs_slug}"
def test_get_plaform_fs_structure_normal_structure(
def test_get_platform_fs_structure_normal_structure(
self, handler: FSPlatformsHandler, config
):
"""Test get_plaform_fs_structure with normal structure"""
"""Test get_platform_fs_structure with normal structure"""
fs_slug = "n64"
with patch(
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
):
result = handler.get_plaform_fs_structure(fs_slug)
result = handler.get_platform_fs_structure(fs_slug)
assert result == f"{fs_slug}/{config.ROMS_FOLDER_NAME}"
def test_get_plaform_fs_structure_custom_folder_name(
def test_get_platform_fs_structure_custom_folder_name(
self, handler: FSPlatformsHandler, config_custom_folder
):
"""Test get_plaform_fs_structure with custom folder name"""
"""Test get_platform_fs_structure with custom folder name"""
fs_slug = "psx"
with patch(
"handler.filesystem.platforms_handler.cm.get_config",
return_value=config_custom_folder,
):
result = handler.get_plaform_fs_structure(fs_slug)
result = handler.get_platform_fs_structure(fs_slug)
assert result == f"{fs_slug}/{config_custom_folder.ROMS_FOLDER_NAME}"
async def test_add_platform_creates_directory(
@@ -246,7 +246,7 @@ class TestFSPlatformsHandler:
with patch(
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
):
result = handler.get_plaform_fs_structure(fs_slug)
result = handler.get_platform_fs_structure(fs_slug)
assert result == f"{fs_slug}/{config.ROMS_FOLDER_NAME}"
async def test_path_construction_consistency(
@@ -259,7 +259,7 @@ class TestFSPlatformsHandler:
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
):
# Test both methods return consistent paths
structure_path = handler.get_plaform_fs_structure(fs_slug)
structure_path = handler.get_platform_fs_structure(fs_slug)
with patch.object(handler, "make_directory") as mock_make_directory:
await handler.add_platform(fs_slug)
@@ -275,7 +275,7 @@ class TestFSPlatformsHandler:
):
for platform in existing_platforms:
expected_path = f"{platform}/{config.ROMS_FOLDER_NAME}"
result = handler.get_plaform_fs_structure(platform)
result = handler.get_platform_fs_structure(platform)
assert result == expected_path
async def test_edge_cases_and_error_handling(
@@ -286,7 +286,7 @@ class TestFSPlatformsHandler:
with patch(
"handler.filesystem.platforms_handler.cm.get_config", return_value=config
):
result = handler.get_plaform_fs_structure("")
result = handler.get_platform_fs_structure("")
assert result == f"/{config.ROMS_FOLDER_NAME}"
# Test adding empty platform
@@ -309,5 +309,5 @@ class TestFSPlatformsHandler:
# Test that each platform gets correct structure
for platform in expected_filtered:
structure = handler.get_plaform_fs_structure(platform)
structure = handler.get_platform_fs_structure(platform)
assert structure == f"{platform}/{config.ROMS_FOLDER_NAME}"

View File

@@ -205,7 +205,7 @@ class GamelistExporter:
log.error(f"Platform with ID {platform_id} not found")
return False
platform_fs_structure = fs_platform_handler.get_plaform_fs_structure(
platform_fs_structure = fs_platform_handler.get_platform_fs_structure(
platform.fs_slug
)