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/
|
.git/
|
||||||
|
|
||||||
caches/
|
caches/
|
||||||
|
.idea/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
public/
|
public/
|
||||||
|
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@ public/*/
|
|||||||
|
|
||||||
caches/
|
caches/
|
||||||
!caches/*/.keep
|
!caches/*/.keep
|
||||||
|
.idea/
|
||||||
__pycache__
|
__pycache__
|
||||||
config_local.sh
|
config_local.sh
|
||||||
polymc
|
polymc
|
||||||
|
@ -3,7 +3,7 @@ from enum import Enum
|
|||||||
import requests
|
import requests
|
||||||
from cachecontrol import CacheControl
|
from cachecontrol import CacheControl
|
||||||
from cachecontrol.caches import FileCache
|
from cachecontrol.caches import FileCache
|
||||||
from metautil import *
|
from meta.metautil import *
|
||||||
|
|
||||||
PMC_DIR = os.environ["PMC_DIR"]
|
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"]
|
PMC_DIR = polymc_path()
|
||||||
UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
|
UPSTREAM_DIR = upstream_path()
|
||||||
|
|
||||||
|
ensure_component_dir("net.fabricmc.fabric-loader")
|
||||||
|
ensure_component_dir("net.fabricmc.intermediary")
|
||||||
|
|
||||||
# turn loader versions into packages
|
# turn loader versions into packages
|
||||||
loaderRecommended = []
|
loaderRecommended = []
|
||||||
@ -10,15 +14,6 @@ intermediaryRecommended = []
|
|||||||
intermediaryVersions = []
|
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):
|
def loadJarInfo(mavenKey):
|
||||||
with open(UPSTREAM_DIR + "/fabric/jars/" + mavenKey.replace(":", ".") + ".json", 'r',
|
with open(UPSTREAM_DIR + "/fabric/jars/" + mavenKey.replace(":", ".") + ".json", 'r',
|
||||||
encoding='utf-8') as jarInfoFile:
|
encoding='utf-8') as jarInfoFile:
|
||||||
|
@ -2,21 +2,18 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
from distutils.version import LooseVersion
|
from distutils.version import LooseVersion
|
||||||
|
|
||||||
from forgeutil import *
|
from meta.forgeutil import *
|
||||||
from metautil import *
|
from meta.metautil import *
|
||||||
|
from meta.common import ensure_component_dir, polymc_path, upstream_path
|
||||||
|
|
||||||
PMC_DIR = os.environ["PMC_DIR"]
|
PMC_DIR = polymc_path()
|
||||||
UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
|
UPSTREAM_DIR = upstream_path()
|
||||||
|
|
||||||
def mkdirs(path):
|
ensure_component_dir("net.minecraftforge")
|
||||||
if not os.path.exists(path):
|
|
||||||
os.makedirs(path)
|
|
||||||
|
|
||||||
|
|
||||||
mkdirs(PMC_DIR + "/net.minecraftforge")
|
|
||||||
|
|
||||||
FORGEWRAPPER_MAVEN = "https://polymc.github.io/files/maven/%s"
|
FORGEWRAPPER_MAVEN = "https://polymc.github.io/files/maven/%s"
|
||||||
|
|
||||||
|
|
||||||
def eprint(*args, **kwargs):
|
def eprint(*args, **kwargs):
|
||||||
print(*args, file=sys.stderr, **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"]
|
PMC_DIR = polymc_path()
|
||||||
UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
|
UPSTREAM_DIR = upstream_path()
|
||||||
|
|
||||||
def mkdirs(path):
|
ensure_component_dir("com.mumfrey.liteloader")
|
||||||
if not os.path.exists(path):
|
|
||||||
os.makedirs(path)
|
|
||||||
|
|
||||||
|
|
||||||
mkdirs(PMC_DIR + "/com.mumfrey.liteloader")
|
|
||||||
|
|
||||||
# load the locally cached version list
|
# load the locally cached version list
|
||||||
def loadLiteloaderJson():
|
def loadLiteloaderJson():
|
||||||
with open(UPSTREAM_DIR + "/liteloader/versions.json", 'r', encoding='utf-8') as f:
|
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 operator import itemgetter
|
||||||
from pprint import pprint
|
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"]
|
PMC_DIR = polymc_path()
|
||||||
UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
|
UPSTREAM_DIR = upstream_path()
|
||||||
|
|
||||||
def mkdirs(path):
|
ensure_component_dir("net.minecraft")
|
||||||
if not os.path.exists(path):
|
ensure_component_dir("org.lwjgl")
|
||||||
os.makedirs(path)
|
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):
|
def map_log4j_artifact(version):
|
||||||
if version == "2.0-beta9":
|
if version == "2.0-beta9":
|
||||||
return ("2.0-beta9-fixed", "https://polymc.github.io/files/maven/%s")
|
return ("2.0-beta9-fixed", "https://polymc.github.io/files/maven/%s")
|
||||||
@ -372,7 +369,7 @@ for lwjglVersionVariant in lwjglVersionVariants:
|
|||||||
processSingleVariant(decidedVariant.version)
|
processSingleVariant(decidedVariant.version)
|
||||||
else:
|
else:
|
||||||
raise Exception("No variant decided for version %s out of %d possible ones and %d unknown ones." % (
|
raise Exception("No variant decided for version %s out of %d possible ones and %d unknown ones." % (
|
||||||
lwjglVersionVariant, passedVariants, unknownVariants))
|
lwjglVersionVariant, passedVariants, unknownVariants))
|
||||||
|
|
||||||
lwjglSharedData = PolyMCSharedPackageData(uid='org.lwjgl', name='LWJGL 2')
|
lwjglSharedData = PolyMCSharedPackageData(uid='org.lwjgl', name='LWJGL 2')
|
||||||
lwjglSharedData.recommended = ['2.9.4-nightly-20150209']
|
lwjglSharedData.recommended = ['2.9.4-nightly-20150209']
|
||||||
|
2
index.py
2
index.py
@ -1,7 +1,7 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
|
|
||||||
from metautil import *
|
from meta.metautil import *
|
||||||
|
|
||||||
PMC_DIR = os.environ["PMC_DIR"]
|
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):
|
class FabricInstallerArguments(JsonObject):
|
||||||
@ -21,7 +20,7 @@ class FabricInstallerLibraries(JsonObject):
|
|||||||
class FabricInstallerDataV1(JsonObject):
|
class FabricInstallerDataV1(JsonObject):
|
||||||
version = IntegerProperty(required=True)
|
version = IntegerProperty(required=True)
|
||||||
libraries = ObjectProperty(FabricInstallerLibraries, required=True)
|
libraries = ObjectProperty(FabricInstallerLibraries, required=True)
|
||||||
mainClass = jsonobject.DefaultProperty()
|
mainClass = DefaultProperty()
|
||||||
arguments = ObjectProperty(FabricInstallerArguments, required=False)
|
arguments = ObjectProperty(FabricInstallerArguments, required=False)
|
||||||
launchwrapper = ObjectProperty(FabricInstallerLaunchwrapper, required=False)
|
launchwrapper = ObjectProperty(FabricInstallerLaunchwrapper, required=False)
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
from metautil import *
|
from .metautil import *
|
||||||
|
|
||||||
|
|
||||||
# A post-processed entry constructed from the reconstructed Forge version index
|
# 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 __future__ import absolute_import
|
||||||
from .base import JsonObjectMeta
|
from .base import JsonObjectMeta
|
||||||
from .containers import JsonArray
|
from .containers import JsonArray
|
||||||
@ -10,5 +12,6 @@ __all__ = [
|
|||||||
'StringProperty', 'BooleanProperty',
|
'StringProperty', 'BooleanProperty',
|
||||||
'DateProperty', 'DateTimeProperty', 'TimeProperty',
|
'DateProperty', 'DateTimeProperty', 'TimeProperty',
|
||||||
'ObjectProperty', 'ListProperty', 'DictProperty', 'SetProperty',
|
'ObjectProperty', 'ListProperty', 'DictProperty', 'SetProperty',
|
||||||
'JsonObject', 'JsonArray', 'AbstractDateProperty', 'JsonProperty'
|
'JsonObject', 'JsonArray', 'AbstractDateProperty', 'JsonProperty',
|
||||||
|
'DefaultProperty'
|
||||||
]
|
]
|
@ -137,7 +137,7 @@ class JsonContainerProperty(JsonProperty):
|
|||||||
self.item_type
|
self.item_type
|
||||||
|
|
||||||
def set_item_type(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'):
|
if hasattr(item_type, '_type'):
|
||||||
item_type = item_type._type
|
item_type = item_type._type
|
||||||
if isinstance(item_type, tuple):
|
if isinstance(item_type, tuple):
|
@ -1,4 +1,4 @@
|
|||||||
from metautil import *
|
from .metautil import *
|
||||||
|
|
||||||
'''
|
'''
|
||||||
"repo":{
|
"repo":{
|
@ -3,7 +3,7 @@ import json
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
import iso8601
|
import iso8601
|
||||||
from jsonobject import *
|
from .jsonobject import *
|
||||||
|
|
||||||
PMC_DIR = os.environ["PMC_DIR"]
|
PMC_DIR = os.environ["PMC_DIR"]
|
||||||
|
|
@ -4,7 +4,7 @@ import zipfile
|
|||||||
import requests
|
import requests
|
||||||
from cachecontrol import CacheControl
|
from cachecontrol import CacheControl
|
||||||
from cachecontrol.caches import FileCache
|
from cachecontrol.caches import FileCache
|
||||||
from fabricutil import *
|
from meta.fabricutil import *
|
||||||
|
|
||||||
DATETIME_FORMAT_HTTP = "%a, %d %b %Y %H:%M:%S %Z"
|
DATETIME_FORMAT_HTTP = "%a, %d %b %Y %H:%M:%S %Z"
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ from pprint import pprint
|
|||||||
import requests
|
import requests
|
||||||
from cachecontrol import CacheControl
|
from cachecontrol import CacheControl
|
||||||
from cachecontrol.caches import FileCache
|
from cachecontrol.caches import FileCache
|
||||||
from forgeutil import *
|
from meta.forgeutil import *
|
||||||
from metautil import *
|
from meta.metautil import *
|
||||||
|
|
||||||
UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
|
UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import sys
|
|||||||
import requests
|
import requests
|
||||||
from cachecontrol import CacheControl
|
from cachecontrol import CacheControl
|
||||||
from cachecontrol.caches import FileCache
|
from cachecontrol.caches import FileCache
|
||||||
from liteloaderutil import *
|
from meta.liteloaderutil import *
|
||||||
|
|
||||||
UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
|
UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import requests
|
import requests
|
||||||
from cachecontrol import CacheControl
|
from cachecontrol import CacheControl
|
||||||
from cachecontrol.caches import FileCache
|
from cachecontrol.caches import FileCache
|
||||||
from metautil import *
|
from meta.metautil import *
|
||||||
|
|
||||||
UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
|
UPSTREAM_DIR = os.environ["UPSTREAM_DIR"]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user