chore: drop seemingly unused enumerateForge.py

This commit is contained in:
Sefa Eyeoglu 2022-04-05 00:18:11 +02:00
parent 5a6ae18755
commit b0810ce299
No known key found for this signature in database
GPG Key ID: C10411294912A422
3 changed files with 0 additions and 133 deletions

View File

@ -1,128 +0,0 @@
from enum import Enum
import requests
from cachecontrol import CacheControl
from cachecontrol.caches import FileCache
from meta.metautil import *
PMC_DIR = os.environ["PMC_DIR"]
# with open(PMC_DIR + '/index.json', 'r', encoding='utf-8') as index:
# packages = PolyMCPackageIndex(json.load(index))
# for entry in packages.packages:
# print (entry)
class DownloadType(Enum):
NORMAL = 1
FORGE_XZ = 2
class DownloadEntry:
def __init__(self, url: str, kind: DownloadType, name: GradleSpecifier):
self.name = name
self.url = url
self.kind = kind
def __lt__(self, other):
return self.name < other.name
def __eq__(self, other):
return self.name == other.name
def __ne__(self, other):
return not self.__eq__(other)
def __hash__(self):
return self.name.__hash__()
def toString(self):
return "%s %s" % (self.name.toString(), self.url)
def __repr__(self):
return "DownloadEntry('" + self.toString() + "')"
class MojangLibrary(JsonObject):
extract = ObjectProperty(MojangLibraryExtractRules, exclude_if_none=True, default=None)
name = GradleSpecifierProperty(required=True)
downloads = ObjectProperty(MojangLibraryDownloads, exclude_if_none=True, default=None)
natives = DictProperty(StringProperty, exclude_if_none=True, default=None)
rules = ListProperty(MojangRule, exclude_if_none=True, default=None)
class PolyMCLibrary(MojangLibrary):
url = StringProperty(exclude_if_none=True, default=None)
mmcHint = StringProperty(name="MMC-hint", exclude_if_none=True, default=None) # this is supposed to be MMC-hint!
def GetLibraryDownload(library: PolyMCLibrary):
if library.natives:
raise Exception('Natives are not handled yet')
name = library.name
if library.mmcHint == 'forge-pack-xz':
kind = DownloadType.FORGE_XZ
name.extension = 'jar.pack.xz'
else:
kind = DownloadType.NORMAL
if library.downloads:
url = library.downloads.artifact.url
if url.endswith('.zip'):
name.extension = 'zip'
if library.downloads:
url = library.downloads.artifact.url
else:
if library.url:
url = library.url + name.getPath()
else:
url = 'https://libraries.minecraft.net/' + name.getPath()
return DownloadEntry(url, kind, name)
with open(PMC_DIR + '/net.minecraftforge/index.json', 'r', encoding='utf-8') as forgeIndex:
forgeVersions = PolyMCVersionIndex(json.load(forgeIndex))
urlSet = set()
for entry in forgeVersions.versions:
versionString = entry.version
versionPath = PMC_DIR + "/net.minecraftforge/%s.json" % versionString
with open(versionPath, 'r') as infile:
forgeVersion = PolyMCVersionFile(json.load(infile))
if forgeVersion.libraries:
for entry in forgeVersion.libraries:
urlSet.add(GetLibraryDownload(entry))
if forgeVersion.jarMods:
for entry in forgeVersion.jarMods:
urlSet.add(GetLibraryDownload(entry))
if forgeVersion.mavenFiles:
for entry in forgeVersion.mavenFiles:
urlSet.add(GetLibraryDownload(entry))
forever_cache = FileCache('caches/forge_cache', forever=True)
sess = CacheControl(requests.Session(), forever_cache)
for entry in urlSet:
libraryName = entry.name
folderPath = "caches/forgemaven/%s" % libraryName.getBase()
filePath = "caches/forgemaven/%s" % libraryName.getPath()
if not os.path.isfile(filePath):
os.makedirs(folderPath, exist_ok=True)
rfile = sess.get(entry.url, stream=True)
try:
rfile.raise_for_status()
except requests.exceptions.HTTPError as exc:
print('Missing: %s %s' % (entry.name, entry.url))
continue
print('Downloading %s' % entry.name)
print('To %s' % filePath)
with open(filePath, 'wb') as f:
for chunk in rfile.iter_content(chunk_size=4096):
f.write(chunk)

View File

@ -81,11 +81,6 @@ if [ "${DEPLOY_TO_GIT}" = true ] ; then
fi fi
fi fi
if [ "${UPDATE_FORGE_MAVEN}" = true ] ; then
echo "Updating the copy of Forge maven"
python enumerateForge.py
fi
if [ "${DEPLOY_TO_FOLDER}" = true ] ; then if [ "${DEPLOY_TO_FOLDER}" = true ] ; then
DEPLOY_FOLDER_var="DEPLOY_FOLDER_$MODE" DEPLOY_FOLDER_var="DEPLOY_FOLDER_$MODE"
DEPLOY_FOLDER="${!DEPLOY_FOLDER_var}" DEPLOY_FOLDER="${!DEPLOY_FOLDER_var}"