Install black.
This commit is contained in:
@@ -8,24 +8,24 @@ def read_file_content(file):
|
||||
# old (list)
|
||||
def parse_book_string(book_string):
|
||||
book = {}
|
||||
book['title'] = book_string.split('[')[1].split(']')[0]
|
||||
book['url'] = book_string.split(']')[1].split('(')[1].split(')')[0]
|
||||
book['author'] = book_string.split(' by ')[-1]
|
||||
book['rating'] = ''
|
||||
book['year'] = ''
|
||||
book["title"] = book_string.split("[")[1].split("]")[0]
|
||||
book["url"] = book_string.split("]")[1].split("(")[1].split(")")[0]
|
||||
book["author"] = book_string.split(" by ")[-1]
|
||||
book["rating"] = ""
|
||||
book["year"] = ""
|
||||
return book
|
||||
|
||||
|
||||
# new (table)
|
||||
def parse_book_string_new(book_string):
|
||||
book = {}
|
||||
book_split = book_string.split('|')
|
||||
book_split = book_string.split("|")
|
||||
# print(book_split)
|
||||
book['title'] = book_split[1].strip()
|
||||
book['author'] = book_split[2].strip()
|
||||
book['url'] = book_split[3].strip().split('[')[1].split('(')[1].split(')')[0]
|
||||
book['rating'] = book_split[3].strip().split('[')[1].split(']')[0]
|
||||
book['year'] = book_split[4].strip()
|
||||
book["title"] = book_split[1].strip()
|
||||
book["author"] = book_split[2].strip()
|
||||
book["url"] = book_split[3].strip().split("[")[1].split("(")[1].split(")")[0]
|
||||
book["rating"] = book_split[3].strip().split("[")[1].split("]")[0]
|
||||
book["year"] = book_split[4].strip()
|
||||
return book
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ def load(file, file_type):
|
||||
file = read_file_content(file)
|
||||
|
||||
# we start one line after tilte # Books
|
||||
line_to_start = file.index('# Books') + 1
|
||||
current_title = ''
|
||||
line_to_start = file.index("# Books") + 1
|
||||
current_title = ""
|
||||
books_under_current_title = []
|
||||
library = {}
|
||||
|
||||
@@ -42,7 +42,7 @@ def load(file, file_type):
|
||||
line = file[i]
|
||||
|
||||
# we have a title
|
||||
if line.startswith('##'):
|
||||
if line.startswith("##"):
|
||||
if len(current_title) == 0:
|
||||
current_title = line
|
||||
else:
|
||||
@@ -52,12 +52,16 @@ def load(file, file_type):
|
||||
continue
|
||||
|
||||
# we have a book
|
||||
if file_type == 'old':
|
||||
if line.startswith('*'):
|
||||
if file_type == "old":
|
||||
if line.startswith("*"):
|
||||
book = parse_book_string(line)
|
||||
books_under_current_title.append(book)
|
||||
else:
|
||||
if line.startswith('|') and not line.startswith('| Name') and not line.startswith('|---'):
|
||||
if (
|
||||
line.startswith("|")
|
||||
and not line.startswith("| Name")
|
||||
and not line.startswith("|---")
|
||||
):
|
||||
book = parse_book_string_new(line)
|
||||
books_under_current_title.append(book)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user