Return an array of assertion metadatas from the raw JSON-like stuff from the CLI.
422573
public function assertionsFromRawCliConfig(array $rawAssertions)
    {
        $assertions = [];

        foreach ($rawAssertions as $rawAssertion) {
            $config = $this->jsonDecoder->decode($rawAssertion);
            $assertions[] = new AssertionMetadata($config);
        }

        return $assertions;
    }
798050
def get_metadata(headers):
  """"""
  return dict((k, v) for k, v in headers.iteritems()
              if any(k.lower().startswith(valid) for valid in _GCS_METADATA))
1228812
def extract_function_metadata(wrapped, instance, args, kwargs, return_value):
    """"""
    LOGGER.debug(
        'Extracting function call metadata',
        args=args,
        kwargs=kwargs,
    )
    return {
        'metadata': {
            'args': args,
            'kwargs': kwargs,
        },
    }
107665
def inspect_to_metadata(metadata_object, inspect_data):
    
    identifier = graceful_get(inspect_data, 'Id')
    if identifier:
        if ":" in identifier:
            # format of image name from docker inspect:
            # sha256:8f0e66c924c0c169352de487a3c2463d82da24e9442fc097dddaa5f800df7129
            metadata_object.identifier = identifier.split(':')[1]
        else:
            # container
            metadata_object.identifier = identifier

    # format of Environment Variables from docker inspect:
    # ['DISTTAG=f26container', 'FGC=f26']
    raw_env_vars = graceful_get(inspect_data, "Config", "Env") or []
    if raw_env_vars:
        metadata_object.env_variables = {}
        for env_variable in raw_env_vars:
            splits = env_variable.split("=", 1)
            name = splits[0]
            value = splits[1] if len(splits) > 1 else None
            if value is not None:
                metadata_object.env_variables.update({name: value})

    raw_exposed_ports = graceful_get(inspect_data, "Config", "ExposedPorts")
    if raw_exposed_ports:
        metadata_object.exposed_ports = list(raw_exposed_ports.keys())

    # specific to images
    raw_repo_tags = graceful_get(inspect_data, 'RepoTags')
    if raw_repo_tags:
        metadata_object.name = raw_repo_tags[0]
    metadata_object.labels = graceful_get(inspect_data, 'Config', 'Labels')
    metadata_object.command = graceful_get(inspect_data, 'Config', 'Cmd')
    metadata_object.creation_timestamp = inspect_data.get('Created', None)
    # specific to images
    metadata_object.image_names = inspect_data.get('RepoTags', None)
    # specific to images
    digests = inspect_data.get("RepoDigests", None)
    if digests:
        metadata_object.repo_digests = digests
        metadata_object.digest = digests[0]

    return metadata_object
314100
def _get_formatted_data(cls, path, context=None, site=None, language=None):
        
        return FormattedMetadata(cls(), cls._get_instances(path, context, site, language), path, site, language)
795908
def read_metadata(text, ext):
    """"""
    ext = '.' + ext.split('.')[-1]
    lines = text.splitlines()

    if ext in ['.md', '.Rmd']:
        comment = ''
    else:
        comment = _SCRIPT_EXTENSIONS.get(ext, {}).get('comment', '#')

    metadata, _, _, _ = header_to_metadata_and_cell(lines, comment, ext)
    if ext in ['.r', '.R'] and not metadata:
        metadata, _, _, _ = header_to_metadata_and_cell(lines, "#'", ext)

    return metadata
469241
def metadata(ctx, archive_name):
    '''
    
    '''

    _generate_api(ctx)
    var = ctx.obj.api.get_archive(archive_name)
    click.echo(pprint.pformat(var.get_metadata()))
194384
def parse_json(path):
    # type: (str) -> List[FunctionInfo]
    
    with open(path) as f:
        data = json.load(f)  # type: List[RawEntry]
    result = []

    def assert_type(value, typ):
        # type: (object, type) -> None
        assert isinstance(value, typ), '%s: Unexpected type %r' % (path, type(value).__name__)

    def assert_dict_item(dictionary, key, typ):
        # type: (Mapping[Any, Any], str, type) -> None
        assert key in dictionary, '%s: Missing dictionary key %r' % (path, key)
        value = dictionary[key]
        assert isinstance(value, typ), '%s: Unexpected type %r for key %r' % (
            path, type(value).__name__, key)

    assert_type(data, list)
    for item in data:
        assert_type(item, dict)
        assert_dict_item(item, 'path', Text)
        assert_dict_item(item, 'line', int)
        assert_dict_item(item, 'func_name', Text)
        assert_dict_item(item, 'type_comments', list)
        for comment in item['type_comments']:
            assert_type(comment, Text)
        assert_type(item['samples'], int)
        info = FunctionInfo(encode(item['path']),
                            item['line'],
                            encode(item['func_name']),
                            [encode(comment) for comment in item['type_comments']],
                            item['samples'])
        result.append(info)
    return result
