mirror of
https://github.com/tuna/mirror-web.git
synced 2025-12-25 20:32:46 +00:00
add sorting support to genisolist
This commit is contained in:
parent
711e59f369
commit
772087c469
|
|
@ -51,6 +51,7 @@ version = $3
|
|||
type = $2
|
||||
platform = $4
|
||||
key_by = $2 $4
|
||||
sort_by = $4 $2
|
||||
|
||||
[ubuntu desktop]
|
||||
distro = Ubuntu
|
||||
|
|
@ -235,6 +236,7 @@ version = $3
|
|||
type = $2
|
||||
platform = $1
|
||||
key_by = $1 $2
|
||||
sort_by = $1 $2
|
||||
|
||||
[manjaro]
|
||||
distro = Manjaro
|
||||
|
|
@ -387,6 +389,7 @@ platform = $3
|
|||
type = $1
|
||||
version = $2
|
||||
key_by = $1 $3
|
||||
sort_by = $3 $1
|
||||
|
||||
[docker mac]
|
||||
distro = Docker
|
||||
|
|
@ -513,6 +516,7 @@ pattern = (VSCodium\w+-\w+)-([\.\d]+)\.exe(?!.)
|
|||
platform = Windows
|
||||
type = $1
|
||||
version = $2
|
||||
sort_by = Windows $1 $2
|
||||
category = app
|
||||
|
||||
[vscodium linux tar]
|
||||
|
|
@ -523,16 +527,18 @@ pattern = VSCodium-linux-(\w+)-([\.\d]+)\.tar\.gz(?!.)
|
|||
platform = Linux
|
||||
type = $1 tar
|
||||
version = $2
|
||||
sort_by = Linux $1 $2
|
||||
category = app
|
||||
|
||||
[vscodium linux package]
|
||||
distro = VS Codium
|
||||
listvers = 10
|
||||
location = github-release/VSCodium/vscodium/*/*
|
||||
pattern = codium[_-]([\.\w-]+)[_\.-](x86_64|amd64|armhf|arm64)\.(\w+)(?!.)
|
||||
pattern = codium[_-]([\.\d]+)[\.\w-]+[_\.-](x86_64|amd64|armhf|arm64)\.(\w+)(?!.)
|
||||
platform = Linux
|
||||
type = $2 $3
|
||||
version = $1
|
||||
sort_by = Linux $2 $1
|
||||
category = app
|
||||
|
||||
[vscodium mac]
|
||||
|
|
@ -543,6 +549,7 @@ pattern = VSCodium\.([\.\d]+)\.dmg(?!.)
|
|||
platform = macOS
|
||||
type = x86_64
|
||||
version = $1
|
||||
sort_by = macOS x86_64 $1
|
||||
category = app
|
||||
|
||||
[vlc]
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import re
|
|||
import glob
|
||||
import json
|
||||
import logging
|
||||
import collections
|
||||
from urllib.parse import urljoin
|
||||
from distutils.version import LooseVersion
|
||||
from configparser import ConfigParser
|
||||
|
|
@ -31,6 +32,18 @@ def renderTemplate(template, result):
|
|||
return template
|
||||
|
||||
|
||||
def getSortKeys(template, result):
|
||||
keys = []
|
||||
for i in template.split(' '):
|
||||
if not i:
|
||||
continue
|
||||
if i[0] != '$':
|
||||
keys.append(i)
|
||||
else:
|
||||
keys.append(result.group(int(i[1:])))
|
||||
return keys
|
||||
|
||||
|
||||
def parseSection(items):
|
||||
items = dict(items)
|
||||
|
||||
|
|
@ -68,6 +81,11 @@ def parseSection(items):
|
|||
imageinfo[prop] = renderTemplate(items.get(prop, ""), result)
|
||||
if 'version' not in imageinfo:
|
||||
imageinfo['version'] = '0.0'
|
||||
sort_by = items.get("sort_by", "")
|
||||
if not(sort_by):
|
||||
imageinfo['sort_key'] = (imageinfo['version'], imageinfo['platform'], imageinfo['type'])
|
||||
else:
|
||||
imageinfo['sort_key'] = getSortKeys(sort_by, result)
|
||||
|
||||
logger.debug("[JSON] %r", imageinfo)
|
||||
key = renderTemplate(items.get("key_by", ""), result)
|
||||
|
|
@ -136,17 +154,18 @@ def getImageList():
|
|||
oldcwd = os.getcwd()
|
||||
os.chdir(root)
|
||||
|
||||
url_dict = {}
|
||||
img_dict = collections.defaultdict(list)
|
||||
for section in ini.sections():
|
||||
if section == "%main%":
|
||||
continue
|
||||
for image in parseSection(ini.items(section)):
|
||||
if not image['distro'] in url_dict:
|
||||
url_dict[image['distro']] = []
|
||||
img_dict[image['distro']].append(image)
|
||||
|
||||
url_dict[image['distro']].append(
|
||||
getDetail(image, urlbase)
|
||||
)
|
||||
url_dict = {}
|
||||
for distro, images in img_dict.items():
|
||||
images.sort(key=lambda x: x['sort_key'])
|
||||
logger.debug("[IMAGES] %r %r", distro, images)
|
||||
url_dict[distro] = [getDetail(image, urlbase) for image in images]
|
||||
|
||||
os.chdir(oldcwd)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue