chore: add log to file

This commit is contained in:
2025-10-28 10:46:45 +01:00
parent ab62212201
commit a4460ec17b

View File

@@ -5,6 +5,7 @@ from pyzotero import zotero
from src import settings from src import settings
from src.logic.webrequest import BibTextTransformer, WebRequest from src.logic.webrequest import BibTextTransformer, WebRequest
from src.shared.logging import log
@dataclass @dataclass
@@ -185,7 +186,7 @@ class ZoteroController:
web = WebRequest() web = WebRequest()
web.get_ppn(isbn) web.get_ppn(isbn)
data = web.get_data_elsa() data = web.get_data_elsa()
bib = BibTextTransformer("ARRAY") bib = BibTextTransformer()
bib.get_data(data) bib.get_data(data)
book = bib.return_data() book = bib.return_data()
return book return book
@@ -207,13 +208,14 @@ class ZoteroController:
authors = [ authors = [
Creator().from_string(author).__dict__ for author in book.author.split(";") Creator().from_string(author).__dict__ for author in book.author.split(";")
] ]
authors = [author for author in authors if author["lastName"] is not None]
bookdata.creators = authors bookdata.creators = authors
return bookdata return bookdata
def createItem(self, item) -> Optional[str]: def createItem(self, item) -> Optional[str]:
resp = self.zot.create_items([item]) # type: ignore resp = self.zot.create_items([item]) # type: ignore
if "successful" in resp.keys(): if "successful" in resp.keys():
# #print(resp["successful"]["0"]["key"]) log.debug(resp)
return resp["successful"]["0"]["key"] return resp["successful"]["0"]["key"]
else: else:
return None return None
@@ -227,6 +229,7 @@ class ZoteroController:
break break
def createHGSection(self, book: Book, data: dict) -> Optional[str]: def createHGSection(self, book: Book, data: dict) -> Optional[str]:
log.debug(book)
chapter = BookSection() chapter = BookSection()
chapter.assign(book) chapter.assign(book)
chapter.pages = data["pages"] chapter.pages = data["pages"]
@@ -244,7 +247,7 @@ class ZoteroController:
] ]
chapter.creators += authors chapter.creators += authors
# #print(chapter.to_dict()) log.debug(chapter.to_dict())
return self.createItem(chapter.to_dict()) return self.createItem(chapter.to_dict())
pass pass