1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Decluttered namespace

This commit is contained in:
Krateng 2019-06-13 10:51:25 +02:00
parent f358b856dd
commit 060cb7ea23

View File

@ -1,14 +1,15 @@
# server # server
from bottle import request, response, FormsDict from bottle import request, response, FormsDict
# rest of the project # rest of the project
from cleanup import * from cleanup import CleanerAgent, CollectorAgent
from utilities import * import utilities
from malojatime import * from malojatime import register_scrobbletime, time_stamps, ranges
from urihandler import uri_to_internal, internal_to_uri, compose_querystring from urihandler import uri_to_internal, internal_to_uri, compose_querystring
import compliant_api import compliant_api
# doreah toolkit # doreah toolkit
from doreah.logging import log from doreah.logging import log
from doreah import tsv from doreah import tsv
from doreah import settings
from doreah.caching import Cache, DeepCache from doreah.caching import Cache, DeepCache
try: try:
from doreah.persistence import DiskDict from doreah.persistence import DiskDict
@ -30,7 +31,6 @@ import urllib
dblock = Lock() #global database lock dblock = Lock() #global database lock
SCROBBLES = [] # Format: tuple(track_ref,timestamp,saved) SCROBBLES = [] # Format: tuple(track_ref,timestamp,saved)
@ -868,10 +868,10 @@ def build_db():
# coa.updateIDs(ARTISTS) # coa.updateIDs(ARTISTS)
#start regular tasks #start regular tasks
update_medals() utilities.update_medals()
global db_rulestate global db_rulestate
db_rulestate = consistentRulestate("scrobbles",cla.checksums) db_rulestate = utilities.consistentRulestate("scrobbles",cla.checksums)
log("Database fully built!") log("Database fully built!")
@ -904,7 +904,7 @@ def sync():
for e in entries: for e in entries:
tsv.add_entries("scrobbles/" + e + ".tsv",entries[e],comments=False) tsv.add_entries("scrobbles/" + e + ".tsv",entries[e],comments=False)
#addEntries("scrobbles/" + e + ".tsv",entries[e],escape=False) #addEntries("scrobbles/" + e + ".tsv",entries[e],escape=False)
combineChecksums("scrobbles/" + e + ".tsv",cla.checksums) utilities.combineChecksums("scrobbles/" + e + ".tsv",cla.checksums)
global lastsync global lastsync
@ -934,7 +934,7 @@ cacheday = (0,0,0)
def db_query(**kwargs): def db_query(**kwargs):
check_cache_age() check_cache_age()
global cache_query, cache_query_permanent global cache_query, cache_query_permanent
key = serialize(kwargs) key = utilities.serialize(kwargs)
if "timerange" in kwargs and not kwargs["timerange"].active(): if "timerange" in kwargs and not kwargs["timerange"].active():
if key in cache_query_permanent: if key in cache_query_permanent:
#print("Hit") #print("Hit")
@ -959,7 +959,7 @@ else:
def db_aggregate(**kwargs): def db_aggregate(**kwargs):
check_cache_age() check_cache_age()
global cache_aggregate, cache_aggregate_permanent global cache_aggregate, cache_aggregate_permanent
key = serialize(kwargs) key = utilities.serialize(kwargs)
if "timerange" in kwargs and not kwargs["timerange"].active(): if "timerange" in kwargs and not kwargs["timerange"].active():
if key in cache_aggregate_permanent: return copy.copy(cache_aggregate_permanent.get(key)) if key in cache_aggregate_permanent: return copy.copy(cache_aggregate_permanent.get(key))
result = db_aggregate_full(**kwargs) result = db_aggregate_full(**kwargs)