Skip to content

Commit

Permalink
Fixed SyntaxWarnings about invalid escape sequences in Python 3.13 (D…
Browse files Browse the repository at this point in the history
…eprecationWarning in 3.11)
  • Loading branch information
sammyfung committed Feb 6, 2025
1 parent 00d4916 commit e004c1a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions hk0weather/hk0weather/spiders/hkoforecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ def parse_hko_forecast(self, response):
outlook_item = ForecastItem()
outlook_item.update(item)

if re.search('\&lang=en', response.url):
if re.search('&lang=en', response.url):
item['forecast_category'] = 'general_situation'
item['description'] = data['generalSituation']
forecast_item['forecast_category'] = 'forecast'
forecast_item['description'] = data['forecastDesc']
outlook_item['forecast_category'] = 'outlook'
outlook_item['description'] = data['outlook']
elif re.search('\&lang=tc', response.url):
elif re.search('&lang=tc', response.url):
language = 'zh_hk'
item['language'] = language
item['forecast_category'] = 'general_situation'
Expand All @@ -87,9 +87,9 @@ def parse_hko_9day_forecast(self, response):
item['report_time'] = datetime.fromisoformat(data['updateTime']).isoformat(timespec='milliseconds')
item['forecast_type'] = 'forecast_9day'
item['language'] = 'en'
if re.search('\&lang=en', response.url):
if re.search('&lang=en', response.url):
item['language'] = 'en'
elif re.search('\&lang=tc', response.url):
elif re.search('&lang=tc', response.url):
item['language'] = 'zh_hk'

first_forecast_date = None
Expand Down
6 changes: 3 additions & 3 deletions hk0weather/hk0weather/spiders/hkoweather.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ def parse_weather_info(self, response):
else:
continue

dataline = re.sub('^\s','',i[6:])
dataline = re.sub('\*',' ',dataline)
data = re.split('\s+',dataline)
dataline = re.sub('^ ','',i[6:])
dataline = re.sub('\\*',' ',dataline)
data = re.split(' +',dataline)

# Handling sections
if section == 'temperature' and laststation != '':
Expand Down
2 changes: 1 addition & 1 deletion hk0weather/hk0weather/spiders/rainfall.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def parse(self, response):
def parse_time(self, timeperiod):
endtime = re.sub('^.* and ','',timeperiod)
endtime = re.sub(',.*','',endtime)
endtime = re.sub('\.','',endtime).upper()
endtime = re.sub('\\.','',endtime).upper()
endtime = re.sub('^0','12',endtime)
endtime = datetime.combine(datetime.today().date(), datetime.strptime(endtime,"%I:%M %p").time())
endtime = endtime.replace(tzinfo = pytz.timezone('Etc/GMT-8'))
Expand Down

0 comments on commit e004c1a

Please sign in to comment.