Transforms raw HADS observations into a dict:
            station code -> [(variable, time, value), ...]

        Takes into account the var filter (if set).
5054
def _parse_data(self, raw_data, var_filter, time_extents):
        

        retval = defaultdict(list)
        p = parser()

        begin_time, end_time = time_extents

        for line in raw_data.splitlines():
            if len(line) == 0:
                continue

            fields = line.split("|")[0:-1]
            if var_filter is None or fields[2] in var_filter:
                dt = p.parse(fields[3]).replace(tzinfo=pytz.utc)
                if (begin_time is None or dt >= begin_time) and (
                    end_time is None or dt <= end_time
                ):
                    try:
                        value = (
                            float(fields[4]) if fields[4] != "NaN" else npNan
                        )
                    except ValueError:
                        value = npNan
                    retval[fields[0]].append((fields[2], dt, value))

        return dict(retval)
838383
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'enabled') and self.enabled is not None:
            _dict['enabled'] = self.enabled
        if hasattr(self, 'time_zone') and self.time_zone is not None:
            _dict['time_zone'] = self.time_zone
        if hasattr(self, 'frequency') and self.frequency is not None:
            _dict['frequency'] = self.frequency
        return _dict
1343270
def _get_py_dictionary(self, var, names=None, used___dict__=False):
        '''
        
        '''

        # TODO: Those should be options (would fix https://github.com/Microsoft/ptvsd/issues/66).
        filter_private = False
        filter_special = True
        filter_function = True
        filter_builtin = True

        if not names:
            names, used___dict__ = self.get_names(var)
        d = {}

        # Be aware that the order in which the filters are applied attempts to
        # optimize the operation by removing as many items as possible in the
        # first filters, leaving fewer items for later filters

        if filter_builtin or filter_function:
            for name in names:
                try:
                    name_as_str = name
                    if name_as_str.__class__ != str:
                        name_as_str = '%r' % (name_as_str,)

                    if filter_special:
                        if name_as_str.startswith('__') and name_as_str.endswith('__'):
                            continue

                    if filter_private:
                        if name_as_str.startswith('_') or name_as_str.endswith('__'):
                            continue
                    if not used___dict__:
                        attr = getattr(var, name)
                    else:
                        attr = var.__dict__[name]

                    # filter builtins?
                    if filter_builtin:
                        if inspect.isbuiltin(attr):
                            continue

                    # filter functions?
                    if filter_function:
                        if inspect.isroutine(attr) or isinstance(attr, MethodWrapperType):
                            continue
                except:
                    # if some error occurs getting it, let's put it to the user.
                    strIO = StringIO.StringIO()
                    traceback.print_exc(file=strIO)
                    attr = strIO.getvalue()

                d[name_as_str] = attr

        return d, used___dict__
600693
def parse(station: str, txt: str) -> TafData:
    
    core.valid_station(station)
    while len(txt) > 3 and txt[:4] in ('TAF ', 'AMD ', 'COR '):
        txt = txt[4:]
    _, station, time = core.get_station_and_time(txt[:20].split(' '))
    retwx = {
        'end_time': None,
        'raw': txt,
        'remarks': None,
        'start_time': None,
        'station': station,
        'time': core.make_timestamp(time)
    }
    txt = txt.replace(station, '')
    txt = txt.replace(time, '').strip()
    if core.uses_na_format(station):
        use_na = True
        units = Units(**NA_UNITS)  # type: ignore
    else:
        use_na = False
        units = Units(**IN_UNITS)  # type: ignore
    # Find and remove remarks
    txt, retwx['remarks'] = core.get_taf_remarks(txt)
    # Split and parse each line
    lines = core.split_taf(txt)
    parsed_lines = parse_lines(lines, units, use_na)
    # Perform additional info extract and corrections
    if parsed_lines:
        parsed_lines[-1]['other'], retwx['max_temp'], retwx['min_temp'] \
            = core.get_temp_min_and_max(parsed_lines[-1]['other'])
        if not (retwx['max_temp'] or retwx['min_temp']):
            parsed_lines[0]['other'], retwx['max_temp'], retwx['min_temp'] \
                = core.get_temp_min_and_max(parsed_lines[0]['other'])
        # Set start and end times based on the first line
        start, end = parsed_lines[0]['start_time'], parsed_lines[0]['end_time']
        parsed_lines[0]['end_time'] = None
        retwx['start_time'], retwx['end_time'] = start, end
        parsed_lines = core.find_missing_taf_times(parsed_lines, start, end)
        parsed_lines = core.get_taf_flight_rules(parsed_lines)
    # Extract Oceania-specific data
    if retwx['station'][0] == 'A':  # type: ignore
        parsed_lines[-1]['other'], retwx['alts'], retwx['temps'] \
            = core.get_oceania_temp_and_alt(parsed_lines[-1]['other'])
    # Convert to dataclass
    retwx['forecast'] = [TafLineData(**line) for line in parsed_lines]  # type: ignore
    return TafData(**retwx), units
