diff options
| author | Sefa Eyeoglu <contact@scrumplex.net> | 2022-04-02 16:49:31 +0200 |
|---|---|---|
| committer | Sefa Eyeoglu <contact@scrumplex.net> | 2022-04-05 14:30:30 +0200 |
| commit | 5895e5accfbb1268500f9dd35003abf207a548c8 (patch) | |
| tree | 811353153fa339d81f59485cd58cc52d6fda04ce /meta | |
| parent | 7cd825c67f288cfec366cb1e38f389e769307be9 (diff) | |
| download | Project-Tick-5895e5accfbb1268500f9dd35003abf207a548c8.tar.gz Project-Tick-5895e5accfbb1268500f9dd35003abf207a548c8.zip | |
feat: implement experiments updates
Diffstat (limited to 'meta')
| -rw-r--r-- | meta/common/__init__.py | 6 | ||||
| -rw-r--r-- | meta/common/http.py | 6 | ||||
| -rw-r--r-- | meta/common/mojang.py | 2 | ||||
| -rw-r--r-- | meta/model/mojang.py | 20 |
4 files changed, 33 insertions, 1 deletions
diff --git a/meta/common/__init__.py b/meta/common/__init__.py index f0f620f4e9..478404362a 100644 --- a/meta/common/__init__.py +++ b/meta/common/__init__.py @@ -20,6 +20,12 @@ def upstream_path(): return "upstream" +def static_path(): + if "STATIC_DIR" in os.environ: + return os.environ["STATIC_DIR"] + return "static" + + def ensure_upstream_dir(path): path = os.path.join(upstream_path(), path) if not os.path.exists(path): diff --git a/meta/common/http.py b/meta/common/http.py new file mode 100644 index 0000000000..c057e4b06f --- /dev/null +++ b/meta/common/http.py @@ -0,0 +1,6 @@ +def download_binary_file(sess, path, url): + with open(path, 'wb') as f: + r = sess.get(url) + r.raise_for_status() + for chunk in r.iter_content(chunk_size=128): + f.write(chunk) diff --git a/meta/common/mojang.py b/meta/common/mojang.py index 953e3d1d37..1c16afc885 100644 --- a/meta/common/mojang.py +++ b/meta/common/mojang.py @@ -6,5 +6,7 @@ VERSION_MANIFEST_FILE = join(BASE_DIR, "version_manifest_v2.json") VERSIONS_DIR = join(BASE_DIR, "versions") ASSETS_DIR = join(BASE_DIR, "assets") +STATIC_EXPERIMENTS_FILE = join(BASE_DIR, "minecraft-experiments.json") + MINECRAFT_COMPONENT = "" LWJGL_COMPONENT = "" diff --git a/meta/model/mojang.py b/meta/model/mojang.py index 37a14b4435..fa00071dd7 100644 --- a/meta/model/mojang.py +++ b/meta/model/mojang.py @@ -1,5 +1,7 @@ from datetime import datetime -from typing import Optional, List +from typing import Optional, List, Dict + +from pydantic import AnyHttpUrl from . import MetaBase @@ -50,3 +52,19 @@ class MojangIndexWrap: self.index = index self.latest = index.latest self.versions = dict((x.id, x) for x in index.versions) + + +class ExperimentEntry(MetaBase): + id: str + url: AnyHttpUrl + wiki: Optional[AnyHttpUrl] + + +class ExperimentIndex(MetaBase): + experiments: List[ExperimentEntry] + + +class ExperimentIndexWrap: + def __init__(self, index: ExperimentIndex): + self.index: ExperimentIndex = index + self.versions: Dict[str, ExperimentEntry] = dict((x.id, x) for x in index.experiments) |
