Reads the es_defs and returns a dict of special kwargs to use when
    query for data of an instance of a class

    reference: rdfframework.sparl.queries.sparqlAllItemDataTemplate.rq
763071
def get_query_kwargs(es_defs):
    
    rtn_dict = {}
    if es_defs:
        if es_defs.get("kds_esSpecialUnion"):
            rtn_dict['special_union'] = \
                    es_defs["kds_esSpecialUnion"][0]
        if es_defs.get("kds_esQueryFilter"):
            rtn_dict['filters'] = \
                    es_defs["kds_esQueryFilter"][0]
    return rtn_dict
536736
def _get_rdfclass(self, class_type, **kwargs):
        
        def select_class(class_name):
            """ finds the class in the rdfclass Module"""
            try:
                return getattr(MODULE.rdfclass, class_name.pyuri)
            except AttributeError:
                return RdfClassBase

        if kwargs.get("def_load"):
            return RdfClassBase

        if isinstance(class_type[self.omap], list):
            bases = [select_class(class_name)
                     for class_name in class_type[self.omap]]
            bases = [base for base in bases if base != RdfClassBase]
            if len(bases) == 0:
                return RdfClassBase
            elif len(bases) == 1:
                return bases[0]
            else:
                bases = remove_parents(bases)
                if len(bases) == 1:
                    return bases[0]
                else:
                    name = "_".join(sorted(class_type[self.omap]))
                    # if the the class has already been created return it
                    if hasattr(MODULE.rdfclass, name):
                        return getattr(MODULE.rdfclass, name)
                    new_class = type(name,
                                     tuple(bases),
                                     {})
                    new_class.hierarchy = list_hierarchy(class_type[self.omap][0],
                                                         bases)
                    new_class.class_names = sorted([base.__name__ \
                            for base in bases \
                            if base not in [RdfClassBase, dict]])
                    setattr(MODULE.rdfclass, name, new_class)
                    return new_class
        else:
            return select_class(class_type[self.omap])
439230
function getAPIDescriptionElems(){
	var resp = $('.documentation__routes');
	var namespaces = _.map(resp.children(), function(sectionChild){
		var namespace = {
			name: sectionChild.attribs.id.replace(/\s/, ''),
		};
		var methodDescWrapElems = _.map(sectionChild.children, function(child, i){
			if(child.attribs && child.attribs.class && utils.hasClass('toc-el', child.attribs.class)){
				return child; 	
			}
		});
		namespace.el = _.compact(methodDescWrapElems);
		return namespace;
	});
	return namespaces;
}
122270
def get_dbcollection_with_es(self, **kwargs):
        
        es_objects = self.get_collection_es()
        db_objects = self.Model.filter_objects(es_objects)
        return db_objects
390830
def getQueryEngineDescription(self, queryEngine, **kwargs):
        
        response = self.getQueryEngineDescriptionResponse(queryEngine, **kwargs)
        return self._read_dataone_type_response(response, 'QueryEngineDescription')
165753
def json_qry(dataset, qry_str, params={}):
    
    # if qry_str.startswith("$.bf_itemOf[rdf_type=bf_Print].='print',\n"):
    #     pdb.set_trace()
    if not '$' in qry_str:
        qry_str = ".".join(['$', qry_str.strip()])
    dallor_val = params.get("$", dataset)
    if isinstance(dallor_val, rdflib.URIRef):
        dallor_val = Uri(dallor_val)
    if qry_str.strip() == '$':
        return [dallor_val]
    parsed_qry = parse_json_qry(qry_str)
    qry_parts = parsed_qry['qry_parts']
    post_actions = parsed_qry['params']
    # print(qry_parts)
    rtn_list = UniqueList()
    if params.get('dataset'):
        dataset = params['dataset']
    for or_part in qry_parts:
        if or_part[1] == 0:
            if isinstance(dallor_val, dict):
                result = dallor_val
            else:
                try:
                    result = dataset[dallor_val]
                except KeyError:
                    try:
                        result = dataset[Uri(dallor_val)]
                    except KeyError:
                        try:
                            result = dataset[BlankNode(dallor_val)]
                        except KeyError:
                            continue

            forward = True
            for part in or_part[0][1:]:
                if part == "*":
                    forward = not forward
                else:
                    if forward:
                        result = get_json_qry_item(result, part)
                    else:
                        result = get_reverse_json_qry_item(result,
                                                           part,
                                                           False)
        else:
            result = dataset
            parts = or_part[0].copy()
            parts.reverse()
            forward = False
            for part in parts[1:]:
                if part == "*":
                    forward = not forward
                else:
                    if forward:
                        result = get_json_qry_item(result, part)
                    else:
                        result = get_reverse_json_qry_item(result,
                                                           part,
                                                           False,
                                                           dallor_val)
        rtn_list += result
    for action in post_actions:
        rtn_list = action(rtn_list)
    return rtn_list
