tokenator 0.1.0__py3-none-any.whl → 0.1.1__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- tokenator/schemas.py +7 -1
- tokenator/utils.py +7 -4
- {tokenator-0.1.0.dist-info → tokenator-0.1.1.dist-info}/METADATA +1 -1
- {tokenator-0.1.0.dist-info → tokenator-0.1.1.dist-info}/RECORD +6 -6
- {tokenator-0.1.0.dist-info → tokenator-0.1.1.dist-info}/LICENSE +0 -0
- {tokenator-0.1.0.dist-info → tokenator-0.1.1.dist-info}/WHEEL +0 -0
tokenator/schemas.py
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
import uuid
|
4
4
|
from datetime import datetime
|
5
|
+
import os
|
5
6
|
|
6
7
|
from sqlalchemy import create_engine, Column, Integer, String, DateTime, Float, Index
|
7
8
|
from sqlalchemy.orm import sessionmaker, scoped_session, declarative_base
|
@@ -12,7 +13,12 @@ Base = declarative_base()
|
|
12
13
|
|
13
14
|
def get_engine(db_path: str = None):
|
14
15
|
"""Create SQLAlchemy engine with the given database path."""
|
15
|
-
|
16
|
+
if db_path is None:
|
17
|
+
try:
|
18
|
+
import google.colab # type: ignore
|
19
|
+
db_path = '/content/tokenator.db'
|
20
|
+
except ImportError:
|
21
|
+
db_path = get_default_db_path()
|
16
22
|
return create_engine(f"sqlite:///{db_path}", echo=False)
|
17
23
|
|
18
24
|
def get_session(db_path: str = None):
|
tokenator/utils.py
CHANGED
@@ -23,13 +23,16 @@ def get_default_db_path() -> str:
|
|
23
23
|
xdg_data_home = os.environ.get("XDG_DATA_HOME", "")
|
24
24
|
if not xdg_data_home:
|
25
25
|
xdg_data_home = os.path.join(str(Path.home()), ".local", "share")
|
26
|
-
|
26
|
+
db_path = os.path.join(xdg_data_home, "tokenator", "usage.db")
|
27
27
|
elif system == "windows":
|
28
28
|
# Use %LOCALAPPDATA% on Windows
|
29
29
|
local_app_data = os.environ.get("LOCALAPPDATA", "")
|
30
30
|
if not local_app_data:
|
31
31
|
local_app_data = os.path.join(str(Path.home()), "AppData", "Local")
|
32
|
-
|
32
|
+
db_path = os.path.join(local_app_data, "tokenator", "usage.db")
|
33
33
|
else:
|
34
|
-
|
35
|
-
|
34
|
+
db_path = os.path.join(str(Path.home()), ".tokenator", "usage.db")
|
35
|
+
|
36
|
+
# Create directory if it doesn't exist
|
37
|
+
os.makedirs(os.path.dirname(db_path), exist_ok=True)
|
38
|
+
return db_path
|
@@ -7,10 +7,10 @@ tokenator/migrations/env.py,sha256=eFTw66gG464JV53740RKU32wqEL8uZFReS_INrvkFrU,1
|
|
7
7
|
tokenator/migrations/script.py.mako,sha256=nJL-tbLQE0Qy4P9S4r4ntNAcikPtoFUlvXe6xvm9ot8,635
|
8
8
|
tokenator/migrations.py,sha256=GH84M6AzidTcscMP0nQspBaQ1v6bjx00V4FeN-v5XAo,1354
|
9
9
|
tokenator/models.py,sha256=EprE_MMJxDS-YXlcIQLZzfekH7xTYbeOC3bx3B2osVw,1171
|
10
|
-
tokenator/schemas.py,sha256=
|
10
|
+
tokenator/schemas.py,sha256=eVdBWi6_hTETnPw50glq0OvSh3PbP2pLl_aHdf3fi-M,2278
|
11
11
|
tokenator/usage.py,sha256=aHjGwzDzaiVznahNk5HqVyk3IxDo5FtFVfOUCeE7DZ4,7833
|
12
|
-
tokenator/utils.py,sha256=
|
13
|
-
tokenator-0.1.
|
14
|
-
tokenator-0.1.
|
15
|
-
tokenator-0.1.
|
16
|
-
tokenator-0.1.
|
12
|
+
tokenator/utils.py,sha256=WAMRY78d2g0PGSQZzPGoEuhJvQO5Iabgx4Wb6ykYp0Q,1407
|
13
|
+
tokenator-0.1.1.dist-info/LICENSE,sha256=wdG-B6-ODk8RQ4jq5uXSn0w1UWTzCH_MMyvh7AwtGns,1074
|
14
|
+
tokenator-0.1.1.dist-info/METADATA,sha256=ot6LXHhCJ6JrPOU6o18D-rgoarh2ZT0mn4uhPgJbcXU,2444
|
15
|
+
tokenator-0.1.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
16
|
+
tokenator-0.1.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|