Converts GrrMessage into a set of RDFValues.

    Args:
      metadata: ExportedMetadata to be used for conversion.
      grr_message: GrrMessage to be converted.
      token: Security token.

    Returns:
      List or generator with resulting RDFValues.
324766
def Convert(self, metadata, grr_message, token=None):
    
    return self.BatchConvert([(metadata, grr_message)], token=token)
1017395
function checkMetaMessages(context, exportsNode) {
    if (exportsNode.type !== "ObjectExpression") {

        // if the exported node is not the correct format, "internal-no-invalid-meta" will already report this.
        return;
    }

    const metaProperty = getPropertyFromObject("meta", exportsNode);
    const messages = metaProperty && getPropertyFromObject("messages", metaProperty.value);

    if (!messages) {
        context.report({
            node: metaProperty,
            messageId: "expectedMessages"
        });
    }
}
805372
def json_options_to_metadata(options, add_brackets=True):
    """"""
    try:
        options = loads('{' + options + '}' if add_brackets else options)
        return options
    except ValueError:
        return {}
287873
def extract_http_metadata(wrapped, instance, args, kwargs, return_value):
    
    response = return_value
    LOGGER.debug(
        'Extracting HTTP metadata',
        args=args,
        kwargs=kwargs,
    )
    if 'request' in kwargs:
        request = kwargs['request']
    else:
        request = args[0]

    metadata = {
        'http': {
            'request': {
                'method': request.method.upper(),
                'url': request.url,
            },
        },
    }
    if response is not None:
        metadata['http']['response'] = {
            'status': response.status_code,
        }

    return metadata
243226
def global_meta_data(self):
        
        with switch_db(MetaDataModel, 'hyperstream'):
            return sorted(map(lambda x: x.to_dict(), MetaDataModel.objects),
                          key=lambda x: len(x['identifier'].split('.')),
                          reverse=True)
1034555
def _parse_metadata_and_message_count(response):
    '''
    
    '''
    metadata = _parse_metadata(response)

    headers = _parse_response_for_dict(response)
    metadata.approximate_message_count = _int_to_str(headers.get('x-ms-approximate-messages-count'))

    return metadata
312441
def metadata_converter_help_content():
    
    message = m.Message()
    paragraph = m.Paragraph(tr(
        'This tool will convert InaSAFE 4.x keyword metadata into the '
        'metadata format used by InaSAFE 3.5. The primary reason for doing '
        'this is to prepare data for use in GeoSAFE - the online version of '
        'InaSAFE.'
    ))
    message.add(paragraph)
    paragraph = m.Paragraph(tr(
        'You should note that this tool will not touch the original data or '
        'metadata associated with a layer. Instead it will make a copy of the '
        'original layer to the place that you nominate, and create a new '
        'keywords XML file to accompany that data. This new keywords file '
        'will contain InaSAFE keywords in the 3.5 format.'
    ))
    message.add(paragraph)
    return message
79015
def convert_meta(self):
        
        if self.meta_str:
            self.meta_str = regex_meta.findall(self.meta_str + ',')
        if self.meta_str:
            for par in self.meta_str:
                if par[0] is not '':
                    val1 = par[0]
                    val2 = par[1]
                else:
                    val1 = par[2]
                    val2 = par[3]
                val1 = val1.strip()
                val2 = val2.strip()
                if val1 in CRTFParser.valid_global_keys or val1 == 'label':
                    if val1 in ('range', 'corr', 'labeloff'):
                        val2 = val2.split(',')
                        val2 = [x.strip() for x in val2]
                    self.meta[val1] = val2
                else:
                    self._raise_error("'{0}' is not a valid meta key".format(val1))

        self.meta['include'] = self.include != '-'
        self.include = self.meta['include']

        if 'range' in self.meta:
            self.meta['range'] = [u.Quantity(x) for x in self.meta['range']]

        self.meta['type'] = self.type_
