Browse Source

Made ctabus module executable and bumped version number to reflect rename

atexit v2.0
Raphael Roberts 7 years ago
parent
commit
b01fc22d3d
  1. 22
      ctabus/__init__.py
  2. 3
      ctabus/__main__.py
  3. 0
      ctabus/fetch.py
  4. 13
      setup.py

22
ctabus/__init__.py

@ -15,7 +15,7 @@ import shutil
from ctabus.internal.config import log_dir
from ctabus.internal.disk_cache import disk_cache, make_key
from ctabus import ctabus
from ctabus import fetch
HAS_TOAST = shutil.which('termux-toast') is not None
CHICAGO_TZ = tz.gettz("America/Chicago")
@ -170,16 +170,16 @@ def _picker(args):
from ctabus.internal.search import Search, StopSearch
# routes
if not args.route:
data = ctabus.get_routes()['routes']
data = fetch.get_routes()['routes']
route = gen_list(data, 'rt', 'rt', 'rtnm',
num_pic=False, key=numb_sort)
else:
route = args.route
data = ctabus.get_directions(route)['directions']
data = fetch.get_directions(route)['directions']
# direction
if not args.direction:
for direction_obj in data:
friendly_name = ctabus.get_name_from_direction(
friendly_name = fetch.get_name_from_direction(
route, direction_obj['dir'])
direction_obj['friendly_name'] = friendly_name
direction = gen_list(data, 'dir', 'dir', 'friendly_name')
@ -187,7 +187,7 @@ def _picker(args):
s = Search(args.direction)
direction = sorted((obj['dir'] for obj in data), key=s)[0]
# direction
stops = ctabus.get_stops(route, direction)['stops']
stops = fetch.get_stops(route, direction)['stops']
s = StopSearch(args.arg)
if args.lucky:
stop_id = sorted(stops, key=lambda stop: s(stop['stpnm']))[
@ -212,7 +212,7 @@ def _main_periodic(args, stop_id, init_data):
timeout = 1
if args.periodic > timeout:
timeout = args.periodic
data = ctabus.get_times(stop_id, timeout=timeout)
data = fetch.get_times(stop_id, timeout=timeout)
e = time.perf_counter() - s
except (urllib.error.URLError, socket.timeout):
e = time.perf_counter() - s
@ -240,12 +240,12 @@ def main(args=None):
else:
stop_id = _picker(args)
data = ctabus.get_times(stop_id)
data = fetch.get_times(stop_id)
info = data['prd'][0]
key = make_key(info['rt'], info['rtdir'], ctabus.api, None)
if key not in ctabus.get_name_from_direction.cache.keys():
ctabus.get_name_from_direction.cache[key] = info['des']
ctabus.get_name_from_direction.fresh = True
key = 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
if args.periodic is not None:
_main_periodic(args, stop_id, data)

3
ctabus/__main__.py

@ -0,0 +1,3 @@
from ctabus import main
if __name__ == "__main__":
main()

ctabus/ctabus.py → ctabus/fetch.py

13
setup.py

@ -5,7 +5,7 @@ with open('requirements.txt') as file:
setup(
name='ctabus',
version='1.0.1',
version='2.0',
description='Python package for tracking cta bus times',
install_requires=INSTALL_REQUIRES,
author='rlbr',
@ -13,5 +13,14 @@ setup(
packages=find_packages(),
entry_points={
'console_scripts': ['ctabus=ctabus:main']
}
},
classifiers=[
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
]
)
Loading…
Cancel
Save