SDC Metadata specified by there specs
    https://eng.joyent.com/mdata/datadict.html
19649
def _sdc_mdata(mdata_list=None, mdata_get=None):
    '''
    
    '''
    grains = {}
    sdc_text_keys = [
        'uuid',
        'server_uuid',
        'datacenter_name',
        'hostname',
        'dns_domain',
    ]
    sdc_json_keys = [
        'resolvers',
        'nics',
        'routes',
    ]

    if not mdata_list:
        mdata_list = salt.utils.path.which('mdata-list')

    if not mdata_get:
        mdata_get = salt.utils.path.which('mdata-get')

    if not mdata_list or not mdata_get:
        return grains

    for mdata_grain in sdc_text_keys+sdc_json_keys:
        mdata_value = __salt__['cmd.run']('{0} sdc:{1}'.format(mdata_get, mdata_grain), ignore_retcode=True)

        if not mdata_value.startswith('No metadata for '):
            if 'mdata' not in grains:
                grains['mdata'] = {}
            if 'sdc' not in grains['mdata']:
                grains['mdata']['sdc'] = {}

            log.debug('found mdata entry sdc:%s with value %s', mdata_grain, mdata_value)
            mdata_grain = mdata_grain.replace('-', '_')
            mdata_grain = mdata_grain.replace(':', '_')
            if mdata_grain in sdc_json_keys:
                grains['mdata']['sdc'][mdata_grain] = salt.utils.json.loads(mdata_value)
            else:
                grains['mdata']['sdc'][mdata_grain] = mdata_value

    return grains
262107
def _GetNestedDict(self, value):
    """"""
    row = {}
    for type_info in value.__class__.type_infos:
      # We only expect the metadata proto to be included as ProtoEmbedded.
      if type_info.__class__.__name__ == "ProtoEmbedded":
        row[type_info.name] = self._GetNestedDict(value.Get(type_info.name))
      else:
        row[type_info.name] = utils.SmartStr(value.Get(type_info.name))

    return row
745972
function metaData() {
            const meta = {};

            Object.keys(schema.paths).forEach((k) => {
                switch (schema.paths[k].type) {
                    case 'geoPoint':
                        // This allows us to automatically convert valid lng/lat objects
                        // to Datastore.geoPoints
                        meta.geoPointsProps = meta.geoPointsProps || [];
                        meta.geoPointsProps.push(k);
                        break;
                    case 'entityKey':
                        meta.refProps = meta.refProps || {};
                        meta.refProps[k] = true;
                        break;
                    default:
                }
            });

            return meta;
        }
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
1092039
def get_description_metadata(self):
        
        metadata = dict(self._mdata['description'])
        metadata.update({'existing_string_values': self._my_map['description']['text']})
        return Metadata(**metadata)
972374
def fileattr_from_metadata(md):
    # type: (dict) -> collections.namedtuple
    
    try:
        mdattr = json.loads(
            md[JSON_KEY_BLOBXFER_METADATA])[_JSON_KEY_FILE_ATTRIBUTES]
    except (KeyError, TypeError):
        return None
    else:
        if blobxfer.util.on_windows():
            global _FILEATTR_WARNED_ON_WINDOWS
            if not _FILEATTR_WARNED_ON_WINDOWS:
                _FILEATTR_WARNED_ON_WINDOWS = True
                logger.warning(
                    'file attributes store/restore on Windows is not '
                    'supported yet')
            fileattr = None
        else:
            try:
                fileattr = PosixFileAttr(
                    mode=mdattr[_JSON_KEY_FILE_ATTRIBUTES_POSIX][
                        _JSON_KEY_FILE_ATTRIBUTES_MODE],
                    uid=mdattr[_JSON_KEY_FILE_ATTRIBUTES_POSIX][
                        _JSON_KEY_FILE_ATTRIBUTES_UID],
                    gid=mdattr[_JSON_KEY_FILE_ATTRIBUTES_POSIX][
                        _JSON_KEY_FILE_ATTRIBUTES_GID],
                )
            except KeyError:
                fileattr = None
        return fileattr
527774
def get_upload_key_metadata(self):
        """"""
        key = self.get_upload_key()
        metadata = key.metadata.copy()

        # Some http header properties which are stored on the key need to be
        # copied to the metadata when updating
        headers = {
            # http header name, key attribute name
            'Cache-Control': 'cache_control',
            'Content-Type': 'content_type',
            'Content-Disposition': 'content_disposition',
            'Content-Encoding': 'content_encoding',
        }

        for header_name, attribute_name in headers.items():
            attribute_value = getattr(key, attribute_name, False)
            if attribute_value:
                metadata.update({b'{0}'.format(header_name):
                                 b'{0}'.format(attribute_value)})
        return metadata
