File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 1- #!/usr/bin/env python
1+ #!/usr/bin/env python3
22"""
33BSD 3-Clause License
44
@@ -143,6 +143,24 @@ def get_station_list(self):
143143 """
144144 return self .site_list
145145
146+ def find_station (self , station_name ):
147+ """
148+ Returns station object for station matching station_name,
149+ otherwise returns None
150+ """
151+ matching_list = [station for station in self .site_list if station .scode == station_name ]
152+
153+ # Not found
154+ if not len (matching_list ):
155+ return None
156+
157+ # Alert user that are multiple matches
158+ if len (matching_list ) > 1 :
159+ print ("[WARNING]: multiple stations match station name %s!" % (station_name ))
160+
161+ # Return match
162+ return matching_list [0 ]
163+
146164if __name__ == "__main__" :
147165 print ("Testing Module: %s" % (sys .argv [0 ]))
148166 STATION_LIST = StationList (sys .argv [1 ])
You can’t perform that action at this time.
0 commit comments