Transforms raw HADS metadata into a dictionary (station code -> props)
976873
def _parse_metadata(self, metadata):
        
        retval = {}

        # these are the first keys, afterwards follows a var-len list of variables/props
        # first key always blank so skip it
        field_keys = [
            "nesdis_id",
            "nwsli",
            "location_text",
            "latitude",
            "longitude",
            "hsa",
            "state",
            "owner",
            "manufacturer",
            "channel",
            "init_transmit",  # HHMM
            "trans_interval",
        ]  # min

        # repeat in blocks of 7 after field_keys
        var_keys = [
            "pe_code",
            "data_interval",  # min
            "coefficient",
            "constant",
            "time_offset",  # min
            "base_elevation",  # ft
            "gauge_correction",
        ]  # ft

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

            raw_fields = line.split("|")

            fields = dict(zip(field_keys, raw_fields[1 : len(field_keys)]))

            # how many blocks of var_keys after initial fields
            var_offset = len(field_keys) + 1
            var_blocks = (len(raw_fields) - var_offset) // len(
                var_keys
            )  # how many variables
            vars_only = raw_fields[var_offset:]
            variables = {}

            for offset in range(var_blocks):
                var_dict = dict(
                    zip(
                        var_keys,
                        vars_only[
                            offset
                            * len(var_keys) : (offset + 1)
                            * len(var_keys)
                        ],
                    )
                )
                variables[var_dict["pe_code"]] = var_dict

                var_dict["base_elevation"] = float(var_dict["base_elevation"])
                var_dict["gauge_correction"] = float(
                    var_dict["gauge_correction"]
                )
                del var_dict["pe_code"]  # no need to duplicate

            line_val = {"variables": variables}
            line_val.update(fields)

            # conversions
            def dms_to_dd(dms):
                parts = dms.split(" ")
                sec = int(parts[1]) * 60 + int(parts[2])
                return float(parts[0]) + (
                    sec / 3600.0
                )  # negative already in first portion

            line_val["latitude"] = dms_to_dd(line_val["latitude"])
            line_val["longitude"] = dms_to_dd(line_val["longitude"])

            retval[line_val["nesdis_id"]] = line_val

        return retval
955262
def get_dict_from_response(response):
    """"""
    result = {}
    if getattr(response, '_resp') and response._resp.code > 400:
        return result

    for i in response.data:
        # strip the schema from the key
        k = i['Type'].replace(REMOTE_APP_RESOURCE_SCHEMA, '')
        result.setdefault(k, list())
        result[k].append(i['Value'])
    return result
1300794
def parse_metadata(self):
        """"""

        all_models = defaultdict(list)

        with open(self.metadata_index_json) as f:
            loaded = json.load(f)

        for m in loaded['index']:
            all_models[m['uniprot_ac']].append(m)

        self.all_models = dict(all_models)
944470
def as_dict(self):
        """"""
        return {config_name: getattr(self, config_name)
                for config_name, _ in self._iter_config_props()}
805372
def json_options_to_metadata(options, add_brackets=True):
    """"""
    try:
        options = loads('{' + options + '}' if add_brackets else options)
        return options
    except ValueError:
        return {}
1324925
def as_dict(self):
        """"""
        dictionary = {}
        for section in self.parser.sections():
            dictionary[section] = {}
            for option in self.parser.options(section):
                dictionary[section][option] = self.parser.get(section, option)
        return dictionary
165738
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self, 'duration') and self.duration is not None:
            _dict['duration'] = self.duration
        if hasattr(self, 'name') and self.name is not None:
            _dict['name'] = self.name
        if hasattr(self, 'details') and self.details is not None:
            _dict['details'] = self.details._to_dict()
        if hasattr(self, 'status') and self.status is not None:
            _dict['status'] = self.status
        if hasattr(self, 'container') and self.container is not None:
            _dict['container'] = self.container._to_dict()
        if hasattr(self, 'audio') and self.audio is not None:
            _dict['audio'] = [x._to_dict() for x in self.audio]
        return _dict