180916
def etd_ms_py2dict(elements):
    """"""
    metadata_dict = {}
    # Loop through all elements in the Python object.
    for element in elements.children:
        # Start an empty element list if an entry for the element
        # list hasn't been made in the dictionary.
        if element.tag not in metadata_dict:
            metadata_dict[element.tag] = []
        element_dict = {}
        if hasattr(element, 'role'):
            element_dict['role'] = element.role
        elif hasattr(element, 'scheme'):
            element_dict['scheme'] = element.scheme
        elif hasattr(element, 'qualifier') and element.qualifier is not None \
                and element.tag == 'title':
            element_dict['qualifier'] = element.qualifier
        # Set the element's content as a dictionary
        # of children elements.
        if element.children:
            child_dict = {}
            for child in element.children:
                if child.content is not None:
                    child_dict[child.tag] = child.content
            element_dict['content'] = child_dict
        # Set element content that is not children.
        elif element.content is not None:
            if element.content.strip() != '':
                element_dict['content'] = element.content
        # Append the dictionary to the element list
        # if the element has content or children.
        if element_dict.get('content', False):
            metadata_dict[element.tag].append(element_dict)

    return metadata_dict
928586
def c_metadata(api, args, verbose=False):
    
    obj = api.get_object(args['<URL>'].split('/')[-1])
    if not set_metadata(args['<JSON>'], obj):
        return json.dumps(obj.metadata.read(), indent=4)
154768
def get_resource_mdata():
    """"""
    return {
        'group': {
            'element_label': {
                'text': 'group',
                'languageTypeId': str(DEFAULT_LANGUAGE_TYPE),
                'scriptTypeId': str(DEFAULT_SCRIPT_TYPE),
                'formatTypeId': str(DEFAULT_FORMAT_TYPE),
            },
            'instructions': {
                'text': 'enter either true or false.',
                'languageTypeId': str(DEFAULT_LANGUAGE_TYPE),
                'scriptTypeId': str(DEFAULT_SCRIPT_TYPE),
                'formatTypeId': str(DEFAULT_FORMAT_TYPE),
            },
            'required': False,
            'read_only': False,
            'linked': False,
            'array': False,
            'default_boolean_values': [None],
            'syntax': 'BOOLEAN',
        },
        'avatar': {
            'element_label': {
                'text': 'avatar',
                'languageTypeId': str(DEFAULT_LANGUAGE_TYPE),
                'scriptTypeId': str(DEFAULT_SCRIPT_TYPE),
                'formatTypeId': str(DEFAULT_FORMAT_TYPE),
            },
            'instructions': {
                'text': 'accepts an osid.id.Id object',
                'languageTypeId': str(DEFAULT_LANGUAGE_TYPE),
                'scriptTypeId': str(DEFAULT_SCRIPT_TYPE),
                'formatTypeId': str(DEFAULT_FORMAT_TYPE),
            },
            'required': False,
            'read_only': False,
            'linked': False,
            'array': False,
            'default_id_values': [''],
            'syntax': 'ID',
            'id_set': [],
        },
    }
807322
def _metadata(image, datapath):
    
    metadata = {'series_number': 0, 'datadir': datapath}
    spacing = image.GetSpacing()
    metadata['voxelsize_mm'] = [
        spacing[2],
        spacing[0],
        spacing[1],
    ]
    return metadata
378852
def _dict2schema(dct):
    
    attrs = dct.copy()
    if MARSHMALLOW_VERSION_INFO[0] < 3:

        class Meta(object):
            strict = True

        attrs["Meta"] = Meta
    return type(str(""), (ma.Schema,), attrs)
1374238
def getMetadataId(self, metadata):
        
        return str(datamodel.VariantSetMetadataCompoundId(
            self.getCompoundId(), 'metadata:' + metadata.key))
