Refactor book title stripping into function

This commit is contained in:
Marty Oehme 2023-02-22 11:09:04 +01:00
parent d301a61e92
commit 71cf84443d
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

View file

@ -20,10 +20,9 @@ def main(fpath, db):
csv = csv.DictReader(f)
title_strip_pattern = re.compile(r"([^\s\w]|_)+")
note_file = ""
for row in csv:
title_stripped = title_strip_pattern.sub("", row["Title"])
title_stripped = strip_book_title(row["Title"])
# switch to next book
if not is_same_book(row["Title"]):
@ -96,6 +95,10 @@ def write_to_files(notes):
num_added += 1
print(f"Added {num_added} entries to it.")
title_strip_pattern = re.compile(r"([^\s\w]|_)+")
def strip_book_title(title) -> str:
return title_strip_pattern.sub("", title)
if __name__ == "__main__":
# use argument passed to command as file or default file here