Pull metadata from topics and push to maps.
545088
private void pullTopicMetadata(final AbstractPipelineInput input, final Collection<FileInfo> fis) throws DITAOTException {
        // Pull metadata (such as navtitle) into the map from the referenced topics
        final File styleFile = new File(input.getAttribute(ANT_INVOKER_EXT_PARAM_STYLE));
        for (final FileInfo f : fis) {
            final File inputFile = new File(job.tempDir, f.file.getPath());
            final File tmp = new File(inputFile.getAbsolutePath() + ".tmp" + Long.toString(System.currentTimeMillis()));
            if (!tmp.getParentFile().exists() && !tmp.getParentFile().mkdirs()) {
                throw new DITAOTException("Failed to create directory " + tmp.getParent());
            }
            logger.info("Processing " + inputFile.toURI());
            logger.debug("Processing " + inputFile.toURI() + " to " + tmp.toURI());

            Source source = null;
            Result result = null;
            try {
                source = new StreamSource(inputFile.toURI().toString());
                result = new StreamResult(tmp);

                logger.info("Loading stylesheet " + styleFile);
                final TransformerFactory tf = TransformerFactory.newInstance();
                final CatalogResolver xmlCatalog = CatalogUtils.getCatalogResolver();
                tf.setURIResolver(xmlCatalog);
                final Transformer t = withLogger(tf.newTransformer(new StreamSource(styleFile)), logger);
                final URIResolver resolver;
                if (Configuration.DEBUG) {
                    resolver = new DebugURIResolver(xmlCatalog);
                } else {
                    resolver = xmlCatalog;
                }
                t.setURIResolver(resolver);
                for (Entry<String, String> e : input.getAttributes().entrySet()) {
                    logger.debug("Set parameter " + e.getKey() + " to '" + e.getValue() + "'");
                    t.setParameter(e.getKey(), e.getValue());
                }

                t.transform(source, result);
            } catch (final TransformerConfigurationException e) {
                throw new RuntimeException("Failed to compile stylesheet '" + styleFile.toURI() + "': " + e.getMessage(), e);
            } catch (final Exception e) {
                throw new DITAOTException("Failed to transform document: " + e.getMessage(), e);
            } finally {
                try {
                    XMLUtils.close(source);
                } catch (final IOException e) {
                    // NOOP
                }
                try {
                    XMLUtils.close(result);
                } catch (final IOException e) {
                    // NOOP
                }
            }
            try {
                logger.debug("Moving " + tmp.toURI() + " to " + inputFile.toURI());
                if (!inputFile.delete()) {
                    throw new IOException("Failed to to delete input file " + inputFile.toURI());
                }
                if (!tmp.renameTo(inputFile)) {
                    throw new IOException("Failed to to replace input file " + inputFile.toURI());
                }
            } catch (final IOException e) {
                throw new DITAOTException("Failed to replace document: " + e.getMessage(), e);
            } finally {
                logger.debug("Remove " + tmp.toURI());
                FileUtils.delete(tmp);
            }
        }
    }
707160
function processRetrievedContent(content, filePrismicMetadata, queryKey, ctx) {
            if (content.results != null && content.results.length > 0) {
                var queryMetadata = filePrismicMetadata[queryKey];
                for (var i = 0; i < content.results.length; i++) {
                    var result = processRetrievedDocument(content.results[i], filePrismicMetadata, queryKey, ctx);
                    filePrismicMetadata[queryKey].results.push(result);
                }
            }
        }
1196930
def _ReadStorageMetadata(self):
    """"""
    query = 'SELECT key, value FROM metadata'
    self._cursor.execute(query)

    metadata_values = {row[0]: row[1] for row in self._cursor.fetchall()}

    self._compression_format = metadata_values['compression_format']
917714
protected void populateDatabaseTopics(final BuildData buildData,
            final Map<String, BaseTopicWrapper<?>> topics) throws BuildProcessingException {
        final List<TopicWrapper> allTopics = new ArrayList<TopicWrapper>();
        final List<TopicWrapper> latestTopics = new ArrayList<TopicWrapper>();
        final List<TopicWrapper> revisionTopics = new ArrayList<TopicWrapper>();

        // Calculate the ids of all the topics to get
        final List<ITopicNode> topicNodes = buildData.getContentSpec().getAllTopicNodes();
        for (final ITopicNode topicNode : topicNodes) {
            // Determine which topics we need to fetch the latest topics for and which topics we need to fetch revisions for.
            final TopicWrapper topic;
            if (topicNode.getRevision() != null && !buildData.getBuildOptions().getUseLatestVersions()) {
                topic = topicProvider.getTopic(topicNode.getDBId(), topicNode.getRevision());
                revisionTopics.add(topic);
                allTopics.add(topic);
            } else if (buildData.getBuildOptions().getMaxRevision() != null && !buildData.getBuildOptions().getUseLatestVersions()) {
                topic = topicProvider.getTopic(topicNode.getDBId(), buildData.getBuildOptions().getMaxRevision());
                revisionTopics.add(topic);
                allTopics.add(topic);
            } else {
                topic = topicProvider.getTopic(topicNode.getDBId());
                latestTopics.add(topic);
                allTopics.add(topic);
            }

            // Add the topic to the topics collection
            final String key = DocBookBuildUtilities.getTopicBuildKey(topic);
            topics.put(key, topic);
            buildData.getBuildDatabase().add(topicNode, key);
        }
    }
