Update public source
This commit is contained in:
+25
-5
@@ -10,7 +10,7 @@
|
||||
по всему проекту.
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
from functools import lru_cache
|
||||
|
||||
import yaml
|
||||
|
||||
@@ -55,10 +55,30 @@ RECENT_SESSIONS_LIMIT = REPORTS_CONFIG.get(
|
||||
10
|
||||
)
|
||||
|
||||
TIMEZONE = CONFIG.get(
|
||||
"timezone",
|
||||
"Europe/Moscow"
|
||||
)
|
||||
TIMEZONE = CONFIG.get("timezone", "Europe/Moscow")
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
def _load_timezone(mtime_ns, size):
|
||||
with CONFIG_FILE.open("r", encoding="utf-8") as fp:
|
||||
config = yaml.safe_load(fp) or {}
|
||||
|
||||
timezone_name = config.get("timezone", "Europe/Moscow")
|
||||
if not isinstance(timezone_name, str) or not timezone_name:
|
||||
return "Europe/Moscow"
|
||||
|
||||
return timezone_name
|
||||
|
||||
|
||||
def get_timezone():
|
||||
try:
|
||||
stat = CONFIG_FILE.stat()
|
||||
except OSError:
|
||||
return "Europe/Moscow"
|
||||
|
||||
try:
|
||||
return _load_timezone(stat.st_mtime_ns, stat.st_size)
|
||||
except (OSError, yaml.YAMLError):
|
||||
return TIMEZONE
|
||||
|
||||
# ============================================================
|
||||
# Каталог отчёта
|
||||
|
||||
Reference in New Issue
Block a user