Browse Source

Made disk_cache work properly and fixed missing import

atexit
Raphael Roberts 6 years ago
parent
commit
40b2046518
  1. 11
      ctabus/__main__.py
  2. 3
      ctabus/ui/util.py

11
ctabus/__main__.py

@ -19,8 +19,7 @@ from ctabus.internal.config import log_dir, recent_list, CHICAGO_TZ
notification_module = lazy_import.lazy_module("ctabus.ui.notification")
toast_module = lazy_import.lazy_module("ctabus.ui.toast")
disk_cache = lazy_import.lazy_class("ctabus.internal.disk_cache.disk_cache")
make_key = lazy_import.lazy_function("ctabus.internal.disk_cache.make_key")
disk_cache = lazy_import.lazy_module("ctabus.internal.disk_cache")
fetch = lazy_import.lazy_module("ctabus.fetch")
_picker = lazy_import.lazy_function("ctabus.ui.picker._picker")
@ -166,9 +165,6 @@ def main(args=None):
if args is None:
args = parser.parse_args()
sys.stderr = open(osp.join(log_dir, "stderr.log"), "w")
if args.kill_cache:
for cache_obj in disk_cache.caches:
cache_obj.delete_cache()
args.arg = " ".join(args.arg)
from_recent = False
if args.arg.isdecimal():
@ -182,9 +178,12 @@ def main(args=None):
if not from_recent:
recent_list.add(stop_id)
data = fetch.get_times(stop_id)
if args.kill_cache:
for cache_obj in disk_cache.disk_cache.caches:
cache_obj.delete_cache()
fetch.get_data_from_stop_id(stop_id, __setup__=data)
info = data["prd"][0]
key = make_key(info["rt"], info["rtdir"], fetch.api, None)
key = disk_cache.make_key(info["rt"], info["rtdir"], fetch.api, None)
if key not in fetch.get_name_from_direction.cache.keys():
fetch.get_name_from_direction.cache[key] = info["des"]
fetch.get_name_from_direction.fresh = True

3
ctabus/ui/util.py

@ -1,3 +1,6 @@
import re
def atoi(text):
return int(text) if text.isdigit() else text

Loading…
Cancel
Save