diff options
| author | Sefa Eyeoglu <contact@scrumplex.net> | 2023-08-06 15:45:34 +0200 |
|---|---|---|
| committer | Sefa Eyeoglu <contact@scrumplex.net> | 2023-08-06 16:01:34 +0200 |
| commit | 7675db816943df4014754716a807786ffa397b40 (patch) | |
| tree | f1139dd859524214f4a1d96aa1ea1d184bcadf37 | |
| parent | f31198321b6123d00864b10b932ac507a29f6254 (diff) | |
| download | Project-Tick-7675db816943df4014754716a807786ffa397b40.tar.gz Project-Tick-7675db816943df4014754716a807786ffa397b40.zip | |
fix: remove unused code
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
| -rw-r--r-- | generateNeoForge.py | 121 | ||||
| -rw-r--r-- | meta/model/neoforge.py | 14 | ||||
| -rw-r--r-- | updateNeoForge.py | 26 |
3 files changed, 12 insertions, 149 deletions
diff --git a/generateNeoForge.py b/generateNeoForge.py index 2e556a6337..0e45e808bb 100644 --- a/generateNeoForge.py +++ b/generateNeoForge.py @@ -14,7 +14,6 @@ from meta.common.neoforge import ( INSTALLER_INFO_DIR, FORGEWRAPPER_MAVEN, ) -from meta.common.forge import FORGE_COMPONENT from meta.common.mojang import MINECRAFT_COMPONENT from meta.model import ( MetaVersion, @@ -27,7 +26,6 @@ from meta.model import ( ) from meta.model.neoforge import ( NeoForgeVersion, - NeoForgeInstallerProfile, NeoForgeInstallerProfileV2, InstallerInfo, DerivedNeoForgeIndex, @@ -45,105 +43,6 @@ def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs) -# Construct a set of libraries out of a Minecraft version file, for filtering. -mc_version_cache = {} - - -def load_mc_version_filter(version: str): - if version in mc_version_cache: - return mc_version_cache[version] - v = MetaVersion.parse_file( - os.path.join(LAUNCHER_DIR, MINECRAFT_COMPONENT, f"{version}.json") - ) - libs = set(map(attrgetter("name"), v.libraries)) - mc_version_cache[version] = libs - return libs - - -""" -Match a library coordinate to a set of library coordinates. - * Block those that pass completely. - * For others, block those with lower versions than in the set. -""" - - -def should_ignore_artifact(libs: Collection[GradleSpecifier], match: GradleSpecifier): - for ver in libs: - if ( - ver.group == match.group - and ver.artifact == match.artifact - and ver.classifier == match.classifier - ): - if ver.version == match.version: - # Everything is matched perfectly - this one will be ignored - return True - elif LooseVersion(ver.version) > LooseVersion(match.version): - return True - else: - # Otherwise it did not match - new version is higher and this is an upgrade - return False - # No match found in the set - we need to keep this - return False - - -def version_from_profile( - profile: NeoForgeInstallerProfile, version: NeoForgeVersion -) -> MetaVersion: - v = MetaVersion(name="NeoForge", version=version.rawVersion, uid=NEOFORGE_COMPONENT) - mc_version = profile.install.minecraft - v.requires = [Dependency(uid=MINECRAFT_COMPONENT, equals=mc_version)] - v.main_class = profile.version_info.main_class - v.release_time = profile.version_info.time - - args = profile.version_info.minecraft_arguments - tweakers = [] - expression = re.compile(r"--tweakClass ([a-zA-Z0-9.]+)") - match = expression.search(args) - while match is not None: - tweakers.append(match.group(1)) - args = args[: match.start()] + args[match.end() :] - match = expression.search(args) - if len(tweakers) > 0: - args = args.strip() - v.additional_tweakers = tweakers - # v.minecraftArguments = args - - v.libraries = [] - mc_filter = load_mc_version_filter(mc_version) - for forge_lib in profile.version_info.libraries: - if ( - forge_lib.name.is_lwjgl() - or forge_lib.name.is_log4j() - or should_ignore_artifact(mc_filter, forge_lib.name) - ): - continue - - overridden_name = forge_lib.name - if overridden_name.group == "net.minecraftforge": - if overridden_name.artifact == "minecraftforge": - overridden_name.artifact = "forge" - overridden_name.version = "%s-%s" % ( - mc_version, - overridden_name.version, - ) - - overridden_name.classifier = "universal" - elif overridden_name.artifact == "forge": - overridden_name.classifier = "universal" - - overridden_lib = Library(name=overridden_name) - if forge_lib.url == "http://maven.minecraftforge.net/": - overridden_lib.url = "https://maven.minecraftforge.net/" - else: - overridden_lib.url = forge_lib.url - # if forge_lib.checksums and len(forge_lib.checksums) == 2: - # overridden_lib.mmcHint = "forge-pack-xz" - v.libraries.append(overridden_lib) - - v.order = 5 - return v - - def version_from_build_system_installer( installer: MojangVersion, profile: NeoForgeInstallerProfileV2, @@ -284,22 +183,14 @@ def main(): ) eprint(installer_version_filepath) - if os.path.isfile(installer_version_filepath): - installer = MojangVersion.parse_file(installer_version_filepath) - profile = NeoForgeInstallerProfileV2.parse_file(profile_filepath) - v = version_from_build_system_installer(installer, profile, version) - else: - if version.uses_installer(): - # If we do not have the Forge json, we ignore this version - if not os.path.isfile(profile_filepath): - eprint("Skipping %s with missing profile json" % key) - continue - profile = NeoForgeInstallerProfile.parse_file(profile_filepath) - v = version_from_profile(profile, version) + assert os.path.isfile( + installer_version_filepath + ), f"version {installer_version_filepath} does not have installer version manifest" + installer = MojangVersion.parse_file(installer_version_filepath) + profile = NeoForgeInstallerProfileV2.parse_file(profile_filepath) + v = version_from_build_system_installer(installer, profile, version) v.write(os.path.join(LAUNCHER_DIR, NEOFORGE_COMPONENT, f"{v.version}.json")) - v.version = "NEO-" + v.version - v.write(os.path.join(LAUNCHER_DIR, FORGE_COMPONENT, f"{v.version}.json")) recommended_versions.sort() diff --git a/meta/model/neoforge.py b/meta/model/neoforge.py index 906b20bfca..a13605c282 100644 --- a/meta/model/neoforge.py +++ b/meta/model/neoforge.py @@ -132,12 +132,6 @@ class NeoForgeOptional(MetaBase): maven: Optional[str] -class NeoForgeInstallerProfile(MetaBase): - install: NeoForgeInstallerProfileInstallSection - version_info: NeoForgeVersionFile = Field(alias="versionInfo") - optionals: Optional[List[NeoForgeOptional]] - - class DataSpec(MetaBase): client: Optional[str] server: Optional[str] @@ -211,14 +205,10 @@ class NeoForgeVersion: self.changelog_url = url def name(self): - return "forge %d" % self.build + return "neoforge %d" % self.build def uses_installer(self): - if self.installer_url is None: - return False - if self.mc_version == "1.5.2": - return False - return True + return self.installer_url is not None def filename(self): if self.uses_installer(): diff --git a/updateNeoForge.py b/updateNeoForge.py index 57b5492606..431930c401 100644 --- a/updateNeoForge.py +++ b/updateNeoForge.py @@ -17,7 +17,7 @@ import urllib.parse from pydantic import ValidationError from meta.common import upstream_path, ensure_upstream_dir, static_path, default_session -from meta.common.forge import ( +from meta.common.neoforge import ( JARS_DIR, INSTALLER_INFO_DIR, INSTALLER_MANIFEST_DIR, @@ -30,7 +30,6 @@ from meta.model.neoforge import ( NeoForgeMCVersionInfo, DerivedNeoForgeIndex, NeoForgeVersion, - NeoForgeInstallerProfile, NeoForgeInstallerProfileV2, InstallerInfo, ) @@ -98,19 +97,8 @@ def get_single_forge_files_manifest(longversion): classifier = file["name"][find_nth(name, "-", 3) + 1 : len(file_name)] # assert len(extensionObj.items()) == 1 - index = 0 - count = 0 file_obj = NeoForgeFile(classifier=classifier, extension=file_ext[1:]) - if count == 0: - ret_dict[classifier] = file_obj - index += 1 - count += 1 - else: - print( - "%s: Multiple objects detected for classifier %s:" - % (longversion, classifier) - ) - assert False + ret_dict[classifier] = file_obj if not from_file: Path(path_thing).parent.mkdir(parents=True, exist_ok=True) @@ -141,9 +129,7 @@ def main(): assert type(long_version) == str mc_version = long_version.split("-")[0] match = version_expression.match(long_version) - if not match: - pprint(long_version) - assert match + assert match, f"{long_version} doesn't match version regex" assert match.group("mc") == mc_version try: files = get_single_forge_files_manifest(long_version) @@ -153,6 +139,7 @@ def main(): version = match.group("ver") branch = match.group("branch") + # TODO: what *is* recommended? is_recommended = False entry = NeoForgeEntry( @@ -263,11 +250,6 @@ def main(): is_parsable = False exception = None try: - NeoForgeInstallerProfile.parse_raw(install_profile_data) - is_parsable = True - except ValidationError as err: - exception = err - try: NeoForgeInstallerProfileV2.parse_raw(install_profile_data) is_parsable = True except ValidationError as err: |
