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