<s> from wq . io import CsvParser , BaseIO , TimeSeriesMapper <EOL> from wq . io . parsers . base import BaseParser <EOL> from owslib . waterml . wml11 import WaterML_1_1 as WaterML <EOL> class RdbParser ( CsvParser ) : <EOL> """<STR_LIT>""" <EOL> max_header_row = <NUM_LIT:100> <EOL> delimiter = '<STR_LIT:\t>' <EOL> def parse ( self ) : <EOL> super ( RdbParser , self ) . parse ( ) <EOL> self . data = self . data [ <NUM_LIT:1> : ] <EOL> class TimeSeriesIO ( TimeSeriesMapper , BaseIO ) : <EOL> """<STR_LIT>""" <EOL> date_formats = [ ] <EOL> class WaterMlParser ( BaseParser ) : <EOL> """<STR_LIT>""" <EOL> nested = True <EOL> no_pickle_parser = [ '<STR_LIT>' ] <EOL> def parse ( self ) : <EOL> response = WaterML ( self . file . read ( ) . encode ( '<STR_LIT:utf-8>' ) ) . response <EOL> self . response = response <EOL> self . data = list ( map ( self . parse_timeseries , response . time_series ) ) <EOL> def parse_timeseries ( self , ts ) : <EOL> site = ts . source_info <EOL> param = ts . variable <EOL> lng , lat = list ( map ( float , site . location . geo_coords [ <NUM_LIT:0> ] ) ) <EOL> values = ts . values [ <NUM_LIT:0> ] <EOL> data = [ { <EOL> '<STR_LIT:date>' : date , <EOL> '<STR_LIT:value>' : value , <EOL> } for date , value in values . get_date_values ( ) ] <EOL> return { <EOL> '<STR_LIT>' : site . site_name , <EOL> '<STR_LIT>' : site . site_codes [ <NUM_LIT:0> ] , <EOL> '<STR_LIT>' : param . variable_name , <EOL> '<STR_LIT>' : param . variable_code , <EOL> '<STR_LIT>' : param . unit . code , <EOL> '<STR_LIT>' : lat , <EOL> '<STR_LIT>' : lng , <EOL> '<STR_LIT:data>' : TimeSeriesIO ( data = data ) <EOL> } </s>
