mirror of
https://github.com/ansible/awx.git
synced 2026-03-07 19:51:08 -03:30
Upgrade six to 1.9.0
This commit is contained in:
@@ -56,5 +56,5 @@ rax-scheduled-images-python-novaclient-ext==0.2.1 (rax_scheduled_images_python_n
|
|||||||
requests==2.5.1 (requests/*)
|
requests==2.5.1 (requests/*)
|
||||||
setuptools==12.0.5 (setuptools/*, _markerlib/*, pkg_resources/*, easy_install.py)
|
setuptools==12.0.5 (setuptools/*, _markerlib/*, pkg_resources/*, easy_install.py)
|
||||||
simplejson==3.6.0 (simplejson/*, excluded simplejson/_speedups.so)
|
simplejson==3.6.0 (simplejson/*, excluded simplejson/_speedups.so)
|
||||||
six==1.7.3 (six.py)
|
six==1.9.0 (six.py)
|
||||||
South==0.8.4 (south/*)
|
South==0.8.4 (south/*)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"""Utilities for writing code that runs on Python 2 and 3"""
|
"""Utilities for writing code that runs on Python 2 and 3"""
|
||||||
|
|
||||||
# Copyright (c) 2010-2014 Benjamin Peterson
|
# Copyright (c) 2010-2015 Benjamin Peterson
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
@@ -20,13 +20,16 @@
|
|||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
# SOFTWARE.
|
# SOFTWARE.
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
|
import itertools
|
||||||
import operator
|
import operator
|
||||||
import sys
|
import sys
|
||||||
import types
|
import types
|
||||||
|
|
||||||
__author__ = "Benjamin Peterson <benjamin@python.org>"
|
__author__ = "Benjamin Peterson <benjamin@python.org>"
|
||||||
__version__ = "1.7.3"
|
__version__ = "1.9.0"
|
||||||
|
|
||||||
|
|
||||||
# Useful for very coarse version differentiation.
|
# Useful for very coarse version differentiation.
|
||||||
@@ -86,8 +89,12 @@ class _LazyDescr(object):
|
|||||||
def __get__(self, obj, tp):
|
def __get__(self, obj, tp):
|
||||||
result = self._resolve()
|
result = self._resolve()
|
||||||
setattr(obj, self.name, result) # Invokes __set__.
|
setattr(obj, self.name, result) # Invokes __set__.
|
||||||
# This is a bit ugly, but it avoids running this again.
|
try:
|
||||||
delattr(obj.__class__, self.name)
|
# This is a bit ugly, but it avoids running this again by
|
||||||
|
# removing this descriptor.
|
||||||
|
delattr(obj.__class__, self.name)
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@@ -225,10 +232,12 @@ _moved_attributes = [
|
|||||||
MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"),
|
MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"),
|
||||||
MovedAttribute("filterfalse", "itertools", "itertools", "ifilterfalse", "filterfalse"),
|
MovedAttribute("filterfalse", "itertools", "itertools", "ifilterfalse", "filterfalse"),
|
||||||
MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"),
|
MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"),
|
||||||
|
MovedAttribute("intern", "__builtin__", "sys"),
|
||||||
MovedAttribute("map", "itertools", "builtins", "imap", "map"),
|
MovedAttribute("map", "itertools", "builtins", "imap", "map"),
|
||||||
MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"),
|
MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"),
|
||||||
MovedAttribute("reload_module", "__builtin__", "imp", "reload"),
|
MovedAttribute("reload_module", "__builtin__", "imp", "reload"),
|
||||||
MovedAttribute("reduce", "__builtin__", "functools"),
|
MovedAttribute("reduce", "__builtin__", "functools"),
|
||||||
|
MovedAttribute("shlex_quote", "pipes", "shlex", "quote"),
|
||||||
MovedAttribute("StringIO", "StringIO", "io"),
|
MovedAttribute("StringIO", "StringIO", "io"),
|
||||||
MovedAttribute("UserDict", "UserDict", "collections"),
|
MovedAttribute("UserDict", "UserDict", "collections"),
|
||||||
MovedAttribute("UserList", "UserList", "collections"),
|
MovedAttribute("UserList", "UserList", "collections"),
|
||||||
@@ -248,6 +257,7 @@ _moved_attributes = [
|
|||||||
MovedModule("html_parser", "HTMLParser", "html.parser"),
|
MovedModule("html_parser", "HTMLParser", "html.parser"),
|
||||||
MovedModule("http_client", "httplib", "http.client"),
|
MovedModule("http_client", "httplib", "http.client"),
|
||||||
MovedModule("email_mime_multipart", "email.MIMEMultipart", "email.mime.multipart"),
|
MovedModule("email_mime_multipart", "email.MIMEMultipart", "email.mime.multipart"),
|
||||||
|
MovedModule("email_mime_nonmultipart", "email.MIMENonMultipart", "email.mime.nonmultipart"),
|
||||||
MovedModule("email_mime_text", "email.MIMEText", "email.mime.text"),
|
MovedModule("email_mime_text", "email.MIMEText", "email.mime.text"),
|
||||||
MovedModule("email_mime_base", "email.MIMEBase", "email.mime.base"),
|
MovedModule("email_mime_base", "email.MIMEBase", "email.mime.base"),
|
||||||
MovedModule("BaseHTTPServer", "BaseHTTPServer", "http.server"),
|
MovedModule("BaseHTTPServer", "BaseHTTPServer", "http.server"),
|
||||||
@@ -317,6 +327,13 @@ _urllib_parse_moved_attributes = [
|
|||||||
MovedAttribute("unquote_plus", "urllib", "urllib.parse"),
|
MovedAttribute("unquote_plus", "urllib", "urllib.parse"),
|
||||||
MovedAttribute("urlencode", "urllib", "urllib.parse"),
|
MovedAttribute("urlencode", "urllib", "urllib.parse"),
|
||||||
MovedAttribute("splitquery", "urllib", "urllib.parse"),
|
MovedAttribute("splitquery", "urllib", "urllib.parse"),
|
||||||
|
MovedAttribute("splittag", "urllib", "urllib.parse"),
|
||||||
|
MovedAttribute("splituser", "urllib", "urllib.parse"),
|
||||||
|
MovedAttribute("uses_fragment", "urlparse", "urllib.parse"),
|
||||||
|
MovedAttribute("uses_netloc", "urlparse", "urllib.parse"),
|
||||||
|
MovedAttribute("uses_params", "urlparse", "urllib.parse"),
|
||||||
|
MovedAttribute("uses_query", "urlparse", "urllib.parse"),
|
||||||
|
MovedAttribute("uses_relative", "urlparse", "urllib.parse"),
|
||||||
]
|
]
|
||||||
for attr in _urllib_parse_moved_attributes:
|
for attr in _urllib_parse_moved_attributes:
|
||||||
setattr(Module_six_moves_urllib_parse, attr.name, attr)
|
setattr(Module_six_moves_urllib_parse, attr.name, attr)
|
||||||
@@ -542,6 +559,12 @@ if PY3:
|
|||||||
|
|
||||||
def iterlists(d, **kw):
|
def iterlists(d, **kw):
|
||||||
return iter(d.lists(**kw))
|
return iter(d.lists(**kw))
|
||||||
|
|
||||||
|
viewkeys = operator.methodcaller("keys")
|
||||||
|
|
||||||
|
viewvalues = operator.methodcaller("values")
|
||||||
|
|
||||||
|
viewitems = operator.methodcaller("items")
|
||||||
else:
|
else:
|
||||||
def iterkeys(d, **kw):
|
def iterkeys(d, **kw):
|
||||||
return iter(d.iterkeys(**kw))
|
return iter(d.iterkeys(**kw))
|
||||||
@@ -555,6 +578,12 @@ else:
|
|||||||
def iterlists(d, **kw):
|
def iterlists(d, **kw):
|
||||||
return iter(d.iterlists(**kw))
|
return iter(d.iterlists(**kw))
|
||||||
|
|
||||||
|
viewkeys = operator.methodcaller("viewkeys")
|
||||||
|
|
||||||
|
viewvalues = operator.methodcaller("viewvalues")
|
||||||
|
|
||||||
|
viewitems = operator.methodcaller("viewitems")
|
||||||
|
|
||||||
_add_doc(iterkeys, "Return an iterator over the keys of a dictionary.")
|
_add_doc(iterkeys, "Return an iterator over the keys of a dictionary.")
|
||||||
_add_doc(itervalues, "Return an iterator over the values of a dictionary.")
|
_add_doc(itervalues, "Return an iterator over the values of a dictionary.")
|
||||||
_add_doc(iteritems,
|
_add_doc(iteritems,
|
||||||
@@ -581,6 +610,9 @@ if PY3:
|
|||||||
import io
|
import io
|
||||||
StringIO = io.StringIO
|
StringIO = io.StringIO
|
||||||
BytesIO = io.BytesIO
|
BytesIO = io.BytesIO
|
||||||
|
_assertCountEqual = "assertCountEqual"
|
||||||
|
_assertRaisesRegex = "assertRaisesRegex"
|
||||||
|
_assertRegex = "assertRegex"
|
||||||
else:
|
else:
|
||||||
def b(s):
|
def b(s):
|
||||||
return s
|
return s
|
||||||
@@ -593,19 +625,35 @@ else:
|
|||||||
return ord(bs[0])
|
return ord(bs[0])
|
||||||
def indexbytes(buf, i):
|
def indexbytes(buf, i):
|
||||||
return ord(buf[i])
|
return ord(buf[i])
|
||||||
def iterbytes(buf):
|
iterbytes = functools.partial(itertools.imap, ord)
|
||||||
return (ord(byte) for byte in buf)
|
|
||||||
import StringIO
|
import StringIO
|
||||||
StringIO = BytesIO = StringIO.StringIO
|
StringIO = BytesIO = StringIO.StringIO
|
||||||
|
_assertCountEqual = "assertItemsEqual"
|
||||||
|
_assertRaisesRegex = "assertRaisesRegexp"
|
||||||
|
_assertRegex = "assertRegexpMatches"
|
||||||
_add_doc(b, """Byte literal""")
|
_add_doc(b, """Byte literal""")
|
||||||
_add_doc(u, """Text literal""")
|
_add_doc(u, """Text literal""")
|
||||||
|
|
||||||
|
|
||||||
|
def assertCountEqual(self, *args, **kwargs):
|
||||||
|
return getattr(self, _assertCountEqual)(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
def assertRaisesRegex(self, *args, **kwargs):
|
||||||
|
return getattr(self, _assertRaisesRegex)(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
def assertRegex(self, *args, **kwargs):
|
||||||
|
return getattr(self, _assertRegex)(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
if PY3:
|
if PY3:
|
||||||
exec_ = getattr(moves.builtins, "exec")
|
exec_ = getattr(moves.builtins, "exec")
|
||||||
|
|
||||||
|
|
||||||
def reraise(tp, value, tb=None):
|
def reraise(tp, value, tb=None):
|
||||||
|
if value is None:
|
||||||
|
value = tp()
|
||||||
if value.__traceback__ is not tb:
|
if value.__traceback__ is not tb:
|
||||||
raise value.with_traceback(tb)
|
raise value.with_traceback(tb)
|
||||||
raise value
|
raise value
|
||||||
@@ -629,6 +677,21 @@ else:
|
|||||||
""")
|
""")
|
||||||
|
|
||||||
|
|
||||||
|
if sys.version_info[:2] == (3, 2):
|
||||||
|
exec_("""def raise_from(value, from_value):
|
||||||
|
if from_value is None:
|
||||||
|
raise value
|
||||||
|
raise value from from_value
|
||||||
|
""")
|
||||||
|
elif sys.version_info[:2] > (3, 2):
|
||||||
|
exec_("""def raise_from(value, from_value):
|
||||||
|
raise value from from_value
|
||||||
|
""")
|
||||||
|
else:
|
||||||
|
def raise_from(value, from_value):
|
||||||
|
raise value
|
||||||
|
|
||||||
|
|
||||||
print_ = getattr(moves.builtins, "print", None)
|
print_ = getattr(moves.builtins, "print", None)
|
||||||
if print_ is None:
|
if print_ is None:
|
||||||
def print_(*args, **kwargs):
|
def print_(*args, **kwargs):
|
||||||
@@ -683,13 +746,22 @@ if print_ is None:
|
|||||||
write(sep)
|
write(sep)
|
||||||
write(arg)
|
write(arg)
|
||||||
write(end)
|
write(end)
|
||||||
|
if sys.version_info[:2] < (3, 3):
|
||||||
|
_print = print_
|
||||||
|
def print_(*args, **kwargs):
|
||||||
|
fp = kwargs.get("file", sys.stdout)
|
||||||
|
flush = kwargs.pop("flush", False)
|
||||||
|
_print(*args, **kwargs)
|
||||||
|
if flush and fp is not None:
|
||||||
|
fp.flush()
|
||||||
|
|
||||||
_add_doc(reraise, """Reraise an exception.""")
|
_add_doc(reraise, """Reraise an exception.""")
|
||||||
|
|
||||||
if sys.version_info[0:2] < (3, 4):
|
if sys.version_info[0:2] < (3, 4):
|
||||||
def wraps(wrapped):
|
def wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS,
|
||||||
|
updated=functools.WRAPPER_UPDATES):
|
||||||
def wrapper(f):
|
def wrapper(f):
|
||||||
f = functools.wraps(wrapped)(f)
|
f = functools.wraps(wrapped, assigned, updated)(f)
|
||||||
f.__wrapped__ = wrapped
|
f.__wrapped__ = wrapped
|
||||||
return f
|
return f
|
||||||
return wrapper
|
return wrapper
|
||||||
@@ -711,17 +783,36 @@ def add_metaclass(metaclass):
|
|||||||
"""Class decorator for creating a class with a metaclass."""
|
"""Class decorator for creating a class with a metaclass."""
|
||||||
def wrapper(cls):
|
def wrapper(cls):
|
||||||
orig_vars = cls.__dict__.copy()
|
orig_vars = cls.__dict__.copy()
|
||||||
orig_vars.pop('__dict__', None)
|
|
||||||
orig_vars.pop('__weakref__', None)
|
|
||||||
slots = orig_vars.get('__slots__')
|
slots = orig_vars.get('__slots__')
|
||||||
if slots is not None:
|
if slots is not None:
|
||||||
if isinstance(slots, str):
|
if isinstance(slots, str):
|
||||||
slots = [slots]
|
slots = [slots]
|
||||||
for slots_var in slots:
|
for slots_var in slots:
|
||||||
orig_vars.pop(slots_var)
|
orig_vars.pop(slots_var)
|
||||||
|
orig_vars.pop('__dict__', None)
|
||||||
|
orig_vars.pop('__weakref__', None)
|
||||||
return metaclass(cls.__name__, cls.__bases__, orig_vars)
|
return metaclass(cls.__name__, cls.__bases__, orig_vars)
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
|
def python_2_unicode_compatible(klass):
|
||||||
|
"""
|
||||||
|
A decorator that defines __unicode__ and __str__ methods under Python 2.
|
||||||
|
Under Python 3 it does nothing.
|
||||||
|
|
||||||
|
To support Python 2 and 3 with a single code base, define a __str__ method
|
||||||
|
returning text and apply this decorator to the class.
|
||||||
|
"""
|
||||||
|
if PY2:
|
||||||
|
if '__str__' not in klass.__dict__:
|
||||||
|
raise ValueError("@python_2_unicode_compatible cannot be applied "
|
||||||
|
"to %s because it doesn't define __str__()." %
|
||||||
|
klass.__name__)
|
||||||
|
klass.__unicode__ = klass.__str__
|
||||||
|
klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
|
||||||
|
return klass
|
||||||
|
|
||||||
|
|
||||||
# Complete the moves implementation.
|
# Complete the moves implementation.
|
||||||
# This code is at the end of this module to speed up module loading.
|
# This code is at the end of this module to speed up module loading.
|
||||||
# Turn this module into a package.
|
# Turn this module into a package.
|
||||||
|
|||||||
Reference in New Issue
Block a user