mirror of
https://github.com/etienne-hd/lbc-finder.git
synced 2026-04-18 15:22:40 +02:00
refactor: id.json and logs have been moved to /data
This commit is contained in:
@@ -16,12 +16,13 @@ class ID:
|
||||
|
||||
def _get_ids(self) -> List[str]:
|
||||
ids: List[str] = []
|
||||
if os.path.exists("id.json"):
|
||||
with open("id.json", "r") as f:
|
||||
id_path = os.path.join("data", "id.json")
|
||||
if os.path.exists(id_path):
|
||||
with open(id_path, "r") as f:
|
||||
try:
|
||||
ids = json.load(f)
|
||||
except json.JSONDecodeError:
|
||||
os.remove("id.json")
|
||||
os.remove(id_path)
|
||||
except:
|
||||
logger.exception("An error occurred while attempting to open the id.json file.")
|
||||
return ids
|
||||
@@ -30,9 +31,10 @@ class ID:
|
||||
return id_ in self._ids
|
||||
|
||||
def add(self, id_: str) -> bool:
|
||||
id_path = os.path.join("data", "id.json")
|
||||
if not id_ in self._ids:
|
||||
self._ids.append(id_)
|
||||
with open("id.json", "w") as f:
|
||||
with open(id_path, "w") as f:
|
||||
json.dump(self._ids[-MAX_ID:], f, indent=3)
|
||||
self._ids = self._ids[-MAX_ID:]
|
||||
return True
|
||||
|
||||
@@ -4,8 +4,8 @@ from datetime import datetime
|
||||
|
||||
# File management
|
||||
timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
|
||||
file_path: str = os.path.join("logs", f"log_{timestamp}.log")
|
||||
os.makedirs("logs", exist_ok=True)
|
||||
file_path: str = os.path.join("data", "logs", f"log_{timestamp}.log")
|
||||
os.makedirs(os.path.join("data", "logs"), exist_ok=True)
|
||||
|
||||
# Config logging
|
||||
logger = logging.getLogger("lbc-finder")
|
||||
|
||||
Reference in New Issue
Block a user