File: __init__.py

package info (click to toggle)
python-pecan 1.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,276 kB
  • sloc: python: 10,400; makefile: 133; sh: 46
file content (32 lines) | stat: -rw-r--r-- 917 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import inspect

import six

if six.PY3:
    import urllib.parse as urlparse
    from urllib.parse import quote, unquote_plus
    from urllib.request import urlopen, URLError
    from html import escape
    izip = zip
else:
    import urlparse  # noqa
    from urllib import quote, unquote_plus  # noqa
    from urllib2 import urlopen, URLError  # noqa
    from cgi import escape  # noqa
    from itertools import izip


def is_bound_method(ob):
    return inspect.ismethod(ob) and six.get_method_self(ob) is not None


def getargspec(func):
    import sys
    if sys.version_info < (3, 5):
        return inspect.getargspec(func)

    from collections import namedtuple
    ArgSpec = namedtuple('ArgSpec', 'args varargs keywords defaults')
    args, varargs, keywords, defaults = inspect.getfullargspec(func)[:4]
    return ArgSpec(args=args, varargs=varargs, keywords=keywords,
                   defaults=defaults)