Pulls only for code/ID from the iri

        I only add the str() conversion for the iri because rdflib objects need to be converted.
423917
def extract_fragment(self, iri: str) -> str:
        ''' 
        '''
        fragment = str(iri).rsplit('/')[-1].split(':', 1)[-1].split('#', 1)[-1].split('_', 1)[-1]
        return fragment
387992
def Decode(self, attribute, value):
    """"""
    required_type = self._attribute_types.get(attribute, "bytes")
    if required_type == "integer":
      return rdf_structs.SignedVarintReader(value, 0)[0]
    elif required_type == "unsigned_integer":
      return rdf_structs.VarintReader(value, 0)[0]
    elif required_type == "string":
      if isinstance(value, bytes):
        return value.decode("utf-8")
      else:
        return utils.SmartUnicode(value)
    else:
      return value
1096344
def get_code(self, value, exclude=()):
        
        key = (value, exclude)
        if key not in self:
            self[key] = self._get(value, exclude)
        return self[key]
69005
def clean_iri(uri_string):
    ''''''
    uri_string = str(uri_string).strip()
    if uri_string[:1] == "<" and uri_string[len(uri_string)-1:] == ">":
        uri_string = uri_string[1:len(uri_string)-1]
    return uri_string
721005
def _extract_id_from_batch_response(r, name='id'):
        """"""
        names = name + 's'
        if names in r:
            # soon-to-be deprecated batch reponse
            if 'errors' in r and r['errors']:
                raise GeneralException(r['errors'][0]['desc'])
            id = r[names][0]
        else:
            # new-style simplified api response
            id = r[name]
        return int(id)
1036512
def conv_json(self, uri_format="sparql_uri", add_ids=False):
        
        def convert_item(ivalue):
            """ converts an idividual value to a json value

            Args:
                ivalue: value of the item to convert

            Returns:
                JSON serializable value
            """
            nvalue = ivalue
            if isinstance(ivalue, BaseRdfDataType):
                if ivalue.type == 'uri':
                    if ivalue.startswith("pyuri") and uri_format == "pyuri":
                        nvalue = getattr(ivalue, "sparql")
                    else:
                        nvalue = getattr(ivalue, uri_format)
                else:
                    nvalue = ivalue.to_json
            elif isinstance(ivalue, RdfClassBase):
                if ivalue.subject.type == "uri":
                    nvalue = ivalue.conv_json(uri_format, add_ids)
                elif ivalue.subject.type == "bnode":
                    nvalue = ivalue.conv_json(uri_format, add_ids)
            elif isinstance(ivalue, list):
                nvalue = []
                for item in ivalue:
                    temp = convert_item(item)
                    nvalue.append(temp)
            return nvalue

        rtn_val = {key: convert_item(value) for key, value in self.items()}
        #pdb.set_trace()
        if add_ids:

            if self.subject.type == 'uri':
                rtn_val['uri'] = self.subject.sparql_uri
                rtn_val['id'] = sha1(rtn_val['uri'].encode()).hexdigest()
        #return {key: convert_item(value) for key, value in self.items()}
        return rtn_val
381189
def to_primitive(self, value, context=None):
        

        if context and context.get('rel_ids'):
            return value.rid
        else:
            return {'rtype': value.rtype, 'rid': value.rid}
961881
def primitive_datatype(self, t: URIRef) -> Optional[URIRef]:
        
        for sco in self._o.objects(t, RDFS.subClassOf):
            sco_type = self._o.value(sco, RDF.type)
            sco_prop = self._o.value(sco, OWL.onProperty)
            if sco_type == OWL.Restriction and sco_prop == FHIR.value:
                # The older versions of fhir.ttl (incorrectly) referenced the datatype directly
                restriction_type = self._o.value(sco, OWL.allValuesFrom)
                if not restriction_type:
                    restriction_dt_entry = self._o.value(sco, OWL.someValuesFrom)
                    restriction_type = self._o.value(restriction_dt_entry, OWL.onDatatype)
                return restriction_type
        return None
