当前位置: 首页>>代码示例>>Python>>正文


Python IBCCVLMetadata.get方法代码示例

本文整理汇总了Python中org.bccvl.site.interfaces.IBCCVLMetadata.get方法的典型用法代码示例。如果您正苦于以下问题:Python IBCCVLMetadata.get方法的具体用法?Python IBCCVLMetadata.get怎么用?Python IBCCVLMetadata.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bccvl.site.interfaces.IBCCVLMetadata的用法示例。


在下文中一共展示了IBCCVLMetadata.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: DatasetSearchableText

# 需要导入模块: from org.bccvl.site.interfaces import IBCCVLMetadata [as 别名]
# 或者: from org.bccvl.site.interfaces.IBCCVLMetadata import get [as 别名]
def DatasetSearchableText(obj, **kw):
    md = IBCCVLMetadata(obj)
    entries = [safe_unicode(obj.id), safe_unicode(obj.title) or u"", safe_unicode(obj.description) or u""]
    if "layers" in md:
        layer_vocab = getUtility(IVocabularyFactory, "layer_source")(obj)
        for key in md["layers"]:
            if key not in layer_vocab:
                continue
            entries.append(safe_unicode(layer_vocab.getTerm(key).title) or u"")
    if "species" in md:
        entries.extend(
            (
                safe_unicode(md.get("species", {}).get("scientificName")) or u"",
                safe_unicode(md.get("species", {}).get("vernacularName")) or u"",
            )
        )
    if md.get("genre") == "DataGenreFC":
        # year, gcm, emsc
        emsc_vocab = getUtility(IVocabularyFactory, "emsc_source")(obj)
        gcm_vocab = getUtility(IVocabularyFactory, "gcm_source")(obj)
        year = unicode(md.get("year", u""))
        month = unicode(md.get("month", u""))
        if md["emsc"] in emsc_vocab:
            entries.append(safe_unicode(emsc_vocab.getTerm(md["emsc"]).title) or u"")
        if md["gcm"] in gcm_vocab:
            entries.append(safe_unicode(gcm_vocab.getTerm(md["gcm"]).title) or u"")
        entries.append(year)
        entries.append(month)
    elif md.get("genre") == "DataGenreCC":
        entries.append(u"current")
    return u" ".join(entries)
开发者ID:BCCVL,项目名称:org.bccvl.site,代码行数:33,代码来源:indexers.py

示例2: biodiverse_listing_details

# 需要导入模块: from org.bccvl.site.interfaces import IBCCVLMetadata [as 别名]
# 或者: from org.bccvl.site.interfaces.IBCCVLMetadata import get [as 别名]
def biodiverse_listing_details(expbrain):
    details = {}
    exp = expbrain.getObject()
    species = set()
    years = set()
    emscs = set()
    gcms = set()
    for dsuuid in chain.from_iterable(map(lambda x: x.keys(), exp.projection.itervalues())):
        dsobj = uuidToObject(dsuuid)
        # TODO: should inform user about missing dataset
        if dsobj:
            md = IBCCVLMetadata(dsobj)
            species.add(md.get("species", {}).get("scientificName", ""))
            period = md.get("temporal")
            if period:
                years.add(Period(period).start)
            gcm = md.get("gcm")
            if gcm:
                gcms.add(gcm)
            emsc = md.get("emsc")
            if emsc:
                emscs.add(emsc)
    details.update(
        {
            "type": "BIODIVERSE",
            "functions": "endemism, redundancy",
            "species_occurrence": ", ".join(sorted(species)),
            "species_absence": "{}, {}".format(", ".join(sorted(emscs)), ", ".join(sorted(gcms))),
            "years": ", ".join(sorted(years)),
        }
    )
    return details
开发者ID:sarahrichmond,项目名称:org.bccvl.site,代码行数:34,代码来源:experiments_listing_view.py

示例3: rat

