How to use the urlpath._URLFlavour function in urlpath

To help you get started, we’ve selected a few urlpath examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chrono-meter / urlpath / urlpath.py View on Github external
scheme, netloc, path, query, fragment = urllib.parse.urlsplit(part)

        # trick to escape '/' in query and fragment and trailing
        if not re.match(re.escape(sep) + '+$', path):
            path = re.sub('%s+$' % (re.escape(sep),), lambda m: '\\x00' * len(m.group(0)), path)
        path = urllib.parse.urlunsplit(('', '', path, query.replace('/', '\\x00'), fragment.replace('/', '\\x00')))

        drive = urllib.parse.urlunsplit((scheme, netloc, '', '', ''))
        root, path = re.match('^(%s*)(.*)$' % (re.escape(sep),), path).groups()

        return drive, root, path


class URL(urllib.parse._NetlocResultMixinStr, PurePath):
    _flavour = _URLFlavour()
    _parse_qsl_args = {}
    _urlencode_args = {'doseq': True}

    @classmethod
    def _parse_args(cls, args):
        return super()._parse_args((cls._canonicalize_arg(a) for a in args))

    @classmethod
    def _canonicalize_arg(cls, a):
        if isinstance(a, urllib.parse.SplitResult):
            return urllib.parse.urlunsplit(a)

        if isinstance(a, urllib.parse.ParseResult):
            return urllib.parse.urlunparse(a)

        if webob and isinstance(a, webob.Request):

urlpath

Object-oriented URL from `urllib.parse` and `pathlib`

Python-2.0
Latest version published 3 years ago

Package Health Score

46 / 100
Full package analysis