-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathhelpers.py
More file actions
29 lines (19 loc) · 703 Bytes
/
helpers.py
File metadata and controls
29 lines (19 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
import sys
from datetime import datetime
import time
def resource_path(relative_path: str) -> str:
if hasattr(sys, '_MEIPASS'):
return os.path.join(sys._MEIPASS, relative_path)
return os.path.join(os.path.abspath("."), relative_path)
def dt_to_ts(dt: datetime) -> float:
return time.mktime(dt.timetuple())
def ts_to_dt(ts: float) -> datetime:
return datetime.fromtimestamp(ts)
def get_app_data_path() -> str:
path = os.path.join(os.sep, os.path.expanduser("~"), "AppData", "Local", "EULogger")
if not os.path.exists(path):
os.makedirs(path)
return path
def format_filename(fn: str) -> str:
return os.path.join(get_app_data_path(), fn)