From 1ad5b5950182beff0dd16a2c8df48f2de28d05fe Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Mon, 21 Mar 2022 22:25:21 +0100 Subject: refactor: improve fabric scripts --- meta/common.py | 19 ------------------- meta/common/__init__.py | 31 +++++++++++++++++++++++++++++++ meta/common/fabric.py | 10 ++++++++++ meta/metautil.py | 3 ++- 4 files changed, 43 insertions(+), 20 deletions(-) delete mode 100644 meta/common.py create mode 100644 meta/common/__init__.py create mode 100644 meta/common/fabric.py (limited to 'meta') diff --git a/meta/common.py b/meta/common.py deleted file mode 100644 index 5454f517f3..0000000000 --- a/meta/common.py +++ /dev/null @@ -1,19 +0,0 @@ -import os - - -def polymc_path(): - if "PMC_DIR" in os.environ: - return os.environ["PMC_DIR"] - return "polymc" - - -def upstream_path(): - if "UPSTREAM_DIR" in os.environ: - return os.environ["UPSTREAM_DIR"] - return "upstream" - - -def ensure_component_dir(component_id): - path = os.path.join(polymc_path(), component_id) - if not os.path.exists(path): - os.makedirs(path) diff --git a/meta/common/__init__.py b/meta/common/__init__.py new file mode 100644 index 0000000000..77aa996552 --- /dev/null +++ b/meta/common/__init__.py @@ -0,0 +1,31 @@ +import os + +DATETIME_FORMAT_HTTP = "%a, %d %b %Y %H:%M:%S %Z" + + +def polymc_path(): + if "PMC_DIR" in os.environ: + return os.environ["PMC_DIR"] + return "polymc" + + +def upstream_path(): + if "UPSTREAM_DIR" in os.environ: + return os.environ["UPSTREAM_DIR"] + return "upstream" + + +def ensure_upstream_dir(path): + path = os.path.join(upstream_path(), path) + if not os.path.exists(path): + os.makedirs(path) + + +def ensure_component_dir(component_id): + path = os.path.join(polymc_path(), component_id) + if not os.path.exists(path): + os.makedirs(path) + + +def transform_maven_key(maven_key: str): + return maven_key.replace(":", ".") diff --git a/meta/common/fabric.py b/meta/common/fabric.py new file mode 100644 index 0000000000..0861730ce9 --- /dev/null +++ b/meta/common/fabric.py @@ -0,0 +1,10 @@ +from os.path import join + +BASE_DIR = "fabric" + +JARS_DIR = join(BASE_DIR, "jars") +INSTALLER_INFO_DIR = join(BASE_DIR, "loader-installer-json") +META_DIR = join(BASE_DIR, "loader-installer-json") + +LOADER_COMPONENT = "net.fabricmc.fabric-loader" +INTERMEDIARY_COMPONENT = "net.fabricmc.intermediary" diff --git a/meta/metautil.py b/meta/metautil.py index e417bd6e65..11c4009868 100644 --- a/meta/metautil.py +++ b/meta/metautil.py @@ -4,8 +4,9 @@ import os import iso8601 from .jsonobject import * +from .common import polymc_path -PMC_DIR = os.environ["PMC_DIR"] +PMC_DIR = polymc_path() class ISOTimestampProperty(AbstractDateProperty): -- cgit 0.0.5-2-1-g0f52