Skip to content

Commit 3216fc1

Browse files
committed
os.path.dirname(self.db_file)...
1 parent 8e079eb commit 3216fc1

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/busylogger/json_business_logger.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ def _setup_backend(self, db_file: str) -> bool:
2323
self.db_file = db_file
2424
self.file_handle = None
2525
try:
26-
os.makedirs(os.path.dirname(self.db_file), exist_ok=True)
26+
path_dirname = os.path.dirname(self.db_file)
27+
if len(path_dirname):
28+
os.makedirs(path_dirname, exist_ok=True)
2729
return True
2830
except Exception as e:
2931
logging.error(f"Erreur lors de la création du répertoire pour {self.logger_name}: {e}")

src/busylogger/sqlite_business_logger.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ def _setup_backend(self, db_file: str) -> bool:
2929
self.table_name = os.getenv("SQLITE_BUSINESS_LOGGER_TABLE_NAME", "business_events")
3030
self.conn = None
3131
try:
32-
os.makedirs(os.path.dirname(self.db_file), exist_ok=True)
32+
path_dirname = os.path.dirname(self.db_file)
33+
if len(path_dirname):
34+
os.makedirs(path_dirname, exist_ok=True)
3335
with sqlite3.connect(self.db_file) as conn:
3436
cursor = conn.cursor()
3537
cursor.execute(f"""

0 commit comments

Comments
 (0)