Get Layer with matching catalog and uuid
352852
def layer_mapproxy(request, catalog_slug, layer_uuid, path_info):
    
    layer = get_object_or_404(Layer,
                              uuid=layer_uuid,
                              catalog__slug=catalog_slug)

    # for WorldMap layers we need to use the url of the layer
    if layer.service.type == 'Hypermap:WorldMap':
        layer.service.url = layer.url

    # Set up a mapproxy app for this particular layer
    mp, yaml_config = get_mapproxy(layer)

    query = request.META['QUERY_STRING']

    if len(query) > 0:
        path_info = path_info + '?' + query

    params = {}
    headers = {
            'X-Script-Name': '/registry/{0}/layer/{1}/map/'.format(catalog_slug, layer.id),
            'X-Forwarded-Host': request.META['HTTP_HOST'],
            'HTTP_HOST': request.META['HTTP_HOST'],
            'SERVER_NAME': request.META['SERVER_NAME'],
            }

    if path_info == '/config':
        response = HttpResponse(yaml_config, content_type='text/plain')
        return response

    # Get a response from MapProxy as if it was running standalone.
    mp_response = mp.get(path_info, params, headers)

    # Create a Django response from the MapProxy WSGI response.
    response = HttpResponse(mp_response.body, status=mp_response.status_int)
    for header, value in mp_response.headers.iteritems():
        response[header] = value

    return response
596050
def getlayer(self, cls, nb=1, _track=None, _subclass=None, **flt):
        
        if _subclass is None:
            _subclass = self.match_subclass or None
        if _subclass:
            match = lambda cls1, cls2: issubclass(cls1, cls2)
        else:
            match = lambda cls1, cls2: cls1 == cls2
        if isinstance(cls, int):
            nb = cls + 1
            cls = None
        if isinstance(cls, str) and "." in cls:
            ccls, fld = cls.split(".", 1)
        else:
            ccls, fld = cls, None
        if cls is None or match(self.__class__, cls) \
           or ccls in [self.__class__.__name__, self._name]:
            if all(self.getfieldval(fldname) == fldvalue
                   for fldname, fldvalue in six.iteritems(flt)):
                if nb == 1:
                    if fld is None:
                        return self
                    else:
                        return self.getfieldval(fld)
                else:
                    nb -= 1
        for f in self.packetfields:
            fvalue_gen = self.getfieldval(f.name)
            if fvalue_gen is None:
                continue
            if not f.islist:
                fvalue_gen = SetGen(fvalue_gen, _iterpacket=0)
            for fvalue in fvalue_gen:
                if isinstance(fvalue, Packet):
                    track = []
                    ret = fvalue.getlayer(cls, nb=nb, _track=track,
                                          _subclass=_subclass, **flt)
                    if ret is not None:
                        return ret
                    nb = track[0]
        return self.payload.getlayer(cls, nb=nb, _track=_track,
                                     _subclass=_subclass, **flt)
572207
def find_object(self, key, layers):
        ''''''
        state = self.state

        if layers is None or layers == '':
            layers = state.layers.keys()
        for layer in layers:
            if key in state.layers[layer]:
                return state.layers[layer][key]
        return None
1089986
public Entry getEntryByUUID(final UUID UUID) {
        List<Entry> allEntries = getEntries();

        List<Entry> entries = ListFilter.filter(allEntries, new Filter<Entry>() {

            @Override
            public boolean matches(Entry item) {

                if (item.getUuid() != null && item.getUuid().compareTo(UUID) == 0) {
                    return true;
                } else {
                    return false;
                }
            }
        });

        if (entries.size() == 1) {
            return entries.get(0);
        } else {
            return null;
        }
    }
956741
def get_catalog_by_name(name):
    
    kwargs = {
            'name' : name,
        }
    result = util.callm("%s/%s" % ('catalog', 'profile'), kwargs)
    return Catalog(**util.fix(result['response']['catalog']))
1273524
def getLayer(self, name):
        
        name = normalizers.normalizeLayerName(name)
        return self._getLayer(name)
265567
def _get_item_class(self, url):
        
        if '/layers/' in url:
            return Layer
        elif '/tables/' in url:
            return Table
        elif '/sets/' in url:
            return Set
        # elif '/documents/' in url:
        #     return Document
        else:
            raise NotImplementedError("No support for catalog results of type %s" % url)
