Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
boubou19 committed Dec 7, 2024
1 parent bb869d1 commit d699a80
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
8 changes: 6 additions & 2 deletions src/gtnh/assembler/generic_assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ def get_mods(self, side: Side) -> List[Tuple[GTNHModInfo, GTNHVersion]]:
mods: List[Tuple[GTNHModInfo, GTNHVersion]] = github_mods + external_mods
return mods

def external_mods(self, valid_sides: Set[Side], release:Optional[GTNHRelease]=None) -> List[Tuple[GTNHModInfo, GTNHVersion]]:
def external_mods(
self, valid_sides: Set[Side], release: Optional[GTNHRelease] = None
) -> List[Tuple[GTNHModInfo, GTNHVersion]]:
"""
Method to grab the external mod info objects as well as their targetted version.
Expand All @@ -147,7 +149,9 @@ def external_mods(self, valid_sides: Set[Side], release:Optional[GTNHRelease]=No

return external_mods

def github_mods(self, valid_sides: Set[Side], release:Optional[GTNHRelease]=None) -> List[Tuple[GTNHModInfo, GTNHVersion]]:
def github_mods(
self, valid_sides: Set[Side], release: Optional[GTNHRelease] = None
) -> List[Tuple[GTNHModInfo, GTNHVersion]]:
"""
Method to grab the github mod info objects as well as their targetted version.
Expand Down
28 changes: 21 additions & 7 deletions src/gtnh/assembler/technic.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,31 +100,43 @@ async def partial_assemble(self, side: Side, verbose: bool = False) -> None:
os.remove(removed_modlist_name)
log.warn(f"Previous modlist {Fore.YELLOW}'{removed_modlist_name}'{Fore.RESET} deleted")

log.info(f"Constructing {Fore.YELLOW}{side}{Fore.RESET} archive at {Fore.YELLOW}'{updated_mods_archive_name}'{Fore.RESET}")
log.info(
f"Constructing {Fore.YELLOW}{side}{Fore.RESET} archive at {Fore.YELLOW}'{updated_mods_archive_name}'{Fore.RESET}"
)

with ZipFile(updated_mods_archive_name, "w", compression=ZIP_DEFLATED) as archive:
log.info("Adding mods to the archive")
self.add_mods(side, self.differential_update(side, DifferentialUpdateMode.UPDATED_MODS), archive, verbose=verbose)
self.add_mods(
side, self.differential_update(side, DifferentialUpdateMode.UPDATED_MODS), archive, verbose=verbose
)
log.info("Adding config to the archive")
self.add_config(side, self.get_config(), archive, verbose=verbose)
log.info("Generating the readme for the modpack repo")
self.generate_readme()
log.info("Archive created successfully!")

log.info(f"Constructing {Fore.YELLOW}{side}{Fore.RESET} archive at {Fore.YELLOW}'{new_mods_archive_name}'{Fore.RESET}")
log.info(
f"Constructing {Fore.YELLOW}{side}{Fore.RESET} archive at {Fore.YELLOW}'{new_mods_archive_name}'{Fore.RESET}"
)

with ZipFile(new_mods_archive_name, "w", compression=ZIP_DEFLATED) as archive:
log.info("Adding mods to the archive")
self.add_mods(side, self.differential_update(side, DifferentialUpdateMode.NEW_MODS), archive, verbose=verbose)
self.add_mods(
side, self.differential_update(side, DifferentialUpdateMode.NEW_MODS), archive, verbose=verbose
)
log.info("Archive created successfully!")

with open(removed_modlist_name, "w") as file:
log.info("generating removed modlist")
removed_modlist: List[tuple[GTNHModInfo, GTNHVersion]] = self.differential_update(side, DifferentialUpdateMode.REMOVED_MODS)
removed_modlist: List[tuple[GTNHModInfo, GTNHVersion]] = self.differential_update(
side, DifferentialUpdateMode.REMOVED_MODS
)
file.write("\n".join([f"{mod.name}: {version.version_tag}" for (mod, version) in removed_modlist]))
log.info("modlist created successfully!")

def differential_update(self, side: Side, update_mode:DifferentialUpdateMode) -> list[Tuple[GTNHModInfo, GTNHVersion]]:
def differential_update(
self, side: Side, update_mode: DifferentialUpdateMode
) -> list[Tuple[GTNHModInfo, GTNHVersion]]:
update_source: Callable[[GTNHRelease, GTNHRelease], set[str]]

if update_mode == DifferentialUpdateMode.NEW_MODS:
Expand All @@ -135,7 +147,9 @@ def differential_update(self, side: Side, update_mode:DifferentialUpdateMode) ->
update_source = self.modpack_manager.get_removed_mods

last_release: GTNHRelease = self.modpack_manager.get_release(self.release.last_version) # type: ignore
process_release: GTNHRelease = last_release if update_mode == DifferentialUpdateMode.REMOVED_MODS else self.release
process_release: GTNHRelease = (
last_release if update_mode == DifferentialUpdateMode.REMOVED_MODS else self.release
)

valid_sides: Set[Side] = side.valid_mod_sides()
j9_sides: Set[Side] = {Side.CLIENT_JAVA9, Side.BOTH_JAVA9}
Expand Down
12 changes: 8 additions & 4 deletions src/gtnh/modpack_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,13 +1028,17 @@ def get_changed_mods(self, release: GTNHRelease, previous_release: GTNHRelease)
common_github_mods = current_releases_github - removed_mods - new_mods
common_external_mods = current_releases_external - removed_mods - new_mods

changed_github_mods = {x for x in common_github_mods if release.github_mods[x].version != previous_release.github_mods[x].version}
changed_external_mods = {x for x in common_external_mods if release.external_mods[x].version != previous_release.external_mods[x].version}
changed_github_mods = {
x for x in common_github_mods if release.github_mods[x].version != previous_release.github_mods[x].version
}
changed_external_mods = {
x
for x in common_external_mods
if release.external_mods[x].version != previous_release.external_mods[x].version
}

return changed_github_mods | changed_external_mods



def generate_changelog(
self, release: GTNHRelease, previous_release: GTNHRelease | None = None, include_no_changelog: bool = False
) -> dict[str, list[str]]:
Expand Down

0 comments on commit d699a80

Please sign in to comment.