633863
def _process(self, data):
        
        indices = []
        for indexname, indexdata in list(data.items()):
            idata = []
            for docname, docdata in list(indexdata.get("mappings", {}).items()):
                o = get_field(docname, docdata, document_object_field=self.document_object_field, is_document=True)
                o.connection = self.connection
                o.index_name = indexname
                idata.append((docname, o))
            idata.sort()
            indices.append((indexname, idata))
        indices.sort()
        self.indices = OrderedDict(indices)
997757
def map(self, options=None):
        """"""
        for path, data in self.paths.items():
            references = data.get("references", [])
            for item in data["items"]:
                for obj in self.create_class(item, options, references=references):
                    self.add_object(obj)

        self.organize_objects()
283875
public static Map<String, String> toMap(List<EntityMetadata> metadata) {
		
		Map<String, String> map = new LinkedHashMap<String, String>();
		
		if(CollectionUtils.isNotEmpty(metadata)) {
			
			for(EntityMetadata m : metadata) {
				
				map.put(m.getName(), m.getValue());
				
			}
		
		}
		
		return map;
		
	}
280744
def loadMetadata(self):
        
        #TODO: change that spectra dont have to be iterated to extract metadata
        #node
        if self._parsed:
            raise TypeError('Mzml file already parsed.')
        [None for _ in self._parseMzml()]
        self._parsed = True
106546
def push(self):
        """"""

        tx = Tx(self.tx_project_slug)

        if self.options.resources:
            articles = [
                self.desk.articles().by_id(r.strip())
                for r in self.options.resources.split(',')
            ]
        else:
            articles = self.desk.articles()

        for a in articles:

            self.log.debug(
                'Inspecting Desk resource %s', a.api_href
            )

            for translation in a.translations.items().values():
                our_locale = self.desk_to_our_locale(translation.locale)

                self.log.debug('Checking locale %s', translation.locale)

                if not self._process_locale(translation.locale):
                    self.log.debug('Skipping locale.')
                    continue

                # make sure the project exists in Tx
                tx.get_project(our_locale)

                a_id = a.api_href.rsplit('/', 1)[1]
                if (self.options.force or
                    not tx.resource_exists(a_id, our_locale) or
                    translation.outdated
                ):
                    self.log.info('Resource %(id)s out of date in %(locale)s; updating.' %
                             {'id': a_id,
                              'locale': our_locale,
                              },
                    )

                    tx.create_or_update_resource(
                        a_id,
                        our_locale,
                        self.make_resource_title(a),
                        self.make_resource_document(a.subject, a.body),
                    )
936130
def _build_pcollection(self, pipeline, filepaths, language):
    """"""

    beam = tfds.core.lazy_imports.apache_beam

    def _extract_content(filepath):
      """Extracts article content from a single WikiMedia XML file."""
      logging.info("generating examples from = %s", filepath)
      with tf.io.gfile.GFile(filepath) as f:
        for _, elem in etree.iterparse(f, events=("end",)):
          if not elem.tag.endswith("page"):
            continue
          namespace = elem.tag[:-4]
          title = elem.find("./{0}title".format(namespace)).text
          ns = elem.find("./{0}ns".format(namespace)).text

          # Filter pages that are not in the "main" namespace.
          if ns != "0":
            continue

          raw_content = elem.find(
              "./{0}revision/{0}text".format(namespace)).text
          elem.clear()

          # Filter redirects.
          if raw_content is None or raw_content.lower().startswith("#redirect"):
            beam.metrics.Metrics.counter(language, "filtered-redirects").inc()
            continue

          beam.metrics.Metrics.counter(language, "extracted-examples").inc()
          yield (title, raw_content)

    def _clean_content(inputs):
      """Cleans raw wikicode to extract text."""
      title, raw_content = inputs
      try:
        text = _parse_and_clean_wikicode(raw_content)
      except (
          tfds.core.lazy_imports.mwparserfromhell.parser.ParserError) as e:
        beam.metrics.Metrics.counter(language, "parser-error").inc()
        logging.error("mwparserfromhell ParseError: %s", e)
        return

      beam.metrics.Metrics.counter(language, "cleaned-examples").inc()

      yield {
          "title": title,
          "text": text
      }

    return (
        pipeline
        | beam.Create(filepaths)
        | beam.FlatMap(_extract_content)
        | beam.FlatMap(_clean_content)
    )