1331232
def get_field(catalog, identifier=None, title=None,
              distribution_identifier=None):
    """"""

    msg = "Se requiere un 'id' o 'title' para buscar el field."
    assert identifier or title, msg

    # 1. BUSCA los fields en el catálogo
    # búsqueda optimizada por identificador
    if identifier:
        try:
            return _get_field_by_identifier(catalog, identifier)
        except BaseException:
            try:
                catalog._build_index()
                return _get_field_by_identifier(catalog, identifier)
            except BaseException:
                filtered_fields = get_fields(
                    catalog, {"field": {"id": identifier}})
    elif title and distribution_identifier:
        filtered_fields = get_fields(
            catalog, {
                "distribution": {"identifier": distribution_identifier},
                "field": {"title": title}
            }
        )
    elif title:
        filtered_fields = get_fields(
            catalog, {"field": {"title": title}})

    # 2. CHEQUEA que la cantidad de fields es consistente
    if len(filtered_fields) > 1:
        if identifier:
            raise ce.FieldIdRepetitionError(
                identifier, filtered_fields)
        elif title and distribution_identifier:
            # el título de un field no puede repetirse en una distribution
            raise ce.FieldTitleRepetitionError(
                title, filtered_fields)
        elif title:
            # el título de un field puede repetirse
            return filtered_fields
    elif len(filtered_fields) == 0:
        return None
    else:
        return filtered_fields[0]
839866
def list(self, wg_uuid, parent=None, flat=False, node_types=None):
        
        url = "%(base)s/%(wg_uuid)s/nodes" % {
            'base': self.local_base_url,
            'wg_uuid': wg_uuid
        }
        param = []
        if parent:
            # I use only the last folder uuid, the first ones are not really useful
            if isinstance(parent, (list,)):
                if len(parent) >= 1:
                    parent = parent[-1]
            param.append(("parent", parent))
        if flat:
            param.append(("flat", True))
        if node_types:
            for node_type in node_types:
                param.append(("type", node_type))
        encode = urllib.urlencode(param)
        if encode:
            url += "?"
            url += encode
        return self.core.list(url)
492550
def get_image_layer(self, image_id):
        """"""
        return self._http_call(self.IMAGE_JSON, get, image_id=image_id)
299081
def get_tags(ctx, archive_name):
    '''
    
    '''

    _generate_api(ctx)

    var = ctx.obj.api.get_archive(archive_name)

    click.echo(' '.join(var.get_tags()), nl=False)
    print('')
820550
def get(self, wg_uuid, uuid, tree=False):
        
        url = "%(base)s/%(wg_uuid)s/nodes/%(uuid)s" % {
            'base': self.local_base_url,
            'wg_uuid': wg_uuid,
            'uuid': uuid
        }
        param = {}
        if tree:
            param['tree'] = True
        encode = urllib.urlencode(param)
        if encode:
            url += "?"
            url += encode
        return self.core.get(url)
184302
def _get_lsun(directory, category, split_name):
  """"""
  generator_utils.maybe_download(directory,
                                 _LSUN_DATA_FILENAME % (category, split_name),
                                 _LSUN_URL % (category, split_name))
53937
def get_hierarchies_by_ids(self, *args, **kwargs):
        """"""
        # Implemented from kitosid template for -
        # osid.resource.BinLookupSession.get_bins_by_ids
        catalogs = self._get_provider_session('hierarchy_lookup_session').get_hierarchies_by_ids(*args, **kwargs)
        cat_list = []
        for cat in catalogs:
            cat_list.append(Hierarchy(self._provider_manager, cat, self._runtime, self._proxy))
        return HierarchyList(cat_list)
846192
def find_uuid(es_url, index):
    

    uid_field = None

    # Get the first item to detect the data source and raw/enriched type
    res = requests.get('%s/%s/_search?size=1' % (es_url, index))
    first_item = res.json()['hits']['hits'][0]['_source']
    fields = first_item.keys()

    if 'uuid' in fields:
        uid_field = 'uuid'
    else:
        # Non perceval backend
        uuid_value = res.json()['hits']['hits'][0]['_id']
        logging.debug("Finding unique id for %s with value %s", index, uuid_value)
        for field in fields:
            if first_item[field] == uuid_value:
                logging.debug("Found unique id for %s: %s", index, field)
                uid_field = field
                break

    if not uid_field:
        logging.error("Can not find uid field for %s. Can not copy the index.", index)
        logging.error("Try to copy it directly with elasticdump or similar.")
        sys.exit(1)

    return uid_field
1062884
def getExperiments(uuid: str):
    
    return jsonify([x.deserialize() for x in Experiment.query.all()])
497640
def from_uuid(self, uuid, session=None):
        '''
'''
        elems = uuid.split('.')
        if len(elems) == 2:
            model = get_model_from_hash(elems[0])
            if not model:
                raise Model.DoesNotExist(
                    'model id "{0}" not available'.format(elems[0]))
            if not session or session.router is not self:
                session = self.session()
            return session.query(model).get(id=elems[1])
        raise Model.DoesNotExist('uuid "{0}" not recognized'.format(uuid))