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