637142
def _to_meta_data(pif_obj, dataset_hit, mdf_acl):
    """"""
    pif = pif_obj.as_dictionary()
    dataset = dataset_hit.as_dictionary()
    mdf = {}
    try:
        if pif.get("names"):
            mdf["title"] = pif["names"][0]
        else:
            mdf["title"] = "Citrine PIF " + str(pif["uid"])

        if pif.get("chemicalFormula"):
            mdf["composition"] = pif["chemicalFormula"]
        elif pif.get("composition"):
            mdf["composition"] = ''.join([comp["element"] for comp in pif["composition"] if comp["element"]])
        if not mdf["composition"]:
            mdf.pop("composition")

        mdf["acl"] = mdf_acl
        mdf["source_name"] = _construct_new_key(dataset["name"])

        if pif.get("contacts"):
            mdf["data_contact"] = []
            for contact in pif["contacts"]:
                data_c = {
                    "given_name": contact["name"]["given"],  #REQ
                    "family_name": contact["name"]["family"]  #REQ
                    }
                if contact.get("email"):
                    data_c["email"] = contact.get("email", "")
                if contact.get("orcid"):
                    data_c["orcid"] = contact.get("orcid", "")
                mdf["data_contact"].append(data_c)
            if not mdf["data_contact"]:
                mdf.pop("data_contact")
        
        mdf["data_contributor"] = [{}] 
        if "owner" in dataset:
            name = dataset["owner"].split()
            contributor = {
                "given_name": name[0],
                "family_name": name[1],
                "email": dataset["email"]
            }
            mdf["data_contributor"] = [contributor]

        mdf["links"] = {
            "landing_page": "https://citrination.com/datasets/{}".format(dataset["id"]),
            "publication": []
            }
        if pif.get("references"):
            mdf["author"] = []
            mdf["citation"] = []
            for ref in pif["references"]:
                if ref.get("doi"):
                    mdf["citation"].append(ref["doi"]) #TODO: Make actual citation
                    mdf["links"]["publication"].append(ref["doi"])
                if ref.get("authors"):
                    for author in ref["authors"]:
                        if author.get("given") and author.get("family"):
                            mdf["author"].append({
                                "given_name": author["given"],
                                "family_name": author["family"]
                                })
            # Remove fields if blank
            if not mdf["author"]:
                mdf.pop("author")
            if not mdf["citation"]:
                mdf.pop("citation")
        if not mdf["links"]["publication"]:
            mdf["links"].pop("publication")

        if pif.get("licenses", [{}])[0].get("url"):
            mdf["license"] = pif["licenses"][0]["url"]
        if pif.get("tags"):
            mdf["tags"] = pif["tags"]

    # If required MDF metadata is missing from PIF, abort
    except KeyError as e:
        print("Error: Required MDF metadata", str(e), "not found in PIF", pif["uid"])
        return None

    return mdf
964624
def map_data(self, map_name):
    """"""
    with gfile.Open(os.path.join(self.data_dir, "Maps", map_name), "rb") as f:
      return f.read()
1138710
def load(self, arguments):
        ""
        features = arguments[1:-1]
        list(map(self.load_feature, features))
1257830
def topic_metadata(topic_names)
      ensure_connected
      req = MetadataRequest.new( request_common(:metadata),
                                 topic_names)
      send_request(req)
      read_response(MetadataResponse)
    end
912065
def merge_offsets_metadata(topics, *offsets_responses):
    
    result = dict()
    for topic in topics:
        partition_offsets = [
            response[topic]
            for response in offsets_responses
            if topic in response
        ]
        result[topic] = merge_partition_offsets(*partition_offsets)
    return result
1004550
def metadata(self):
        """"""
        output = dict(self.defaults)
        output.update(self.extra_metadata)
        return output
1358329
protected function loadMetadatas()
    {
        try {
            $this->metadatas = array();
            $em = $this->getEntityManager();
            $cmf = $em->getMetadataFactory();
            foreach ($cmf->getAllMetadata() as $metaData) {
                $this->metadatas[$metaData->getName()] = $metaData;
            }
        } catch (MappingException $e) {
            // we don't want them complaining about a src directory not being in the package.
        }
    }