1169850
def BatchConvert(self, metadata_value_pairs, token=None):
    """"""

    urns = [urn for metadata, urn in metadata_value_pairs]
    urns_dict = dict((urn, metadata) for metadata, urn in metadata_value_pairs)

    results = []
    for hash_urn, client_files in filestore.HashFileStore.GetClientsForHashes(
        urns, token=token):
      for hit in client_files:
        metadata = ExportedMetadata(urns_dict[hash_urn])
        metadata.client_urn = rdfvalue.RDFURN(hit).Split(2)[0]

        result = ExportedFileStoreHash(
            metadata=metadata,
            hash=hash_urn.hash_value,
            fingerprint_type=hash_urn.fingerprint_type,
            hash_type=hash_urn.hash_type,
            target_urn=hit)
        results.append(result)

    return results
517147
def json(self):
        """"""
        d = { 'id': self.id, 'format': self.formatclass.__name__,'label': self.label, 'mimetype': self.formatclass.mimetype,  'schema': self.formatclass.schema }
        if self.unique:
            d['unique'] = True
        if self.filename:
            d['filename'] = self.filename
        if self.extension:
            d['extension'] = self.extension
        if self.acceptarchive:
            d['acceptarchive'] = self.acceptarchive
        #d['parameters'] = {}

        #The actual parameters are included as XML, and transformed by clam.js using XSLT (parameter.xsl) to generate the forms
        parametersxml = ''
        for parameter in self.parameters:
            parametersxml += parameter.xml()
        d['parametersxml'] = '<?xml version="1.0" encoding="utf-8" ?><parameters>' + parametersxml + '</parameters>'
        d['converters'] = [ {'id':x.id, 'label':x.label} for x in self.converters ]
        d['inputsources'] = [ {'id':x.id, 'label':x.label} for x in self.inputsources ]

        return json.dumps(d)
955544
def __metadata_helper(json_path):
    
    url = shakedown.dcos_url_path('dcos-metadata/{}'.format(json_path))
    try:
        response = dcos.http.request('get', url)

        if response.status_code == 200:
            return response.json()
    except:
        pass

    return None
1013130
def _context_json(name):
    """"""
    from renku.models import provenance

    cls = getattr(provenance, name)
    return {
        '@context': cls._jsonld_context,
        '@type': cls._jsonld_type,
    }
862197
def _read_routine_metadata(self):
        
        metadata = {}
        if os.path.isfile(self._metadata_filename):
            with open(self._metadata_filename, 'r') as file:
                metadata = json.load(file)

        return metadata
400976
def json(self, args=None):
        
        names = ['identifier', 'abstract', 'keywords']
        out = {key: getattr(self, key) for key in names}
        out.update(self.cf_attrs)
        out = self.format(out, args)

        out['notes'] = self.notes

        out['parameters'] = str({key: {'default': p.default if p.default != p.empty else None, 'desc': ''}
                                 for (key, p) in self._sig.parameters.items()})

        if six.PY2:
            out = walk_map(out, lambda x: x.decode('utf8') if isinstance(x, six.string_types) else x)

        return out
356073
def _reprJSON(self):
        
        return {'__Smi__': (self.id, self.specfile, self.attributes,
                            self.params, self.scanListParams, self.scanList,
                            self.precursorList, self.productList
                            )
                }
688528
def data_json(self, pretty=False):
        """"""
        if pretty:
            return json.dumps(self.data, sort_keys=True, indent=4, separators=(',', ': '))
        else:
            return json.dumps(self.data)
159639
def extract_metadata(graph_def):
  
  meta_matches = [n for n in graph_def.node if n.name==metadata_node_name]
  if meta_matches:
    assert len(meta_matches) == 1, "found more than 1 lucid metadata node!"
    meta_tensor = meta_matches[0].attr['value'].tensor
    return json.loads(meta_tensor.string_val[0])
  else:
    return None