From 98b3a720dc171650668598b94b4c77c6e330d4db Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Mon, 15 May 2023 20:08:48 +0200 Subject: [PATCH] Add files via upload --- bib/add_item_to_authordb.py | 16 ++++++++++++++++ bib/add_item_to_typedb.py | 19 +++++++++++++++++++ bib/shorten_authorname.py | 8 ++++++++ 3 files changed, 43 insertions(+) create mode 100644 bib/add_item_to_authordb.py create mode 100644 bib/add_item_to_typedb.py diff --git a/bib/add_item_to_authordb.py b/bib/add_item_to_authordb.py new file mode 100644 index 0000000..d242812 --- /dev/null +++ b/bib/add_item_to_authordb.py @@ -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}": []}) diff --git a/bib/add_item_to_typedb.py b/bib/add_item_to_typedb.py new file mode 100644 index 0000000..298ceca --- /dev/null +++ b/bib/add_item_to_typedb.py @@ -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}"]}) diff --git a/bib/shorten_authorname.py b/bib/shorten_authorname.py index cf709b0..688467f 100644 --- a/bib/shorten_authorname.py +++ b/bib/shorten_authorname.py @@ -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(" ")