665840
def get_metas(cookie, tokens, filelist, dlink=True):
    '''
    '''
    if isinstance(filelist, str):
        filelist = [filelist, ]
    url = ''.join([
        const.PAN_API_URL,
        'filemetas?channel=chunlei&clienttype=0&web=1',
        '&bdstoken=', tokens['bdstoken'],
    ])
    if dlink:
        data = ('dlink=1&target=' +
                encoder.encode_uri_component(json.dumps(filelist)))
    else:
        data = ('dlink=0&target=' +
                encoder.encode_uri_component(json.dumps(filelist)))
    req = net.urlopen(url, headers={
        'Cookie': cookie.sub_output('BDUSS'),
        'Content-type': const.CONTENT_FORM,
        }, data=data.encode())
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
448752
def _collapseMsg(self, msg):
        
        retval = {}
        for logname in msg:
            data = u""
            for m in msg[logname]:
                m = bytes2unicode(m, self.builder.unicode_encoding)
                data += m
            if isinstance(logname, tuple) and logname[0] == 'log':
                retval['log'] = (logname[1], data)
            else:
                retval[logname] = data
        return retval
231033
def extract_metadata
      raise ArgumentError, "MIME type unspecified or not configured" if schema.blank?
      fn = "extract_#{schema.downcase}_metadata"
      raise ArgumentError, "Unsupported metadata standard: #{schema}" unless respond_to?(fn.to_sym)
      send(fn, metadata_xml)
    end
293407
def get_metadata():
    
    misc_path = pkg_resources.resource_filename('hwrt', 'misc/')
    wm_symbols = os.path.join(misc_path, 'wm_symbols.csv')
    wm_tags = os.path.join(misc_path, 'wm_tags.csv')
    wm_tags2symbols = os.path.join(misc_path, 'wm_tags2symbols.csv')
    return {'symbols': read_csv(wm_symbols),
            'tags': read_csv(wm_tags),
            'tags2symbols': read_csv(wm_tags2symbols)}
1273849
def metadata(request, config_loader_path=None, valid_for=None):
    
    conf = get_config(config_loader_path, request)
    metadata = entity_descriptor(conf)
    return HttpResponse(content=text_type(metadata).encode('utf-8'),
                        content_type="text/xml; charset=utf8")
1170481
function toCassandraValues(metadata, values) {
  if (values === null || values === undefined) {
    return null;
  }
  var specs = metadata.columnSpecs;
  var list = [];
  for (var i = 0; i < specs.length; i++) {
    var value = values[i];
    if (value === null || value === undefined) {
      list.push(null);
    } else {
      var spec = specs[i];
      var type = types.fromType(spec.type);
      list.push(type.serialize(value));
    }
  }
  return list;
}
446116
function initMetadataConversions() {
  var mdc = this.metadataConversions

  mdc['publish'] = {
    deserialize: function (dateString) {
      if (dateString)
        return new Date(Date.parse(dateString))
      else
        return dateString
    },
    serialize: function (date) {
      if (date instanceof Date) {
        return date.getFullYear() + '-' 
          + ('0' + (date.getMonth()+1)).slice(-2) + '-'
          + ('0' + date.getDate())
      } else {
        return date.toString()
      }
    }
  }

  mdc['tags'] = {
    deserialize: function (tagString) { //prob not very readable
      if (S(tagString).contains(',')) return tagString.split(',').map(function(tag){ return tag.trim() })
      //else if (S(tagString).contains(' ')) return tagString.split(' ').map(function(tag){ return tag.trim() })
      else return [tagString]
    },
    serialize: function (tagArray) {
      return tagArray.join(', ')
    }
  }
}
348628
def read_creds_from_ec2_instance_metadata():
    
    creds = init_creds()
    try:
        has_role = requests.get('http://169.254.169.254/latest/meta-data/iam/security-credentials', timeout = 1)
        if has_role.status_code == 200:
            iam_role = has_role.text
            credentials = requests.get('http://169.254.169.254/latest/meta-data/iam/security-credentials/%s/' %
                                       iam_role.strip()).json()
            for c in ['AccessKeyId', 'SecretAccessKey']:
                creds[c] = credentials[c]
            creds['SessionToken'] = credentials['Token']
        return creds
    except Exception as e:
        return False
69848
def get_metadata(self, loadbalancer, node=None, raw=False):
        
        if node:
            uri = "/loadbalancers/%s/nodes/%s/metadata" % (
                    utils.get_id(loadbalancer), utils.get_id(node))
        else:
            uri = "/loadbalancers/%s/metadata" % utils.get_id(loadbalancer)
        resp, body = self.api.method_get(uri)
        meta = body.get("metadata", [])
        if raw:
            return meta
        ret = dict([(itm["key"], itm["value"]) for itm in meta])
        return ret