Station information.

    Args:
        station_code (str): station code.

    Returns (dict): station information
358234
def eere_station(station_code):
    
    with open(env.SRC_PATH + '/eere_meta.csv') as eere_meta:
        stations = csv.DictReader(eere_meta)
        for station in stations:
            if station['station_code'] == station_code:
                return station
    raise KeyError('station not found')
550336
def get_field_names(self):
        
        field_names = super(StationDataIO, self).get_field_names()
        if set(field_names) == set(['meta', 'data']):
            meta_fields = list(self.data[0]['meta'].keys())
            if set(meta_fields) < set(self.getvalue('meta')):
                meta_fields = self.getvalue('meta')
            field_names = list(meta_fields) + ['data']
        return field_names
1031007
def fetch(self, station: str) -> str:
        
        valid_station(station)
        try:
            resp = getattr(requests, self.method.lower())(self.url.format(self.rtype, station))
            if resp.status_code != 200:
                raise SourceError(f'{self.__class__.__name__} server returned {resp.status_code}')
        except requests.exceptions.ConnectionError:
            raise ConnectionError(f'Unable to connect to {self.__class__.__name__} server')
        report = self._extract(resp.text, station)
        # This split join replaces all *whitespace elements with a single space
        return ' '.join(report.split())
707870
def error_codes(self):
        
        request_url = "{}/api/0/error_codes".format(self.instance)
        return_value = self._call_api(request_url)
        return return_value
547298
def view_code(self):
        

        return self.data.groupby(level=1).apply(
            lambda x:
            [item for item in x.index.remove_unused_levels().levels[0]]
        )
945944
def get_event_description(event_type, event_code):
    
    description = 'Unknown'
    lookup_map = LRR_TYPE_MAP.get(event_type, None)

    if lookup_map is not None:
        description = lookup_map.get(event_code, description)

    return description
987480
def params_dict(self):
        
        location_code = 'US'
        language_code = 'en'
        if len(self.location):
            location_code = locationMap[process.extractOne(self.location, self.locations)[0]]
        if len(self.language):
            language_code = langMap[process.extractOne(self.language, self.languages)[0]]
        params = {
            'hl': language_code,
            'gl': location_code,
            'ceid': '{}:{}'.format(location_code, language_code)
        }
        return params
884492
def qr_code(self, instance):
        
        try:
            return self._qr_code(instance)
        except Exception as err:
            if settings.DEBUG:
                import traceback
                return "<pre>%s</pre>" % traceback.format_exc()
850244
def data(self) -> Dict[str, Any]:
        """"""
        data: Dict[str, Any] = {}
        data["station"] = self.station
        data["stationId"] = self.station_id
        data["filter"] = self.products_filter

        journeys = []
        for j in sorted(self.journeys, key=lambda k: k.real_departure)[
            : self.max_journeys
        ]:
            journeys.append(
                {
                    "product": j.product,
                    "number": j.number,
                    "trainId": j.train_id,
                    "direction": j.direction,
                    "departure_time": j.real_departure_time,
                    "minutes": j.real_departure,
                    "delay": j.delay,
                    "stops": [s["station"] for s in j.stops],
                    "info": j.info,
                    "info_long": j.info_long,
                    "icon": j.icon,
                }
            )
        data["journeys"] = journeys
        return data
596297
def retrieve_metar(station_icao) -> typing.Tuple[typing.Optional[str], typing.Optional[str]]:
    
    url = _BASE_METAR_URL.format(station=station_icao)
    with requests.get(url) as resp:
        if not resp.ok:
            return f'unable to obtain METAR for station {station_icao}\n' \
                   f'Got to "http://tgftp.nws.noaa.gov/data/observations/metar/stations" ' \
                   f'for a list of valid stations', None
        return None, resp.content.decode().split('\n')[1]
1182317
def get_code(self):
        
        stub = []
        bases = ("(" + ", ".join(self.bases) + ")") if len(self.bases) > 0 else ""
        slots = {"n": self.name, "b": bases}
        if (len(self.children) == 0) and (len(self.variables) == 0):
            stub.append("class %(n)s%(b)s: ..." % slots)
        else:
            stub.append("class %(n)s%(b)s:" % slots)
            super_code = super().get_code() if PY3 else StubNode.get_code(self)
            for line in super_code:
                stub.append(INDENT + line)
        return stub
960945
def extract_current_routine(page, stations):
    '''
    '''
    current_routines = CURRENT_ROUTINE_PATTERN.findall(page.text())
    if not current_routines:
        return

    terminal_station = stations['stations'][-1]
    for routine in current_routines:
        if _(routine[0]) == terminal_station:
            distance = int(routine[1])
    stations_to_this_dir = stations['terminal'][terminal_station]

    waiting_station = _(page('.now .stateName').val())
    idx = stations_to_this_dir.index(waiting_station)
    bus_station = stations_to_this_dir[idx - distance + 1]

    return {
        'destinate_station': terminal_station,
        'bus_station': bus_station,
        'waiting_station': waiting_station,
        'distance': distance
    }
1289110
def get_info(self):
        '''  '''
        return {
            'Connected': self.is_connected(),
            'Port': self.port,
            'Bytes Waiting': self.ser.in_waiting if self.ser else 0
        }
696448
def coordinates_vs_code
      result = {}
      File.open(File.join(File.dirname(__FILE__), "stations.kml")) do |file|
        doc = Hpricot(file)
        (doc/"kml/Document/Folder/Folder/Placemark").each do |placemark|
          if ((placemark/"styleurl") || (placemark/"styleUrl")).inner_text == "#railStation"
            name = (placemark/"name").inner_text
            description = (placemark/"description").inner_text
            code = /summary.aspx\?T\=([A-Z]{3})\"/.match(description)[1]
            longitude, latitude = (placemark/"point/coordinates").inner_text.split(",").map(&:to_f)
            result[code] = { :name => name, :latitude => latitude, :longitude => longitude }
          end
        end
      end
      result["SFA"] = { :name => "Stratford International", :latitude => 51.5445797, :longitude => -0.0097182 }
      result["EBD"] = { :name => "Ebbsfleet International", :latitude => 51.4428002, :longitude => 0.3209516 }
      result
    end
855670
def location_lookup(self, req_location):
        
        location = False
        try:
            location = self.samecodes[req_location['code']]
        except Exception:
            pass
        try:
            location = self.lookup_samecode(req_location['local'], req_location['state'])
        except Exception:
            pass
        return location
205176
def _get_example_csv(self):
        
        station_key = self.json["station"][0]["key"]
        period = "corrected-archive"
        url = self.url\
                  .replace(".json", "/station/{}/period/{}/data.csv"\
                  .format(station_key, period))

        r = requests.get(url)
        if r.status_code == 200:
            return DataCsv().from_string(r.content)
        else:
            raise Exception("Error connecting to api")
392715
function(line) {
		return {
			'name': String(line[1]),
			'country_code': String(line[0]),
			'gmt_offset': Number(line[2]),
			'dst_offset': Number(line[3]),
			'raw_offset': Number(line[4])
		};
	}