# 需要导入模块: from org.bccvl.site.interfaces import IBCCVLMetadata [as 别名]
# 或者: from org.bccvl.site.interfaces.IBCCVLMetadata import get [as 别名]
    def rat(self):
        uuid = self.request.form.get('uuid')
        layer = self.request.form.get('layer')
        brain = None
        try:
            brain = uuidToCatalogBrain(uuid)
        except Exception as e:
            LOG.error('Caught exception %s', e)

        if not brain:
            self.record_error('Not Found', 404,
                              'dataset not found',
                              {'parameter': 'uuid'})
            raise NotFound(self, 'metadata', self.request)
        md = IBCCVLMetadata(brain.getObject())
        if not layer and layer not in md.get('layers', {}):
            self.record_error('Bad Request', 400,
                              'Missing parameter layer',
                              {'parameter': 'layer'})
            raise BadRequest('Missing parameter layer')
        try:
            rat = md.get('layers', {}).get(layer, {}).get('rat')
            rat = json.loads(unicode(rat))
            return rat
        except Exception as e:
            LOG.warning(
                "Couldn't decode Raster Attribute Table from metadata. %s: %s",
                self.context, repr(e))
        raise NotFound(self, 'rat', self.request)
开发者ID:BCCVL,项目名称:org.bccvl.site,代码行数:31,代码来源:dm.py

示例4: details

# 需要导入模块: from org.bccvl.site.interfaces import IBCCVLMetadata [as 别名]
# 或者: from org.bccvl.site.interfaces.IBCCVLMetadata import get [as 别名]
 def details(self, context=None):
     # fetch details about dataset, if attributes are unpopulated
     # get data from associated collection
     if context is None:
         context = self.context
     coll = context
     while not (ISiteRoot.providedBy(coll) or ICollection.providedBy(coll)):
         coll = coll.__parent__
     # we have either hit siteroot or found a collection
     ret = {
         'title': context.title,
         'description': context.description or coll.description,
         'attribution': context.attribution or getattr(coll, 'attribution'),
         'rights': context.rights or coll.rights,
         'external_description': context.external_description or getattr(coll, 'external_description'),
     }
     md = IBCCVLMetadata(context)
     if 'layers' in md:
         layers = []
         for layer in sorted(md.get('layers', ())):
             try:
                 layers.append(self.layer_vocab.getTerm(layer))
             except:
                 layers.append(SimpleTerm(layer, layer, layer))
         if layers:
             ret['layers'] = layers
     return ret
开发者ID:BCCVL,项目名称:org.bccvl.site,代码行数:29,代码来源:dataset_tools.py

示例5: getdatasetparams

# 需要导入模块: from org.bccvl.site.interfaces import IBCCVLMetadata [as 别名]
# 或者: from org.bccvl.site.interfaces.IBCCVLMetadata import get [as 别名]
def getdatasetparams(uuid):
    # return dict with:
    #    filename
    #    downloadurl
    #    dm_accessurl-> maybe add url rewrite to datamover?
    #    # occurrence specific:
    #    species
    #    # raster specific:
    #    layers ... need to split this up
    dsobj = uuidToObject(uuid)
    if dsobj is None:
        return None
    dsinfo = getDatasetInfo(dsobj, uuid)
    # if we have species info add it

    dsmdr = IBCCVLMetadata(dsobj)
    species = dsmdr.get('species', {}).get('scientificName')
    if species:
        dsinfo['species'] = species
    # if we can get layermetadata, let's add it
    biomod = getdsmetadata(dsobj)
    layers = biomod.get('layers', [])

    if len(layers) > 0:
        for lk, lv in biomod['layers'].items():
            if lv is not None:
                dsinfo.setdefault('layers', {})[lk] = {
                    'filename': lv.get('filename', biomod['filename']),
                    'datatype': lv.get('datatype', None)}
    # return infoset
    return dsinfo
开发者ID:slowchoy,项目名称:org.bccvl.compute,代码行数:33,代码来源:utils.py

示例6: items

