chore(all): run formatting on repo, start work on porting webrequest over to api library
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import json
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any, Optional, Union
|
||||
from typing import Any
|
||||
|
||||
import regex
|
||||
|
||||
@@ -12,9 +12,9 @@ class BookData:
|
||||
signature: str | None = None
|
||||
edition: str | None = None
|
||||
link: str | None = None
|
||||
isbn: Union[str, list[str], None] = field(default_factory=list[str])
|
||||
isbn: str | list[str] | None = field(default_factory=list[str])
|
||||
author: str | None = None
|
||||
language: Union[str, list[str], None] = field(default_factory=list)
|
||||
language: str | list[str] | None = field(default_factory=list)
|
||||
publisher: str | None = None
|
||||
place: str | None = None
|
||||
year: int | None = None
|
||||
@@ -23,9 +23,10 @@ class BookData:
|
||||
in_apparat: bool | None = False
|
||||
adis_idn: str | None = None
|
||||
old_book: Any | None = None
|
||||
media_type: str | None = None #
|
||||
media_type: str | None = None
|
||||
in_library: bool | None = None # whether the book is in the library or not
|
||||
libraries: list[str] | None = field(default_factory=list)
|
||||
medianr: int | None = None # media number
|
||||
|
||||
def __post_init__(self):
|
||||
self.library_location = (
|
||||
@@ -72,11 +73,10 @@ class BookData:
|
||||
key: value for key, value in self.__dict__.items() if value is not None
|
||||
}
|
||||
# remove old_book from data_dict
|
||||
if "old_book" in data_dict:
|
||||
del data_dict["old_book"]
|
||||
data_dict.pop("old_book", None)
|
||||
return json.dumps(data_dict, ensure_ascii=False)
|
||||
|
||||
def from_dataclass(self, dataclass: Optional[Any]) -> None:
|
||||
def from_dataclass(self, dataclass: Any | None) -> None:
|
||||
if dataclass is None:
|
||||
return
|
||||
for key, value in dataclass.__dict__.items():
|
||||
@@ -86,8 +86,7 @@ class BookData:
|
||||
if isinstance(self.media_type, str):
|
||||
if "Online" in self.pages:
|
||||
return "eBook"
|
||||
else:
|
||||
return "Druckausgabe"
|
||||
return "Druckausgabe"
|
||||
return None
|
||||
|
||||
def from_string(self, data: str) -> "BookData":
|
||||
@@ -114,7 +113,7 @@ class BookData:
|
||||
return self
|
||||
|
||||
@property
|
||||
def edition_number(self) -> Optional[int]:
|
||||
def edition_number(self) -> int | None:
|
||||
if self.edition is None:
|
||||
return 0
|
||||
match = regex.search(r"(\d+)", self.edition)
|
||||
|
||||
Reference in New Issue
Block a user