1062046
def result_to_dict(res):
    
    keys = res.keys()
    return [dict(itertools.izip(keys, row)) for row in res]
991342
def to_dict(self, remove_nones=False):
        

        if remove_nones:
            return super().to_dict(remove_nones=True)

        tags = None
        if self.tags is not None:
            tags = [tag.to_dict(remove_nones=remove_nones) for tag in self.tags]

        return {
            'value': self.value,
            'indicatorType': self.type,
            'priorityLevel': self.priority_level,
            'correlationCount': self.correlation_count,
            'whitelisted': self.whitelisted,
            'weight': self.weight,
            'reason': self.reason,
            'firstSeen': self.first_seen,
            'lastSeen': self.last_seen,
            'source': self.source,
            'notes': self.notes,
            'tags': tags,
            'enclaveIds': self.enclave_ids
        }
867146
def dict_contents(self, use_dict=None, as_class=dict):
        """"""
        # make/extend the dictionary of content
        if use_dict is None:
            use_dict = as_class()

        # save the content
        use_dict.__setitem__('dnet', self.rtDNET)
        use_dict.__setitem__('port_id', self.rtPortID)
        use_dict.__setitem__('port_info', self.rtPortInfo)

        # return what we built/updated
        return use_dict
749623
def to_dict(cls):
        
        return dict((item.name, item.number) for item in iter(cls))
525340
def _get_dump_item_context(self, index, name, opts):
        
        c = {
            'item_no': index,
            'label': name,
            'name': name,
            'models': ' '.join(opts['models']),
            'natural_key': '',
        }
        if opts.get('use_natural_key', False):
            c['natural_key'] = ' -n'
        c.update(self.get_global_context())
        return c
657266
def to_s
      props = {
        property: property,
        type: type,
        status: status,
        section: section
      }
      "DataCriteria#{props}"
    end
1346875
def to_dict(self):
        """"""
        d = {}
        if self.valid_since is not None:
            d['@valid_since'] = datetime_to_str(self.valid_since)
        for attr_list, prefix in [(self.attributes, '@'), (self.children, '')]:
            for attr in attr_list:
                value = getattr(self, attr)
                if isinstance(value, Serializable):
                    value = value.to_dict()
                if value or isinstance(value, (bool, int, long)):
                    d[prefix + attr] = value
        if hasattr(self, 'display') and self.display:
            d['display'] = self.display
        return d
1103238
def __dict_to_pod_spec(spec):
    '''
    
    '''
    spec_obj = kubernetes.client.V1PodSpec()
    for key, value in iteritems(spec):
        if hasattr(spec_obj, key):
            setattr(spec_obj, key, value)

    return spec_obj
1215282
def _transform_to_dict(result):
        
        result_dict = {}
        property_list = result.item
        for item in property_list:
            result_dict[item.key[0]] = item.value[0]
        return result_dict
1188147
def _to_dict(self):
        """"""
        _dict = {}
        if hasattr(self,
                   'configuration_id') and self.configuration_id is not None:
            _dict['configuration_id'] = self.configuration_id
        if hasattr(self, 'name') and self.name is not None:
            _dict['name'] = self.name
        if hasattr(self, 'created') and self.created is not None:
            _dict['created'] = datetime_to_string(self.created)
        if hasattr(self, 'updated') and self.updated is not None:
            _dict['updated'] = datetime_to_string(self.updated)
        if hasattr(self, 'description') and self.description is not None:
            _dict['description'] = self.description
        if hasattr(self, 'conversions') and self.conversions is not None:
            _dict['conversions'] = self.conversions._to_dict()
        if hasattr(self, 'enrichments') and self.enrichments is not None:
            _dict['enrichments'] = [x._to_dict() for x in self.enrichments]
        if hasattr(self, 'normalizations') and self.normalizations is not None:
            _dict['normalizations'] = [
                x._to_dict() for x in self.normalizations
            ]
        if hasattr(self, 'source') and self.source is not None:
            _dict['source'] = self.source._to_dict()
        return _dict