790914
function _objectToRDF(item) {
  var object = {};

  // convert value object to RDF
  if(_isValue(item)) {
    object.type = 'literal';
    var value = item['@value'];
    var datatype = item['@type'] || null;

    // convert to XSD datatypes as appropriate
    if(_isBoolean(value)) {
      object.value = value.toString();
      object.datatype = datatype || XSD_BOOLEAN;
    }
    else if(_isDouble(value) || datatype === XSD_DOUBLE) {
      // canonical double representation
      object.value = value.toExponential(15).replace(/(\d)0*e\+?/, '$1E');
      object.datatype = datatype || XSD_DOUBLE;
    }
    else if(_isNumber(value)) {
      object.value = value.toFixed(0);
      object.datatype = datatype || XSD_INTEGER;
    }
    else if('@language' in item) {
      object.value = value;
      object.datatype = datatype || RDF_LANGSTRING;
      object.language = item['@language'];
    }
    else {
      object.value = value;
      object.datatype = datatype || XSD_STRING;
    }
  }
  // convert string/node object to RDF
  else {
    var id = _isObject(item) ? item['@id'] : item;
    object.type = (id.indexOf('_:') === 0) ? 'blank node' : 'IRI';
    object.value = id;
  }

  return object;
}
1087187
def iri_to_uri(value, normalize=False):
    

    if not isinstance(value, str_cls):
        raise TypeError(unwrap(
            '''
            value must be a unicode string, not %s
            ''',
            type_name(value)
        ))

    scheme = None
    # Python 2.6 doesn't split properly is the URL doesn't start with http:// or https://
    if sys.version_info < (2, 7) and not value.startswith('http://') and not value.startswith('https://'):
        real_prefix = None
        prefix_match = re.match('^[^:]*://', value)
        if prefix_match:
            real_prefix = prefix_match.group(0)
            value = 'http://' + value[len(real_prefix):]
        parsed = urlsplit(value)
        if real_prefix:
            value = real_prefix + value[7:]
            scheme = _urlquote(real_prefix[:-3])
    else:
        parsed = urlsplit(value)

    if scheme is None:
        scheme = _urlquote(parsed.scheme)
    hostname = parsed.hostname
    if hostname is not None:
        hostname = hostname.encode('idna')
    # RFC 3986 allows userinfo to contain sub-delims
    username = _urlquote(parsed.username, safe='!$&\'()*+,;=')
    password = _urlquote(parsed.password, safe='!$&\'()*+,;=')
    port = parsed.port
    if port is not None:
        port = str_cls(port).encode('ascii')

    netloc = b''
    if username is not None:
        netloc += username
        if password:
            netloc += b':' + password
        netloc += b'@'
    if hostname is not None:
        netloc += hostname
    if port is not None:
        default_http = scheme == b'http' and port == b'80'
        default_https = scheme == b'https' and port == b'443'
        if not normalize or (not default_http and not default_https):
            netloc += b':' + port

    # RFC 3986 allows a path to contain sub-delims, plus "@" and ":"
    path = _urlquote(parsed.path, safe='/!$&\'()*+,;=@:')
    # RFC 3986 allows the query to contain sub-delims, plus "@", ":" , "/" and "?"
    query = _urlquote(parsed.query, safe='/?!$&\'()*+,;=@:')
    # RFC 3986 allows the fragment to contain sub-delims, plus "@", ":" , "/" and "?"
    fragment = _urlquote(parsed.fragment, safe='/?!$&\'()*+,;=@:')

    if normalize and query is None and fragment is None and path == b'/':
        path = None

    # Python 2.7 compat
    if path is None:
        path = ''

    output = urlunsplit((scheme, netloc, path, query, fragment))
    if isinstance(output, str_cls):
        output = output.encode('latin1')
    return output
1304402
def extract_name_value_type(self, name, value, limit_size=False):
        
        MAX_STRING_LEN_TO_RETURN = 487
        try:
            t_value = repr(value)
        except:
            t_value = "Error while extracting value"

        # convert all var names to string
        if isinstance(name, str):
            r_name = name
        else:
            r_name = repr(name)

        # truncate value to limit data flow between ikpdb and client
        if len(t_value) > MAX_STRING_LEN_TO_RETURN:
            r_value = "%s ... (truncated by ikpdb)" % (t_value[:MAX_STRING_LEN_TO_RETURN],) 
            r_name = "%s*" % r_name  # add a visual marker to truncated var's name
        else:
            r_value = t_value
            
        if isinstance(value, str):
            r_type = "%s [%s]" % (IKPdbRepr(value), len(value),)
        else:
            r_type = IKPdbRepr(value)
            
        return r_name, r_value, r_type
1178798
def scrubID(ID):
    

    try:
        if type(ID) == list:
            return int(ID[0])
        elif type(ID) == str:
            return int(ID)
        elif type(ID) == int:
            return ID
        elif type(ID) == unicode:
            return int(ID)

    except ValueError:
        return None
142305
def convert(obj, ids, attr_type, item_func, cdata, parent='root'):
    """"""
    
    LOG.info('Inside convert(). obj type is: "%s", obj="%s"' % (type(obj).__name__, unicode_me(obj)))
    
    item_name = item_func(parent)
    
    if isinstance(obj, numbers.Number) or type(obj) in (str, unicode):
        return convert_kv(item_name, obj, attr_type, cdata)
        
    if hasattr(obj, 'isoformat'):
        return convert_kv(item_name, obj.isoformat(), attr_type, cdata)
        
    if type(obj) == bool:
        return convert_bool(item_name, obj, attr_type, cdata)
        
    if obj is None:
        return convert_none(item_name, '', attr_type, cdata)
        
    if isinstance(obj, dict):
        return convert_dict(obj, ids, parent, attr_type, item_func, cdata)
        
    if isinstance(obj, collections.Iterable):
        return convert_list(obj, ids, parent, attr_type, item_func, cdata)
        
    raise TypeError('Unsupported data type: %s (%s)' % (obj, type(obj).__name__))
1215715
def _process_for_id(cls, response_raw):
        

        json = response_raw.body_bytes.decode()
        obj = converter.json_to_class(dict, json)
        id_ = converter.deserialize(
            Id,
            cls._unwrap_response_single(obj, cls._FIELD_ID)
        )

        return client.BunqResponse(id_.id_, response_raw.headers)
838301
def str2rsi(key):
    
    rlzi, sid, imt = key.split('/')
    return int(rlzi[4:]), int(sid[4:]), imt
82968
def predicate_to_IRI(self, predicate: ShExDocParser.PredicateContext) -> ShExJ.IRIREF:
        
        if predicate.iri():
            return self.iri_to_iriref(predicate.iri())
        else:
            return RDF_TYPE
1299989
def get_rdltype(value):
    

    if isinstance(value, (int, bool, str)):
        # Pass canonical types as-is
        return type(value)
    elif is_user_enum(type(value)):
        return type(value)
    elif is_user_struct(type(value)):
        return type(value)
    elif isinstance(value, enum.Enum):
        return type(value)
    elif isinstance(value, list):
        # Create ArrayPlaceholder representation
        # Determine element type and make sure it is uniform
        array_el_type = None
        for el in value:
            el_type = get_rdltype(el)
            if el_type is None:
                return None

            if (array_el_type is not None) and (el_type != array_el_type):
                return None
            array_el_type = el_type
        return ArrayPlaceholder(array_el_type)
    else:
        return None