545138
def read_instance(self, cls, sdmxobj, offset=None, first_only=True):
        '''
          
        '''
        if offset:
            try:
                base = self._paths[offset](sdmxobj._elem)[0]
            except IndexError:
                return None
        else:
            base = sdmxobj._elem
        result = self._paths[cls](base)
        if result:
            if first_only:
                return cls(self, result[0])
            else:
                return [cls(self, i) for i in result]
1220556
def get_response_example(self, resp_spec):
        
        if 'schema' in resp_spec.keys():
            if '$ref' in resp_spec['schema']:  # Standard definition
                definition_name = self.get_definition_name_from_ref(resp_spec['schema']['$ref'])
                return self.definitions_example[definition_name]
            elif 'items' in resp_spec['schema'] and resp_spec['schema']['type'] == 'array':  # Array
                if '$ref' in resp_spec['schema']['items']:
                    definition_name = self.get_definition_name_from_ref(resp_spec['schema']['items']['$ref'])
                else:
                    if 'type' in resp_spec['schema']['items']:
                        definition_name = self.get_definition_name_from_ref(resp_spec['schema']['items'])
                        return [definition_name]
                    else:
                        logging.warn("No item type in: " + resp_spec['schema'])
                        return ''
                return [self.definitions_example[definition_name]]
            elif 'type' in resp_spec['schema']:
                return self.get_example_from_prop_spec(resp_spec['schema'])
        else:
            return ''
1338010
def getquerylist(self, sep='&', encoding='utf-8', errors='strict'):
        
        if not self.query:
            return []
        elif isinstance(sep, type(self.query)):
            qsl = self.query.split(sep)
        elif isinstance(sep, bytes):
            qsl = self.query.split(sep.decode('ascii'))
        else:
            qsl = self.query.split(sep.encode('ascii'))
        items = []
        for parts in [qs.partition(self.EQ) for qs in qsl if qs]:
            name = uridecode(parts[0], encoding, errors)
            if parts[1]:
                value = uridecode(parts[2], encoding, errors)
            else:
                value = None
            items.append((name, value))
        return items
976898
def iter_qs(qs, adapter):
    ''''''
    for obj in qs.no_cache().no_dereference().timeout(False):
        if adapter.is_indexable(obj):
            try:
                doc = adapter.from_model(obj).to_dict(include_meta=True)
                yield doc
            except Exception as e:
                model = adapter.model.__name__
                log.error('Unable to index %s "%s": %s', model, str(obj.id),
                          str(e), exc_info=True)
137076
def _refs(obj, named, *ats, **kwds):
    '''
    '''
    if named:
        for a in ats:  # cf. inspect.getmembers()
            if hasattr(obj, a):
                yield _NamedRef(a, getattr(obj, a))
        if kwds:  # kwds are _dir2() args
            for a, o in _dir2(obj, **kwds):
                yield _NamedRef(a, o)
    else:
        for a in ats:  # cf. inspect.getmembers()
            if hasattr(obj, a):
                yield getattr(obj, a)
        if kwds:  # kwds are _dir2() args
            for _, o in _dir2(obj, **kwds):
                yield o
597282
def __deserialize_model(self, data, klass):
        
        if not klass.swagger_types:
            return data

        kwargs = {}
        for attr, attr_type in iteritems(klass.swagger_types):
            if data is not None \
               and klass.attribute_map[attr] in data \
               and isinstance(data, (list, dict)):
                value = data[klass.attribute_map[attr]]
                kwargs[attr] = self.__deserialize(value, attr_type)

        instance = klass(**kwargs)     

        return instance
