mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Reworked pkginfo again
This commit is contained in:
parent
5228a12e3f
commit
0ec93d7d0f
@ -2,19 +2,22 @@
|
||||
# the package access to some global meta-information about itself
|
||||
|
||||
try:
|
||||
# package distributrion
|
||||
import pkg_resources
|
||||
self = pkg_resources.get_distribution('maloja')
|
||||
metadata = {'version':self.version}
|
||||
except:
|
||||
# from source
|
||||
import toml
|
||||
with open("./pyproject.toml") as filed:
|
||||
metadata = toml.load(filed)['project']
|
||||
VERSIONSTR = metadata['version']
|
||||
HOMEPAGE = metadata['urls']['homepage']
|
||||
except:
|
||||
# package distributrion
|
||||
from importlib import metadata
|
||||
VERSIONSTR = metadata.version('maloja')
|
||||
urls = metadata.metadata('maloja').get_all('Project-URL')
|
||||
urls = [e.split(', ') for e in urls]
|
||||
HOMEPAGE = [e[1] for e in urls if e[0] == 'homepage'][0]
|
||||
|
||||
versionstr = metadata['version']
|
||||
version = versionstr.split('.')
|
||||
urls = {
|
||||
"repo":"https://github.com/krateng/maloja"
|
||||
}
|
||||
user_agent = f"Maloja/{versionstr} ( {urls['repo']} )"
|
||||
|
||||
VERSION = VERSIONSTR.split('.')
|
||||
|
||||
|
||||
USER_AGENT = f"Maloja/{VERSIONSTR} ( {HOMEPAGE} )"
|
||||
|
@ -1,6 +1,6 @@
|
||||
from ..database import *
|
||||
from ..globalconf import malojaconfig, apikeystore
|
||||
from ..__pkginfo__ import version
|
||||
from ..__pkginfo__ import VERSION, VERSIONSTR
|
||||
from ..malojauri import uri_to_internal
|
||||
from .. import utilities
|
||||
|
||||
@ -42,8 +42,8 @@ def server_info():
|
||||
|
||||
return {
|
||||
"name":malojaconfig["NAME"],
|
||||
"version":version,
|
||||
"versionstring":".".join(str(n) for n in version),
|
||||
"version":VERSION,
|
||||
"versionstring":VERSIONSTR,
|
||||
"db_status":dbstatus
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ from doreah.configuration import Configuration
|
||||
from doreah.configuration import types as tp
|
||||
from doreah.keystore import KeyStore
|
||||
|
||||
from .__pkginfo__ import versionstr
|
||||
from .__pkginfo__ import VERSIONSTR
|
||||
|
||||
|
||||
|
||||
@ -275,7 +275,7 @@ data_dir = {
|
||||
|
||||
### write down the last ran version
|
||||
with open(pthj(dir_settings['state'],".lastmalojaversion"),"w") as filed:
|
||||
filed.write(versionstr)
|
||||
filed.write(VERSIONSTR)
|
||||
filed.write("\n")
|
||||
|
||||
|
||||
|
@ -15,8 +15,8 @@ from .. import globalconf
|
||||
def print_header_info():
|
||||
print()
|
||||
print("#####")
|
||||
print("Maloja v" + info.versionstr)
|
||||
print(info.urls['repo'])
|
||||
print("Maloja v" + info.VERSIONSTR)
|
||||
print(info.HOMEPAGE)
|
||||
print("#####")
|
||||
print()
|
||||
|
||||
@ -120,7 +120,7 @@ def main(*args,**kwargs):
|
||||
}
|
||||
|
||||
if "version" in kwargs:
|
||||
print(info.versionstr)
|
||||
print(info.VERSIONSTR)
|
||||
|
||||
elif len(args) > 0:
|
||||
action = args[0]
|
||||
|
4
maloja/thirdparty/musicbrainz.py
vendored
4
maloja/thirdparty/musicbrainz.py
vendored
@ -3,7 +3,7 @@ import urllib.parse, urllib.request
|
||||
import json
|
||||
import time
|
||||
import threading
|
||||
from ..__pkginfo__ import user_agent
|
||||
from ..__pkginfo__ import USER_AGENT
|
||||
|
||||
class MusicBrainz(MetadataInterface):
|
||||
name = "MusicBrainz"
|
||||
@ -11,7 +11,7 @@ class MusicBrainz(MetadataInterface):
|
||||
|
||||
# musicbrainz is rate-limited
|
||||
lock = threading.Lock()
|
||||
useragent = user_agent
|
||||
useragent = USER_AGENT
|
||||
|
||||
settings = {
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
from ..__pkginfo__ import version
|
||||
from ..__pkginfo__ import VERSIONSTR
|
||||
from ..malojatime import ranges, thisweek, thisyear
|
||||
from ..globalconf import malojaconfig
|
||||
|
||||
@ -100,7 +100,7 @@ def send_stats():
|
||||
"data":json.dumps({
|
||||
"name":malojaconfig["NAME"],
|
||||
"url":malojaconfig["PUBLIC_URL"],
|
||||
"version":".".join(str(d) for d in version),
|
||||
"version":VERSIONSTR,
|
||||
"artists":len(ARTISTS),
|
||||
"tracks":len(TRACKS),
|
||||
"scrobbles":len(SCROBBLES)
|
||||
|
@ -9,7 +9,7 @@ authors = [ { name="Johannes Krattenmacher", email="maloja@dev.krateng.ch" } ]
|
||||
|
||||
urls.repository = "https://github.com/krateng/maloja"
|
||||
urls.documentation = "https://github.com/krateng/maloja"
|
||||
urls.homepage = "https://maloja.krateng.ch"
|
||||
urls.homepage = "https://github.com/krateng/maloja"
|
||||
|
||||
keywords = ["scrobbling", "music", "selfhosted", "database", "charts", "statistics"]
|
||||
classifiers = [
|
||||
|
Loading…
Reference in New Issue
Block a user