From b01fc22d3d4dae362b0c1f9cff84cec8538194c5 Mon Sep 17 00:00:00 2001 From: Raphael Roberts Date: Sat, 27 Apr 2019 22:01:25 -0500 Subject: [PATCH] Made ctabus module executable and bumped version number to reflect rename --- ctabus/__init__.py | 22 +++++++++++----------- ctabus/__main__.py | 3 +++ ctabus/{ctabus.py => fetch.py} | 0 setup.py | 13 +++++++++++-- 4 files changed, 25 insertions(+), 13 deletions(-) create mode 100644 ctabus/__main__.py rename ctabus/{ctabus.py => fetch.py} (100%) diff --git a/ctabus/__init__.py b/ctabus/__init__.py index 7f53a58..3461570 100644 --- a/ctabus/__init__.py +++ b/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) diff --git a/ctabus/__main__.py b/ctabus/__main__.py new file mode 100644 index 0000000..2afcd1a --- /dev/null +++ b/ctabus/__main__.py @@ -0,0 +1,3 @@ +from ctabus import main +if __name__ == "__main__": + main() diff --git a/ctabus/ctabus.py b/ctabus/fetch.py similarity index 100% rename from ctabus/ctabus.py rename to ctabus/fetch.py diff --git a/setup.py b/setup.py index d2cf498..3dd7b74 100644 --- a/setup.py +++ b/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', + + ] + )