@@ -52,7 +52,7 @@ def get_tropical_bulletin(bulletin):
52
52
for item in items :
53
53
54
54
desc = item .find ('description' )
55
- desc = desc .text
55
+ desc = desc .text . replace ( '<br />' , '' )
56
56
headers = desc .split ("BULLETIN" )[1 ].split ("SUMMARY OF" )[0 ]
57
57
headers = headers .strip ().split ("\n " )
58
58
headers = [line for line in headers if line != '' ]
@@ -105,14 +105,14 @@ def get_tropical_bulletin(bulletin):
105
105
106
106
warnings = desc .split ("WATCHES AND WARNINGS" , 1 )[1 ].split ("DISCUSSION AND OUTLOOK" ,1 )[0 ]
107
107
matches = re .findall (r'A ([\w\s]+) is in effect for\.\.\.' , warnings )
108
- if warnings . __contains__ ( "There are no coastal watches or warnings in effect." ) or len (matches ) == 0 :
108
+ if "There are no coastal watches or warnings in effect." in warnings or len (matches ) == 0 :
109
109
signals ["nowarning" ] = True
110
110
111
111
112
- if warnings . __contains__ ( "CHANGES WITH THIS ADVISORY:" ) :
112
+ if "CHANGES WITH THIS ADVISORY:" in warnings :
113
113
changes = desc .split ("CHANGES WITH THIS ADVISORY:" , 1 )[1 ].split ("SUMMARY OF WATCHES AND WARNINGS IN EFFECT:" ,1 )[0 ]
114
114
115
- if changes . __contains__ ( "None" ) or not contains_area (changes , area ):
115
+ if "None" in changes or not contains_area (changes , area ):
116
116
signals ["noupdate" ] = True
117
117
118
118
@@ -135,16 +135,17 @@ def get_tropical_bulletin(bulletin):
135
135
data ["events" ] = []
136
136
for match in matches :
137
137
try :
138
- event = {}
139
- event ["type" ] = match
140
- event ["places" ] = []
141
- event ["relevant" ] = False
138
+ event = {
139
+ 'type' : match ,
140
+ 'places' : [],
141
+ 'relevant' : False
142
+ }
142
143
index = warnings .index ("A " + match + " is in effect for..." ) + 1
143
144
#find all events and for each event places
144
145
while index < len (warnings ) and warnings [index ] != '$' :
145
146
place = warnings [index ].replace ("* " , "" ).strip ()
146
- event [ "places" ]. append ( translate ( place ))
147
- if place . casefold (). __contains__ ( "puerto rico" ):
147
+ if "puerto rico" in place . casefold ():
148
+ event [ "places" ]. append ( translate ( place ))
148
149
event ["relevant" ] = True
149
150
150
151
@@ -159,6 +160,8 @@ def get_tropical_bulletin(bulletin):
159
160
if event ["relevant" ] == True :
160
161
data ["practive" ].append (event )
161
162
signals ["practive" ] = True
163
+ else :
164
+ logger .debug (f"event { event ['type' ]} not deemed relevant" )
162
165
163
166
#hazards affecting land
164
167
hazards = desc .split ("HAZARDS AFFECTING LAND" ,1 )[1 ].split ("FORECASTER" ,1 )[0 ]
@@ -177,7 +180,7 @@ def get_tropical_bulletin(bulletin):
177
180
sentence = sentence .strip ().replace ("\n " , "" )
178
181
location_amount = {}
179
182
180
- if sentence . __contains__ ( "..." ) :
183
+ if "..." in sentence :
181
184
182
185
location = sentence .split ("..." )[0 ]
183
186
height = sentence .split ("..." )[1 ]
@@ -192,7 +195,7 @@ def get_tropical_bulletin(bulletin):
192
195
location_amount ["height" ] = translate (height )
193
196
count += 1
194
197
rainlist .append (location_amount )
195
- elif sentence . __contains__ ( ":" ) :
198
+ elif ":" in sentence :
196
199
location = sentence .split (":" )[0 ]
197
200
height = sentence .split (":" )[1 ]
198
201
if contains_area (location , area ):
@@ -219,7 +222,7 @@ def get_tropical_bulletin(bulletin):
219
222
surgedata = re .search (surgepattern , hazards , re .DOTALL )
220
223
221
224
if surgedata :
222
- if surgedata . group ( 1 ). __contains__ ( "..." ):
225
+ if "..." in surgedata . group ( 1 ):
223
226
224
227
surgedata = surgedata .group (1 ).split ("..." , 1 ) [1 ]
225
228
patt = r'([A-Za-z\s.-]+)\.\.\.(\d+\s+to\s+\d+)\s+ft'
0 commit comments