mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-04-01 17:50:39 +08:00
refactor: clean left os.path code
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
from os import PathLike
|
||||
from pathlib import Path
|
||||
import sqlite3
|
||||
|
||||
from .delete import Delete
|
||||
@@ -10,10 +11,13 @@ from module.conf import DATA_PATH
|
||||
|
||||
|
||||
class Connector:
|
||||
def __init__(self, table_name: str, data: dict, database: str = DATA_PATH):
|
||||
def __init__(
|
||||
self, table_name: str, data: dict, database: PathLike[str] | Path = DATA_PATH
|
||||
):
|
||||
# Create folder if not exists
|
||||
if not os.path.exists(os.path.dirname(DATA_PATH)):
|
||||
os.makedirs(os.path.dirname(DATA_PATH))
|
||||
if isinstance(database, PathLike):
|
||||
database = Path(database)
|
||||
database.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
self._conn = sqlite3.connect(database)
|
||||
self._cursor = self._conn.cursor()
|
||||
|
||||
Reference in New Issue
Block a user