Add files via upload
This commit is contained in:
parent
65d8f4a31f
commit
98b3a720dc
3 changed files with 43 additions and 0 deletions
16
bib/add_item_to_authordb.py
Normal file
16
bib/add_item_to_authordb.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
def add_item_to_authordb(item: str, author_db: dict):
|
||||
was_found: bool = False
|
||||
|
||||
for the_keys in author_db.keys():
|
||||
assert isinstance(author_db[the_keys], list) is True
|
||||
|
||||
if str(the_keys) == str(item):
|
||||
return
|
||||
|
||||
for i in author_db[the_keys]:
|
||||
print(i)
|
||||
if str(i) == str(item):
|
||||
return
|
||||
|
||||
if was_found is False:
|
||||
author_db.update({f"{item}": []})
|
19
bib/add_item_to_typedb.py
Normal file
19
bib/add_item_to_typedb.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
def add_item_to_typedb(item: str, types_db: dict):
|
||||
was_found: bool = False
|
||||
|
||||
for the_keys in types_db.keys():
|
||||
assert isinstance(types_db[the_keys], list) is True
|
||||
assert len(types_db[the_keys]) == 3
|
||||
assert isinstance(types_db[the_keys][0], list) is True
|
||||
assert isinstance(types_db[the_keys][1], str) is True
|
||||
assert isinstance(types_db[the_keys][2], str) is True
|
||||
|
||||
if str(the_keys) == str(item):
|
||||
return
|
||||
|
||||
for i in types_db[the_keys][0]:
|
||||
if str(i) == str(item):
|
||||
return
|
||||
|
||||
if was_found is False:
|
||||
types_db.update({f"{item}": [[], f"{item}", f"{item}"]})
|
|
@ -1,4 +1,12 @@
|
|||
import html
|
||||
|
||||
|
||||
def filter_string(input):
|
||||
return str(html.escape(input).encode("ascii", "xmlcharrefreplace").decode())
|
||||
|
||||
|
||||
def shorten_authorname(input: str) -> str:
|
||||
input = filter_string(input)
|
||||
temp = input.split(",")
|
||||
name: str = temp[0].lstrip().rstrip() + str(",")
|
||||
temp = temp[1].lstrip().rstrip().split(" ")
|
||||
|
|
Loading…
Reference in a new issue