File: compat.py

package info (click to toggle)
python-urlobject 2.3.4-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 276 kB
  • ctags: 474
  • sloc: python: 1,256; makefile: 135
file content (18 lines) | stat: -rw-r--r-- 570 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
try:
    import urlparse
except ImportError:
    # Python 3
    from urllib import parse as urlparse


# First hasattr checks for Python < 3, second checks for Python < 2.6
if hasattr(urlparse, 'BaseResult') and not hasattr(urlparse, 'ResultMixin'):
    def _replace(split_result, **replace):
        return urlparse.SplitResult(
            **dict((attr, replace.get(attr, getattr(split_result, attr)))
                for attr in ('scheme', 'netloc', 'path', 'query', 'fragment')))
    urlparse.BaseResult._replace = _replace
    del _replace


__all__ = ['urlparse']