def crocus_station_list(): stat = json.load(open('Test/Data/crocus_stations.json', 'r')) station_list = stat['crocus_stations_2016'] wr = wsKlimaRequest('getStationsProperties', {'stations': station_list, 'username': ''}) rsp = wr.get() print(type(rsp.content)) sd = parse_get_stations_properties(rsp.content) # sd = crocus_station_list() db = CrocusStationDB('./Test/Data/stations.db') # db.create_station_db() for s in iter(sd.values()): print(s) db.insert_station(s) db.close()
def eklima_station_list(): """ Currently I need to change this part in wsklima_parser.py def parse_get_stations_properties(xml_data): #TODO: need to fix the case when a file name is directly passed. if os.path.isfile(xml_data): root = etree.parse(xml_data) elif isinstance(xml_data, str): root = etree.fromstring(xml_data) :return: """ sd = parse_get_stations_properties(r'./Test/Data/getStationsProperties.out.all.xml') db = CrocusStationDB('./Test/Data/all_eklima_stations.db') # db.create_station_db() for st in iter(sd.values()): # sd.itervalues() in Python 2.7 print(st) db.insert_station(st) db.close()