mirror of
https://github.com/unmojang/meta.git
synced 2025-09-23 03:01:21 -04:00
refactor: move utils into package
This commit is contained in:
parent
0731956adc
commit
a8babf42c5
@ -1,6 +1,7 @@
|
||||
.git/
|
||||
|
||||
caches/
|
||||
.idea/
|
||||
__pycache__/
|
||||
public/
|
||||
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@ public/*/
|
||||
|
||||
caches/
|
||||
!caches/*/.keep
|
||||
.idea/
|
||||
__pycache__
|
||||
config_local.sh
|
||||
polymc
|
||||
|
@ -3,7 +3,7 @@ from enum import Enum
|
||||
import requests
|
||||
from cachecontrol import CacheControl
|
||||
from cachecontrol.caches import FileCache
|
||||
from metautil import *
|
||||
from meta.metautil import *
|
||||
|
||||
PMC_DIR = os.environ["PMC_DIR"]
|
||||
|
||||
|
@ -1,7 +1,11 @@
|
||||
from fabricutil import *
|
||||
from meta.fabricutil import *
|
||||
from meta.common import ensure_component_dir, polymc_path, upstream_path
|
||||
|
||||
PMC_DIR = os.environ["PMC_DIR"]
|
||||
UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
|
||||
PMC_DIR = polymc_path()
|
||||
UPSTREAM_DIR = upstream_path()
|
||||
|
||||
ensure_component_dir("net.fabricmc.fabric-loader")
|
||||
ensure_component_dir("net.fabricmc.intermediary")
|
||||
|
||||
# turn loader versions into packages
|
||||
loaderRecommended = []
|
||||
@ -10,15 +14,6 @@ intermediaryRecommended = []
|
||||
intermediaryVersions = []
|
||||
|
||||
|
||||
def mkdirs(path):
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
|
||||
|
||||
mkdirs(PMC_DIR + "/net.fabricmc.fabric-loader")
|
||||
mkdirs(PMC_DIR + "/net.fabricmc.intermediary")
|
||||
|
||||
|
||||
def loadJarInfo(mavenKey):
|
||||
with open(UPSTREAM_DIR + "/fabric/jars/" + mavenKey.replace(":", ".") + ".json", 'r',
|
||||
encoding='utf-8') as jarInfoFile:
|
||||
|
@ -2,21 +2,18 @@ import re
|
||||
import sys
|
||||
from distutils.version import LooseVersion
|
||||
|
||||
from forgeutil import *
|
||||
from metautil import *
|
||||
from meta.forgeutil import *
|
||||
from meta.metautil import *
|
||||
from meta.common import ensure_component_dir, polymc_path, upstream_path
|
||||
|
||||
PMC_DIR = os.environ["PMC_DIR"]
|
||||
UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
|
||||
PMC_DIR = polymc_path()
|
||||
UPSTREAM_DIR = upstream_path()
|
||||
|
||||
def mkdirs(path):
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
|
||||
|
||||
mkdirs(PMC_DIR + "/net.minecraftforge")
|
||||
ensure_component_dir("net.minecraftforge")
|
||||
|
||||
FORGEWRAPPER_MAVEN = "https://polymc.github.io/files/maven/%s"
|
||||
|
||||
|
||||
def eprint(*args, **kwargs):
|
||||
print(*args, file=sys.stderr, **kwargs)
|
||||
|
||||
|
@ -1,15 +1,12 @@
|
||||
from liteloaderutil import *
|
||||
from meta.liteloaderutil import *
|
||||
from meta.common import ensure_component_dir, polymc_path, upstream_path
|
||||
|
||||
PMC_DIR = os.environ["PMC_DIR"]
|
||||
UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
|
||||
PMC_DIR = polymc_path()
|
||||
UPSTREAM_DIR = upstream_path()
|
||||
|
||||
def mkdirs(path):
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
ensure_component_dir("com.mumfrey.liteloader")
|
||||
|
||||
|
||||
mkdirs(PMC_DIR + "/com.mumfrey.liteloader")
|
||||
|
||||
# load the locally cached version list
|
||||
def loadLiteloaderJson():
|
||||
with open(UPSTREAM_DIR + "/liteloader/versions.json", 'r', encoding='utf-8') as f:
|
||||
|
@ -4,20 +4,17 @@ from collections import defaultdict, namedtuple
|
||||
from operator import itemgetter
|
||||
from pprint import pprint
|
||||
|
||||
from metautil import *
|
||||
from meta.metautil import *
|
||||
from meta.common import ensure_component_dir, polymc_path, upstream_path
|
||||
|
||||
PMC_DIR = os.environ["PMC_DIR"]
|
||||
UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
|
||||
PMC_DIR = polymc_path()
|
||||
UPSTREAM_DIR = upstream_path()
|
||||
|
||||
def mkdirs(path):
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
ensure_component_dir("net.minecraft")
|
||||
ensure_component_dir("org.lwjgl")
|
||||
ensure_component_dir("org.lwjgl")
|
||||
|
||||
|
||||
mkdirs(PMC_DIR + "/net.minecraft")
|
||||
mkdirs(PMC_DIR + "/org.lwjgl")
|
||||
mkdirs(PMC_DIR + "/org.lwjgl3")
|
||||
|
||||
def map_log4j_artifact(version):
|
||||
if version == "2.0-beta9":
|
||||
return ("2.0-beta9-fixed", "https://polymc.github.io/files/maven/%s")
|
||||
|
2
index.py
2
index.py
@ -1,7 +1,7 @@
|
||||
import hashlib
|
||||
from operator import itemgetter
|
||||
|
||||
from metautil import *
|
||||
from meta.metautil import *
|
||||
|
||||
PMC_DIR = os.environ["PMC_DIR"]
|
||||
|
||||
|
1
meta/__init__.py
Normal file
1
meta/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
"""Meta package of meta"""
|
19
meta/common.py
Normal file
19
meta/common.py
Normal file
@ -0,0 +1,19 @@
|
||||
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)
|
@ -1,5 +1,4 @@
|
||||
import jsonobject
|
||||
from metautil import *
|
||||
from .metautil import *
|
||||
|
||||
|
||||
class FabricInstallerArguments(JsonObject):
|
||||
@ -21,7 +20,7 @@ class FabricInstallerLibraries(JsonObject):
|
||||
class FabricInstallerDataV1(JsonObject):
|
||||
version = IntegerProperty(required=True)
|
||||
libraries = ObjectProperty(FabricInstallerLibraries, required=True)
|
||||
mainClass = jsonobject.DefaultProperty()
|
||||
mainClass = DefaultProperty()
|
||||
arguments = ObjectProperty(FabricInstallerArguments, required=False)
|
||||
launchwrapper = ObjectProperty(FabricInstallerLaunchwrapper, required=False)
|
||||
|
@ -1,6 +1,6 @@
|
||||
from collections import namedtuple
|
||||
|
||||
from metautil import *
|
||||
from .metautil import *
|
||||
|
||||
|
||||
# A post-processed entry constructed from the reconstructed Forge version index
|
@ -1,3 +1,5 @@
|
||||
# TODO: maybe move to pydantic in the future?
|
||||
|
||||
from __future__ import absolute_import
|
||||
from .base import JsonObjectMeta
|
||||
from .containers import JsonArray
|
||||
@ -10,5 +12,6 @@ __all__ = [
|
||||
'StringProperty', 'BooleanProperty',
|
||||
'DateProperty', 'DateTimeProperty', 'TimeProperty',
|
||||
'ObjectProperty', 'ListProperty', 'DictProperty', 'SetProperty',
|
||||
'JsonObject', 'JsonArray', 'AbstractDateProperty', 'JsonProperty'
|
||||
'JsonObject', 'JsonArray', 'AbstractDateProperty', 'JsonProperty',
|
||||
'DefaultProperty'
|
||||
]
|
@ -137,7 +137,7 @@ class JsonContainerProperty(JsonProperty):
|
||||
self.item_type
|
||||
|
||||
def set_item_type(self, item_type):
|
||||
from jsonobject.base import JsonObjectMeta
|
||||
from meta.jsonobject.base import JsonObjectMeta
|
||||
if hasattr(item_type, '_type'):
|
||||
item_type = item_type._type
|
||||
if isinstance(item_type, tuple):
|
@ -1,4 +1,4 @@
|
||||
from metautil import *
|
||||
from .metautil import *
|
||||
|
||||
'''
|
||||
"repo":{
|
@ -3,7 +3,7 @@ import json
|
||||
import os
|
||||
|
||||
import iso8601
|
||||
from jsonobject import *
|
||||
from .jsonobject import *
|
||||
|
||||
PMC_DIR = os.environ["PMC_DIR"]
|
||||
|
@ -4,7 +4,7 @@ import zipfile
|
||||
import requests
|
||||
from cachecontrol import CacheControl
|
||||
from cachecontrol.caches import FileCache
|
||||
from fabricutil import *
|
||||
from meta.fabricutil import *
|
||||
|
||||
DATETIME_FORMAT_HTTP = "%a, %d %b %Y %H:%M:%S %Z"
|
||||
|
||||
|
@ -13,8 +13,8 @@ from pprint import pprint
|
||||
import requests
|
||||
from cachecontrol import CacheControl
|
||||
from cachecontrol.caches import FileCache
|
||||
from forgeutil import *
|
||||
from metautil import *
|
||||
from meta.forgeutil import *
|
||||
from meta.metautil import *
|
||||
|
||||
UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
|
||||
|
||||
|
@ -7,7 +7,7 @@ import sys
|
||||
import requests
|
||||
from cachecontrol import CacheControl
|
||||
from cachecontrol.caches import FileCache
|
||||
from liteloaderutil import *
|
||||
from meta.liteloaderutil import *
|
||||
|
||||
UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import requests
|
||||
from cachecontrol import CacheControl
|
||||
from cachecontrol.caches import FileCache
|
||||
from metautil import *
|
||||
from meta.metautil import *
|
||||
|
||||
UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user