578924
def _read_metadata(self, f, endianness):
        
        self.data_type = types.tds_data_types[0xFFFFFFFF]
        self.dimension = types.Uint32.read(f, endianness)
        # In TDMS format version 2.0, 1 is the only valid value for dimension
        if self.dimension != 1:
            log.warning("Data dimension is not 1")
        self.chunk_size = types.Uint64.read(f, endianness)
        # size of vector of format changing scalers
        self.scaler_vector_length = types.Uint32.read(f, endianness)
        # Size of the vector
        log.debug("mxDAQ format scaler vector size '%d'" %
                  (self.scaler_vector_length,))
        if self.scaler_vector_length > 1:
            log.error("mxDAQ multiple format changing scalers not implemented")

        for idx in range(self.scaler_vector_length):
            # WARNING: This code overwrites previous values with new
            # values.  At this time NI provides no documentation on
            # how to use these scalers and sample TDMS files do not
            # include more than one of these scalers.
            self.scaler_data_type_code = types.Uint32.read(f, endianness)
            self.scaler_data_type = (
                types.tds_data_types[self.scaler_data_type_code])

            # more info for format changing scaler
            self.scaler_raw_buffer_index = types.Uint32.read(f, endianness)
            self.scaler_raw_byte_offset = types.Uint32.read(f, endianness)
            self.scaler_sample_format_bitmap = types.Uint32.read(f, endianness)
            self.scale_id = types.Uint32.read(f, endianness)

        raw_data_widths_length = types.Uint32.read(f, endianness)
        self.raw_data_widths = np.zeros(raw_data_widths_length, dtype=np.int32)
        for cnt in range(raw_data_widths_length):
            self.raw_data_widths[cnt] = types.Uint32.read(f, endianness)
148004
def attrs(self):
        
        return dict((k, v) for k, v in iteritems(self.__dict__) if k is not "sdk")
1222412
def get_data_metadata(self):
        
        # Implemented from template for osid.resource.ResourceForm.get_group_metadata_template
        metadata = dict(self._mdata['data'])
        metadata.update({'existing_object_values': self._my_map['data']})
        return Metadata(**metadata)
1315229
def _read_metadata(self, f):
        """"""

        raw_data_index = types.Uint32.read(f, self.endianness)

        log.debug("Reading metadata for object %s", self.tdms_object.path)

        # Object has no data in this segment
        if raw_data_index == 0xFFFFFFFF:
            log.debug("Object has no data in this segment")
            self.has_data = False
            # Leave number_values and data_size as set previously,
            # as these may be re-used by later segments.
        # Data has same structure as previously
        elif raw_data_index == 0x00000000:
            log.debug(
                "Object has same data structure as in the previous segment")
            self.has_data = True
        elif raw_data_index == 0x00001269 or raw_data_index == 0x00001369:
            # This is a DAQmx raw data segment.
            #    0x00001269 for segment containing Format Changing scaler.
            #    0x00001369 for segment containing Digital Line scaler.
            if raw_data_index == 0x00001369:
                # special scaling for DAQ's digital input lines?
                log.warning("DAQmx with Digital Line scaler has not tested")

            # DAQmx raw data format metadata has its own class
            self.has_data = True
            self.tdms_object.has_data = True

            info = self._read_metadata_mx(f)
            self.dimension = info.dimension
            self.data_type = info.data_type
            # DAQmx format has special chunking
            self.data_size = info.chunk_size
            self.number_values = info.chunk_size
            # segment reading code relies on a single consistent raw
            # data width so assert that there is only one.
            assert(len(info.raw_data_widths) == 1)
            self.raw_data_width = info.raw_data_widths[0]
            # fall through and read properties
        else:
            # Assume metadata format is legacy TDMS format.
            # raw_data_index gives the length of the index information.
            self.has_data = True
            self.tdms_object.has_data = True

            # Read the data type
            try:
                self.data_type = types.tds_data_types[
                    types.Uint32.read(f, self.endianness)]
            except KeyError:
                raise KeyError("Unrecognised data type")
            if (self.tdms_object.data_type is not None and
                    self.data_type != self.tdms_object.data_type):
                raise ValueError(
                    "Segment object doesn't have the same data "
                    "type as previous segments.")
            else:
                self.tdms_object.data_type = self.data_type
            log.debug("Object data type: %r", self.tdms_object.data_type)

            if (self.tdms_object.data_type.size is None and
                    self.tdms_object.data_type != types.String):
                raise ValueError(
                    "Unsupported data type: %r" % self.tdms_object.data_type)

            # Read data dimension
            self.dimension = types.Uint32.read(f, self.endianness)
            # In TDMS version 2.0, 1 is the only valid value for dimension
            if self.dimension != 1:
                log.warning("Data dimension is not 1")

            # Read number of values
            self.number_values = types.Uint64.read(f, self.endianness)

            # Variable length data types have total size
            if self.data_type in (types.String, ):
                self.data_size = types.Uint64.read(f, self.endianness)
            else:
                self.data_size = (
                    self.number_values *
                    self.data_type.size * self.dimension)

            log.debug(
                "Object number of values in segment: %d", self.number_values)

        # Read data properties
        num_properties = types.Uint32.read(f, self.endianness)
        log.debug("Reading %d properties", num_properties)
        for i in range(num_properties):
            prop_name, value = read_property(f, self.endianness)
            self.tdms_object.properties[prop_name] = value