Skip to content

Commit

Permalink
Fix the wrong location name cause a error while get response from
Browse files Browse the repository at this point in the history
opendata
  • Loading branch information
tsunglung committed Dec 26, 2024
1 parent 25586ea commit 742530c
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ def weather_at_place(self, name, interval):
loc_id = self.supported_city(name)
if loc_id is None:
raise ValueError("%s is not support location".format(name))

if '\u5e02' in name.lower():
name = name.lower().split('\u5e02')[1] if len(name.lower().split('\u5e02')) >= 2 else name

params = {'locationName': name}
if interval == 'hourly':
uri = loc_id
Expand Down Expand Up @@ -310,6 +314,11 @@ def forecast_at_place(self, name, interval, limit=None):
loc_id = self.supported_city(name)
if loc_id is None:
raise ValueError("%s is not support location".format(name))

if '\u5e02' in name.lower():
name = name.lower().split('\u5e02')[1] if len(name.lower().split('\u5e02')) >= 2 else name


if limit is not None:
assert isinstance(limit, int), "'limit' must be an int or None"
if limit < 1:
Expand Down

0 comments on commit 742530c

Please sign in to comment.