# 需要导入模块: from org.bccvl.site.interfaces import IBCCVLMetadata [as 别名]
# 或者: from org.bccvl.site.interfaces.IBCCVLMetadata import get [as 别名]
    def items(self):
        # return dict with keys for experiment
        # and subkey 'models' for models within experiment
        if self.value:
            for experiment_uuid, model_uuids in self.value.items():
                item = {}
                expbrain = uuidToCatalogBrain(experiment_uuid)
                item['title'] = expbrain.Title
                item['uuid'] = expbrain.UID

                # TODO: what else wolud I need from an experiment?
                exp = expbrain.getObject()
                expmd = IBCCVLMetadata(exp)
                item['resolution'] = expmd.get('resolution')
                item['brain'] = expbrain

                # now search all models within and add infos
                pc = getToolByName(self.context, 'portal_catalog')
                brains = pc.searchResults(path=expbrain.getPath(),
                                          BCCDataGenre=self.genre)
                # TODO: maybe as generator?
                item['datasets'] = [{'uuid': brain.UID,
                                     'title': brain.Title,
                                     'obj': brain.getObject(),
                                     'md': IBCCVLMetadata(brain.getObject()),
                                     'selected': brain.UID in self.value[experiment_uuid]}
                                                 for brain in brains]
                yield item
开发者ID:sarahrichmond,项目名称:org.bccvl.site,代码行数:30,代码来源:widgets.py

示例7: dataset_environmental_layer

# 需要导入模块: from org.bccvl.site.interfaces import IBCCVLMetadata [as 别名]
# 或者: from org.bccvl.site.interfaces.IBCCVLMetadata import get [as 别名]
def dataset_environmental_layer(obj, **kw):
    md = IBCCVLMetadata(obj)
    # if we have 'layers_used' index it
    if 'layers_used' in md:
        return md['layers_used']
    # otherwise index list of layers provided by dataset
    return md.get('layers', None)
开发者ID:BCCVL,项目名称:org.bccvl.site,代码行数:9,代码来源:indexers.py

示例8: year

# 需要导入模块: from org.bccvl.site.interfaces import IBCCVLMetadata [as 别名]
# 或者: from org.bccvl.site.interfaces.IBCCVLMetadata import get [as 别名]
def year(obj, **kw):
    # FIXME: this indexer is meant for future projection only ....
    # - make sure we don't index any other datasets. i.e. environmental and current datasets, which may have a date attached to it, but it is meaningless for future projections
    md = IBCCVLMetadata(obj)
    year = md.get('year', None)
    if year:
        year = str(year)
    return year
开发者ID:BCCVL,项目名称:org.bccvl.site,代码行数:10,代码来源:indexers.py

示例9: scientific_category

# 需要导入模块: from org.bccvl.site.interfaces import IBCCVLMetadata [as 别名]
# 或者: from org.bccvl.site.interfaces.IBCCVLMetadata import get [as 别名]
def scientific_category(obj, **kw):
    md = IBCCVLMetadata(obj)
    vocab = getUtility(IVocabularyFactory, 'scientific_category_source')(obj)
    path = set()
    for cat in md.get('categories', ()):
        path.update(vocab.getTermPath(cat))
    if path:
        return tuple(path)
    return None
开发者ID:BCCVL,项目名称:org.bccvl.site,代码行数:11,代码来源:indexers.py

示例10: items