824904
def parse_object_ref(ref)
      prefix = ref[1]
      ref = ref[0]
      # Let's make sure the value isn't nil. If it is, return the default Hash.
      return {} if ref.nil?
      class_name =
        if ref.respond_to?(:haml_object_ref)
          ref.haml_object_ref
        else
          underscore(ref.class)
        end
      ref_id =
        if ref.respond_to?(:to_key)
          key = ref.to_key
          key.join('_') unless key.nil?
        else
          ref.id
        end
      id = "#{class_name}_#{ref_id || 'new'}"
      if prefix
        class_name = "#{ prefix }_#{ class_name}"
        id = "#{ prefix }_#{ id }"
      end

      { 'id'.freeze => id, 'class'.freeze => class_name }
    end
857244
def refine(query, description):
    

    for attribute, arguments in description.items():
        if hasattr(query, attribute):
            attribute = getattr(query, attribute)
        else:
            raise ValueError("Unknown query method: " + attribute)

        # query descriptions are often automatically generated, and
        # may include empty calls, which we skip
        if utils.isempty(arguments):
            continue

        if callable(attribute):
            method = attribute
            if isinstance(arguments, dict):
                query = method(**arguments)
            elif isinstance(arguments, list):
                query = method(*arguments)
            else:
                query = method(arguments)
        else:
            setattr(attribute, arguments)

    return query
172556
def es_mapping(cls, base_class, **kwargs):
        

        es_map = {}
        ranges = cls.rdfs_range # pylint: disable=no-member
        rng_defs = get_prop_range_defs(cls.class_names, cls.kds_rangeDef)
        rng_def = get_prop_range_def(rng_defs)
        if rng_def.get("kds_esIndexClass"):
            ranges = rng_def['kds_esIndexClass'].copy()
        # pdb.set_trace()
        # if cls._prop_name == "bf_partOf":
        #     pdb.set_trace()
        idx_types = get_idx_types(rng_def, ranges)
        if 'es_Ignored' in idx_types:
            return {'type': 'text',
                    'index': es_idx_types['es_NotIndexed']}
        if 'es_Nested' in idx_types:
            if (kwargs.get('depth', 0) >= 1 and \
                    kwargs.get('class') == ranges[0]) or \
                    kwargs.get('depth', 0) > 2:
                return {"type" : "keyword"}
            nested_map = getattr(MODULE.rdfclass,
                                 ranges[0]).es_mapping(base_class,
                                                       'es_Nested',
                                                       **kwargs)
            es_map['properties'] = nested_map
            es_map['type'] = "nested"
        elif len(idx_types) > 1:
            fields = {}
            for idx in idx_types:
                fields.update(es_idx_types[idx])
            es_map['fields'] = fields
        elif len(idx_types) == 1:
            if cls._prop_name == 'rdf_type': # pylint: disable=no-member
                es_map['type'] = 'keyword'
            elif idx_types[0] == 'es_NotIndexed':
                es_map['index'] = False
            else:
                es_map['type'] = es_idx_types[idx_types[0]]
        try:
            if not es_map.get('type'):
                fld_type = BaseRdfDataType[ranges[0]].es_type
                es_map['type'] = fld_type
                if cls._prop_name == 'rdf_type':
                    es_map['type'] = 'keyword'
        except (KeyError, AttributeError):
            if cls._prop_name == 'rdf_type': # pylint: disable=no-member
                es_map['type'] = 'keyword'
            else:
                es_map['type'] = 'text'
        if es_map['type'] == "nested":
            del es_map['type']
        try:
            fld_format = BaseRdfDataType[ranges[0]].es_format
            es_map['format'] = fld_format
        except (KeyError, AttributeError):
            pass
        return es_map
16903
def _dict_refs(obj, named):
    '''
    '''
    if named:
        for k, v in _items(obj):
            s = str(k)
            yield _NamedRef('[K] ' + s, k)
            yield _NamedRef('[V] ' + s + ': ' + _repr(v), v)
    else:
        for k, v in _items(obj):
            yield k
            yield v
920511
def _aws_model_ref_from_swagger_ref(self, r):
        '''
        
        '''
        model_name = r.split('/')[-1]
        return 'https://apigateway.amazonaws.com/restapis/{0}/models/{1}'.format(self.restApiId, model_name)