Remove unused imports and clean up code structure across multiple files
This commit is contained in:
@@ -2,7 +2,7 @@ import re
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
from enum import Enum
|
||||
|
||||
import json
|
||||
|
||||
@dataclass
|
||||
class Prof:
|
||||
@@ -77,23 +77,19 @@ class BookData:
|
||||
for key, value in data.items():
|
||||
setattr(self, key, value)
|
||||
|
||||
@property
|
||||
def to_dict(self):
|
||||
return self.__dict__
|
||||
"""Convert the dataclass to a dictionary."""
|
||||
return json.dumps(self.__dict__, ensure_ascii=False)
|
||||
|
||||
def from_dataclass(self, dataclass):
|
||||
for key, value in dataclass.__dict__.items():
|
||||
setattr(self, key, value)
|
||||
|
||||
def from_string(self, data: str):
|
||||
if not data.startswith("BookData"):
|
||||
raise ValueError("No valid BookData string")
|
||||
else:
|
||||
pattern = r"(\w+)='([^']*)'"
|
||||
data_dict = dict(re.findall(pattern, data))
|
||||
# print(data_dict)
|
||||
for key, value in data_dict.items():
|
||||
setattr(self, key, value)
|
||||
return self
|
||||
data = json.loads(data)
|
||||
|
||||
return BookData(**data)
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@@ -14,7 +14,7 @@ from loguru import logger as log
|
||||
|
||||
logger = log
|
||||
logger.remove()
|
||||
logger.add("logs/application.log", rotation="1 week", enqueue=True)
|
||||
logger.add("logs/application.log", rotation="1 week", retention="1 month", enqueue=True)
|
||||
log.add(
|
||||
f"logs/webrequest.log",
|
||||
rotation="1 day",
|
||||
|
||||
@@ -8,7 +8,7 @@ from typing import Union, Any
|
||||
|
||||
logger = log
|
||||
logger.remove()
|
||||
logger.add("logs/wordparser.log", rotation="1 week", enqueue=True)
|
||||
logger.add("logs/wordparser.log", rotation="1 week", retention="1 month", enqueue=True)
|
||||
log.add(
|
||||
f"logs/application.log",
|
||||
rotation="1 day",
|
||||
|
||||
Reference in New Issue
Block a user