Skip to content

Commit

Permalink
Merge pull request #1 from benjaminjulian/patch-2
Browse files Browse the repository at this point in the history
Specify UTF8 encoding
  • Loading branch information
vthorsteinsson authored Nov 19, 2019
2 parents 90f7f4f + d547d80 commit 68baeff
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/straeto/straeto.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
# you must apply to Straeto bs to obtain permission and get your own URL)
_STATUS_URL_FILE = os.path.join(_THIS_PATH, "config", "status_url.txt")
try:
_STATUS_URL = open(_STATUS_URL_FILE, "r").read().strip()
_STATUS_URL = open(_STATUS_URL_FILE, "r", encoding="utf-8").read().strip()
except FileNotFoundError:
_STATUS_URL = None
# Real-time status refresh interval
Expand Down Expand Up @@ -194,6 +194,7 @@ def initialize():
with open(
os.path.join(_THIS_PATH, "resources", "calendar_dates.txt"),
"r",
encoding="utf-8",
) as f:
index = 0
for line in f:
Expand Down Expand Up @@ -561,7 +562,7 @@ def all_routes():
def initialize():
""" Read information about bus routes from the trips.txt file """
BusRoute._all_routes = dict()
with open(os.path.join(_THIS_PATH, "resources", "trips.txt"), "r") as f:
with open(os.path.join(_THIS_PATH, "resources", "trips.txt"), "r", encoding="utf-8") as f:
index = 0
for line in f:
index += 1
Expand Down Expand Up @@ -729,7 +730,7 @@ def add_halt(stop_id, halt):
@staticmethod
def initialize():
""" Read information about bus stops from the stops.txt file """
with open(os.path.join(_THIS_PATH, "resources", "stops.txt"), "r") as f:
with open(os.path.join(_THIS_PATH, "resources", "stops.txt"), "r", encoding="utf-8") as f:
index = 0
for line in f:
index += 1
Expand Down Expand Up @@ -819,7 +820,7 @@ def to_hms(s):
""" Convert a hh:mm:ss string to a (h, m, s) tuple """
return (int(s[0:2]), int(s[3:5]), int(s[6:8]))

with open(os.path.join(_THIS_PATH, "resources", "stop_times.txt"), "r") as f:
with open(os.path.join(_THIS_PATH, "resources", "stop_times.txt"), "r", encoding="utf-8") as f:
index = 0
for line in f:
index += 1
Expand Down

0 comments on commit 68baeff

Please sign in to comment.