From d4faa9f7d808db3944972d73ae9d31cb813946bc Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Fri, 16 Apr 2021 03:51:16 +0000 Subject: [PATCH] Fix path issues for a few miscelaneous tools on Windows. --- bemani/data/data.py | 2 +- bemani/format/ifs.py | 12 ++++++------ bemani/frontend/app.py | 6 +++--- bemani/utils/afputils.py | 14 +++++++------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/bemani/data/data.py b/bemani/data/data.py index 918f459..b926bad 100644 --- a/bemani/data/data.py +++ b/bemani/data/data.py @@ -139,7 +139,7 @@ class Data: return False def __alembic_cmd(self, command: str, *args: str) -> None: - base_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'migrations/') + base_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'migrations') alembicArgs = [ '-c', os.path.join(base_dir, 'alembic.ini'), diff --git a/bemani/format/ifs.py b/bemani/format/ifs.py index d2e86b7..62c0293 100644 --- a/bemani/format/ifs.py +++ b/bemani/format/ifs.py @@ -76,14 +76,14 @@ class IFS: def get_children(parent: str, node: Node) -> None: real_name = self.__fix_name(node.name) if node.data_type == '3s32': - node_name = os.path.join(parent, real_name).replace('/imgfs/', '') + node_name = os.path.join(parent, real_name).replace(f'{os.sep}imgfs{os.sep}', '') files[node_name] = (node.value[0] + data_index, node.value[1], node.value[2]) else: for subchild in node.children: - get_children(os.path.join(parent, f"{real_name}/"), subchild) + get_children(os.path.join(parent, f"{real_name}{os.sep}"), subchild) # Recursively walk the entire filesystem extracting files and their locations. - get_children("/", header) + get_children(os.sep, header) for fn in files: (start, size, pack_time) = files[fn] @@ -92,9 +92,9 @@ class IFS: # Now, find all of the index files that are available. for filename in list(self.__files.keys()): - abs_filename = ("/" if filename.startswith("/") else "") + filename + abs_filename = (os.sep if filename.startswith(os.sep) else "") + filename - if abs_filename.endswith("/texturelist.xml"): + if abs_filename.endswith(f"{os.sep}texturelist.xml"): # This is a texture index. texdir = os.path.dirname(filename) @@ -156,7 +156,7 @@ class IFS: rect[2] // 2, rect[3] // 2, ) - elif abs_filename.endswith("/afplist.xml"): + elif abs_filename.endswith(f"{os.sep}afplist.xml"): # This is a texture index. afpdir = os.path.dirname(filename) bsidir = os.path.join(afpdir, "bsi") diff --git a/bemani/frontend/app.py b/bemani/frontend/app.py index 0da006d..f7d8a42 100644 --- a/bemani/frontend/app.py +++ b/bemani/frontend/app.py @@ -157,7 +157,7 @@ def render_react( 'react.html', **{ 'title': title, - 'reactbase': os.path.join('controllers/', controller), + 'reactbase': os.path.join('controllers', controller), 'inits': inits, 'links': links, }, @@ -234,8 +234,8 @@ def valid_pin(pin: str, type: str) -> bool: def navigation() -> Dict[str, Any]: # Look up JSX components we should provide for every page load components = [ - os.path.join('components/', f) - for f in os.listdir(os.path.join(static_location, 'components/')) + os.path.join('components', f) + for f in os.listdir(os.path.join(static_location, 'components')) if re.search(r'\.react\.js$', f) ] diff --git a/bemani/utils/afputils.py b/bemani/utils/afputils.py index 4f56501..891ded5 100644 --- a/bemani/utils/afputils.py +++ b/bemani/utils/afputils.py @@ -457,9 +457,9 @@ def main() -> int: if ifsfile is not None: for fname in ifsfile.filenames: - if fname.startswith("geo/"): + if fname.startswith(f"geo{os.sep}"): # Trim off directory. - shapename = fname[4:] + shapename = fname[(3 + len(os.sep)):] # Load file, register it. fdata = ifsfile.read_file(fname) @@ -468,9 +468,9 @@ def main() -> int: if args.verbose: print(f"Added {shapename} to SWF shape library.", file=sys.stderr) - elif fname.startswith("tex/") and fname.endswith(".png"): + elif fname.startswith(f"tex{os.sep}") and fname.endswith(".png"): # Trim off directory, png extension. - texname = fname[4:][:-4] + texname = fname[(3 + len(os.sep)):][:-4] # Load file, register it. fdata = ifsfile.read_file(fname) @@ -479,10 +479,10 @@ def main() -> int: if args.verbose: print(f"Added {texname} to SWF texture library.", file=sys.stderr) - elif fname.startswith("afp/"): + elif fname.startswith(f"afp{os.sep}"): # Trim off directory, see if it has a corresponding bsi. - afpname = fname[4:] - bsipath = f"afp/bsi/{afpname}" + afpname = fname[(3 + len(os.sep)):] + bsipath = f"afp{os.sep}bsi{os.sep}{afpname}" if bsipath in ifsfile.filenames: afpdata = ifsfile.read_file(fname)