Attempt to convert any object into a UrlPath.

        Raise a value error if this is not possible.
324988
def from_object(cls, obj):
        # type: (Any) -> UrlPath
        
        if isinstance(obj, UrlPath):
            return obj
        if isinstance(obj, _compat.string_types):
            return UrlPath.parse(obj)
        if isinstance(obj, PathParam):
            return UrlPath(obj)
        if isinstance(obj, (tuple, list)):
            return UrlPath(*obj)
        raise ValueError("Unable to convert object to UrlPath `%r`" % obj)
653972
def path(string):
        
        if not os.path.exists(string):
            msg = "Path %s not found!" % string
            raise ArgumentTypeError(msg)
        return string
305521
def parse_url(url):
    
    split_url = url.split('/', 3)
    if len(split_url) == 3:
        # http://foo.com
        path = '/'
    elif len(split_url) == 4:
        path = '/' + split_url[3]
    else:
        raise ValueError('Invalid URL: %s' % url)

    try:
        parse_result = urlparse(url)
    except Exception:
        raise ValueError('Invalid URL: %s' % url)

    protocol = parse_result.scheme
    protocol = protocol.lower()
    if protocol not in ('http', 'https'):
        raise ValueError('Invalid URL protocol "%s"' % protocol)

    split_netloc = parse_result.netloc.split(':')
    domain = split_netloc[0]
    domain = domain.lower()

    if len(split_netloc) == 2:
        try:
            port = int(split_netloc[1])
        except:
            raise ValueError('Invalid port: "%s"' % split_netloc[1])
    elif protocol == 'https':
        port = 443
    elif protocol == 'http':
        port = 80
    else:
        raise ValueError('Invalid scheme: "%s"' % protocol)

    return protocol, domain, port, path
140638
def to_internal_value(self, data):
        
        if not data:
            return None
        request = self._get_request()
        user = request.user
        try:
            obj = core_utils.instance_from_url(data, user=user)
            model = obj.__class__
        except ValueError:
            raise serializers.ValidationError(_('URL is invalid: %s.') % data)
        except (Resolver404, AttributeError, MultipleObjectsReturned, ObjectDoesNotExist):
            raise serializers.ValidationError(_("Can't restore object from url: %s") % data)
        if model not in self.related_models:
            raise serializers.ValidationError(_('%s object does not support such relationship.') % six.text_type(obj))
        return obj
491004
def path_to_url(self, path):
        
        if path not in self.schemas:
            return None
        return self.url_map.bind(
            self.app.config['JSONSCHEMAS_HOST'],
            url_scheme=self.app.config['JSONSCHEMAS_URL_SCHEME']
        ).build(
            'schema', values={'path': path}, force_external=True)
123572
def parts_to_url(parts=None, scheme=None, netloc=None, path=None, query=None, fragment=None):
    

    if isinstance(parts, _urllib_parse.SplitResult):
        scheme, netloc, path, query, fragment = parts
    elif parts and isinstance(parts, dict):
        scheme = parts.get('scheme', 'http')
        netloc = parts.get('netloc', '')
        path = parts.get('path', [])
        query = parts.get('query', {})
        fragment = parts.get('fragment', '')

    if isinstance(path, (list, tuple)):
        path = '/' + '/'.join(path).strip('/')
    if isinstance(query, (dict, tuple)):
        query = _unquote(_urlencode(query, doseq=True))

    return _urlunsplit((scheme, netloc, path, query, fragment)) or None
460189
def _parse_url(url=None):
    """"""
    if url is None:
        return ('', '')

    scheme, netloc, path, _, _ = parse.urlsplit(url)

    if scheme != 's3':
        raise InvalidURL(url, "URL scheme must be s3://")

    if path and not netloc:
        raise InvalidURL(url)

    return netloc, path[1:]
404752
def to_path_value(self, obj):
        
        if type(obj) == list:
            return ','.join(obj)
        else:
            return str(obj)
618373
def _read(obj):
    
    if _is_url(obj):
        with urlopen(obj) as url:
            text = url.read()
    elif hasattr(obj, 'read'):
        text = obj.read()
    elif isinstance(obj, (str, bytes)):
        text = obj
        try:
            if os.path.isfile(text):
                with open(text, 'rb') as f:
                    return f.read()
        except (TypeError, ValueError):
            pass
    else:
        raise TypeError("Cannot read object of type %r" % type(obj).__name__)
    return text
296329
def url_object(code)
      @code_bucket.get(code, :r => 1)
    rescue Riak::FailedRequest => err
      raise unless err.not_found?
    end
285548
def _parse_url(path):
    """"""

    # path changes from bytes to Unicode in going from Python 2 to
    # Python 3.
    if sys.version_info[0] < 3:
        o = urlparse(urllib.parse.unquote_plus(path).decode('utf8'))
    else:
        o = urlparse(urllib.parse.unquote_plus(path))

    path = o.path
    args = {}

    # Convert parse_qs' str --> [str] dictionary to a str --> str
    # dictionary since we never use multi-value GET arguments
    # anyway.
    multiargs = parse_qs(o.query, keep_blank_values=True)
    for arg, value in list(multiargs.items()):
        args[arg] = value[0]

    return path, args
292678
def path(self, value=None):
        
        if value is not None:
            if not value.startswith('/'):
                value = '/' + value
            encoded_value = unicode_quote(value)
            return URL._mutate(self, path=encoded_value)
        return self._tuple.path
652653
def object_url(self, object_t, object_id=None, relation=None, **kwargs):
        
        if object_t not in self.objects_types:
            raise TypeError("{} is not a valid type".format(object_t))
        request_items = (
            str(item) for item in [object_t, object_id, relation] if item is not None
        )
        request = "/".join(request_items)
        base_url = self.url(request)
        if self.access_token is not None:
            kwargs["access_token"] = str(self.access_token)
        if kwargs:
            for key, value in kwargs.items():
                if not isinstance(value, str):
                    kwargs[key] = str(value)
            # kwargs are sorted (for consistent tests between Python < 3.7 and >= 3.7)
            sorted_kwargs = SortedDict.from_dict(kwargs)
            result = "{}?{}".format(base_url, urlencode(sorted_kwargs))
        else:
            result = base_url
        return result
568296
function searchToObject(urlSearch) {
	  //var urlSearch= window.location.search;
	  var pairs = urlSearch.substring(1).split("&"),
	    obj = {},
	    pair,
	    i;

	  for ( i in pairs ) {
	    if ( pairs[i] === "" ) continue;

	    pair = pairs[i].split("=");
	    obj[ decodeURIComponent( pair[0] ) ] = decodeURIComponent( pair[1] );
	  }

	  return obj;
	}
568176
def code_object(url)
      sha = url_key url
      if o = @url_bucket.get(sha, :r => 1)
        fix_url_object(o)
      end
    rescue Riak::FailedRequest => err
      raise unless err.not_found?
    end
708210
def urlparse(uri):
    """"""
    scheme, netloc, path, params, query, fragment = parse.urlparse(uri)
    return (
        parse.unquote(scheme),
        parse.unquote(netloc),
        parse.unquote(path),
        parse.unquote(params),
        parse.unquote(query),
        parse.unquote(fragment)
    )
1011004
def serialize_uri(value):
    
    if isinstance(value, BNode):
        return value.n3()
    if isinstance(value, URIRef):
        return unicode(value)
    raise ValueError("Cannot get prepvalue for {0} of type {1}".format(value, value.__class__))