875992
def _unify_values(self, section, vars):
        
        sectiondict = {}
        try:
            sectiondict = self._sections[section]
        except KeyError:
            if section != self.default_section:
                raise NoSectionError(section)
        # Update with the entry specific variables
        vardict = {}
        if vars:
            for key, value in vars.items():
                if value is not None:
                    value = str(value)
                vardict[self.optionxform(key)] = value
        return _ChainMap(vardict, sectiondict, self._defaults)
1135390
def extract_stations(page):
    '''
    '''
    stations = [_(station.value) for station in page('.stateName')]
    return {
        'terminal': {
            stations[0]: list(reversed(stations)),
            stations[-1]: stations
        },
        'stations': stations
    }
54243
def get_station_and_time(wxdata: [str]) -> ([str], str, str):  # type: ignore
    
    station = wxdata.pop(0)
    qtime = wxdata[0]
    if wxdata and qtime.endswith('Z') and qtime[:-1].isdigit():
        rtime = wxdata.pop(0)
    elif wxdata and len(qtime) == 6 and qtime.isdigit():
        rtime = wxdata.pop(0) + 'Z'
    else:
        rtime = ''
    return wxdata, station, rtime
1138363
def is_timeseries_profile_single_station(nc, variable):
    '''
    
    '''

    # x, y, z(z), t(t)
    # X(t, z)
    dims = nc.variables[variable].dimensions
    cmatrix = coordinate_dimension_matrix(nc)

    for req in ('x', 'y', 'z', 't'):
        if req not in cmatrix:
            return False
    if len(cmatrix['x']) != 0:
        return False
    if cmatrix['x'] != cmatrix['y']:
        return False

    z = get_z_variable(nc)
    if cmatrix['z'] != (z,):
        return False
    t = get_time_variable(nc)
    if cmatrix['t'] != (t,):
        return False

    if dims == (t, z):
        return True
    return False
665462
def raw(self, format=None, **kwargs):
        
        station_codes = self._apply_features_filter(self._get_station_codes())
        metadata = self._get_metadata(station_codes, **kwargs)
        raw_data = self._get_raw_data(station_codes, **kwargs)

        return (metadata, raw_data)
233070
def _parse_line_vars(self, line):
        
        key_values = {}

        # Undocumented feature allows json in vars sections like so:
        #   [prod:vars]
        #   json_like_vars=[{'name': 'htpasswd_auth'}]
        # We'll try this first. If it fails, we'll fall back to normal var
        # lines. Since it's undocumented, we just assume some things.
        k, v = line.strip().split('=', 1)
        if v.startswith('['):
            try:
                list_res = ihateyaml.safe_load(v)
                if isinstance(list_res[0], dict):
                    key_values = list_res[0]
                    return key_values
            except ValueError:
                pass

        # Guess it's not YAML. Parse as normal host variables
        tokens = shlex.split(line.strip())
        key_values = self._parse_vars(tokens)
        return key_values
1166172
def set_var(var, set_='""'):
    ''''''
    if isinstance(set_, str):
        to_set = json.dumps(set_)
    elif isinstance(set_, dict) or isinstance(set_, list):
        try:
            to_set = json.dumps(set_)
        except ValueError:
            raise Exception('var not jsonable')
    else:
        raise Exception('var must be jsonable list or dict')

    os.environ['NBCONVERT_' + var] = to_set
1040328
function substituteVars(rawText, vars)
{
    if (!vars)
    {
        return rawText;
    }
    //after loading contents, perform variable substitution
    Object.keys(vars).forEach(function (varName)
    {
        if (vars.hasOwnProperty(varName))
        {
            var varValue = vars[varName];
            rawText = replaceAll(rawText, varName, varValue);
        }
    });
    return rawText;
}
522539
def _encode_observations(self, observations):
    """"""
    return [
        Observation(
            self._session.obj.run(
                self._encoded_image_t.obj,
                feed_dict={self._decoded_image_p.obj: observation}
            ),
            self._decode_png
        )
        for observation in observations
    ]
849743
def find_program_variables(code):
    
    vars = {}
    lines = code.split('\n')
    for line in lines:
        m = re.match(r"\s*" + re_prog_var_declaration + r"\s*(=|;)", line)
        if m is not None:
            vtype, dtype, names = m.groups()[:3]
            for name in names.split(','):
                vars[name.strip()] = (vtype, dtype)
    return vars
306178
def handle_var(value, context):
    
    # Resolve FilterExpression and Variable immediately
    if isinstance(value, FilterExpression) or isinstance(value, Variable):
        return value.resolve(context)
    # Return quoted strings unquoted
    # http://djangosnippets.org/snippets/886
    stringval = QUOTED_STRING.search(value)
    if stringval:
        return stringval.group("noquotes")
    # Resolve variable or return string value
    try:
        return Variable(value).resolve(context)
    except VariableDoesNotExist:
        return value
988791
def to_dict(self):
        
        return {'station_id': self.station_id,
                'timestamp': self.timestamp,
                'aggregated_on': self.aggregated_on,
                'temp': self.temp,
                'humidity': self.humidity,
                'wind': self.wind,
                'pressure': self.pressure,
                'precipitation': self.precipitation}
668082
def _station_info(station_code):
    """"""
    url_file = open(env.SRC_PATH + '/eere.csv')
    for line in csv.DictReader(url_file):
        if line['station_code'] == station_code:
            return line
    raise KeyError('Station not found')