# 需要导入模块: from org.bccvl.site.interfaces import IBCCVLMetadata [as 别名]
# 或者: from org.bccvl.site.interfaces.IBCCVLMetadata import get [as 别名]
    def items(self):
        # return dict with keys for experiment
        # and subkey 'models' for models within experiment
        if self.value:
            for experiment_uuid, model_uuids in self.value.items():
                item = {}
                expbrain = uuidToCatalogBrain(experiment_uuid)
                # TODO: we have an experiment_uuid, but can't access the
                #       experiment (deleted?, access denied?)
                #       shall we at least try to get some details?
                if expbrain is None:
                    continue
                item['title'] = expbrain.Title
                item['uuid'] = expbrain.UID
                item['brain'] = expbrain

                # TODO: what else wolud I need from an experiment?
                exp = expbrain.getObject()
                expmd = IBCCVLMetadata(exp)
                item['resolution'] = expmd.get('resolution')

                # now search all datasets within and add infos
                pc = getToolByName(self.context, 'portal_catalog')
                results = pc.searchResults(path=expbrain.getPath(),
                                           portal_type='Folder',
                                           job_state='COMPLETED')
                brains = pc.searchResults(path=[r.getPath() for r in results],
                                          BCCDataGenre=self.genre)
                # TODO: maybe as generator?
                item['subitems'] = []
                for brain in brains:
                    # FIXME: I need a different list of thresholds for display;
                    # esp. don't look up threshold, but take vales (threshold
                    # id and value) from field as is
                    thresholds = dataset.getThresholds(brain.UID)[brain.UID]
                    threshold = self.value[experiment_uuid].get(brain.UID)
                    # is threshold in list?
                    if threshold and threshold['label'] not in thresholds:
                        # maybe a custom entered number?
                        # ... I guess we don't really care as long as we produce the same the user entered. (validate?)
                        thresholds[threshold['label']] = threshold['label']
                    dsobj = brain.getObject()
                    dsmd = IBCCVLMetadata(dsobj)
                    item['subitems'].append({
                        'uuid': brain.UID,
                        'title': brain.Title,
                        'selected': brain.UID in self.value[experiment_uuid],
                        'threshold': threshold,
                        'thresholds': thresholds,
                        'brain': brain,
                        'md': dsmd,
                        'obj': dsobj,
                        # TODO: this correct? only one layer ever?
                        'layermd': dsmd['layers'].values()[0]
                    })
                yield item
开发者ID:BCCVL,项目名称:org.bccvl.site,代码行数:58,代码来源:widgets.py

示例11: getGenreSchemata

# 需要导入模块: from org.bccvl.site.interfaces import IBCCVLMetadata [as 别名]
# 或者: from org.bccvl.site.interfaces.IBCCVLMetadata import get [as 别名]
 def getGenreSchemata(self):
     schemata = []
     md = IBCCVLMetadata(self.context)
     genre = md.get('genre')
     if genre in self.genre_interface_map:
         schemata.append(self.genre_interface_map[genre])
     if IBlobDataset.providedBy(self.context):
         schemata.append(IBlobDataset)
     if IRemoteDataset.providedBy(self.context):
         schemata.append(IRemoteDataset)
     return schemata
开发者ID:sarahrichmond,项目名称:org.bccvl.site,代码行数:13,代码来源:dataset_base.py

示例12: subitems

# 需要导入模块: from org.bccvl.site.interfaces import IBCCVLMetadata [as 别名]
# 或者: from org.bccvl.site.interfaces.IBCCVLMetadata import get [as 别名]
 def subitems(self, dsbrain):
     # return a generator of selectable items within dataset
     md = IBCCVLMetadata(dsbrain.getObject())
     layer_vocab = self.dstools.layer_vocab
     selectedlayers = self.value.get(dsbrain.UID) or ()
     for layer in sorted(md.get('layers', ())):
         subitem = {
             'id': layer,
             'title': layer_vocab.getTerm(layer).title,
             'selected': layer in selectedlayers,
         }
         yield subitem
开发者ID:sarahrichmond,项目名称:org.bccvl.site,代码行数:14,代码来源:widgets.py

示例13: DatasetSearchableText

