mirror of
https://github.com/krateng/maloja.git
synced 2025-04-15 00:10:32 +03:00
Removed dependency on doreah's tsv module
This commit is contained in:
parent
387c40d18c
commit
e9d8303763
@ -7,6 +7,8 @@ from doreah.logging import log
|
||||
from ..globalconf import data_dir
|
||||
|
||||
apikeystore = KeyStore(file=data_dir['clients']("apikeys.yml"),save_endpoint="/apis/mlj_1/apikeys")
|
||||
|
||||
|
||||
from .. import upgrade
|
||||
upgrade.upgrade_apikeys()
|
||||
|
||||
|
@ -16,7 +16,6 @@ from . import dbcache
|
||||
|
||||
# doreah toolkit
|
||||
from doreah.logging import log
|
||||
from doreah import tsv
|
||||
from doreah.auth import authenticated_api, authenticated_api_with_alternate
|
||||
import doreah
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
## directly in sql
|
||||
|
||||
|
||||
from doreah import tsv
|
||||
|
||||
import csv
|
||||
import os
|
||||
|
||||
from . import sqldb
|
||||
from ..globalconf import data_dir
|
||||
@ -18,8 +18,14 @@ def load_associated_rules():
|
||||
conn.execute(op)
|
||||
|
||||
# load from file
|
||||
raw = tsv.parse_all(data_dir["rules"](),"string","string","string")
|
||||
rules = [{'source_artist':b,'target_artist':c} for [a,b,c] in raw if a=="countas"]
|
||||
rawrules = []
|
||||
for f in os.listdir(data_dir["rules"]()):
|
||||
if f.split('.')[-1].lower() != 'tsv': continue
|
||||
filepath = data_dir["rules"](f)
|
||||
with open(filepath,'r') as filed:
|
||||
reader = csv.reader(filed,delimiter="\t")
|
||||
rawrules += [[col for col in entry if col] for entry in reader if len(entry)>0 and not entry[0].startswith('#')]
|
||||
rules = [{'source_artist':r[1],'target_artist':r[2]} for r in rawrules if r[0]=="countas"]
|
||||
|
||||
#for rule in rules:
|
||||
# print(f"Rule to replace {rule['source_artist']} with {rule['target_artist']}:")
|
||||
|
@ -2,12 +2,13 @@
|
||||
|
||||
import os
|
||||
import re
|
||||
import csv
|
||||
|
||||
from doreah.logging import log
|
||||
from doreah.io import col
|
||||
|
||||
from .globalconf import data_dir, dir_settings
|
||||
from . import apis
|
||||
from .apis import _apikeys
|
||||
|
||||
|
||||
def upgrade_apikeys():
|
||||
@ -15,12 +16,14 @@ def upgrade_apikeys():
|
||||
oldfile = os.path.join(dir_settings['config'],"clients","authenticated_machines.tsv")
|
||||
if os.path.exists(oldfile):
|
||||
try:
|
||||
from doreah import tsv
|
||||
clients = tsv.parse(oldfile,"string","string")
|
||||
for key,identifier in clients:
|
||||
apis.apikeystore[identifier] = key
|
||||
os.remove(oldfile)
|
||||
with open(oldfile,'r') as filed:
|
||||
reader = csv.reader(filed,delimiter="\t")
|
||||
entries = [[col for col in entry if col] for entry in reader if len(entry)>0 and not entry[0].startswith('#')]
|
||||
for key,identifier in entries:
|
||||
_apikeys.apikeystore[identifier] = key
|
||||
os.remove(oldfile)
|
||||
except:
|
||||
raise
|
||||
pass
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user