Skip to content

Commit

Permalink
Added _DEBUG flag; version 0.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
vthorsteinsson committed Nov 19, 2019
1 parent 68baeff commit 796398d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ def read(*names, **kwargs):
setup(
name="straeto",
# Remember to modify version number in src/straeto/__init__.py as well
version="0.0.7",
version="0.0.8",
license="GNU GPLv3",
description="A package for information about buses and bus routes",
long_description="{0}\n".format(read("README.md")),
long_description_content_type="text/markdown",
author="Miðeind ehf",
author_email="[email protected]",
author_email="[email protected]",
url="https://github.com/mideind/Straeto",
packages=find_packages("src"),
package_dir={"": "src"},
Expand Down
2 changes: 1 addition & 1 deletion src/straeto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@
__author__ = "Miðeind ehf."
__copyright__ = "(C) 2019 Miðeind ehf."
# Remember to update the version in setup.py as well
__version__ = "0.0.7"
__version__ = "0.0.8"

27 changes: 17 additions & 10 deletions src/straeto/straeto.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
import requests


# Set _DEBUG to True to emit diagnostic messages
_DEBUG = False

_THIS_PATH = os.path.dirname(__file__) or "."
# Where the URL to fetch bus status data is stored (this is not public information;
# you must apply to Straeto bs to obtain permission and get your own URL)
Expand Down Expand Up @@ -1265,17 +1268,18 @@ def diff(hms1, hms2):
continue
# We have a potentially usable result: if the arrival is closer than
# the previously stored one (if any), we accept it
print(
"Predicting that the bus at ({0:.6f}, {1:.6f}) will take "
"{2:.1f} seconds to drive from {3} to {4}, and then "
"{5:.1f} seconds from there to {6}, arriving at {7}"
.format(
*bus.location, last_halt.time_to(next_halt) * d_ratio,
last_halt.stop.name, next_halt.stop.name,
next_halt.time_to(our_halt), our_halt.stop.name,
estimated_arrival
if _DEBUG:
print(
"Predicting that the bus at ({0:.6f}, {1:.6f}) will take "
"{2:.1f} seconds to drive from {3} to {4}, and then "
"{5:.1f} seconds from there to {6}, arriving at {7}"
.format(
*bus.location, last_halt.time_to(next_halt) * d_ratio,
last_halt.stop.name, next_halt.stop.name,
next_halt.time_to(our_halt), our_halt.stop.name,
estimated_arrival
)
)
)
direction = trip.last_stop.name
if direction not in result or estimated_arrival < result[direction]:
result[direction] = estimated_arrival
Expand Down Expand Up @@ -1365,6 +1369,9 @@ def print_next_arrivals(schedule, location, route_number):

if __name__ == "__main__":

# This main program contains a mix of test and demo cases.
# Normally you use Straeto as a module through import, not as a main program.

if False:
# 'Hvar er næsta stoppistöð?'
print_closest_stop(_MIDEIND_LOCATION)
Expand Down

0 comments on commit 796398d

Please sign in to comment.