# 需要导入模块: from org.bccvl.site.interfaces import IBCCVLMetadata [as 别名]
# 或者: from org.bccvl.site.interfaces.IBCCVLMetadata import get [as 别名]
def DatasetSearchableText(obj, **kw):
    md = IBCCVLMetadata(obj)
    entries = [
        safe_unicode(obj.id),
        safe_unicode(obj.title) or u"",
        safe_unicode(obj.description) or u""
    ]
    if 'layers' in md:
        layer_vocab = getUtility(IVocabularyFactory, 'layer_source')(obj)
        for key in md['layers']:
            if key not in layer_vocab:
                continue
            entries.append(
                safe_unicode(layer_vocab.getTerm(key).title) or u""
            )
    if 'species' in md:
        entries.extend((
            safe_unicode(md.get('species', {}).get('scientificName')) or u"",
            safe_unicode(md.get('species', {}).get('vernacularName')) or u"",
        ))
    if md.get('genre') == "DataGenreFC":
        # year, gcm, emsc
        emsc_vocab = getUtility(IVocabularyFactory, 'emsc_source')(obj)
        gcm_vocab = getUtility(IVocabularyFactory, 'gcm_source')(obj)
        year = Period(md.get('period','')).start
        if md['emsc'] in emsc_vocab:
            entries.append(
                safe_unicode(emsc_vocab.getTerm(md['emsc']).title) or u""
            )
        if md['gcm'] in gcm_vocab:
            entries.append(
                safe_unicode(gcm_vocab.getTerm(md['gcm']).title) or u""
            )
        entries.append(safe_unicode(year) or u"")
    elif md.get('genre') == "DataGenreCC":
        entries.append(u"current")
    return u" ".join(entries)
开发者ID:sarahrichmond,项目名称:org.bccvl.site,代码行数:39,代码来源:indexers.py

示例14: subitems

# 需要导入模块: from org.bccvl.site.interfaces import IBCCVLMetadata [as 别名]
# 或者: from org.bccvl.site.interfaces.IBCCVLMetadata import get [as 别名]
 def subitems(self, dsbrain):
     # return a generator of selectable items within dataset
     md = IBCCVLMetadata(dsbrain.getObject())
     layer_vocab = self.dstools.layer_vocab
     selectedsubitems = self.value.get(dsbrain.UID) or ()
     if md.get('genre') != 'DataGenreSpeciesCollection':
         for layer in sorted(md.get('layers', ())):
             subitem = {
                 'id': layer,
                 'title': layer_vocab.getTerm(layer).title if layer in layer_vocab else layer,
                 'selected': layer in selectedsubitems,
             }
             yield subitem
     for subdsid in sorted(getattr(dsbrain.getObject(), 'parts', ())):
         part = uuidToCatalogBrain(subdsid)
         # TODO: should we just ignore it?
         if not part:
             continue
         subitem = {
             'id': subdsid,
             'title': part.Title,
             'selected': subdsid in selectedsubitems
         }
         yield subitem
开发者ID:BCCVL,项目名称:org.bccvl.site,代码行数:26,代码来源:widgets.py

示例15: getRAT

# 需要导入模块: from org.bccvl.site.interfaces import IBCCVLMetadata [as 别名]
# 或者: from org.bccvl.site.interfaces.IBCCVLMetadata import get [as 别名]
 def getRAT(self, datasetid, layer=None):
     query = {'UID': datasetid}
     dsbrain = dataset.query(self.context, brains=True, **query)
     if dsbrain:
         # get first brain from list
         dsbrain = next(dsbrain, None)
     if not dsbrain:
         raise NotFound(self.context, datasetid, self.request)
     md = IBCCVLMetadata(dsbrain.getObject())
     rat = md.get('layers', {}).get(layer, {}).get('rat')
     # if we have a rat, let's try and parse it
     if rat:
         try:
             rat = json.loads(unicode(rat))
         except Exception as e:
             LOG.warning("Couldn't decode Raster Attribute Table from metadata. %s: %s", self.context, repr(e))
             rat = None
     return rat
开发者ID:sarahrichmond,项目名称:org.bccvl.site,代码行数:20,代码来源:xmlrpc.py


注:本文中的org.bccvl.site.interfaces.IBCCVLMetadata.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。