Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Commit

Permalink
Tiny code cleanup, fix syntax error
Browse files Browse the repository at this point in the history
  • Loading branch information
NiceneNerd committed Jun 9, 2020
1 parent 4415787 commit ad9729d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
14 changes: 7 additions & 7 deletions bcml/__version__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
_major = 3
_minor = 0
_patch = "0b14"
_MAJOR = 3
_MINOR = 0
_PATCH = "0b15"

VERSION = f"{_major}.{_minor}.{_patch}"
USER_VERSION = f"""{_major}.{_minor}.{_patch[0:1]} {
'alpha' if _major < 1 else ''
VERSION = f"{_MAJOR}.{_MINOR}.{_PATCH}"
USER_VERSION = f"""{_MAJOR}.{_MINOR}.{_PATCH[0:1]} {
'alpha' if _MAJOR < 1 else ''
}{
f'beta {_patch[_patch.rindex("b") + 1:]}' if 'b' in _patch else ''
f'beta {_PATCH[_PATCH.rindex("b") + 1:]}' if 'b' in _PATCH else ''
}"""
28 changes: 13 additions & 15 deletions bcml/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import re
import shutil
import subprocess
import traceback
from base64 import b64decode
from copy import deepcopy
from functools import partial
Expand All @@ -21,10 +20,9 @@
from xml.dom import minidom

import oead
import xxhash

from bcml import util, mergers, dev, upgrade
from bcml.util import BcmlMod, ZPATH, InstallError
from bcml.util import BcmlMod, ZPATH


def extract_mod_meta(mod: Path) -> {}:
Expand Down Expand Up @@ -131,7 +129,7 @@ def find_modded_files(tmp_dir: Path, pool: Pool = None) -> List[Union[Path, str]
if (tmp_dir / util.get_dlc_path()).exists:
try:
util.get_aoc_dir()
except FileNotFoundError as err:
except FileNotFoundError:
raise FileNotFoundError(
"This mod uses DLC files, but BCML cannot locate the DLC folder in "
"your game dump."
Expand Down Expand Up @@ -160,16 +158,16 @@ def find_modded_files(tmp_dir: Path, pool: Pool = None) -> List[Union[Path, str]
partial(_check_modded, tmp_dir=tmp_dir),
{f for f in tmp_dir.rglob("**/*") if f.is_file()},
)
for r in results:
if r:
modded_files.append(r)
for result in results:
if result:
modded_files.append(result)
total = len(modded_files)
print(f'Found {total} modified file{"s" if total > 1 else ""}')

total = 0
sarc_files = {f for f in modded_files if f.suffix in util.SARC_EXTS}
if sarc_files:
print(f"Scanning files packed in SARCs...")
print("Scanning files packed in SARCs...")
for files in this_pool.imap_unordered(
partial(find_modded_sarc_files, tmp_dir=tmp_dir), sarc_files
):
Expand Down Expand Up @@ -306,13 +304,13 @@ def refresh_master_export():
bcmlentry = settings.createElement("Entry")
if new_cemu:
bcmlentry.setAttribute(
"filename", f"graphicPacks\\BreathOfTheWild_BCML\\rules.txt"
"filename", "graphicPacks\\BreathOfTheWild_BCML\\rules.txt"
)
else:
entryfile = settings.createElement("filename")
entryfile.appendChild(
settings.createTextNode(
f"graphicPacks\\BreathOfTheWild_BCML\\rules.txt"
"graphicPacks\\BreathOfTheWild_BCML\\rules.txt"
)
)
bcmlentry.appendChild(entryfile)
Expand All @@ -329,15 +327,15 @@ def process_cp_mod(mod: Path):
def nx2u(nx_text: str) -> str:
return (
nx_text.replace("\\\\", "/")
nx_text.replace("\\", "/")
.replace("\\", "/")
.replace("01007EF00011E000/romfs", "content")
.replace("01007EF00011F001/romfs", "aoc/0010")
)

def u2nx(u_text: str) -> str:
return (
u_text.replace("\\\\", "/")
u_text.replace("\\", "/")
.replace("\\", "/")
.replace("content", "01007EF00011E000/romfs")
.replace("aoc/0010", "01007EF00011F001/romfs")
)
Expand Down Expand Up @@ -586,7 +584,7 @@ def install_mod(
output_mod = BcmlMod(mod_dir)
try:
util.get_mod_link_meta(rules)
util.get_mod_preview(output_mod, rules)
util.get_mod_preview(output_mod)
except Exception: # pylint: disable=broad-except
pass

Expand Down Expand Up @@ -627,7 +625,7 @@ def disable_mod(mod: BcmlMod, wait_merge: bool = False):
(mod.path / ".disabled").write_bytes(b"")
if not wait_merge:
with Pool() as pool:
print(f"Remerging affected files...")
print("Remerging affected files...")
for merger in remergers:
merger.set_pool(pool)
merger.perform_merge()
Expand All @@ -639,7 +637,7 @@ def enable_mod(mod: BcmlMod, wait_merge: bool = False):
print(f"Enabling {mod.name}...")
(mod.path / ".disabled").unlink()
if not wait_merge:
print(f"Remerging affected files...")
print("Remerging affected files...")
with Pool() as pool:
remergers = []
for merger in [merger() for merger in mergers.get_mergers()]:
Expand Down
2 changes: 1 addition & 1 deletion bcml/mergers/rstable.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def calculate_size(path: Path) -> int:
size += 1000
if path.suffix == ".hkrb":
size += 8
if len(data) % 32 == 0:
if path.stat().st_size % 32 == 0:
size += 32
return size
except struct.error:
Expand Down
2 changes: 1 addition & 1 deletion installer.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Application]
name=BCML
publisher=Nicene Nerd
version=3.0.0b14
version=3.0.0b15
entry_point=bcml.__main__:main
icon=bcml/data/bcml.ico
license_file=docs/LICENSE.md
Expand Down

0 comments on commit ad9729d

Please sign in to comment.