* Update module_utils.six to latest
We've been held back on the version of six we could use on the module
side to 1.4.x because of python-2.4 compatibility. Now that our minimum
is Python-2.6, we can update to the latest version of six in
module_utils and get rid of the second copy in lib/ansible/compat.
... | ... |
@@ -16,6 +16,7 @@ Ansible Changes By Release |
16 | 16 |
### Minor Changes |
17 | 17 |
* removed previously deprecated config option 'hostfile' and env var 'ANSIBLE_HOSTS' |
18 | 18 |
* removed unused and deprecated config option 'pattern' |
19 |
+* Updated the copy of six bundled for modules to use from 1.4.1 to 1.10.0 |
|
19 | 20 |
|
20 | 21 |
|
21 | 22 |
#### New: Tests |
... | ... |
@@ -53,19 +53,19 @@ import os |
53 | 53 |
import argparse |
54 | 54 |
import re |
55 | 55 |
|
56 |
-from ansible.compat.six.moves import configparser |
|
56 |
+try: |
|
57 |
+ import json |
|
58 |
+except ImportError: |
|
59 |
+ import simplejson as json |
|
57 | 60 |
|
58 | 61 |
try: |
59 | 62 |
from apstra.aosom.session import Session |
60 |
- |
|
61 | 63 |
HAS_AOS_PYEZ = True |
62 | 64 |
except ImportError: |
63 | 65 |
HAS_AOS_PYEZ = False |
64 | 66 |
|
65 |
-try: |
|
66 |
- import json |
|
67 |
-except ImportError: |
|
68 |
- import simplejson as json |
|
67 |
+from ansible.module_utils.six.moves import configparser |
|
68 |
+ |
|
69 | 69 |
|
70 | 70 |
""" |
71 | 71 |
## |
... | ... |
@@ -41,7 +41,7 @@ The following is a list of module_utils files and a general description. The mod |
41 | 41 |
- redhat.py - Functions for modules that manage Red Hat Network registration and subscriptions |
42 | 42 |
- service.py - Contains utilities to enable modules to work with Linux services (placeholder, not in use). |
43 | 43 |
- shell.py - Functions to allow modules to create shells and work with shell commands |
44 |
-- six.py - Module utils for working with the Six python 2 and 3 compatibility library |
|
44 |
+- six/__init__.py - Bundled copy of the `Six Python library <https://pythonhosted.org/six/>`_ to aid in writing code compatible with both Python 2 and Python 3. |
|
45 | 45 |
- splitter.py - String splitting and manipulation utilities for working with Jinja2 templates |
46 | 46 |
- urls.py - Utilities for working with http and https requests |
47 | 47 |
- vca.py - Contains utilities for modules that work with VMware vCloud Air |
... | ... |
@@ -325,20 +325,16 @@ Bundled six |
325 | 325 |
|
326 | 326 |
The third-party `python-six <https://pythonhosted.org/six/>`_ library exists |
327 | 327 |
to help projects create code that runs on both Python-2 and Python-3. Ansible |
328 |
-includes version 1.4.1 in module_utils so that other modules can use it |
|
328 |
+includes a version of the library in module_utils so that other modules can use it |
|
329 | 329 |
without requiring that it is installed on the remote system. To make use of |
330 | 330 |
it, import it like this:: |
331 | 331 |
|
332 | 332 |
from ansible.module_utils import six |
333 | 333 |
|
334 |
-.. note:: Why version 1.4.1? |
|
334 |
+.. note:: Ansible can also use a system copy of six |
|
335 | 335 |
|
336 |
- six-1.4.1 is the last version of python-six to support Python-2.4. Until |
|
337 |
- Ansible-2.4, most Ansible modules were required to run on Python-2.4. So |
|
338 |
- the bundled version of six could not be newer than 1.4.1. |
|
339 |
- |
|
340 |
- Ansible-2.4 now targets Python-2.6 or greater for modules. We'll be |
|
341 |
- updating the bundled six soon. |
|
336 |
+ Ansible will use a system copy of six if the system copy is a later |
|
337 |
+ version than the one Ansible bundles. |
|
342 | 338 |
|
343 | 339 |
------------------------------------- |
344 | 340 |
Porting module_utils code to Python 3 |
... | ... |
@@ -33,8 +33,8 @@ from abc import ABCMeta, abstractmethod |
33 | 33 |
|
34 | 34 |
from ansible.release import __version__ |
35 | 35 |
from ansible import constants as C |
36 |
-from ansible.compat.six import with_metaclass |
|
37 | 36 |
from ansible.errors import AnsibleError, AnsibleOptionsError |
37 |
+from ansible.module_utils.six import with_metaclass |
|
38 | 38 |
from ansible.module_utils._text import to_bytes, to_text |
39 | 39 |
from ansible.utils.path import unfrackpath |
40 | 40 |
|
... | ... |
@@ -25,12 +25,11 @@ import traceback |
25 | 25 |
import textwrap |
26 | 26 |
import yaml |
27 | 27 |
|
28 |
-from ansible.compat.six import iteritems, string_types |
|
29 |
- |
|
30 | 28 |
from ansible import constants as C |
29 |
+from ansible.cli import CLI |
|
31 | 30 |
from ansible.errors import AnsibleError, AnsibleOptionsError |
31 |
+from ansible.module_utils.six import iteritems, string_types |
|
32 | 32 |
from ansible.plugins import module_loader, action_loader, lookup_loader, callback_loader, cache_loader, connection_loader, strategy_loader |
33 |
-from ansible.cli import CLI |
|
34 | 33 |
from ansible.utils import plugin_docs |
35 | 34 |
|
36 | 35 |
try: |
37 | 36 |
deleted file mode 100644 |
... | ... |
@@ -1,54 +0,0 @@ |
1 |
-# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com> |
|
2 |
-# |
|
3 |
-# This file is part of Ansible |
|
4 |
-# |
|
5 |
-# Ansible is free software: you can redistribute it and/or modify |
|
6 |
-# it under the terms of the GNU General Public License as published by |
|
7 |
-# the Free Software Foundation, either version 3 of the License, or |
|
8 |
-# (at your option) any later version. |
|
9 |
-# |
|
10 |
-# Ansible is distributed in the hope that it will be useful, |
|
11 |
-# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
-# GNU General Public License for more details. |
|
14 |
-# |
|
15 |
-# You should have received a copy of the GNU General Public License |
|
16 |
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>. |
|
17 |
- |
|
18 |
-# Make coding more python3-ish |
|
19 |
-from __future__ import (absolute_import, division, print_function) |
|
20 |
-__metaclass__ = type |
|
21 |
- |
|
22 |
-''' |
|
23 |
-Compat six library. RHEL7 has python-six 1.3.0 which is too old |
|
24 |
-''' |
|
25 |
-# The following makes it easier for us to script updates of the bundled code |
|
26 |
-_BUNDLED_METADATA = { "pypi_name": "six", "version": "1.10.0" } |
|
27 |
- |
|
28 |
-import os.path |
|
29 |
- |
|
30 |
-try: |
|
31 |
- import six as _system_six |
|
32 |
-except ImportError: |
|
33 |
- _system_six = None |
|
34 |
- |
|
35 |
-if _system_six: |
|
36 |
- # If we need some things from even newer versions of six, then we need to |
|
37 |
- # use our bundled copy instead |
|
38 |
- |
|
39 |
- if ( # Added in six-1.8.0 |
|
40 |
- not hasattr(_system_six.moves, 'shlex_quote') or |
|
41 |
- # Added in six-1.4.0 |
|
42 |
- not hasattr(_system_six, 'byte2int') or |
|
43 |
- not hasattr(_system_six, 'add_metaclass') or |
|
44 |
- not hasattr(_system_six.moves, 'urllib') |
|
45 |
- ): |
|
46 |
- |
|
47 |
- _system_six = False |
|
48 |
- |
|
49 |
-if _system_six: |
|
50 |
- six = _system_six |
|
51 |
-else: |
|
52 |
- from . import _six as six |
|
53 |
-six_py_file = '{0}.py'.format(os.path.splitext(six.__file__)[0]) |
|
54 |
-exec(open(six_py_file, 'rb').read()) |
55 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,870 +0,0 @@ |
1 |
-"""Utilities for writing code that runs on Python 2 and 3""" |
|
2 |
- |
|
3 |
-# Copyright (c) 2010-2015 Benjamin Peterson |
|
4 |
-# |
|
5 |
-# Permission is hereby granted, free of charge, to any person obtaining a copy |
|
6 |
-# of this software and associated documentation files (the "Software"), to deal |
|
7 |
-# in the Software without restriction, including without limitation the rights |
|
8 |
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
9 |
-# copies of the Software, and to permit persons to whom the Software is |
|
10 |
-# furnished to do so, subject to the following conditions: |
|
11 |
-# |
|
12 |
-# The above copyright notice and this permission notice shall be included in all |
|
13 |
-# copies or substantial portions of the Software. |
|
14 |
-# |
|
15 |
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
16 |
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
17 |
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
18 |
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
19 |
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
20 |
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
21 |
-# SOFTWARE. |
|
22 |
- |
|
23 |
-from __future__ import absolute_import |
|
24 |
- |
|
25 |
-import functools |
|
26 |
-import itertools |
|
27 |
-import operator |
|
28 |
-import sys |
|
29 |
-import types |
|
30 |
- |
|
31 |
-__author__ = "Benjamin Peterson <benjamin@python.org>" |
|
32 |
-__version__ = "1.10.0" |
|
33 |
- |
|
34 |
- |
|
35 |
-# Useful for very coarse version differentiation. |
|
36 |
-PY2 = sys.version_info[0] == 2 |
|
37 |
-PY3 = sys.version_info[0] == 3 |
|
38 |
-PY34 = sys.version_info[0:2] >= (3, 4) |
|
39 |
- |
|
40 |
-if PY3: |
|
41 |
- string_types = str, |
|
42 |
- integer_types = int, |
|
43 |
- class_types = type, |
|
44 |
- text_type = str |
|
45 |
- binary_type = bytes |
|
46 |
- cmp = lambda a, b: (a > b) - (a < b) |
|
47 |
- |
|
48 |
- MAXSIZE = sys.maxsize |
|
49 |
-else: |
|
50 |
- string_types = basestring, |
|
51 |
- integer_types = (int, long) |
|
52 |
- class_types = (type, types.ClassType) |
|
53 |
- text_type = unicode |
|
54 |
- binary_type = str |
|
55 |
- cmp = cmp |
|
56 |
- |
|
57 |
- if sys.platform.startswith("java"): |
|
58 |
- # Jython always uses 32 bits. |
|
59 |
- MAXSIZE = int((1 << 31) - 1) |
|
60 |
- else: |
|
61 |
- # It's possible to have sizeof(long) != sizeof(Py_ssize_t). |
|
62 |
- class X(object): |
|
63 |
- |
|
64 |
- def __len__(self): |
|
65 |
- return 1 << 31 |
|
66 |
- try: |
|
67 |
- len(X()) |
|
68 |
- except OverflowError: |
|
69 |
- # 32-bit |
|
70 |
- MAXSIZE = int((1 << 31) - 1) |
|
71 |
- else: |
|
72 |
- # 64-bit |
|
73 |
- MAXSIZE = int((1 << 63) - 1) |
|
74 |
- del X |
|
75 |
- |
|
76 |
- |
|
77 |
-def _add_doc(func, doc): |
|
78 |
- """Add documentation to a function.""" |
|
79 |
- func.__doc__ = doc |
|
80 |
- |
|
81 |
- |
|
82 |
-def _import_module(name): |
|
83 |
- """Import module, returning the module after the last dot.""" |
|
84 |
- __import__(name) |
|
85 |
- return sys.modules[name] |
|
86 |
- |
|
87 |
- |
|
88 |
-class _LazyDescr(object): |
|
89 |
- |
|
90 |
- def __init__(self, name): |
|
91 |
- self.name = name |
|
92 |
- |
|
93 |
- def __get__(self, obj, tp): |
|
94 |
- result = self._resolve() |
|
95 |
- setattr(obj, self.name, result) # Invokes __set__. |
|
96 |
- try: |
|
97 |
- # This is a bit ugly, but it avoids running this again by |
|
98 |
- # removing this descriptor. |
|
99 |
- delattr(obj.__class__, self.name) |
|
100 |
- except AttributeError: |
|
101 |
- pass |
|
102 |
- return result |
|
103 |
- |
|
104 |
- |
|
105 |
-class MovedModule(_LazyDescr): |
|
106 |
- |
|
107 |
- def __init__(self, name, old, new=None): |
|
108 |
- super(MovedModule, self).__init__(name) |
|
109 |
- if PY3: |
|
110 |
- if new is None: |
|
111 |
- new = name |
|
112 |
- self.mod = new |
|
113 |
- else: |
|
114 |
- self.mod = old |
|
115 |
- |
|
116 |
- def _resolve(self): |
|
117 |
- return _import_module(self.mod) |
|
118 |
- |
|
119 |
- def __getattr__(self, attr): |
|
120 |
- _module = self._resolve() |
|
121 |
- value = getattr(_module, attr) |
|
122 |
- setattr(self, attr, value) |
|
123 |
- return value |
|
124 |
- |
|
125 |
- |
|
126 |
-class _LazyModule(types.ModuleType): |
|
127 |
- |
|
128 |
- def __init__(self, name): |
|
129 |
- super(_LazyModule, self).__init__(name) |
|
130 |
- self.__doc__ = self.__class__.__doc__ |
|
131 |
- |
|
132 |
- def __dir__(self): |
|
133 |
- attrs = ["__doc__", "__name__"] |
|
134 |
- attrs += [attr.name for attr in self._moved_attributes] |
|
135 |
- return attrs |
|
136 |
- |
|
137 |
- # Subclasses should override this |
|
138 |
- _moved_attributes = [] |
|
139 |
- |
|
140 |
- |
|
141 |
-class MovedAttribute(_LazyDescr): |
|
142 |
- |
|
143 |
- def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None): |
|
144 |
- super(MovedAttribute, self).__init__(name) |
|
145 |
- if PY3: |
|
146 |
- if new_mod is None: |
|
147 |
- new_mod = name |
|
148 |
- self.mod = new_mod |
|
149 |
- if new_attr is None: |
|
150 |
- if old_attr is None: |
|
151 |
- new_attr = name |
|
152 |
- else: |
|
153 |
- new_attr = old_attr |
|
154 |
- self.attr = new_attr |
|
155 |
- else: |
|
156 |
- self.mod = old_mod |
|
157 |
- if old_attr is None: |
|
158 |
- old_attr = name |
|
159 |
- self.attr = old_attr |
|
160 |
- |
|
161 |
- def _resolve(self): |
|
162 |
- module = _import_module(self.mod) |
|
163 |
- return getattr(module, self.attr) |
|
164 |
- |
|
165 |
- |
|
166 |
-class _SixMetaPathImporter(object): |
|
167 |
- |
|
168 |
- """ |
|
169 |
- A meta path importer to import six.moves and its submodules. |
|
170 |
- |
|
171 |
- This class implements a PEP302 finder and loader. It should be compatible |
|
172 |
- with Python 2.5 and all existing versions of Python3 |
|
173 |
- """ |
|
174 |
- |
|
175 |
- def __init__(self, six_module_name): |
|
176 |
- self.name = six_module_name |
|
177 |
- self.known_modules = {} |
|
178 |
- |
|
179 |
- def _add_module(self, mod, *fullnames): |
|
180 |
- for fullname in fullnames: |
|
181 |
- self.known_modules[self.name + "." + fullname] = mod |
|
182 |
- |
|
183 |
- def _get_module(self, fullname): |
|
184 |
- return self.known_modules[self.name + "." + fullname] |
|
185 |
- |
|
186 |
- def find_module(self, fullname, path=None): |
|
187 |
- if fullname in self.known_modules: |
|
188 |
- return self |
|
189 |
- return None |
|
190 |
- |
|
191 |
- def __get_module(self, fullname): |
|
192 |
- try: |
|
193 |
- return self.known_modules[fullname] |
|
194 |
- except KeyError: |
|
195 |
- raise ImportError("This loader does not know module " + fullname) |
|
196 |
- |
|
197 |
- def load_module(self, fullname): |
|
198 |
- try: |
|
199 |
- # in case of a reload |
|
200 |
- return sys.modules[fullname] |
|
201 |
- except KeyError: |
|
202 |
- pass |
|
203 |
- mod = self.__get_module(fullname) |
|
204 |
- if isinstance(mod, MovedModule): |
|
205 |
- mod = mod._resolve() |
|
206 |
- else: |
|
207 |
- mod.__loader__ = self |
|
208 |
- sys.modules[fullname] = mod |
|
209 |
- return mod |
|
210 |
- |
|
211 |
- def is_package(self, fullname): |
|
212 |
- """ |
|
213 |
- Return true, if the named module is a package. |
|
214 |
- |
|
215 |
- We need this method to get correct spec objects with |
|
216 |
- Python 3.4 (see PEP451) |
|
217 |
- """ |
|
218 |
- return hasattr(self.__get_module(fullname), "__path__") |
|
219 |
- |
|
220 |
- def get_code(self, fullname): |
|
221 |
- """Return None |
|
222 |
- |
|
223 |
- Required, if is_package is implemented""" |
|
224 |
- self.__get_module(fullname) # eventually raises ImportError |
|
225 |
- return None |
|
226 |
- get_source = get_code # same as get_code |
|
227 |
- |
|
228 |
-_importer = _SixMetaPathImporter(__name__) |
|
229 |
- |
|
230 |
- |
|
231 |
-class _MovedItems(_LazyModule): |
|
232 |
- |
|
233 |
- """Lazy loading of moved objects""" |
|
234 |
- __path__ = [] # mark as package |
|
235 |
- |
|
236 |
- |
|
237 |
-_moved_attributes = [ |
|
238 |
- MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"), |
|
239 |
- MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"), |
|
240 |
- MovedAttribute("filterfalse", "itertools", "itertools", "ifilterfalse", "filterfalse"), |
|
241 |
- MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"), |
|
242 |
- MovedAttribute("intern", "__builtin__", "sys"), |
|
243 |
- MovedAttribute("map", "itertools", "builtins", "imap", "map"), |
|
244 |
- MovedAttribute("getcwd", "os", "os", "getcwdu", "getcwd"), |
|
245 |
- MovedAttribute("getcwdb", "os", "os", "getcwd", "getcwdb"), |
|
246 |
- MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"), |
|
247 |
- MovedAttribute("reload_module", "__builtin__", "importlib" if PY34 else "imp", "reload"), |
|
248 |
- MovedAttribute("reduce", "__builtin__", "functools"), |
|
249 |
- MovedAttribute("shlex_quote", "pipes", "shlex", "quote"), |
|
250 |
- MovedAttribute("StringIO", "StringIO", "io"), |
|
251 |
- MovedAttribute("UserDict", "UserDict", "collections"), |
|
252 |
- MovedAttribute("UserList", "UserList", "collections"), |
|
253 |
- MovedAttribute("UserString", "UserString", "collections"), |
|
254 |
- MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"), |
|
255 |
- MovedAttribute("zip", "itertools", "builtins", "izip", "zip"), |
|
256 |
- MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"), |
|
257 |
- MovedModule("builtins", "__builtin__"), |
|
258 |
- MovedModule("configparser", "ConfigParser"), |
|
259 |
- MovedModule("copyreg", "copy_reg"), |
|
260 |
- MovedModule("dbm_gnu", "gdbm", "dbm.gnu"), |
|
261 |
- MovedModule("_dummy_thread", "dummy_thread", "_dummy_thread"), |
|
262 |
- MovedModule("http_cookiejar", "cookielib", "http.cookiejar"), |
|
263 |
- MovedModule("http_cookies", "Cookie", "http.cookies"), |
|
264 |
- MovedModule("html_entities", "htmlentitydefs", "html.entities"), |
|
265 |
- MovedModule("html_parser", "HTMLParser", "html.parser"), |
|
266 |
- MovedModule("http_client", "httplib", "http.client"), |
|
267 |
- MovedModule("email_mime_multipart", "email.MIMEMultipart", "email.mime.multipart"), |
|
268 |
- MovedModule("email_mime_nonmultipart", "email.MIMENonMultipart", "email.mime.nonmultipart"), |
|
269 |
- MovedModule("email_mime_text", "email.MIMEText", "email.mime.text"), |
|
270 |
- MovedModule("email_mime_base", "email.MIMEBase", "email.mime.base"), |
|
271 |
- MovedModule("BaseHTTPServer", "BaseHTTPServer", "http.server"), |
|
272 |
- MovedModule("CGIHTTPServer", "CGIHTTPServer", "http.server"), |
|
273 |
- MovedModule("SimpleHTTPServer", "SimpleHTTPServer", "http.server"), |
|
274 |
- MovedModule("cPickle", "cPickle", "pickle"), |
|
275 |
- MovedModule("queue", "Queue"), |
|
276 |
- MovedModule("reprlib", "repr"), |
|
277 |
- MovedModule("socketserver", "SocketServer"), |
|
278 |
- MovedModule("_thread", "thread", "_thread"), |
|
279 |
- MovedModule("tkinter", "Tkinter"), |
|
280 |
- MovedModule("tkinter_dialog", "Dialog", "tkinter.dialog"), |
|
281 |
- MovedModule("tkinter_filedialog", "FileDialog", "tkinter.filedialog"), |
|
282 |
- MovedModule("tkinter_scrolledtext", "ScrolledText", "tkinter.scrolledtext"), |
|
283 |
- MovedModule("tkinter_simpledialog", "SimpleDialog", "tkinter.simpledialog"), |
|
284 |
- MovedModule("tkinter_tix", "Tix", "tkinter.tix"), |
|
285 |
- MovedModule("tkinter_ttk", "ttk", "tkinter.ttk"), |
|
286 |
- MovedModule("tkinter_constants", "Tkconstants", "tkinter.constants"), |
|
287 |
- MovedModule("tkinter_dnd", "Tkdnd", "tkinter.dnd"), |
|
288 |
- MovedModule("tkinter_colorchooser", "tkColorChooser", |
|
289 |
- "tkinter.colorchooser"), |
|
290 |
- MovedModule("tkinter_commondialog", "tkCommonDialog", |
|
291 |
- "tkinter.commondialog"), |
|
292 |
- MovedModule("tkinter_tkfiledialog", "tkFileDialog", "tkinter.filedialog"), |
|
293 |
- MovedModule("tkinter_font", "tkFont", "tkinter.font"), |
|
294 |
- MovedModule("tkinter_messagebox", "tkMessageBox", "tkinter.messagebox"), |
|
295 |
- MovedModule("tkinter_tksimpledialog", "tkSimpleDialog", |
|
296 |
- "tkinter.simpledialog"), |
|
297 |
- MovedModule("urllib_parse", __name__ + ".moves.urllib_parse", "urllib.parse"), |
|
298 |
- MovedModule("urllib_error", __name__ + ".moves.urllib_error", "urllib.error"), |
|
299 |
- MovedModule("urllib", __name__ + ".moves.urllib", __name__ + ".moves.urllib"), |
|
300 |
- MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"), |
|
301 |
- MovedModule("xmlrpc_client", "xmlrpclib", "xmlrpc.client"), |
|
302 |
- MovedModule("xmlrpc_server", "SimpleXMLRPCServer", "xmlrpc.server"), |
|
303 |
-] |
|
304 |
-# Add windows specific modules. |
|
305 |
-if sys.platform == "win32": |
|
306 |
- _moved_attributes += [ |
|
307 |
- MovedModule("winreg", "_winreg"), |
|
308 |
- ] |
|
309 |
- |
|
310 |
-for attr in _moved_attributes: |
|
311 |
- setattr(_MovedItems, attr.name, attr) |
|
312 |
- if isinstance(attr, MovedModule): |
|
313 |
- _importer._add_module(attr, "moves." + attr.name) |
|
314 |
-del attr |
|
315 |
- |
|
316 |
-_MovedItems._moved_attributes = _moved_attributes |
|
317 |
- |
|
318 |
-moves = _MovedItems(__name__ + ".moves") |
|
319 |
-_importer._add_module(moves, "moves") |
|
320 |
- |
|
321 |
- |
|
322 |
-class Module_six_moves_urllib_parse(_LazyModule): |
|
323 |
- |
|
324 |
- """Lazy loading of moved objects in six.moves.urllib_parse""" |
|
325 |
- |
|
326 |
- |
|
327 |
-_urllib_parse_moved_attributes = [ |
|
328 |
- MovedAttribute("ParseResult", "urlparse", "urllib.parse"), |
|
329 |
- MovedAttribute("SplitResult", "urlparse", "urllib.parse"), |
|
330 |
- MovedAttribute("parse_qs", "urlparse", "urllib.parse"), |
|
331 |
- MovedAttribute("parse_qsl", "urlparse", "urllib.parse"), |
|
332 |
- MovedAttribute("urldefrag", "urlparse", "urllib.parse"), |
|
333 |
- MovedAttribute("urljoin", "urlparse", "urllib.parse"), |
|
334 |
- MovedAttribute("urlparse", "urlparse", "urllib.parse"), |
|
335 |
- MovedAttribute("urlsplit", "urlparse", "urllib.parse"), |
|
336 |
- MovedAttribute("urlunparse", "urlparse", "urllib.parse"), |
|
337 |
- MovedAttribute("urlunsplit", "urlparse", "urllib.parse"), |
|
338 |
- MovedAttribute("quote", "urllib", "urllib.parse"), |
|
339 |
- MovedAttribute("quote_plus", "urllib", "urllib.parse"), |
|
340 |
- MovedAttribute("unquote", "urllib", "urllib.parse"), |
|
341 |
- MovedAttribute("unquote_plus", "urllib", "urllib.parse"), |
|
342 |
- MovedAttribute("urlencode", "urllib", "urllib.parse"), |
|
343 |
- MovedAttribute("splitquery", "urllib", "urllib.parse"), |
|
344 |
- MovedAttribute("splittag", "urllib", "urllib.parse"), |
|
345 |
- MovedAttribute("splituser", "urllib", "urllib.parse"), |
|
346 |
- MovedAttribute("uses_fragment", "urlparse", "urllib.parse"), |
|
347 |
- MovedAttribute("uses_netloc", "urlparse", "urllib.parse"), |
|
348 |
- MovedAttribute("uses_params", "urlparse", "urllib.parse"), |
|
349 |
- MovedAttribute("uses_query", "urlparse", "urllib.parse"), |
|
350 |
- MovedAttribute("uses_relative", "urlparse", "urllib.parse"), |
|
351 |
-] |
|
352 |
-for attr in _urllib_parse_moved_attributes: |
|
353 |
- setattr(Module_six_moves_urllib_parse, attr.name, attr) |
|
354 |
-del attr |
|
355 |
- |
|
356 |
-Module_six_moves_urllib_parse._moved_attributes = _urllib_parse_moved_attributes |
|
357 |
- |
|
358 |
-_importer._add_module(Module_six_moves_urllib_parse(__name__ + ".moves.urllib_parse"), |
|
359 |
- "moves.urllib_parse", "moves.urllib.parse") |
|
360 |
- |
|
361 |
- |
|
362 |
-class Module_six_moves_urllib_error(_LazyModule): |
|
363 |
- |
|
364 |
- """Lazy loading of moved objects in six.moves.urllib_error""" |
|
365 |
- |
|
366 |
- |
|
367 |
-_urllib_error_moved_attributes = [ |
|
368 |
- MovedAttribute("URLError", "urllib2", "urllib.error"), |
|
369 |
- MovedAttribute("HTTPError", "urllib2", "urllib.error"), |
|
370 |
- MovedAttribute("ContentTooShortError", "urllib", "urllib.error"), |
|
371 |
-] |
|
372 |
-for attr in _urllib_error_moved_attributes: |
|
373 |
- setattr(Module_six_moves_urllib_error, attr.name, attr) |
|
374 |
-del attr |
|
375 |
- |
|
376 |
-Module_six_moves_urllib_error._moved_attributes = _urllib_error_moved_attributes |
|
377 |
- |
|
378 |
-_importer._add_module(Module_six_moves_urllib_error(__name__ + ".moves.urllib.error"), |
|
379 |
- "moves.urllib_error", "moves.urllib.error") |
|
380 |
- |
|
381 |
- |
|
382 |
-class Module_six_moves_urllib_request(_LazyModule): |
|
383 |
- |
|
384 |
- """Lazy loading of moved objects in six.moves.urllib_request""" |
|
385 |
- |
|
386 |
- |
|
387 |
-_urllib_request_moved_attributes = [ |
|
388 |
- MovedAttribute("urlopen", "urllib2", "urllib.request"), |
|
389 |
- MovedAttribute("install_opener", "urllib2", "urllib.request"), |
|
390 |
- MovedAttribute("build_opener", "urllib2", "urllib.request"), |
|
391 |
- MovedAttribute("pathname2url", "urllib", "urllib.request"), |
|
392 |
- MovedAttribute("url2pathname", "urllib", "urllib.request"), |
|
393 |
- MovedAttribute("getproxies", "urllib", "urllib.request"), |
|
394 |
- MovedAttribute("Request", "urllib2", "urllib.request"), |
|
395 |
- MovedAttribute("OpenerDirector", "urllib2", "urllib.request"), |
|
396 |
- MovedAttribute("HTTPDefaultErrorHandler", "urllib2", "urllib.request"), |
|
397 |
- MovedAttribute("HTTPRedirectHandler", "urllib2", "urllib.request"), |
|
398 |
- MovedAttribute("HTTPCookieProcessor", "urllib2", "urllib.request"), |
|
399 |
- MovedAttribute("ProxyHandler", "urllib2", "urllib.request"), |
|
400 |
- MovedAttribute("BaseHandler", "urllib2", "urllib.request"), |
|
401 |
- MovedAttribute("HTTPPasswordMgr", "urllib2", "urllib.request"), |
|
402 |
- MovedAttribute("HTTPPasswordMgrWithDefaultRealm", "urllib2", "urllib.request"), |
|
403 |
- MovedAttribute("AbstractBasicAuthHandler", "urllib2", "urllib.request"), |
|
404 |
- MovedAttribute("HTTPBasicAuthHandler", "urllib2", "urllib.request"), |
|
405 |
- MovedAttribute("ProxyBasicAuthHandler", "urllib2", "urllib.request"), |
|
406 |
- MovedAttribute("AbstractDigestAuthHandler", "urllib2", "urllib.request"), |
|
407 |
- MovedAttribute("HTTPDigestAuthHandler", "urllib2", "urllib.request"), |
|
408 |
- MovedAttribute("ProxyDigestAuthHandler", "urllib2", "urllib.request"), |
|
409 |
- MovedAttribute("HTTPHandler", "urllib2", "urllib.request"), |
|
410 |
- MovedAttribute("HTTPSHandler", "urllib2", "urllib.request"), |
|
411 |
- MovedAttribute("FileHandler", "urllib2", "urllib.request"), |
|
412 |
- MovedAttribute("FTPHandler", "urllib2", "urllib.request"), |
|
413 |
- MovedAttribute("CacheFTPHandler", "urllib2", "urllib.request"), |
|
414 |
- MovedAttribute("UnknownHandler", "urllib2", "urllib.request"), |
|
415 |
- MovedAttribute("HTTPErrorProcessor", "urllib2", "urllib.request"), |
|
416 |
- MovedAttribute("urlretrieve", "urllib", "urllib.request"), |
|
417 |
- MovedAttribute("urlcleanup", "urllib", "urllib.request"), |
|
418 |
- MovedAttribute("URLopener", "urllib", "urllib.request"), |
|
419 |
- MovedAttribute("FancyURLopener", "urllib", "urllib.request"), |
|
420 |
- MovedAttribute("proxy_bypass", "urllib", "urllib.request"), |
|
421 |
-] |
|
422 |
-for attr in _urllib_request_moved_attributes: |
|
423 |
- setattr(Module_six_moves_urllib_request, attr.name, attr) |
|
424 |
-del attr |
|
425 |
- |
|
426 |
-Module_six_moves_urllib_request._moved_attributes = _urllib_request_moved_attributes |
|
427 |
- |
|
428 |
-_importer._add_module(Module_six_moves_urllib_request(__name__ + ".moves.urllib.request"), |
|
429 |
- "moves.urllib_request", "moves.urllib.request") |
|
430 |
- |
|
431 |
- |
|
432 |
-class Module_six_moves_urllib_response(_LazyModule): |
|
433 |
- |
|
434 |
- """Lazy loading of moved objects in six.moves.urllib_response""" |
|
435 |
- |
|
436 |
- |
|
437 |
-_urllib_response_moved_attributes = [ |
|
438 |
- MovedAttribute("addbase", "urllib", "urllib.response"), |
|
439 |
- MovedAttribute("addclosehook", "urllib", "urllib.response"), |
|
440 |
- MovedAttribute("addinfo", "urllib", "urllib.response"), |
|
441 |
- MovedAttribute("addinfourl", "urllib", "urllib.response"), |
|
442 |
-] |
|
443 |
-for attr in _urllib_response_moved_attributes: |
|
444 |
- setattr(Module_six_moves_urllib_response, attr.name, attr) |
|
445 |
-del attr |
|
446 |
- |
|
447 |
-Module_six_moves_urllib_response._moved_attributes = _urllib_response_moved_attributes |
|
448 |
- |
|
449 |
-_importer._add_module(Module_six_moves_urllib_response(__name__ + ".moves.urllib.response"), |
|
450 |
- "moves.urllib_response", "moves.urllib.response") |
|
451 |
- |
|
452 |
- |
|
453 |
-class Module_six_moves_urllib_robotparser(_LazyModule): |
|
454 |
- |
|
455 |
- """Lazy loading of moved objects in six.moves.urllib_robotparser""" |
|
456 |
- |
|
457 |
- |
|
458 |
-_urllib_robotparser_moved_attributes = [ |
|
459 |
- MovedAttribute("RobotFileParser", "robotparser", "urllib.robotparser"), |
|
460 |
-] |
|
461 |
-for attr in _urllib_robotparser_moved_attributes: |
|
462 |
- setattr(Module_six_moves_urllib_robotparser, attr.name, attr) |
|
463 |
-del attr |
|
464 |
- |
|
465 |
-Module_six_moves_urllib_robotparser._moved_attributes = _urllib_robotparser_moved_attributes |
|
466 |
- |
|
467 |
-_importer._add_module(Module_six_moves_urllib_robotparser(__name__ + ".moves.urllib.robotparser"), |
|
468 |
- "moves.urllib_robotparser", "moves.urllib.robotparser") |
|
469 |
- |
|
470 |
- |
|
471 |
-class Module_six_moves_urllib(types.ModuleType): |
|
472 |
- |
|
473 |
- """Create a six.moves.urllib namespace that resembles the Python 3 namespace""" |
|
474 |
- __path__ = [] # mark as package |
|
475 |
- parse = _importer._get_module("moves.urllib_parse") |
|
476 |
- error = _importer._get_module("moves.urllib_error") |
|
477 |
- request = _importer._get_module("moves.urllib_request") |
|
478 |
- response = _importer._get_module("moves.urllib_response") |
|
479 |
- robotparser = _importer._get_module("moves.urllib_robotparser") |
|
480 |
- |
|
481 |
- def __dir__(self): |
|
482 |
- return ['parse', 'error', 'request', 'response', 'robotparser'] |
|
483 |
- |
|
484 |
-_importer._add_module(Module_six_moves_urllib(__name__ + ".moves.urllib"), |
|
485 |
- "moves.urllib") |
|
486 |
- |
|
487 |
- |
|
488 |
-def add_move(move): |
|
489 |
- """Add an item to six.moves.""" |
|
490 |
- setattr(_MovedItems, move.name, move) |
|
491 |
- |
|
492 |
- |
|
493 |
-def remove_move(name): |
|
494 |
- """Remove item from six.moves.""" |
|
495 |
- try: |
|
496 |
- delattr(_MovedItems, name) |
|
497 |
- except AttributeError: |
|
498 |
- try: |
|
499 |
- del moves.__dict__[name] |
|
500 |
- except KeyError: |
|
501 |
- raise AttributeError("no such move, %r" % (name,)) |
|
502 |
- |
|
503 |
- |
|
504 |
-if PY3: |
|
505 |
- _meth_func = "__func__" |
|
506 |
- _meth_self = "__self__" |
|
507 |
- |
|
508 |
- _func_closure = "__closure__" |
|
509 |
- _func_code = "__code__" |
|
510 |
- _func_defaults = "__defaults__" |
|
511 |
- _func_globals = "__globals__" |
|
512 |
-else: |
|
513 |
- _meth_func = "im_func" |
|
514 |
- _meth_self = "im_self" |
|
515 |
- |
|
516 |
- _func_closure = "func_closure" |
|
517 |
- _func_code = "func_code" |
|
518 |
- _func_defaults = "func_defaults" |
|
519 |
- _func_globals = "func_globals" |
|
520 |
- |
|
521 |
- |
|
522 |
-try: |
|
523 |
- advance_iterator = next |
|
524 |
-except NameError: |
|
525 |
- def advance_iterator(it): |
|
526 |
- return it.next() |
|
527 |
-next = advance_iterator |
|
528 |
- |
|
529 |
- |
|
530 |
-try: |
|
531 |
- callable = callable |
|
532 |
-except NameError: |
|
533 |
- def callable(obj): |
|
534 |
- return any("__call__" in klass.__dict__ for klass in type(obj).__mro__) |
|
535 |
- |
|
536 |
- |
|
537 |
-if PY3: |
|
538 |
- def get_unbound_function(unbound): |
|
539 |
- return unbound |
|
540 |
- |
|
541 |
- create_bound_method = types.MethodType |
|
542 |
- |
|
543 |
- def create_unbound_method(func, cls): |
|
544 |
- return func |
|
545 |
- |
|
546 |
- Iterator = object |
|
547 |
-else: |
|
548 |
- def get_unbound_function(unbound): |
|
549 |
- return unbound.im_func |
|
550 |
- |
|
551 |
- def create_bound_method(func, obj): |
|
552 |
- return types.MethodType(func, obj, obj.__class__) |
|
553 |
- |
|
554 |
- def create_unbound_method(func, cls): |
|
555 |
- return types.MethodType(func, None, cls) |
|
556 |
- |
|
557 |
- class Iterator(object): |
|
558 |
- |
|
559 |
- def next(self): |
|
560 |
- return type(self).__next__(self) |
|
561 |
- |
|
562 |
- callable = callable |
|
563 |
-_add_doc(get_unbound_function, |
|
564 |
- """Get the function out of a possibly unbound function""") |
|
565 |
- |
|
566 |
- |
|
567 |
-get_method_function = operator.attrgetter(_meth_func) |
|
568 |
-get_method_self = operator.attrgetter(_meth_self) |
|
569 |
-get_function_closure = operator.attrgetter(_func_closure) |
|
570 |
-get_function_code = operator.attrgetter(_func_code) |
|
571 |
-get_function_defaults = operator.attrgetter(_func_defaults) |
|
572 |
-get_function_globals = operator.attrgetter(_func_globals) |
|
573 |
- |
|
574 |
- |
|
575 |
-if PY3: |
|
576 |
- def iterkeys(d, **kw): |
|
577 |
- return iter(d.keys(**kw)) |
|
578 |
- |
|
579 |
- def itervalues(d, **kw): |
|
580 |
- return iter(d.values(**kw)) |
|
581 |
- |
|
582 |
- def iteritems(d, **kw): |
|
583 |
- return iter(d.items(**kw)) |
|
584 |
- |
|
585 |
- def iterlists(d, **kw): |
|
586 |
- return iter(d.lists(**kw)) |
|
587 |
- |
|
588 |
- viewkeys = operator.methodcaller("keys") |
|
589 |
- |
|
590 |
- viewvalues = operator.methodcaller("values") |
|
591 |
- |
|
592 |
- viewitems = operator.methodcaller("items") |
|
593 |
-else: |
|
594 |
- def iterkeys(d, **kw): |
|
595 |
- return d.iterkeys(**kw) |
|
596 |
- |
|
597 |
- def itervalues(d, **kw): |
|
598 |
- return d.itervalues(**kw) |
|
599 |
- |
|
600 |
- def iteritems(d, **kw): |
|
601 |
- return d.iteritems(**kw) |
|
602 |
- |
|
603 |
- def iterlists(d, **kw): |
|
604 |
- return d.iterlists(**kw) |
|
605 |
- |
|
606 |
- viewkeys = operator.methodcaller("viewkeys") |
|
607 |
- |
|
608 |
- viewvalues = operator.methodcaller("viewvalues") |
|
609 |
- |
|
610 |
- viewitems = operator.methodcaller("viewitems") |
|
611 |
- |
|
612 |
-_add_doc(iterkeys, "Return an iterator over the keys of a dictionary.") |
|
613 |
-_add_doc(itervalues, "Return an iterator over the values of a dictionary.") |
|
614 |
-_add_doc(iteritems, |
|
615 |
- "Return an iterator over the (key, value) pairs of a dictionary.") |
|
616 |
-_add_doc(iterlists, |
|
617 |
- "Return an iterator over the (key, [values]) pairs of a dictionary.") |
|
618 |
- |
|
619 |
- |
|
620 |
-if PY3: |
|
621 |
- def b(s): |
|
622 |
- return s.encode("latin-1") |
|
623 |
- |
|
624 |
- def u(s): |
|
625 |
- return s |
|
626 |
- unichr = chr |
|
627 |
- import struct |
|
628 |
- int2byte = struct.Struct(">B").pack |
|
629 |
- del struct |
|
630 |
- byte2int = operator.itemgetter(0) |
|
631 |
- indexbytes = operator.getitem |
|
632 |
- iterbytes = iter |
|
633 |
- import io |
|
634 |
- StringIO = io.StringIO |
|
635 |
- BytesIO = io.BytesIO |
|
636 |
- _assertCountEqual = "assertCountEqual" |
|
637 |
- if sys.version_info[1] <= 1: |
|
638 |
- _assertRaisesRegex = "assertRaisesRegexp" |
|
639 |
- _assertRegex = "assertRegexpMatches" |
|
640 |
- else: |
|
641 |
- _assertRaisesRegex = "assertRaisesRegex" |
|
642 |
- _assertRegex = "assertRegex" |
|
643 |
-else: |
|
644 |
- def b(s): |
|
645 |
- return s |
|
646 |
- # Workaround for standalone backslash |
|
647 |
- |
|
648 |
- def u(s): |
|
649 |
- return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape") |
|
650 |
- unichr = unichr |
|
651 |
- int2byte = chr |
|
652 |
- |
|
653 |
- def byte2int(bs): |
|
654 |
- return ord(bs[0]) |
|
655 |
- |
|
656 |
- def indexbytes(buf, i): |
|
657 |
- return ord(buf[i]) |
|
658 |
- iterbytes = functools.partial(itertools.imap, ord) |
|
659 |
- import StringIO |
|
660 |
- StringIO = BytesIO = StringIO.StringIO |
|
661 |
- _assertCountEqual = "assertItemsEqual" |
|
662 |
- _assertRaisesRegex = "assertRaisesRegexp" |
|
663 |
- _assertRegex = "assertRegexpMatches" |
|
664 |
-_add_doc(b, """Byte literal""") |
|
665 |
-_add_doc(u, """Text literal""") |
|
666 |
- |
|
667 |
- |
|
668 |
-def assertCountEqual(self, *args, **kwargs): |
|
669 |
- return getattr(self, _assertCountEqual)(*args, **kwargs) |
|
670 |
- |
|
671 |
- |
|
672 |
-def assertRaisesRegex(self, *args, **kwargs): |
|
673 |
- return getattr(self, _assertRaisesRegex)(*args, **kwargs) |
|
674 |
- |
|
675 |
- |
|
676 |
-def assertRegex(self, *args, **kwargs): |
|
677 |
- return getattr(self, _assertRegex)(*args, **kwargs) |
|
678 |
- |
|
679 |
- |
|
680 |
-if PY3: |
|
681 |
- exec_ = getattr(moves.builtins, "exec") |
|
682 |
- |
|
683 |
- def reraise(tp, value, tb=None): |
|
684 |
- if value is None: |
|
685 |
- value = tp() |
|
686 |
- if value.__traceback__ is not tb: |
|
687 |
- raise value.with_traceback(tb) |
|
688 |
- raise value |
|
689 |
- |
|
690 |
-else: |
|
691 |
- def exec_(_code_, _globs_=None, _locs_=None): |
|
692 |
- """Execute code in a namespace.""" |
|
693 |
- if _globs_ is None: |
|
694 |
- frame = sys._getframe(1) |
|
695 |
- _globs_ = frame.f_globals |
|
696 |
- if _locs_ is None: |
|
697 |
- _locs_ = frame.f_locals |
|
698 |
- del frame |
|
699 |
- elif _locs_ is None: |
|
700 |
- _locs_ = _globs_ |
|
701 |
- exec("""exec _code_ in _globs_, _locs_""") |
|
702 |
- |
|
703 |
- exec_("""def reraise(tp, value, tb=None): |
|
704 |
- raise tp, value, tb |
|
705 |
-""") |
|
706 |
- |
|
707 |
- |
|
708 |
-if sys.version_info[:2] == (3, 2): |
|
709 |
- exec_("""def raise_from(value, from_value): |
|
710 |
- if from_value is None: |
|
711 |
- raise value |
|
712 |
- raise value from from_value |
|
713 |
-""") |
|
714 |
-elif sys.version_info[:2] > (3, 2): |
|
715 |
- exec_("""def raise_from(value, from_value): |
|
716 |
- raise value from from_value |
|
717 |
-""") |
|
718 |
-else: |
|
719 |
- def raise_from(value, from_value): |
|
720 |
- raise value |
|
721 |
- |
|
722 |
- |
|
723 |
-print_ = getattr(moves.builtins, "print", None) |
|
724 |
-if print_ is None: |
|
725 |
- def print_(*args, **kwargs): |
|
726 |
- """The new-style print function for Python 2.4 and 2.5.""" |
|
727 |
- fp = kwargs.pop("file", sys.stdout) |
|
728 |
- if fp is None: |
|
729 |
- return |
|
730 |
- |
|
731 |
- def write(data): |
|
732 |
- if not isinstance(data, basestring): |
|
733 |
- data = str(data) |
|
734 |
- # If the file has an encoding, encode unicode with it. |
|
735 |
- if (isinstance(fp, file) and |
|
736 |
- isinstance(data, unicode) and |
|
737 |
- fp.encoding is not None): |
|
738 |
- errors = getattr(fp, "errors", None) |
|
739 |
- if errors is None: |
|
740 |
- errors = "strict" |
|
741 |
- data = data.encode(fp.encoding, errors) |
|
742 |
- fp.write(data) |
|
743 |
- want_unicode = False |
|
744 |
- sep = kwargs.pop("sep", None) |
|
745 |
- if sep is not None: |
|
746 |
- if isinstance(sep, unicode): |
|
747 |
- want_unicode = True |
|
748 |
- elif not isinstance(sep, str): |
|
749 |
- raise TypeError("sep must be None or a string") |
|
750 |
- end = kwargs.pop("end", None) |
|
751 |
- if end is not None: |
|
752 |
- if isinstance(end, unicode): |
|
753 |
- want_unicode = True |
|
754 |
- elif not isinstance(end, str): |
|
755 |
- raise TypeError("end must be None or a string") |
|
756 |
- if kwargs: |
|
757 |
- raise TypeError("invalid keyword arguments to print()") |
|
758 |
- if not want_unicode: |
|
759 |
- for arg in args: |
|
760 |
- if isinstance(arg, unicode): |
|
761 |
- want_unicode = True |
|
762 |
- break |
|
763 |
- if want_unicode: |
|
764 |
- newline = unicode("\n") |
|
765 |
- space = unicode(" ") |
|
766 |
- else: |
|
767 |
- newline = "\n" |
|
768 |
- space = " " |
|
769 |
- if sep is None: |
|
770 |
- sep = space |
|
771 |
- if end is None: |
|
772 |
- end = newline |
|
773 |
- for i, arg in enumerate(args): |
|
774 |
- if i: |
|
775 |
- write(sep) |
|
776 |
- write(arg) |
|
777 |
- write(end) |
|
778 |
-if sys.version_info[:2] < (3, 3): |
|
779 |
- _print = print_ |
|
780 |
- |
|
781 |
- def print_(*args, **kwargs): |
|
782 |
- fp = kwargs.get("file", sys.stdout) |
|
783 |
- flush = kwargs.pop("flush", False) |
|
784 |
- _print(*args, **kwargs) |
|
785 |
- if flush and fp is not None: |
|
786 |
- fp.flush() |
|
787 |
- |
|
788 |
-_add_doc(reraise, """Reraise an exception.""") |
|
789 |
- |
|
790 |
-if sys.version_info[0:2] < (3, 4): |
|
791 |
- def wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS, |
|
792 |
- updated=functools.WRAPPER_UPDATES): |
|
793 |
- def wrapper(f): |
|
794 |
- f = functools.wraps(wrapped, assigned, updated)(f) |
|
795 |
- f.__wrapped__ = wrapped |
|
796 |
- return f |
|
797 |
- return wrapper |
|
798 |
-else: |
|
799 |
- wraps = functools.wraps |
|
800 |
- |
|
801 |
- |
|
802 |
-def with_metaclass(meta, *bases): |
|
803 |
- """Create a base class with a metaclass.""" |
|
804 |
- # This requires a bit of explanation: the basic idea is to make a dummy |
|
805 |
- # metaclass for one level of class instantiation that replaces itself with |
|
806 |
- # the actual metaclass. |
|
807 |
- class metaclass(meta): |
|
808 |
- |
|
809 |
- def __new__(cls, name, this_bases, d): |
|
810 |
- return meta(name, bases, d) |
|
811 |
- return type.__new__(metaclass, 'temporary_class', (), {}) |
|
812 |
- |
|
813 |
- |
|
814 |
-def add_metaclass(metaclass): |
|
815 |
- """Class decorator for creating a class with a metaclass.""" |
|
816 |
- def wrapper(cls): |
|
817 |
- orig_vars = cls.__dict__.copy() |
|
818 |
- slots = orig_vars.get('__slots__') |
|
819 |
- if slots is not None: |
|
820 |
- if isinstance(slots, str): |
|
821 |
- slots = [slots] |
|
822 |
- for slots_var in slots: |
|
823 |
- orig_vars.pop(slots_var) |
|
824 |
- orig_vars.pop('__dict__', None) |
|
825 |
- orig_vars.pop('__weakref__', None) |
|
826 |
- return metaclass(cls.__name__, cls.__bases__, orig_vars) |
|
827 |
- return wrapper |
|
828 |
- |
|
829 |
- |
|
830 |
-def python_2_unicode_compatible(klass): |
|
831 |
- """ |
|
832 |
- A decorator that defines __unicode__ and __str__ methods under Python 2. |
|
833 |
- Under Python 3 it does nothing. |
|
834 |
- |
|
835 |
- To support Python 2 and 3 with a single code base, define a __str__ method |
|
836 |
- returning text and apply this decorator to the class. |
|
837 |
- """ |
|
838 |
- if PY2: |
|
839 |
- if '__str__' not in klass.__dict__: |
|
840 |
- raise ValueError("@python_2_unicode_compatible cannot be applied " |
|
841 |
- "to %s because it doesn't define __str__()." % |
|
842 |
- klass.__name__) |
|
843 |
- klass.__unicode__ = klass.__str__ |
|
844 |
- klass.__str__ = lambda self: self.__unicode__().encode('utf-8') |
|
845 |
- return klass |
|
846 |
- |
|
847 |
- |
|
848 |
-# Complete the moves implementation. |
|
849 |
-# This code is at the end of this module to speed up module loading. |
|
850 |
-# Turn this module into a package. |
|
851 |
-__path__ = [] # required for PEP 302 and PEP 451 |
|
852 |
-__package__ = __name__ # see PEP 366 @ReservedAssignment |
|
853 |
-if globals().get("__spec__") is not None: |
|
854 |
- __spec__.submodule_search_locations = [] # PEP 451 @UndefinedVariable |
|
855 |
-# Remove other six meta path importers, since they cause problems. This can |
|
856 |
-# happen if six is removed from sys.modules and then reloaded. (Setuptools does |
|
857 |
-# this for some reason.) |
|
858 |
-if sys.meta_path: |
|
859 |
- for i, importer in enumerate(sys.meta_path): |
|
860 |
- # Here's some real nastiness: Another "instance" of the six module might |
|
861 |
- # be floating around. Therefore, we can't use isinstance() to check for |
|
862 |
- # the six meta path importer, since the other six instance will have |
|
863 |
- # inserted an importer with different class. |
|
864 |
- if (type(importer).__name__ == "_SixMetaPathImporter" and |
|
865 |
- importer.name == __name__): |
|
866 |
- del sys.meta_path[i] |
|
867 |
- break |
|
868 |
- del i, importer |
|
869 |
-# Finally, add the importer to the meta path import hook. |
|
870 |
-sys.meta_path.append(_importer) |
... | ... |
@@ -23,9 +23,9 @@ import os |
23 | 23 |
import tempfile |
24 | 24 |
from string import ascii_letters, digits |
25 | 25 |
|
26 |
-from ansible.compat.six import string_types |
|
27 |
-from ansible.compat.six.moves import configparser |
|
28 | 26 |
from ansible.errors import AnsibleOptionsError |
27 |
+from ansible.module_utils.six import string_types |
|
28 |
+from ansible.module_utils.six.moves import configparser |
|
29 | 29 |
from ansible.module_utils._text import to_text |
30 | 30 |
from ansible.parsing.quoting import unquote |
31 | 31 |
from ansible.utils.path import makedirs_safe |
... | ... |
@@ -406,7 +406,11 @@ class ModuleDepFinder(ast.NodeVisitor): |
406 | 406 |
self.generic_visit(node) |
407 | 407 |
|
408 | 408 |
def visit_ImportFrom(self, node): |
409 |
- if node.module.startswith('ansible.module_utils'): |
|
409 |
+ # Specialcase: six is a special case because of its |
|
410 |
+ # import logic |
|
411 |
+ if node.names[0].name == '_six': |
|
412 |
+ self.submodules.add(('_six',)) |
|
413 |
+ elif node.module.startswith('ansible.module_utils'): |
|
410 | 414 |
where_from = node.module[self.IMPORT_PREFIX_SIZE:] |
411 | 415 |
if where_from: |
412 | 416 |
# from ansible.module_utils.MODULE1[.MODULEn] import IDENTIFIER [as asname] |
... | ... |
@@ -484,6 +488,12 @@ def recursive_finder(name, data, py_module_names, py_module_cache, zf): |
484 | 484 |
module_info = imp.find_module('six', module_utils_paths) |
485 | 485 |
py_module_name = ('six',) |
486 | 486 |
idx = 0 |
487 |
+ elif py_module_name[0] == '_six': |
|
488 |
+ # Special case the python six library because it messes up the |
|
489 |
+ # import process in an incompatible way |
|
490 |
+ module_info = imp.find_module('_six', [os.path.join(p, 'six') for p in module_utils_paths]) |
|
491 |
+ py_module_name = ('six', '_six') |
|
492 |
+ idx = 0 |
|
487 | 493 |
else: |
488 | 494 |
# Check whether either the last or the second to last identifier is |
489 | 495 |
# a module name |
... | ... |
@@ -499,7 +509,7 @@ def recursive_finder(name, data, py_module_names, py_module_cache, zf): |
499 | 499 |
|
500 | 500 |
# Could not find the module. Construct a helpful error message. |
501 | 501 |
if module_info is None: |
502 |
- msg = ['Could not find imported module support code for %s. Looked for' % name] |
|
502 |
+ msg = ['Could not find imported module support code for %s. Looked for' % (name,)] |
|
503 | 503 |
if idx == 2: |
504 | 504 |
msg.append('either %s.py or %s.py' % (py_module_name[-1], py_module_name[-2])) |
505 | 505 |
else: |
... | ... |
@@ -21,14 +21,14 @@ __metaclass__ = type |
21 | 21 |
|
22 | 22 |
import fnmatch |
23 | 23 |
|
24 |
-from ansible.compat.six import iteritems |
|
25 | 24 |
from ansible import constants as C |
26 | 25 |
from ansible.errors import AnsibleError |
27 |
-from ansible.module_utils.six import cmp |
|
26 |
+from ansible.module_utils.six import iteritems |
|
28 | 27 |
from ansible.playbook.block import Block |
29 | 28 |
from ansible.playbook.task import Task |
30 | 29 |
from ansible.playbook.role_include import IncludeRole |
31 | 30 |
|
31 |
+ |
|
32 | 32 |
boolean = C.mk_boolean |
33 | 33 |
|
34 | 34 |
__all__ = ['PlayIterator'] |
... | ... |
@@ -24,11 +24,10 @@ import sys |
24 | 24 |
import time |
25 | 25 |
import traceback |
26 | 26 |
|
27 |
-from ansible.compat.six import iteritems, string_types, binary_type |
|
28 |
- |
|
29 | 27 |
from ansible import constants as C |
30 | 28 |
from ansible.errors import AnsibleError, AnsibleParserError, AnsibleUndefinedVariable, AnsibleConnectionFailure |
31 | 29 |
from ansible.executor.task_result import TaskResult |
30 |
+from ansible.module_utils.six import iteritems, string_types, binary_type |
|
32 | 31 |
from ansible.module_utils._text import to_text |
33 | 32 |
from ansible.playbook.conditional import Conditional |
34 | 33 |
from ansible.playbook.task import Task |
... | ... |
@@ -44,6 +43,7 @@ except ImportError: |
44 | 44 |
from ansible.utils.display import Display |
45 | 45 |
display = Display() |
46 | 46 |
|
47 |
+ |
|
47 | 48 |
__all__ = ['TaskExecutor'] |
48 | 49 |
|
49 | 50 |
|
... | ... |
@@ -24,10 +24,10 @@ import os |
24 | 24 |
import tempfile |
25 | 25 |
|
26 | 26 |
from ansible import constants as C |
27 |
-from ansible.compat.six import string_types |
|
28 | 27 |
from ansible.errors import AnsibleError |
29 | 28 |
from ansible.executor.play_iterator import PlayIterator |
30 | 29 |
from ansible.executor.stats import AggregateStats |
30 |
+from ansible.module_utils.six import string_types |
|
31 | 31 |
from ansible.module_utils._text import to_text |
32 | 32 |
from ansible.playbook.block import Block |
33 | 33 |
from ansible.playbook.play_context import PlayContext |
... | ... |
@@ -44,6 +44,7 @@ except ImportError: |
44 | 44 |
from ansible.utils.display import Display |
45 | 45 |
display = Display() |
46 | 46 |
|
47 |
+ |
|
47 | 48 |
__all__ = ['TaskQueueManager'] |
48 | 49 |
|
49 | 50 |
|
... | ... |
@@ -25,11 +25,11 @@ __metaclass__ = type |
25 | 25 |
import json |
26 | 26 |
|
27 | 27 |
import ansible.constants as C |
28 |
-from ansible.compat.six import string_types |
|
29 |
-from ansible.compat.six.moves.urllib.error import HTTPError |
|
30 |
-from ansible.compat.six.moves.urllib.parse import quote as urlquote, urlencode |
|
31 | 28 |
from ansible.errors import AnsibleError |
32 | 29 |
from ansible.galaxy.token import GalaxyToken |
30 |
+from ansible.module_utils.six import string_types |
|
31 |
+from ansible.module_utils.six.moves.urllib.error import HTTPError |
|
32 |
+from ansible.module_utils.six.moves.urllib.parse import quote as urlquote, urlencode |
|
33 | 33 |
from ansible.module_utils._text import to_native, to_text |
34 | 34 |
from ansible.module_utils.urls import open_url |
35 | 35 |
|
... | ... |
@@ -25,10 +25,9 @@ __metaclass__ = type |
25 | 25 |
import getpass |
26 | 26 |
import json |
27 | 27 |
|
28 |
-from ansible.compat.six.moves.urllib.parse import quote as urlquote, urlparse |
|
29 |
-from ansible.compat.six.moves.urllib.error import HTTPError |
|
30 |
- |
|
31 | 28 |
from ansible.errors import AnsibleError, AnsibleOptionsError |
29 |
+from ansible.module_utils.six.moves.urllib.parse import quote as urlquote, urlparse |
|
30 |
+from ansible.module_utils.six.moves.urllib.error import HTTPError |
|
32 | 31 |
from ansible.module_utils.urls import open_url |
33 | 32 |
from ansible.utils.color import stringc |
34 | 33 |
|
... | ... |
@@ -38,6 +37,7 @@ except ImportError: |
38 | 38 |
from ansible.utils.display import Display |
39 | 39 |
display = Display() |
40 | 40 |
|
41 |
+ |
|
41 | 42 |
class GalaxyLogin(object): |
42 | 43 |
''' Class to handle authenticating user with Galaxy API prior to performing CUD operations ''' |
43 | 44 |
|
... | ... |
@@ -26,14 +26,13 @@ import sys |
26 | 26 |
import re |
27 | 27 |
import itertools |
28 | 28 |
|
29 |
-from ansible.compat.six import string_types, iteritems |
|
30 | 29 |
|
31 | 30 |
from ansible import constants as C |
32 | 31 |
from ansible.errors import AnsibleError |
33 |
- |
|
34 | 32 |
from ansible.inventory.dir import InventoryDirectory, get_file_parser |
35 | 33 |
from ansible.inventory.group import Group |
36 | 34 |
from ansible.inventory.host import Host |
35 |
+from ansible.module_utils.six import string_types, iteritems |
|
37 | 36 |
from ansible.module_utils._text import to_bytes, to_text |
38 | 37 |
from ansible.parsing.utils.addresses import parse_address |
39 | 38 |
from ansible.plugins import vars_loader |
... | ... |
@@ -24,13 +24,12 @@ import subprocess |
24 | 24 |
import sys |
25 | 25 |
from collections import Mapping |
26 | 26 |
|
27 |
-from ansible.compat.six import iteritems |
|
28 |
- |
|
29 | 27 |
from ansible import constants as C |
30 | 28 |
from ansible.errors import AnsibleError |
31 | 29 |
from ansible.inventory.host import Host |
32 | 30 |
from ansible.inventory.group import Group |
33 | 31 |
from ansible.module_utils.basic import json_dict_bytes_to_unicode |
32 |
+from ansible.module_utils.six import iteritems |
|
34 | 33 |
from ansible.module_utils._text import to_native, to_text |
35 | 34 |
|
36 | 35 |
|
... | ... |
@@ -26,8 +26,9 @@ from ansible.inventory.host import Host |
26 | 26 |
from ansible.inventory.group import Group |
27 | 27 |
from ansible.inventory.expand_hosts import detect_range |
28 | 28 |
from ansible.inventory.expand_hosts import expand_hostname_range |
29 |
+from ansible.module_utils.six import string_types |
|
29 | 30 |
from ansible.parsing.utils.addresses import parse_address |
30 |
-from ansible.compat.six import string_types |
|
31 |
+ |
|
31 | 32 |
|
32 | 33 |
class InventoryParser(object): |
33 | 34 |
""" |
34 | 35 |
deleted file mode 100644 |
... | ... |
@@ -1,579 +0,0 @@ |
1 |
-"""Utilities for writing code that runs on Python 2 and 3""" |
|
2 |
- |
|
3 |
-# Copyright (c) 2010-2013 Benjamin Peterson |
|
4 |
-# |
|
5 |
-# Permission is hereby granted, free of charge, to any person obtaining a copy |
|
6 |
-# of this software and associated documentation files (the "Software"), to deal |
|
7 |
-# in the Software without restriction, including without limitation the rights |
|
8 |
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
9 |
-# copies of the Software, and to permit persons to whom the Software is |
|
10 |
-# furnished to do so, subject to the following conditions: |
|
11 |
-# |
|
12 |
-# The above copyright notice and this permission notice shall be included in all |
|
13 |
-# copies or substantial portions of the Software. |
|
14 |
-# |
|
15 |
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
16 |
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
17 |
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
18 |
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
19 |
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
20 |
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
21 |
-# SOFTWARE. |
|
22 |
- |
|
23 |
-import operator |
|
24 |
-import sys |
|
25 |
-import types |
|
26 |
- |
|
27 |
-__author__ = "Benjamin Peterson <benjamin@python.org>" |
|
28 |
-__version__ = "1.4.1" |
|
29 |
- |
|
30 |
- |
|
31 |
-# Useful for very coarse version differentiation. |
|
32 |
-PY2 = sys.version_info[0] == 2 |
|
33 |
-PY3 = sys.version_info[0] == 3 |
|
34 |
- |
|
35 |
-if PY3: |
|
36 |
- string_types = str, |
|
37 |
- integer_types = int, |
|
38 |
- class_types = type, |
|
39 |
- text_type = str |
|
40 |
- binary_type = bytes |
|
41 |
- cmp = lambda a, b: (a > b) - (a < b) |
|
42 |
- |
|
43 |
- MAXSIZE = sys.maxsize |
|
44 |
-else: |
|
45 |
- string_types = basestring, |
|
46 |
- integer_types = (int, long) |
|
47 |
- class_types = (type, types.ClassType) |
|
48 |
- text_type = unicode |
|
49 |
- binary_type = str |
|
50 |
- cmp = cmp |
|
51 |
- |
|
52 |
- if sys.platform.startswith("java"): |
|
53 |
- # Jython always uses 32 bits. |
|
54 |
- MAXSIZE = int((1 << 31) - 1) |
|
55 |
- else: |
|
56 |
- # It's possible to have sizeof(long) != sizeof(Py_ssize_t). |
|
57 |
- class X(object): |
|
58 |
- def __len__(self): |
|
59 |
- return 1 << 31 |
|
60 |
- try: |
|
61 |
- len(X()) |
|
62 |
- except OverflowError: |
|
63 |
- # 32-bit |
|
64 |
- MAXSIZE = int((1 << 31) - 1) |
|
65 |
- else: |
|
66 |
- # 64-bit |
|
67 |
- MAXSIZE = int((1 << 63) - 1) |
|
68 |
- del X |
|
69 |
- |
|
70 |
- |
|
71 |
-def _add_doc(func, doc): |
|
72 |
- """Add documentation to a function.""" |
|
73 |
- func.__doc__ = doc |
|
74 |
- |
|
75 |
- |
|
76 |
-def _import_module(name): |
|
77 |
- """Import module, returning the module after the last dot.""" |
|
78 |
- __import__(name) |
|
79 |
- return sys.modules[name] |
|
80 |
- |
|
81 |
- |
|
82 |
-class _LazyDescr(object): |
|
83 |
- |
|
84 |
- def __init__(self, name): |
|
85 |
- self.name = name |
|
86 |
- |
|
87 |
- def __get__(self, obj, tp): |
|
88 |
- result = self._resolve() |
|
89 |
- setattr(obj, self.name, result) |
|
90 |
- # This is a bit ugly, but it avoids running this again. |
|
91 |
- delattr(tp, self.name) |
|
92 |
- return result |
|
93 |
- |
|
94 |
- |
|
95 |
-class MovedModule(_LazyDescr): |
|
96 |
- |
|
97 |
- def __init__(self, name, old, new=None): |
|
98 |
- super(MovedModule, self).__init__(name) |
|
99 |
- if PY3: |
|
100 |
- if new is None: |
|
101 |
- new = name |
|
102 |
- self.mod = new |
|
103 |
- else: |
|
104 |
- self.mod = old |
|
105 |
- |
|
106 |
- def _resolve(self): |
|
107 |
- return _import_module(self.mod) |
|
108 |
- |
|
109 |
- |
|
110 |
-class MovedAttribute(_LazyDescr): |
|
111 |
- |
|
112 |
- def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None): |
|
113 |
- super(MovedAttribute, self).__init__(name) |
|
114 |
- if PY3: |
|
115 |
- if new_mod is None: |
|
116 |
- new_mod = name |
|
117 |
- self.mod = new_mod |
|
118 |
- if new_attr is None: |
|
119 |
- if old_attr is None: |
|
120 |
- new_attr = name |
|
121 |
- else: |
|
122 |
- new_attr = old_attr |
|
123 |
- self.attr = new_attr |
|
124 |
- else: |
|
125 |
- self.mod = old_mod |
|
126 |
- if old_attr is None: |
|
127 |
- old_attr = name |
|
128 |
- self.attr = old_attr |
|
129 |
- |
|
130 |
- def _resolve(self): |
|
131 |
- module = _import_module(self.mod) |
|
132 |
- return getattr(module, self.attr) |
|
133 |
- |
|
134 |
- |
|
135 |
- |
|
136 |
-class _MovedItems(types.ModuleType): |
|
137 |
- """Lazy loading of moved objects""" |
|
138 |
- |
|
139 |
- |
|
140 |
-_moved_attributes = [ |
|
141 |
- MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"), |
|
142 |
- MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"), |
|
143 |
- MovedAttribute("filterfalse", "itertools", "itertools", "ifilterfalse", "filterfalse"), |
|
144 |
- MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"), |
|
145 |
- MovedAttribute("map", "itertools", "builtins", "imap", "map"), |
|
146 |
- MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"), |
|
147 |
- MovedAttribute("reload_module", "__builtin__", "imp", "reload"), |
|
148 |
- MovedAttribute("reduce", "__builtin__", "functools"), |
|
149 |
- MovedAttribute("StringIO", "StringIO", "io"), |
|
150 |
- MovedAttribute("UserString", "UserString", "collections"), |
|
151 |
- MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"), |
|
152 |
- MovedAttribute("zip", "itertools", "builtins", "izip", "zip"), |
|
153 |
- MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"), |
|
154 |
- |
|
155 |
- MovedModule("builtins", "__builtin__"), |
|
156 |
- MovedModule("configparser", "ConfigParser"), |
|
157 |
- MovedModule("copyreg", "copy_reg"), |
|
158 |
- MovedModule("http_cookiejar", "cookielib", "http.cookiejar"), |
|
159 |
- MovedModule("http_cookies", "Cookie", "http.cookies"), |
|
160 |
- MovedModule("html_entities", "htmlentitydefs", "html.entities"), |
|
161 |
- MovedModule("html_parser", "HTMLParser", "html.parser"), |
|
162 |
- MovedModule("http_client", "httplib", "http.client"), |
|
163 |
- MovedModule("email_mime_multipart", "email.MIMEMultipart", "email.mime.multipart"), |
|
164 |
- MovedModule("email_mime_text", "email.MIMEText", "email.mime.text"), |
|
165 |
- MovedModule("email_mime_base", "email.MIMEBase", "email.mime.base"), |
|
166 |
- MovedModule("BaseHTTPServer", "BaseHTTPServer", "http.server"), |
|
167 |
- MovedModule("CGIHTTPServer", "CGIHTTPServer", "http.server"), |
|
168 |
- MovedModule("SimpleHTTPServer", "SimpleHTTPServer", "http.server"), |
|
169 |
- MovedModule("cPickle", "cPickle", "pickle"), |
|
170 |
- MovedModule("queue", "Queue"), |
|
171 |
- MovedModule("reprlib", "repr"), |
|
172 |
- MovedModule("socketserver", "SocketServer"), |
|
173 |
- MovedModule("tkinter", "Tkinter"), |
|
174 |
- MovedModule("tkinter_dialog", "Dialog", "tkinter.dialog"), |
|
175 |
- MovedModule("tkinter_filedialog", "FileDialog", "tkinter.filedialog"), |
|
176 |
- MovedModule("tkinter_scrolledtext", "ScrolledText", "tkinter.scrolledtext"), |
|
177 |
- MovedModule("tkinter_simpledialog", "SimpleDialog", "tkinter.simpledialog"), |
|
178 |
- MovedModule("tkinter_tix", "Tix", "tkinter.tix"), |
|
179 |
- MovedModule("tkinter_constants", "Tkconstants", "tkinter.constants"), |
|
180 |
- MovedModule("tkinter_dnd", "Tkdnd", "tkinter.dnd"), |
|
181 |
- MovedModule("tkinter_colorchooser", "tkColorChooser", |
|
182 |
- "tkinter.colorchooser"), |
|
183 |
- MovedModule("tkinter_commondialog", "tkCommonDialog", |
|
184 |
- "tkinter.commondialog"), |
|
185 |
- MovedModule("tkinter_tkfiledialog", "tkFileDialog", "tkinter.filedialog"), |
|
186 |
- MovedModule("tkinter_font", "tkFont", "tkinter.font"), |
|
187 |
- MovedModule("tkinter_messagebox", "tkMessageBox", "tkinter.messagebox"), |
|
188 |
- MovedModule("tkinter_tksimpledialog", "tkSimpleDialog", |
|
189 |
- "tkinter.simpledialog"), |
|
190 |
- MovedModule("urllib_parse", __name__ + ".moves.urllib_parse", "urllib.parse"), |
|
191 |
- MovedModule("urllib_error", __name__ + ".moves.urllib_error", "urllib.error"), |
|
192 |
- MovedModule("urllib", __name__ + ".moves.urllib", __name__ + ".moves.urllib"), |
|
193 |
- MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"), |
|
194 |
- MovedModule("winreg", "_winreg"), |
|
195 |
-] |
|
196 |
-for attr in _moved_attributes: |
|
197 |
- setattr(_MovedItems, attr.name, attr) |
|
198 |
-del attr |
|
199 |
- |
|
200 |
-moves = sys.modules[__name__ + ".moves"] = _MovedItems(__name__ + ".moves") |
|
201 |
- |
|
202 |
- |
|
203 |
- |
|
204 |
-class Module_six_moves_urllib_parse(types.ModuleType): |
|
205 |
- """Lazy loading of moved objects in six.moves.urllib_parse""" |
|
206 |
- |
|
207 |
- |
|
208 |
-_urllib_parse_moved_attributes = [ |
|
209 |
- MovedAttribute("ParseResult", "urlparse", "urllib.parse"), |
|
210 |
- MovedAttribute("parse_qs", "urlparse", "urllib.parse"), |
|
211 |
- MovedAttribute("parse_qsl", "urlparse", "urllib.parse"), |
|
212 |
- MovedAttribute("urldefrag", "urlparse", "urllib.parse"), |
|
213 |
- MovedAttribute("urljoin", "urlparse", "urllib.parse"), |
|
214 |
- MovedAttribute("urlparse", "urlparse", "urllib.parse"), |
|
215 |
- MovedAttribute("urlsplit", "urlparse", "urllib.parse"), |
|
216 |
- MovedAttribute("urlunparse", "urlparse", "urllib.parse"), |
|
217 |
- MovedAttribute("urlunsplit", "urlparse", "urllib.parse"), |
|
218 |
- MovedAttribute("quote", "urllib", "urllib.parse"), |
|
219 |
- MovedAttribute("quote_plus", "urllib", "urllib.parse"), |
|
220 |
- MovedAttribute("unquote", "urllib", "urllib.parse"), |
|
221 |
- MovedAttribute("unquote_plus", "urllib", "urllib.parse"), |
|
222 |
- MovedAttribute("urlencode", "urllib", "urllib.parse"), |
|
223 |
-] |
|
224 |
-for attr in _urllib_parse_moved_attributes: |
|
225 |
- setattr(Module_six_moves_urllib_parse, attr.name, attr) |
|
226 |
-del attr |
|
227 |
- |
|
228 |
-sys.modules[__name__ + ".moves.urllib_parse"] = Module_six_moves_urllib_parse(__name__ + ".moves.urllib_parse") |
|
229 |
-sys.modules[__name__ + ".moves.urllib.parse"] = Module_six_moves_urllib_parse(__name__ + ".moves.urllib.parse") |
|
230 |
- |
|
231 |
- |
|
232 |
-class Module_six_moves_urllib_error(types.ModuleType): |
|
233 |
- """Lazy loading of moved objects in six.moves.urllib_error""" |
|
234 |
- |
|
235 |
- |
|
236 |
-_urllib_error_moved_attributes = [ |
|
237 |
- MovedAttribute("URLError", "urllib2", "urllib.error"), |
|
238 |
- MovedAttribute("HTTPError", "urllib2", "urllib.error"), |
|
239 |
- MovedAttribute("ContentTooShortError", "urllib", "urllib.error"), |
|
240 |
-] |
|
241 |
-for attr in _urllib_error_moved_attributes: |
|
242 |
- setattr(Module_six_moves_urllib_error, attr.name, attr) |
|
243 |
-del attr |
|
244 |
- |
|
245 |
-sys.modules[__name__ + ".moves.urllib_error"] = Module_six_moves_urllib_error(__name__ + ".moves.urllib_error") |
|
246 |
-sys.modules[__name__ + ".moves.urllib.error"] = Module_six_moves_urllib_error(__name__ + ".moves.urllib.error") |
|
247 |
- |
|
248 |
- |
|
249 |
-class Module_six_moves_urllib_request(types.ModuleType): |
|
250 |
- """Lazy loading of moved objects in six.moves.urllib_request""" |
|
251 |
- |
|
252 |
- |
|
253 |
-_urllib_request_moved_attributes = [ |
|
254 |
- MovedAttribute("urlopen", "urllib2", "urllib.request"), |
|
255 |
- MovedAttribute("install_opener", "urllib2", "urllib.request"), |
|
256 |
- MovedAttribute("build_opener", "urllib2", "urllib.request"), |
|
257 |
- MovedAttribute("pathname2url", "urllib", "urllib.request"), |
|
258 |
- MovedAttribute("url2pathname", "urllib", "urllib.request"), |
|
259 |
- MovedAttribute("getproxies", "urllib", "urllib.request"), |
|
260 |
- MovedAttribute("Request", "urllib2", "urllib.request"), |
|
261 |
- MovedAttribute("OpenerDirector", "urllib2", "urllib.request"), |
|
262 |
- MovedAttribute("HTTPDefaultErrorHandler", "urllib2", "urllib.request"), |
|
263 |
- MovedAttribute("HTTPRedirectHandler", "urllib2", "urllib.request"), |
|
264 |
- MovedAttribute("HTTPCookieProcessor", "urllib2", "urllib.request"), |
|
265 |
- MovedAttribute("ProxyHandler", "urllib2", "urllib.request"), |
|
266 |
- MovedAttribute("BaseHandler", "urllib2", "urllib.request"), |
|
267 |
- MovedAttribute("HTTPPasswordMgr", "urllib2", "urllib.request"), |
|
268 |
- MovedAttribute("HTTPPasswordMgrWithDefaultRealm", "urllib2", "urllib.request"), |
|
269 |
- MovedAttribute("AbstractBasicAuthHandler", "urllib2", "urllib.request"), |
|
270 |
- MovedAttribute("HTTPBasicAuthHandler", "urllib2", "urllib.request"), |
|
271 |
- MovedAttribute("ProxyBasicAuthHandler", "urllib2", "urllib.request"), |
|
272 |
- MovedAttribute("AbstractDigestAuthHandler", "urllib2", "urllib.request"), |
|
273 |
- MovedAttribute("HTTPDigestAuthHandler", "urllib2", "urllib.request"), |
|
274 |
- MovedAttribute("ProxyDigestAuthHandler", "urllib2", "urllib.request"), |
|
275 |
- MovedAttribute("HTTPHandler", "urllib2", "urllib.request"), |
|
276 |
- MovedAttribute("HTTPSHandler", "urllib2", "urllib.request"), |
|
277 |
- MovedAttribute("FileHandler", "urllib2", "urllib.request"), |
|
278 |
- MovedAttribute("FTPHandler", "urllib2", "urllib.request"), |
|
279 |
- MovedAttribute("CacheFTPHandler", "urllib2", "urllib.request"), |
|
280 |
- MovedAttribute("UnknownHandler", "urllib2", "urllib.request"), |
|
281 |
- MovedAttribute("HTTPErrorProcessor", "urllib2", "urllib.request"), |
|
282 |
- MovedAttribute("urlretrieve", "urllib", "urllib.request"), |
|
283 |
- MovedAttribute("urlcleanup", "urllib", "urllib.request"), |
|
284 |
- MovedAttribute("URLopener", "urllib", "urllib.request"), |
|
285 |
- MovedAttribute("FancyURLopener", "urllib", "urllib.request"), |
|
286 |
-] |
|
287 |
-for attr in _urllib_request_moved_attributes: |
|
288 |
- setattr(Module_six_moves_urllib_request, attr.name, attr) |
|
289 |
-del attr |
|
290 |
- |
|
291 |
-sys.modules[__name__ + ".moves.urllib_request"] = Module_six_moves_urllib_request(__name__ + ".moves.urllib_request") |
|
292 |
-sys.modules[__name__ + ".moves.urllib.request"] = Module_six_moves_urllib_request(__name__ + ".moves.urllib.request") |
|
293 |
- |
|
294 |
- |
|
295 |
-class Module_six_moves_urllib_response(types.ModuleType): |
|
296 |
- """Lazy loading of moved objects in six.moves.urllib_response""" |
|
297 |
- |
|
298 |
- |
|
299 |
-_urllib_response_moved_attributes = [ |
|
300 |
- MovedAttribute("addbase", "urllib", "urllib.response"), |
|
301 |
- MovedAttribute("addclosehook", "urllib", "urllib.response"), |
|
302 |
- MovedAttribute("addinfo", "urllib", "urllib.response"), |
|
303 |
- MovedAttribute("addinfourl", "urllib", "urllib.response"), |
|
304 |
-] |
|
305 |
-for attr in _urllib_response_moved_attributes: |
|
306 |
- setattr(Module_six_moves_urllib_response, attr.name, attr) |
|
307 |
-del attr |
|
308 |
- |
|
309 |
-sys.modules[__name__ + ".moves.urllib_response"] = Module_six_moves_urllib_response(__name__ + ".moves.urllib_response") |
|
310 |
-sys.modules[__name__ + ".moves.urllib.response"] = Module_six_moves_urllib_response(__name__ + ".moves.urllib.response") |
|
311 |
- |
|
312 |
- |
|
313 |
-class Module_six_moves_urllib_robotparser(types.ModuleType): |
|
314 |
- """Lazy loading of moved objects in six.moves.urllib_robotparser""" |
|
315 |
- |
|
316 |
- |
|
317 |
-_urllib_robotparser_moved_attributes = [ |
|
318 |
- MovedAttribute("RobotFileParser", "robotparser", "urllib.robotparser"), |
|
319 |
-] |
|
320 |
-for attr in _urllib_robotparser_moved_attributes: |
|
321 |
- setattr(Module_six_moves_urllib_robotparser, attr.name, attr) |
|
322 |
-del attr |
|
323 |
- |
|
324 |
-sys.modules[__name__ + ".moves.urllib_robotparser"] = Module_six_moves_urllib_robotparser(__name__ + ".moves.urllib_robotparser") |
|
325 |
-sys.modules[__name__ + ".moves.urllib.robotparser"] = Module_six_moves_urllib_robotparser(__name__ + ".moves.urllib.robotparser") |
|
326 |
- |
|
327 |
- |
|
328 |
-class Module_six_moves_urllib(types.ModuleType): |
|
329 |
- """Create a six.moves.urllib namespace that resembles the Python 3 namespace""" |
|
330 |
- parse = sys.modules[__name__ + ".moves.urllib_parse"] |
|
331 |
- error = sys.modules[__name__ + ".moves.urllib_error"] |
|
332 |
- request = sys.modules[__name__ + ".moves.urllib_request"] |
|
333 |
- response = sys.modules[__name__ + ".moves.urllib_response"] |
|
334 |
- robotparser = sys.modules[__name__ + ".moves.urllib_robotparser"] |
|
335 |
- |
|
336 |
- |
|
337 |
-sys.modules[__name__ + ".moves.urllib"] = Module_six_moves_urllib(__name__ + ".moves.urllib") |
|
338 |
- |
|
339 |
- |
|
340 |
-def add_move(move): |
|
341 |
- """Add an item to six.moves.""" |
|
342 |
- setattr(_MovedItems, move.name, move) |
|
343 |
- |
|
344 |
- |
|
345 |
-def remove_move(name): |
|
346 |
- """Remove item from six.moves.""" |
|
347 |
- try: |
|
348 |
- delattr(_MovedItems, name) |
|
349 |
- except AttributeError: |
|
350 |
- try: |
|
351 |
- del moves.__dict__[name] |
|
352 |
- except KeyError: |
|
353 |
- raise AttributeError("no such move, %r" % (name,)) |
|
354 |
- |
|
355 |
- |
|
356 |
-if PY3: |
|
357 |
- _meth_func = "__func__" |
|
358 |
- _meth_self = "__self__" |
|
359 |
- |
|
360 |
- _func_closure = "__closure__" |
|
361 |
- _func_code = "__code__" |
|
362 |
- _func_defaults = "__defaults__" |
|
363 |
- _func_globals = "__globals__" |
|
364 |
- |
|
365 |
- _iterkeys = "keys" |
|
366 |
- _itervalues = "values" |
|
367 |
- _iteritems = "items" |
|
368 |
- _iterlists = "lists" |
|
369 |
-else: |
|
370 |
- _meth_func = "im_func" |
|
371 |
- _meth_self = "im_self" |
|
372 |
- |
|
373 |
- _func_closure = "func_closure" |
|
374 |
- _func_code = "func_code" |
|
375 |
- _func_defaults = "func_defaults" |
|
376 |
- _func_globals = "func_globals" |
|
377 |
- |
|
378 |
- _iterkeys = "iterkeys" |
|
379 |
- _itervalues = "itervalues" |
|
380 |
- _iteritems = "iteritems" |
|
381 |
- _iterlists = "iterlists" |
|
382 |
- |
|
383 |
- |
|
384 |
-try: |
|
385 |
- advance_iterator = next |
|
386 |
-except NameError: |
|
387 |
- def advance_iterator(it): |
|
388 |
- return it.next() |
|
389 |
-next = advance_iterator |
|
390 |
- |
|
391 |
- |
|
392 |
-try: |
|
393 |
- callable = callable |
|
394 |
-except NameError: |
|
395 |
- def callable(obj): |
|
396 |
- return any("__call__" in klass.__dict__ for klass in type(obj).__mro__) |
|
397 |
- |
|
398 |
- |
|
399 |
-if PY3: |
|
400 |
- def get_unbound_function(unbound): |
|
401 |
- return unbound |
|
402 |
- |
|
403 |
- create_bound_method = types.MethodType |
|
404 |
- |
|
405 |
- Iterator = object |
|
406 |
-else: |
|
407 |
- def get_unbound_function(unbound): |
|
408 |
- return unbound.im_func |
|
409 |
- |
|
410 |
- def create_bound_method(func, obj): |
|
411 |
- return types.MethodType(func, obj, obj.__class__) |
|
412 |
- |
|
413 |
- class Iterator(object): |
|
414 |
- |
|
415 |
- def next(self): |
|
416 |
- return type(self).__next__(self) |
|
417 |
- |
|
418 |
- callable = callable |
|
419 |
-_add_doc(get_unbound_function, |
|
420 |
- """Get the function out of a possibly unbound function""") |
|
421 |
- |
|
422 |
- |
|
423 |
-get_method_function = operator.attrgetter(_meth_func) |
|
424 |
-get_method_self = operator.attrgetter(_meth_self) |
|
425 |
-get_function_closure = operator.attrgetter(_func_closure) |
|
426 |
-get_function_code = operator.attrgetter(_func_code) |
|
427 |
-get_function_defaults = operator.attrgetter(_func_defaults) |
|
428 |
-get_function_globals = operator.attrgetter(_func_globals) |
|
429 |
- |
|
430 |
- |
|
431 |
-def iterkeys(d, **kw): |
|
432 |
- """Return an iterator over the keys of a dictionary.""" |
|
433 |
- return iter(getattr(d, _iterkeys)(**kw)) |
|
434 |
- |
|
435 |
-def itervalues(d, **kw): |
|
436 |
- """Return an iterator over the values of a dictionary.""" |
|
437 |
- return iter(getattr(d, _itervalues)(**kw)) |
|
438 |
- |
|
439 |
-def iteritems(d, **kw): |
|
440 |
- """Return an iterator over the (key, value) pairs of a dictionary.""" |
|
441 |
- return iter(getattr(d, _iteritems)(**kw)) |
|
442 |
- |
|
443 |
-def iterlists(d, **kw): |
|
444 |
- """Return an iterator over the (key, [values]) pairs of a dictionary.""" |
|
445 |
- return iter(getattr(d, _iterlists)(**kw)) |
|
446 |
- |
|
447 |
- |
|
448 |
-if PY3: |
|
449 |
- def b(s): |
|
450 |
- return s.encode("latin-1") |
|
451 |
- def u(s): |
|
452 |
- return s |
|
453 |
- unichr = chr |
|
454 |
- if sys.version_info[1] <= 1: |
|
455 |
- def int2byte(i): |
|
456 |
- return bytes((i,)) |
|
457 |
- else: |
|
458 |
- # This is about 2x faster than the implementation above on 3.2+ |
|
459 |
- int2byte = operator.methodcaller("to_bytes", 1, "big") |
|
460 |
- byte2int = operator.itemgetter(0) |
|
461 |
- indexbytes = operator.getitem |
|
462 |
- iterbytes = iter |
|
463 |
- import io |
|
464 |
- StringIO = io.StringIO |
|
465 |
- BytesIO = io.BytesIO |
|
466 |
-else: |
|
467 |
- def b(s): |
|
468 |
- return s |
|
469 |
- def u(s): |
|
470 |
- return unicode(s, "unicode_escape") |
|
471 |
- unichr = unichr |
|
472 |
- int2byte = chr |
|
473 |
- def byte2int(bs): |
|
474 |
- return ord(bs[0]) |
|
475 |
- def indexbytes(buf, i): |
|
476 |
- return ord(buf[i]) |
|
477 |
- def iterbytes(buf): |
|
478 |
- return (ord(byte) for byte in buf) |
|
479 |
- import StringIO |
|
480 |
- StringIO = BytesIO = StringIO.StringIO |
|
481 |
-_add_doc(b, """Byte literal""") |
|
482 |
-_add_doc(u, """Text literal""") |
|
483 |
- |
|
484 |
- |
|
485 |
-if PY3: |
|
486 |
- import builtins |
|
487 |
- exec_ = getattr(builtins, "exec") |
|
488 |
- |
|
489 |
- |
|
490 |
- def reraise(tp, value, tb=None): |
|
491 |
- if value.__traceback__ is not tb: |
|
492 |
- raise value.with_traceback(tb) |
|
493 |
- raise value |
|
494 |
- |
|
495 |
- |
|
496 |
- print_ = getattr(builtins, "print") |
|
497 |
- del builtins |
|
498 |
- |
|
499 |
-else: |
|
500 |
- def exec_(_code_, _globs_=None, _locs_=None): |
|
501 |
- """Execute code in a namespace.""" |
|
502 |
- if _globs_ is None: |
|
503 |
- frame = sys._getframe(1) |
|
504 |
- _globs_ = frame.f_globals |
|
505 |
- if _locs_ is None: |
|
506 |
- _locs_ = frame.f_locals |
|
507 |
- del frame |
|
508 |
- elif _locs_ is None: |
|
509 |
- _locs_ = _globs_ |
|
510 |
- exec("""exec _code_ in _globs_, _locs_""") |
|
511 |
- |
|
512 |
- |
|
513 |
- exec_("""def reraise(tp, value, tb=None): |
|
514 |
- raise tp, value, tb |
|
515 |
-""") |
|
516 |
- |
|
517 |
- |
|
518 |
- def print_(*args, **kwargs): |
|
519 |
- """The new-style print function.""" |
|
520 |
- fp = kwargs.pop("file", sys.stdout) |
|
521 |
- if fp is None: |
|
522 |
- return |
|
523 |
- def write(data): |
|
524 |
- if not isinstance(data, basestring): |
|
525 |
- data = str(data) |
|
526 |
- fp.write(data) |
|
527 |
- want_unicode = False |
|
528 |
- sep = kwargs.pop("sep", None) |
|
529 |
- if sep is not None: |
|
530 |
- if isinstance(sep, unicode): |
|
531 |
- want_unicode = True |
|
532 |
- elif not isinstance(sep, str): |
|
533 |
- raise TypeError("sep must be None or a string") |
|
534 |
- end = kwargs.pop("end", None) |
|
535 |
- if end is not None: |
|
536 |
- if isinstance(end, unicode): |
|
537 |
- want_unicode = True |
|
538 |
- elif not isinstance(end, str): |
|
539 |
- raise TypeError("end must be None or a string") |
|
540 |
- if kwargs: |
|
541 |
- raise TypeError("invalid keyword arguments to print()") |
|
542 |
- if not want_unicode: |
|
543 |
- for arg in args: |
|
544 |
- if isinstance(arg, unicode): |
|
545 |
- want_unicode = True |
|
546 |
- break |
|
547 |
- if want_unicode: |
|
548 |
- newline = unicode("\n") |
|
549 |
- space = unicode(" ") |
|
550 |
- else: |
|
551 |
- newline = "\n" |
|
552 |
- space = " " |
|
553 |
- if sep is None: |
|
554 |
- sep = space |
|
555 |
- if end is None: |
|
556 |
- end = newline |
|
557 |
- for i, arg in enumerate(args): |
|
558 |
- if i: |
|
559 |
- write(sep) |
|
560 |
- write(arg) |
|
561 |
- write(end) |
|
562 |
- |
|
563 |
-_add_doc(reraise, """Reraise an exception.""") |
|
564 |
- |
|
565 |
- |
|
566 |
-def with_metaclass(meta, *bases): |
|
567 |
- """Create a base class with a metaclass.""" |
|
568 |
- return meta("NewBase", bases, {}) |
|
569 |
- |
|
570 |
-def add_metaclass(metaclass): |
|
571 |
- """Class decorator for creating a class with a metaclass.""" |
|
572 |
- def wrapper(cls): |
|
573 |
- orig_vars = cls.__dict__.copy() |
|
574 |
- orig_vars.pop('__dict__', None) |
|
575 |
- orig_vars.pop('__weakref__', None) |
|
576 |
- for slots_var in orig_vars.get('__slots__', ()): |
|
577 |
- orig_vars.pop(slots_var) |
|
578 |
- return metaclass(cls.__name__, cls.__bases__, orig_vars) |
|
579 |
- return wrapper |
580 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,116 @@ |
0 |
+# This code is part of Ansible, but is an independent component. |
|
1 |
+# This particular file snippet, and this file snippet only, is BSD licensed. |
|
2 |
+# Modules you write using this snippet, which is embedded dynamically by Ansible |
|
3 |
+# still belong to the author of the module, and may assign their own license |
|
4 |
+# to the complete work. |
|
5 |
+# |
|
6 |
+# Copyright (c) 2017, Toshio Kuratomi <tkuratomi@ansible.com> |
|
7 |
+# |
|
8 |
+# This code is based on code from Astropy and retains their 3-clause BSD license |
|
9 |
+# reproduced below: |
|
10 |
+# |
|
11 |
+# Copyright (c) 2011-2016, Astropy Developers |
|
12 |
+# |
|
13 |
+# All rights reserved. |
|
14 |
+# |
|
15 |
+# Redistribution and use in source and binary forms, with or without |
|
16 |
+# modification, are permitted provided that the following conditions are met: |
|
17 |
+# |
|
18 |
+# * Redistributions of source code must retain the above copyright notice, this |
|
19 |
+# list of conditions and the following disclaimer. |
|
20 |
+# * Redistributions in binary form must reproduce the above copyright notice, |
|
21 |
+# this list of conditions and the following disclaimer in the documentation |
|
22 |
+# and/or other materials provided with the distribution. |
|
23 |
+# * Neither the name of the Astropy Team nor the names of its contributors may |
|
24 |
+# be used to endorse or promote products derived from this software without |
|
25 |
+# specific prior written permission. |
|
26 |
+# |
|
27 |
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
28 |
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
29 |
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
|
30 |
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
|
31 |
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
32 |
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
|
33 |
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
|
34 |
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
|
35 |
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
36 |
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
37 |
+# |
|
38 |
+# Astropy License: https://github.com/astropy/astropy/blob/cf3265e42a0db8e00bb90644db37c8150f5ac00c/licenses/LICENSE.rst |
|
39 |
+# Astropy Code: https://github.com/astropy/astropy/blob/cf3265e42a0db8e00bb90644db37c8150f5ac00c/astropy/extern/six.py |
|
40 |
+ |
|
41 |
+""" |
|
42 |
+Handle loading six package from system or from the bundled copy |
|
43 |
+""" |
|
44 |
+from __future__ import absolute_import |
|
45 |
+ |
|
46 |
+import imp as _imp |
|
47 |
+import sys as _sys |
|
48 |
+ |
|
49 |
+try: |
|
50 |
+ from distutils.version import LooseVersion as _LooseVersion |
|
51 |
+except ImportError: |
|
52 |
+ # Some platforms *cough*Solaris*cough* don't ship the whole stdlib |
|
53 |
+ _LooseVersion = None |
|
54 |
+ |
|
55 |
+try: |
|
56 |
+ import six as _system_six |
|
57 |
+except ImportError: |
|
58 |
+ _system_six = None |
|
59 |
+ |
|
60 |
+from . import _six as _bundled_six |
|
61 |
+ |
|
62 |
+ |
|
63 |
+def _find_module(name, path=None): |
|
64 |
+ """Alternative to `imp.find_module` that can also search in subpackages""" |
|
65 |
+ parts = name.split('.') |
|
66 |
+ |
|
67 |
+ for part in parts: |
|
68 |
+ if path is not None: |
|
69 |
+ path = [path] |
|
70 |
+ fh, path, descr = _imp.find_module(part, path) |
|
71 |
+ return fh, path, descr |
|
72 |
+ |
|
73 |
+ |
|
74 |
+def _get_bundled_six_source(): |
|
75 |
+ # Special import loader (zipimport for instance) |
|
76 |
+ found = False |
|
77 |
+ for path in _sys.path: |
|
78 |
+ importer = _sys.path_importer_cache.get(path) |
|
79 |
+ if importer: |
|
80 |
+ try: |
|
81 |
+ found = importer.find_module('ansible/module_utils/six/_six') |
|
82 |
+ except ImportError: |
|
83 |
+ continue |
|
84 |
+ if found: |
|
85 |
+ break |
|
86 |
+ else: |
|
87 |
+ raise ImportError("Could not find ansible.module_utils.six._six") |
|
88 |
+ |
|
89 |
+ module_source = importer.get_source('ansible/module_utils/six/_six') |
|
90 |
+ return module_source |
|
91 |
+ |
|
92 |
+ |
|
93 |
+def _get_six_source(): |
|
94 |
+ """Import the newest version of the six library that's available""" |
|
95 |
+ mod_info = None |
|
96 |
+ try: |
|
97 |
+ if _system_six and _LooseVersion and \ |
|
98 |
+ _LooseVersion(_system_six.__version__) >= _LooseVersion(_bundled_six.__version__): |
|
99 |
+ mod_info = _find_module('six') |
|
100 |
+ except: |
|
101 |
+ # Any errors finding the system library, use our bundled lib instead |
|
102 |
+ pass |
|
103 |
+ |
|
104 |
+ if not mod_info: |
|
105 |
+ try: |
|
106 |
+ mod_info = _find_module('ansible.module_utils.six._six') |
|
107 |
+ except ImportError: |
|
108 |
+ # zipimport |
|
109 |
+ module_source = _get_bundled_six_source() |
|
110 |
+ return module_source |
|
111 |
+ |
|
112 |
+ return mod_info[0].read() |
|
113 |
+ |
|
114 |
+source = _get_six_source() |
|
115 |
+exec(source) |
0 | 116 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,870 @@ |
0 |
+"""Utilities for writing code that runs on Python 2 and 3""" |
|
1 |
+ |
|
2 |
+# Copyright (c) 2010-2015 Benjamin Peterson |
|
3 |
+# |
|
4 |
+# Permission is hereby granted, free of charge, to any person obtaining a copy |
|
5 |
+# of this software and associated documentation files (the "Software"), to deal |
|
6 |
+# in the Software without restriction, including without limitation the rights |
|
7 |
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
8 |
+# copies of the Software, and to permit persons to whom the Software is |
|
9 |
+# furnished to do so, subject to the following conditions: |
|
10 |
+# |
|
11 |
+# The above copyright notice and this permission notice shall be included in all |
|
12 |
+# copies or substantial portions of the Software. |
|
13 |
+# |
|
14 |
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
15 |
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
16 |
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
17 |
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
18 |
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
19 |
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
20 |
+# SOFTWARE. |
|
21 |
+ |
|
22 |
+from __future__ import absolute_import |
|
23 |
+ |
|
24 |
+import functools |
|
25 |
+import itertools |
|
26 |
+import operator |
|
27 |
+import sys |
|
28 |
+import types |
|
29 |
+ |
|
30 |
+__author__ = "Benjamin Peterson <benjamin@python.org>" |
|
31 |
+__version__ = "1.10.0" |
|
32 |
+ |
|
33 |
+ |
|
34 |
+# Useful for very coarse version differentiation. |
|
35 |
+PY2 = sys.version_info[0] == 2 |
|
36 |
+PY3 = sys.version_info[0] == 3 |
|
37 |
+PY34 = sys.version_info[0:2] >= (3, 4) |
|
38 |
+ |
|
39 |
+if PY3: |
|
40 |
+ string_types = str, |
|
41 |
+ integer_types = int, |
|
42 |
+ class_types = type, |
|
43 |
+ text_type = str |
|
44 |
+ binary_type = bytes |
|
45 |
+ cmp = lambda a, b: (a > b) - (a < b) |
|
46 |
+ |
|
47 |
+ MAXSIZE = sys.maxsize |
|
48 |
+else: |
|
49 |
+ string_types = basestring, |
|
50 |
+ integer_types = (int, long) |
|
51 |
+ class_types = (type, types.ClassType) |
|
52 |
+ text_type = unicode |
|
53 |
+ binary_type = str |
|
54 |
+ cmp = cmp |
|
55 |
+ |
|
56 |
+ if sys.platform.startswith("java"): |
|
57 |
+ # Jython always uses 32 bits. |
|
58 |
+ MAXSIZE = int((1 << 31) - 1) |
|
59 |
+ else: |
|
60 |
+ # It's possible to have sizeof(long) != sizeof(Py_ssize_t). |
|
61 |
+ class X(object): |
|
62 |
+ |
|
63 |
+ def __len__(self): |
|
64 |
+ return 1 << 31 |
|
65 |
+ try: |
|
66 |
+ len(X()) |
|
67 |
+ except OverflowError: |
|
68 |
+ # 32-bit |
|
69 |
+ MAXSIZE = int((1 << 31) - 1) |
|
70 |
+ else: |
|
71 |
+ # 64-bit |
|
72 |
+ MAXSIZE = int((1 << 63) - 1) |
|
73 |
+ del X |
|
74 |
+ |
|
75 |
+ |
|
76 |
+def _add_doc(func, doc): |
|
77 |
+ """Add documentation to a function.""" |
|
78 |
+ func.__doc__ = doc |
|
79 |
+ |
|
80 |
+ |
|
81 |
+def _import_module(name): |
|
82 |
+ """Import module, returning the module after the last dot.""" |
|
83 |
+ __import__(name) |
|
84 |
+ return sys.modules[name] |
|
85 |
+ |
|
86 |
+ |
|
87 |
+class _LazyDescr(object): |
|
88 |
+ |
|
89 |
+ def __init__(self, name): |
|
90 |
+ self.name = name |
|
91 |
+ |
|
92 |
+ def __get__(self, obj, tp): |
|
93 |
+ result = self._resolve() |
|
94 |
+ setattr(obj, self.name, result) # Invokes __set__. |
|
95 |
+ try: |
|
96 |
+ # This is a bit ugly, but it avoids running this again by |
|
97 |
+ # removing this descriptor. |
|
98 |
+ delattr(obj.__class__, self.name) |
|
99 |
+ except AttributeError: |
|
100 |
+ pass |
|
101 |
+ return result |
|
102 |
+ |
|
103 |
+ |
|
104 |
+class MovedModule(_LazyDescr): |
|
105 |
+ |
|
106 |
+ def __init__(self, name, old, new=None): |
|
107 |
+ super(MovedModule, self).__init__(name) |
|
108 |
+ if PY3: |
|
109 |
+ if new is None: |
|
110 |
+ new = name |
|
111 |
+ self.mod = new |
|
112 |
+ else: |
|
113 |
+ self.mod = old |
|
114 |
+ |
|
115 |
+ def _resolve(self): |
|
116 |
+ return _import_module(self.mod) |
|
117 |
+ |
|
118 |
+ def __getattr__(self, attr): |
|
119 |
+ _module = self._resolve() |
|
120 |
+ value = getattr(_module, attr) |
|
121 |
+ setattr(self, attr, value) |
|
122 |
+ return value |
|
123 |
+ |
|
124 |
+ |
|
125 |
+class _LazyModule(types.ModuleType): |
|
126 |
+ |
|
127 |
+ def __init__(self, name): |
|
128 |
+ super(_LazyModule, self).__init__(name) |
|
129 |
+ self.__doc__ = self.__class__.__doc__ |
|
130 |
+ |
|
131 |
+ def __dir__(self): |
|
132 |
+ attrs = ["__doc__", "__name__"] |
|
133 |
+ attrs += [attr.name for attr in self._moved_attributes] |
|
134 |
+ return attrs |
|
135 |
+ |
|
136 |
+ # Subclasses should override this |
|
137 |
+ _moved_attributes = [] |
|
138 |
+ |
|
139 |
+ |
|
140 |
+class MovedAttribute(_LazyDescr): |
|
141 |
+ |
|
142 |
+ def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None): |
|
143 |
+ super(MovedAttribute, self).__init__(name) |
|
144 |
+ if PY3: |
|
145 |
+ if new_mod is None: |
|
146 |
+ new_mod = name |
|
147 |
+ self.mod = new_mod |
|
148 |
+ if new_attr is None: |
|
149 |
+ if old_attr is None: |
|
150 |
+ new_attr = name |
|
151 |
+ else: |
|
152 |
+ new_attr = old_attr |
|
153 |
+ self.attr = new_attr |
|
154 |
+ else: |
|
155 |
+ self.mod = old_mod |
|
156 |
+ if old_attr is None: |
|
157 |
+ old_attr = name |
|
158 |
+ self.attr = old_attr |
|
159 |
+ |
|
160 |
+ def _resolve(self): |
|
161 |
+ module = _import_module(self.mod) |
|
162 |
+ return getattr(module, self.attr) |
|
163 |
+ |
|
164 |
+ |
|
165 |
+class _SixMetaPathImporter(object): |
|
166 |
+ |
|
167 |
+ """ |
|
168 |
+ A meta path importer to import six.moves and its submodules. |
|
169 |
+ |
|
170 |
+ This class implements a PEP302 finder and loader. It should be compatible |
|
171 |
+ with Python 2.5 and all existing versions of Python3 |
|
172 |
+ """ |
|
173 |
+ |
|
174 |
+ def __init__(self, six_module_name): |
|
175 |
+ self.name = six_module_name |
|
176 |
+ self.known_modules = {} |
|
177 |
+ |
|
178 |
+ def _add_module(self, mod, *fullnames): |
|
179 |
+ for fullname in fullnames: |
|
180 |
+ self.known_modules[self.name + "." + fullname] = mod |
|
181 |
+ |
|
182 |
+ def _get_module(self, fullname): |
|
183 |
+ return self.known_modules[self.name + "." + fullname] |
|
184 |
+ |
|
185 |
+ def find_module(self, fullname, path=None): |
|
186 |
+ if fullname in self.known_modules: |
|
187 |
+ return self |
|
188 |
+ return None |
|
189 |
+ |
|
190 |
+ def __get_module(self, fullname): |
|
191 |
+ try: |
|
192 |
+ return self.known_modules[fullname] |
|
193 |
+ except KeyError: |
|
194 |
+ raise ImportError("This loader does not know module " + fullname) |
|
195 |
+ |
|
196 |
+ def load_module(self, fullname): |
|
197 |
+ try: |
|
198 |
+ # in case of a reload |
|
199 |
+ return sys.modules[fullname] |
|
200 |
+ except KeyError: |
|
201 |
+ pass |
|
202 |
+ mod = self.__get_module(fullname) |
|
203 |
+ if isinstance(mod, MovedModule): |
|
204 |
+ mod = mod._resolve() |
|
205 |
+ else: |
|
206 |
+ mod.__loader__ = self |
|
207 |
+ sys.modules[fullname] = mod |
|
208 |
+ return mod |
|
209 |
+ |
|
210 |
+ def is_package(self, fullname): |
|
211 |
+ """ |
|
212 |
+ Return true, if the named module is a package. |
|
213 |
+ |
|
214 |
+ We need this method to get correct spec objects with |
|
215 |
+ Python 3.4 (see PEP451) |
|
216 |
+ """ |
|
217 |
+ return hasattr(self.__get_module(fullname), "__path__") |
|
218 |
+ |
|
219 |
+ def get_code(self, fullname): |
|
220 |
+ """Return None |
|
221 |
+ |
|
222 |
+ Required, if is_package is implemented""" |
|
223 |
+ self.__get_module(fullname) # eventually raises ImportError |
|
224 |
+ return None |
|
225 |
+ get_source = get_code # same as get_code |
|
226 |
+ |
|
227 |
+_importer = _SixMetaPathImporter(__name__) |
|
228 |
+ |
|
229 |
+ |
|
230 |
+class _MovedItems(_LazyModule): |
|
231 |
+ |
|
232 |
+ """Lazy loading of moved objects""" |
|
233 |
+ __path__ = [] # mark as package |
|
234 |
+ |
|
235 |
+ |
|
236 |
+_moved_attributes = [ |
|
237 |
+ MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"), |
|
238 |
+ MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"), |
|
239 |
+ MovedAttribute("filterfalse", "itertools", "itertools", "ifilterfalse", "filterfalse"), |
|
240 |
+ MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"), |
|
241 |
+ MovedAttribute("intern", "__builtin__", "sys"), |
|
242 |
+ MovedAttribute("map", "itertools", "builtins", "imap", "map"), |
|
243 |
+ MovedAttribute("getcwd", "os", "os", "getcwdu", "getcwd"), |
|
244 |
+ MovedAttribute("getcwdb", "os", "os", "getcwd", "getcwdb"), |
|
245 |
+ MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"), |
|
246 |
+ MovedAttribute("reload_module", "__builtin__", "importlib" if PY34 else "imp", "reload"), |
|
247 |
+ MovedAttribute("reduce", "__builtin__", "functools"), |
|
248 |
+ MovedAttribute("shlex_quote", "pipes", "shlex", "quote"), |
|
249 |
+ MovedAttribute("StringIO", "StringIO", "io"), |
|
250 |
+ MovedAttribute("UserDict", "UserDict", "collections"), |
|
251 |
+ MovedAttribute("UserList", "UserList", "collections"), |
|
252 |
+ MovedAttribute("UserString", "UserString", "collections"), |
|
253 |
+ MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"), |
|
254 |
+ MovedAttribute("zip", "itertools", "builtins", "izip", "zip"), |
|
255 |
+ MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"), |
|
256 |
+ MovedModule("builtins", "__builtin__"), |
|
257 |
+ MovedModule("configparser", "ConfigParser"), |
|
258 |
+ MovedModule("copyreg", "copy_reg"), |
|
259 |
+ MovedModule("dbm_gnu", "gdbm", "dbm.gnu"), |
|
260 |
+ MovedModule("_dummy_thread", "dummy_thread", "_dummy_thread"), |
|
261 |
+ MovedModule("http_cookiejar", "cookielib", "http.cookiejar"), |
|
262 |
+ MovedModule("http_cookies", "Cookie", "http.cookies"), |
|
263 |
+ MovedModule("html_entities", "htmlentitydefs", "html.entities"), |
|
264 |
+ MovedModule("html_parser", "HTMLParser", "html.parser"), |
|
265 |
+ MovedModule("http_client", "httplib", "http.client"), |
|
266 |
+ MovedModule("email_mime_multipart", "email.MIMEMultipart", "email.mime.multipart"), |
|
267 |
+ MovedModule("email_mime_nonmultipart", "email.MIMENonMultipart", "email.mime.nonmultipart"), |
|
268 |
+ MovedModule("email_mime_text", "email.MIMEText", "email.mime.text"), |
|
269 |
+ MovedModule("email_mime_base", "email.MIMEBase", "email.mime.base"), |
|
270 |
+ MovedModule("BaseHTTPServer", "BaseHTTPServer", "http.server"), |
|
271 |
+ MovedModule("CGIHTTPServer", "CGIHTTPServer", "http.server"), |
|
272 |
+ MovedModule("SimpleHTTPServer", "SimpleHTTPServer", "http.server"), |
|
273 |
+ MovedModule("cPickle", "cPickle", "pickle"), |
|
274 |
+ MovedModule("queue", "Queue"), |
|
275 |
+ MovedModule("reprlib", "repr"), |
|
276 |
+ MovedModule("socketserver", "SocketServer"), |
|
277 |
+ MovedModule("_thread", "thread", "_thread"), |
|
278 |
+ MovedModule("tkinter", "Tkinter"), |
|
279 |
+ MovedModule("tkinter_dialog", "Dialog", "tkinter.dialog"), |
|
280 |
+ MovedModule("tkinter_filedialog", "FileDialog", "tkinter.filedialog"), |
|
281 |
+ MovedModule("tkinter_scrolledtext", "ScrolledText", "tkinter.scrolledtext"), |
|
282 |
+ MovedModule("tkinter_simpledialog", "SimpleDialog", "tkinter.simpledialog"), |
|
283 |
+ MovedModule("tkinter_tix", "Tix", "tkinter.tix"), |
|
284 |
+ MovedModule("tkinter_ttk", "ttk", "tkinter.ttk"), |
|
285 |
+ MovedModule("tkinter_constants", "Tkconstants", "tkinter.constants"), |
|
286 |
+ MovedModule("tkinter_dnd", "Tkdnd", "tkinter.dnd"), |
|
287 |
+ MovedModule("tkinter_colorchooser", "tkColorChooser", |
|
288 |
+ "tkinter.colorchooser"), |
|
289 |
+ MovedModule("tkinter_commondialog", "tkCommonDialog", |
|
290 |
+ "tkinter.commondialog"), |
|
291 |
+ MovedModule("tkinter_tkfiledialog", "tkFileDialog", "tkinter.filedialog"), |
|
292 |
+ MovedModule("tkinter_font", "tkFont", "tkinter.font"), |
|
293 |
+ MovedModule("tkinter_messagebox", "tkMessageBox", "tkinter.messagebox"), |
|
294 |
+ MovedModule("tkinter_tksimpledialog", "tkSimpleDialog", |
|
295 |
+ "tkinter.simpledialog"), |
|
296 |
+ MovedModule("urllib_parse", __name__ + ".moves.urllib_parse", "urllib.parse"), |
|
297 |
+ MovedModule("urllib_error", __name__ + ".moves.urllib_error", "urllib.error"), |
|
298 |
+ MovedModule("urllib", __name__ + ".moves.urllib", __name__ + ".moves.urllib"), |
|
299 |
+ MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"), |
|
300 |
+ MovedModule("xmlrpc_client", "xmlrpclib", "xmlrpc.client"), |
|
301 |
+ MovedModule("xmlrpc_server", "SimpleXMLRPCServer", "xmlrpc.server"), |
|
302 |
+] |
|
303 |
+# Add windows specific modules. |
|
304 |
+if sys.platform == "win32": |
|
305 |
+ _moved_attributes += [ |
|
306 |
+ MovedModule("winreg", "_winreg"), |
|
307 |
+ ] |
|
308 |
+ |
|
309 |
+for attr in _moved_attributes: |
|
310 |
+ setattr(_MovedItems, attr.name, attr) |
|
311 |
+ if isinstance(attr, MovedModule): |
|
312 |
+ _importer._add_module(attr, "moves." + attr.name) |
|
313 |
+del attr |
|
314 |
+ |
|
315 |
+_MovedItems._moved_attributes = _moved_attributes |
|
316 |
+ |
|
317 |
+moves = _MovedItems(__name__ + ".moves") |
|
318 |
+_importer._add_module(moves, "moves") |
|
319 |
+ |
|
320 |
+ |
|
321 |
+class Module_six_moves_urllib_parse(_LazyModule): |
|
322 |
+ |
|
323 |
+ """Lazy loading of moved objects in six.moves.urllib_parse""" |
|
324 |
+ |
|
325 |
+ |
|
326 |
+_urllib_parse_moved_attributes = [ |
|
327 |
+ MovedAttribute("ParseResult", "urlparse", "urllib.parse"), |
|
328 |
+ MovedAttribute("SplitResult", "urlparse", "urllib.parse"), |
|
329 |
+ MovedAttribute("parse_qs", "urlparse", "urllib.parse"), |
|
330 |
+ MovedAttribute("parse_qsl", "urlparse", "urllib.parse"), |
|
331 |
+ MovedAttribute("urldefrag", "urlparse", "urllib.parse"), |
|
332 |
+ MovedAttribute("urljoin", "urlparse", "urllib.parse"), |
|
333 |
+ MovedAttribute("urlparse", "urlparse", "urllib.parse"), |
|
334 |
+ MovedAttribute("urlsplit", "urlparse", "urllib.parse"), |
|
335 |
+ MovedAttribute("urlunparse", "urlparse", "urllib.parse"), |
|
336 |
+ MovedAttribute("urlunsplit", "urlparse", "urllib.parse"), |
|
337 |
+ MovedAttribute("quote", "urllib", "urllib.parse"), |
|
338 |
+ MovedAttribute("quote_plus", "urllib", "urllib.parse"), |
|
339 |
+ MovedAttribute("unquote", "urllib", "urllib.parse"), |
|
340 |
+ MovedAttribute("unquote_plus", "urllib", "urllib.parse"), |
|
341 |
+ MovedAttribute("urlencode", "urllib", "urllib.parse"), |
|
342 |
+ MovedAttribute("splitquery", "urllib", "urllib.parse"), |
|
343 |
+ MovedAttribute("splittag", "urllib", "urllib.parse"), |
|
344 |
+ MovedAttribute("splituser", "urllib", "urllib.parse"), |
|
345 |
+ MovedAttribute("uses_fragment", "urlparse", "urllib.parse"), |
|
346 |
+ MovedAttribute("uses_netloc", "urlparse", "urllib.parse"), |
|
347 |
+ MovedAttribute("uses_params", "urlparse", "urllib.parse"), |
|
348 |
+ MovedAttribute("uses_query", "urlparse", "urllib.parse"), |
|
349 |
+ MovedAttribute("uses_relative", "urlparse", "urllib.parse"), |
|
350 |
+] |
|
351 |
+for attr in _urllib_parse_moved_attributes: |
|
352 |
+ setattr(Module_six_moves_urllib_parse, attr.name, attr) |
|
353 |
+del attr |
|
354 |
+ |
|
355 |
+Module_six_moves_urllib_parse._moved_attributes = _urllib_parse_moved_attributes |
|
356 |
+ |
|
357 |
+_importer._add_module(Module_six_moves_urllib_parse(__name__ + ".moves.urllib_parse"), |
|
358 |
+ "moves.urllib_parse", "moves.urllib.parse") |
|
359 |
+ |
|
360 |
+ |
|
361 |
+class Module_six_moves_urllib_error(_LazyModule): |
|
362 |
+ |
|
363 |
+ """Lazy loading of moved objects in six.moves.urllib_error""" |
|
364 |
+ |
|
365 |
+ |
|
366 |
+_urllib_error_moved_attributes = [ |
|
367 |
+ MovedAttribute("URLError", "urllib2", "urllib.error"), |
|
368 |
+ MovedAttribute("HTTPError", "urllib2", "urllib.error"), |
|
369 |
+ MovedAttribute("ContentTooShortError", "urllib", "urllib.error"), |
|
370 |
+] |
|
371 |
+for attr in _urllib_error_moved_attributes: |
|
372 |
+ setattr(Module_six_moves_urllib_error, attr.name, attr) |
|
373 |
+del attr |
|
374 |
+ |
|
375 |
+Module_six_moves_urllib_error._moved_attributes = _urllib_error_moved_attributes |
|
376 |
+ |
|
377 |
+_importer._add_module(Module_six_moves_urllib_error(__name__ + ".moves.urllib.error"), |
|
378 |
+ "moves.urllib_error", "moves.urllib.error") |
|
379 |
+ |
|
380 |
+ |
|
381 |
+class Module_six_moves_urllib_request(_LazyModule): |
|
382 |
+ |
|
383 |
+ """Lazy loading of moved objects in six.moves.urllib_request""" |
|
384 |
+ |
|
385 |
+ |
|
386 |
+_urllib_request_moved_attributes = [ |
|
387 |
+ MovedAttribute("urlopen", "urllib2", "urllib.request"), |
|
388 |
+ MovedAttribute("install_opener", "urllib2", "urllib.request"), |
|
389 |
+ MovedAttribute("build_opener", "urllib2", "urllib.request"), |
|
390 |
+ MovedAttribute("pathname2url", "urllib", "urllib.request"), |
|
391 |
+ MovedAttribute("url2pathname", "urllib", "urllib.request"), |
|
392 |
+ MovedAttribute("getproxies", "urllib", "urllib.request"), |
|
393 |
+ MovedAttribute("Request", "urllib2", "urllib.request"), |
|
394 |
+ MovedAttribute("OpenerDirector", "urllib2", "urllib.request"), |
|
395 |
+ MovedAttribute("HTTPDefaultErrorHandler", "urllib2", "urllib.request"), |
|
396 |
+ MovedAttribute("HTTPRedirectHandler", "urllib2", "urllib.request"), |
|
397 |
+ MovedAttribute("HTTPCookieProcessor", "urllib2", "urllib.request"), |
|
398 |
+ MovedAttribute("ProxyHandler", "urllib2", "urllib.request"), |
|
399 |
+ MovedAttribute("BaseHandler", "urllib2", "urllib.request"), |
|
400 |
+ MovedAttribute("HTTPPasswordMgr", "urllib2", "urllib.request"), |
|
401 |
+ MovedAttribute("HTTPPasswordMgrWithDefaultRealm", "urllib2", "urllib.request"), |
|
402 |
+ MovedAttribute("AbstractBasicAuthHandler", "urllib2", "urllib.request"), |
|
403 |
+ MovedAttribute("HTTPBasicAuthHandler", "urllib2", "urllib.request"), |
|
404 |
+ MovedAttribute("ProxyBasicAuthHandler", "urllib2", "urllib.request"), |
|
405 |
+ MovedAttribute("AbstractDigestAuthHandler", "urllib2", "urllib.request"), |
|
406 |
+ MovedAttribute("HTTPDigestAuthHandler", "urllib2", "urllib.request"), |
|
407 |
+ MovedAttribute("ProxyDigestAuthHandler", "urllib2", "urllib.request"), |
|
408 |
+ MovedAttribute("HTTPHandler", "urllib2", "urllib.request"), |
|
409 |
+ MovedAttribute("HTTPSHandler", "urllib2", "urllib.request"), |
|
410 |
+ MovedAttribute("FileHandler", "urllib2", "urllib.request"), |
|
411 |
+ MovedAttribute("FTPHandler", "urllib2", "urllib.request"), |
|
412 |
+ MovedAttribute("CacheFTPHandler", "urllib2", "urllib.request"), |
|
413 |
+ MovedAttribute("UnknownHandler", "urllib2", "urllib.request"), |
|
414 |
+ MovedAttribute("HTTPErrorProcessor", "urllib2", "urllib.request"), |
|
415 |
+ MovedAttribute("urlretrieve", "urllib", "urllib.request"), |
|
416 |
+ MovedAttribute("urlcleanup", "urllib", "urllib.request"), |
|
417 |
+ MovedAttribute("URLopener", "urllib", "urllib.request"), |
|
418 |
+ MovedAttribute("FancyURLopener", "urllib", "urllib.request"), |
|
419 |
+ MovedAttribute("proxy_bypass", "urllib", "urllib.request"), |
|
420 |
+] |
|
421 |
+for attr in _urllib_request_moved_attributes: |
|
422 |
+ setattr(Module_six_moves_urllib_request, attr.name, attr) |
|
423 |
+del attr |
|
424 |
+ |
|
425 |
+Module_six_moves_urllib_request._moved_attributes = _urllib_request_moved_attributes |
|
426 |
+ |
|
427 |
+_importer._add_module(Module_six_moves_urllib_request(__name__ + ".moves.urllib.request"), |
|
428 |
+ "moves.urllib_request", "moves.urllib.request") |
|
429 |
+ |
|
430 |
+ |
|
431 |
+class Module_six_moves_urllib_response(_LazyModule): |
|
432 |
+ |
|
433 |
+ """Lazy loading of moved objects in six.moves.urllib_response""" |
|
434 |
+ |
|
435 |
+ |
|
436 |
+_urllib_response_moved_attributes = [ |
|
437 |
+ MovedAttribute("addbase", "urllib", "urllib.response"), |
|
438 |
+ MovedAttribute("addclosehook", "urllib", "urllib.response"), |
|
439 |
+ MovedAttribute("addinfo", "urllib", "urllib.response"), |
|
440 |
+ MovedAttribute("addinfourl", "urllib", "urllib.response"), |
|
441 |
+] |
|
442 |
+for attr in _urllib_response_moved_attributes: |
|
443 |
+ setattr(Module_six_moves_urllib_response, attr.name, attr) |
|
444 |
+del attr |
|
445 |
+ |
|
446 |
+Module_six_moves_urllib_response._moved_attributes = _urllib_response_moved_attributes |
|
447 |
+ |
|
448 |
+_importer._add_module(Module_six_moves_urllib_response(__name__ + ".moves.urllib.response"), |
|
449 |
+ "moves.urllib_response", "moves.urllib.response") |
|
450 |
+ |
|
451 |
+ |
|
452 |
+class Module_six_moves_urllib_robotparser(_LazyModule): |
|
453 |
+ |
|
454 |
+ """Lazy loading of moved objects in six.moves.urllib_robotparser""" |
|
455 |
+ |
|
456 |
+ |
|
457 |
+_urllib_robotparser_moved_attributes = [ |
|
458 |
+ MovedAttribute("RobotFileParser", "robotparser", "urllib.robotparser"), |
|
459 |
+] |
|
460 |
+for attr in _urllib_robotparser_moved_attributes: |
|
461 |
+ setattr(Module_six_moves_urllib_robotparser, attr.name, attr) |
|
462 |
+del attr |
|
463 |
+ |
|
464 |
+Module_six_moves_urllib_robotparser._moved_attributes = _urllib_robotparser_moved_attributes |
|
465 |
+ |
|
466 |
+_importer._add_module(Module_six_moves_urllib_robotparser(__name__ + ".moves.urllib.robotparser"), |
|
467 |
+ "moves.urllib_robotparser", "moves.urllib.robotparser") |
|
468 |
+ |
|
469 |
+ |
|
470 |
+class Module_six_moves_urllib(types.ModuleType): |
|
471 |
+ |
|
472 |
+ """Create a six.moves.urllib namespace that resembles the Python 3 namespace""" |
|
473 |
+ __path__ = [] # mark as package |
|
474 |
+ parse = _importer._get_module("moves.urllib_parse") |
|
475 |
+ error = _importer._get_module("moves.urllib_error") |
|
476 |
+ request = _importer._get_module("moves.urllib_request") |
|
477 |
+ response = _importer._get_module("moves.urllib_response") |
|
478 |
+ robotparser = _importer._get_module("moves.urllib_robotparser") |
|
479 |
+ |
|
480 |
+ def __dir__(self): |
|
481 |
+ return ['parse', 'error', 'request', 'response', 'robotparser'] |
|
482 |
+ |
|
483 |
+_importer._add_module(Module_six_moves_urllib(__name__ + ".moves.urllib"), |
|
484 |
+ "moves.urllib") |
|
485 |
+ |
|
486 |
+ |
|
487 |
+def add_move(move): |
|
488 |
+ """Add an item to six.moves.""" |
|
489 |
+ setattr(_MovedItems, move.name, move) |
|
490 |
+ |
|
491 |
+ |
|
492 |
+def remove_move(name): |
|
493 |
+ """Remove item from six.moves.""" |
|
494 |
+ try: |
|
495 |
+ delattr(_MovedItems, name) |
|
496 |
+ except AttributeError: |
|
497 |
+ try: |
|
498 |
+ del moves.__dict__[name] |
|
499 |
+ except KeyError: |
|
500 |
+ raise AttributeError("no such move, %r" % (name,)) |
|
501 |
+ |
|
502 |
+ |
|
503 |
+if PY3: |
|
504 |
+ _meth_func = "__func__" |
|
505 |
+ _meth_self = "__self__" |
|
506 |
+ |
|
507 |
+ _func_closure = "__closure__" |
|
508 |
+ _func_code = "__code__" |
|
509 |
+ _func_defaults = "__defaults__" |
|
510 |
+ _func_globals = "__globals__" |
|
511 |
+else: |
|
512 |
+ _meth_func = "im_func" |
|
513 |
+ _meth_self = "im_self" |
|
514 |
+ |
|
515 |
+ _func_closure = "func_closure" |
|
516 |
+ _func_code = "func_code" |
|
517 |
+ _func_defaults = "func_defaults" |
|
518 |
+ _func_globals = "func_globals" |
|
519 |
+ |
|
520 |
+ |
|
521 |
+try: |
|
522 |
+ advance_iterator = next |
|
523 |
+except NameError: |
|
524 |
+ def advance_iterator(it): |
|
525 |
+ return it.next() |
|
526 |
+next = advance_iterator |
|
527 |
+ |
|
528 |
+ |
|
529 |
+try: |
|
530 |
+ callable = callable |
|
531 |
+except NameError: |
|
532 |
+ def callable(obj): |
|
533 |
+ return any("__call__" in klass.__dict__ for klass in type(obj).__mro__) |
|
534 |
+ |
|
535 |
+ |
|
536 |
+if PY3: |
|
537 |
+ def get_unbound_function(unbound): |
|
538 |
+ return unbound |
|
539 |
+ |
|
540 |
+ create_bound_method = types.MethodType |
|
541 |
+ |
|
542 |
+ def create_unbound_method(func, cls): |
|
543 |
+ return func |
|
544 |
+ |
|
545 |
+ Iterator = object |
|
546 |
+else: |
|
547 |
+ def get_unbound_function(unbound): |
|
548 |
+ return unbound.im_func |
|
549 |
+ |
|
550 |
+ def create_bound_method(func, obj): |
|
551 |
+ return types.MethodType(func, obj, obj.__class__) |
|
552 |
+ |
|
553 |
+ def create_unbound_method(func, cls): |
|
554 |
+ return types.MethodType(func, None, cls) |
|
555 |
+ |
|
556 |
+ class Iterator(object): |
|
557 |
+ |
|
558 |
+ def next(self): |
|
559 |
+ return type(self).__next__(self) |
|
560 |
+ |
|
561 |
+ callable = callable |
|
562 |
+_add_doc(get_unbound_function, |
|
563 |
+ """Get the function out of a possibly unbound function""") |
|
564 |
+ |
|
565 |
+ |
|
566 |
+get_method_function = operator.attrgetter(_meth_func) |
|
567 |
+get_method_self = operator.attrgetter(_meth_self) |
|
568 |
+get_function_closure = operator.attrgetter(_func_closure) |
|
569 |
+get_function_code = operator.attrgetter(_func_code) |
|
570 |
+get_function_defaults = operator.attrgetter(_func_defaults) |
|
571 |
+get_function_globals = operator.attrgetter(_func_globals) |
|
572 |
+ |
|
573 |
+ |
|
574 |
+if PY3: |
|
575 |
+ def iterkeys(d, **kw): |
|
576 |
+ return iter(d.keys(**kw)) |
|
577 |
+ |
|
578 |
+ def itervalues(d, **kw): |
|
579 |
+ return iter(d.values(**kw)) |
|
580 |
+ |
|
581 |
+ def iteritems(d, **kw): |
|
582 |
+ return iter(d.items(**kw)) |
|
583 |
+ |
|
584 |
+ def iterlists(d, **kw): |
|
585 |
+ return iter(d.lists(**kw)) |
|
586 |
+ |
|
587 |
+ viewkeys = operator.methodcaller("keys") |
|
588 |
+ |
|
589 |
+ viewvalues = operator.methodcaller("values") |
|
590 |
+ |
|
591 |
+ viewitems = operator.methodcaller("items") |
|
592 |
+else: |
|
593 |
+ def iterkeys(d, **kw): |
|
594 |
+ return d.iterkeys(**kw) |
|
595 |
+ |
|
596 |
+ def itervalues(d, **kw): |
|
597 |
+ return d.itervalues(**kw) |
|
598 |
+ |
|
599 |
+ def iteritems(d, **kw): |
|
600 |
+ return d.iteritems(**kw) |
|
601 |
+ |
|
602 |
+ def iterlists(d, **kw): |
|
603 |
+ return d.iterlists(**kw) |
|
604 |
+ |
|
605 |
+ viewkeys = operator.methodcaller("viewkeys") |
|
606 |
+ |
|
607 |
+ viewvalues = operator.methodcaller("viewvalues") |
|
608 |
+ |
|
609 |
+ viewitems = operator.methodcaller("viewitems") |
|
610 |
+ |
|
611 |
+_add_doc(iterkeys, "Return an iterator over the keys of a dictionary.") |
|
612 |
+_add_doc(itervalues, "Return an iterator over the values of a dictionary.") |
|
613 |
+_add_doc(iteritems, |
|
614 |
+ "Return an iterator over the (key, value) pairs of a dictionary.") |
|
615 |
+_add_doc(iterlists, |
|
616 |
+ "Return an iterator over the (key, [values]) pairs of a dictionary.") |
|
617 |
+ |
|
618 |
+ |
|
619 |
+if PY3: |
|
620 |
+ def b(s): |
|
621 |
+ return s.encode("latin-1") |
|
622 |
+ |
|
623 |
+ def u(s): |
|
624 |
+ return s |
|
625 |
+ unichr = chr |
|
626 |
+ import struct |
|
627 |
+ int2byte = struct.Struct(">B").pack |
|
628 |
+ del struct |
|
629 |
+ byte2int = operator.itemgetter(0) |
|
630 |
+ indexbytes = operator.getitem |
|
631 |
+ iterbytes = iter |
|
632 |
+ import io |
|
633 |
+ StringIO = io.StringIO |
|
634 |
+ BytesIO = io.BytesIO |
|
635 |
+ _assertCountEqual = "assertCountEqual" |
|
636 |
+ if sys.version_info[1] <= 1: |
|
637 |
+ _assertRaisesRegex = "assertRaisesRegexp" |
|
638 |
+ _assertRegex = "assertRegexpMatches" |
|
639 |
+ else: |
|
640 |
+ _assertRaisesRegex = "assertRaisesRegex" |
|
641 |
+ _assertRegex = "assertRegex" |
|
642 |
+else: |
|
643 |
+ def b(s): |
|
644 |
+ return s |
|
645 |
+ # Workaround for standalone backslash |
|
646 |
+ |
|
647 |
+ def u(s): |
|
648 |
+ return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape") |
|
649 |
+ unichr = unichr |
|
650 |
+ int2byte = chr |
|
651 |
+ |
|
652 |
+ def byte2int(bs): |
|
653 |
+ return ord(bs[0]) |
|
654 |
+ |
|
655 |
+ def indexbytes(buf, i): |
|
656 |
+ return ord(buf[i]) |
|
657 |
+ iterbytes = functools.partial(itertools.imap, ord) |
|
658 |
+ import StringIO |
|
659 |
+ StringIO = BytesIO = StringIO.StringIO |
|
660 |
+ _assertCountEqual = "assertItemsEqual" |
|
661 |
+ _assertRaisesRegex = "assertRaisesRegexp" |
|
662 |
+ _assertRegex = "assertRegexpMatches" |
|
663 |
+_add_doc(b, """Byte literal""") |
|
664 |
+_add_doc(u, """Text literal""") |
|
665 |
+ |
|
666 |
+ |
|
667 |
+def assertCountEqual(self, *args, **kwargs): |
|
668 |
+ return getattr(self, _assertCountEqual)(*args, **kwargs) |
|
669 |
+ |
|
670 |
+ |
|
671 |
+def assertRaisesRegex(self, *args, **kwargs): |
|
672 |
+ return getattr(self, _assertRaisesRegex)(*args, **kwargs) |
|
673 |
+ |
|
674 |
+ |
|
675 |
+def assertRegex(self, *args, **kwargs): |
|
676 |
+ return getattr(self, _assertRegex)(*args, **kwargs) |
|
677 |
+ |
|
678 |
+ |
|
679 |
+if PY3: |
|
680 |
+ exec_ = getattr(moves.builtins, "exec") |
|
681 |
+ |
|
682 |
+ def reraise(tp, value, tb=None): |
|
683 |
+ if value is None: |
|
684 |
+ value = tp() |
|
685 |
+ if value.__traceback__ is not tb: |
|
686 |
+ raise value.with_traceback(tb) |
|
687 |
+ raise value |
|
688 |
+ |
|
689 |
+else: |
|
690 |
+ def exec_(_code_, _globs_=None, _locs_=None): |
|
691 |
+ """Execute code in a namespace.""" |
|
692 |
+ if _globs_ is None: |
|
693 |
+ frame = sys._getframe(1) |
|
694 |
+ _globs_ = frame.f_globals |
|
695 |
+ if _locs_ is None: |
|
696 |
+ _locs_ = frame.f_locals |
|
697 |
+ del frame |
|
698 |
+ elif _locs_ is None: |
|
699 |
+ _locs_ = _globs_ |
|
700 |
+ exec("""exec _code_ in _globs_, _locs_""") |
|
701 |
+ |
|
702 |
+ exec_("""def reraise(tp, value, tb=None): |
|
703 |
+ raise tp, value, tb |
|
704 |
+""") |
|
705 |
+ |
|
706 |
+ |
|
707 |
+if sys.version_info[:2] == (3, 2): |
|
708 |
+ exec_("""def raise_from(value, from_value): |
|
709 |
+ if from_value is None: |
|
710 |
+ raise value |
|
711 |
+ raise value from from_value |
|
712 |
+""") |
|
713 |
+elif sys.version_info[:2] > (3, 2): |
|
714 |
+ exec_("""def raise_from(value, from_value): |
|
715 |
+ raise value from from_value |
|
716 |
+""") |
|
717 |
+else: |
|
718 |
+ def raise_from(value, from_value): |
|
719 |
+ raise value |
|
720 |
+ |
|
721 |
+ |
|
722 |
+print_ = getattr(moves.builtins, "print", None) |
|
723 |
+if print_ is None: |
|
724 |
+ def print_(*args, **kwargs): |
|
725 |
+ """The new-style print function for Python 2.4 and 2.5.""" |
|
726 |
+ fp = kwargs.pop("file", sys.stdout) |
|
727 |
+ if fp is None: |
|
728 |
+ return |
|
729 |
+ |
|
730 |
+ def write(data): |
|
731 |
+ if not isinstance(data, basestring): |
|
732 |
+ data = str(data) |
|
733 |
+ # If the file has an encoding, encode unicode with it. |
|
734 |
+ if (isinstance(fp, file) and |
|
735 |
+ isinstance(data, unicode) and |
|
736 |
+ fp.encoding is not None): |
|
737 |
+ errors = getattr(fp, "errors", None) |
|
738 |
+ if errors is None: |
|
739 |
+ errors = "strict" |
|
740 |
+ data = data.encode(fp.encoding, errors) |
|
741 |
+ fp.write(data) |
|
742 |
+ want_unicode = False |
|
743 |
+ sep = kwargs.pop("sep", None) |
|
744 |
+ if sep is not None: |
|
745 |
+ if isinstance(sep, unicode): |
|
746 |
+ want_unicode = True |
|
747 |
+ elif not isinstance(sep, str): |
|
748 |
+ raise TypeError("sep must be None or a string") |
|
749 |
+ end = kwargs.pop("end", None) |
|
750 |
+ if end is not None: |
|
751 |
+ if isinstance(end, unicode): |
|
752 |
+ want_unicode = True |
|
753 |
+ elif not isinstance(end, str): |
|
754 |
+ raise TypeError("end must be None or a string") |
|
755 |
+ if kwargs: |
|
756 |
+ raise TypeError("invalid keyword arguments to print()") |
|
757 |
+ if not want_unicode: |
|
758 |
+ for arg in args: |
|
759 |
+ if isinstance(arg, unicode): |
|
760 |
+ want_unicode = True |
|
761 |
+ break |
|
762 |
+ if want_unicode: |
|
763 |
+ newline = unicode("\n") |
|
764 |
+ space = unicode(" ") |
|
765 |
+ else: |
|
766 |
+ newline = "\n" |
|
767 |
+ space = " " |
|
768 |
+ if sep is None: |
|
769 |
+ sep = space |
|
770 |
+ if end is None: |
|
771 |
+ end = newline |
|
772 |
+ for i, arg in enumerate(args): |
|
773 |
+ if i: |
|
774 |
+ write(sep) |
|
775 |
+ write(arg) |
|
776 |
+ write(end) |
|
777 |
+if sys.version_info[:2] < (3, 3): |
|
778 |
+ _print = print_ |
|
779 |
+ |
|
780 |
+ def print_(*args, **kwargs): |
|
781 |
+ fp = kwargs.get("file", sys.stdout) |
|
782 |
+ flush = kwargs.pop("flush", False) |
|
783 |
+ _print(*args, **kwargs) |
|
784 |
+ if flush and fp is not None: |
|
785 |
+ fp.flush() |
|
786 |
+ |
|
787 |
+_add_doc(reraise, """Reraise an exception.""") |
|
788 |
+ |
|
789 |
+if sys.version_info[0:2] < (3, 4): |
|
790 |
+ def wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS, |
|
791 |
+ updated=functools.WRAPPER_UPDATES): |
|
792 |
+ def wrapper(f): |
|
793 |
+ f = functools.wraps(wrapped, assigned, updated)(f) |
|
794 |
+ f.__wrapped__ = wrapped |
|
795 |
+ return f |
|
796 |
+ return wrapper |
|
797 |
+else: |
|
798 |
+ wraps = functools.wraps |
|
799 |
+ |
|
800 |
+ |
|
801 |
+def with_metaclass(meta, *bases): |
|
802 |
+ """Create a base class with a metaclass.""" |
|
803 |
+ # This requires a bit of explanation: the basic idea is to make a dummy |
|
804 |
+ # metaclass for one level of class instantiation that replaces itself with |
|
805 |
+ # the actual metaclass. |
|
806 |
+ class metaclass(meta): |
|
807 |
+ |
|
808 |
+ def __new__(cls, name, this_bases, d): |
|
809 |
+ return meta(name, bases, d) |
|
810 |
+ return type.__new__(metaclass, 'temporary_class', (), {}) |
|
811 |
+ |
|
812 |
+ |
|
813 |
+def add_metaclass(metaclass): |
|
814 |
+ """Class decorator for creating a class with a metaclass.""" |
|
815 |
+ def wrapper(cls): |
|
816 |
+ orig_vars = cls.__dict__.copy() |
|
817 |
+ slots = orig_vars.get('__slots__') |
|
818 |
+ if slots is not None: |
|
819 |
+ if isinstance(slots, str): |
|
820 |
+ slots = [slots] |
|
821 |
+ for slots_var in slots: |
|
822 |
+ orig_vars.pop(slots_var) |
|
823 |
+ orig_vars.pop('__dict__', None) |
|
824 |
+ orig_vars.pop('__weakref__', None) |
|
825 |
+ return metaclass(cls.__name__, cls.__bases__, orig_vars) |
|
826 |
+ return wrapper |
|
827 |
+ |
|
828 |
+ |
|
829 |
+def python_2_unicode_compatible(klass): |
|
830 |
+ """ |
|
831 |
+ A decorator that defines __unicode__ and __str__ methods under Python 2. |
|
832 |
+ Under Python 3 it does nothing. |
|
833 |
+ |
|
834 |
+ To support Python 2 and 3 with a single code base, define a __str__ method |
|
835 |
+ returning text and apply this decorator to the class. |
|
836 |
+ """ |
|
837 |
+ if PY2: |
|
838 |
+ if '__str__' not in klass.__dict__: |
|
839 |
+ raise ValueError("@python_2_unicode_compatible cannot be applied " |
|
840 |
+ "to %s because it doesn't define __str__()." % |
|
841 |
+ klass.__name__) |
|
842 |
+ klass.__unicode__ = klass.__str__ |
|
843 |
+ klass.__str__ = lambda self: self.__unicode__().encode('utf-8') |
|
844 |
+ return klass |
|
845 |
+ |
|
846 |
+ |
|
847 |
+# Complete the moves implementation. |
|
848 |
+# This code is at the end of this module to speed up module loading. |
|
849 |
+# Turn this module into a package. |
|
850 |
+__path__ = [] # required for PEP 302 and PEP 451 |
|
851 |
+__package__ = __name__ # see PEP 366 @ReservedAssignment |
|
852 |
+if globals().get("__spec__") is not None: |
|
853 |
+ __spec__.submodule_search_locations = [] # PEP 451 @UndefinedVariable |
|
854 |
+# Remove other six meta path importers, since they cause problems. This can |
|
855 |
+# happen if six is removed from sys.modules and then reloaded. (Setuptools does |
|
856 |
+# this for some reason.) |
|
857 |
+if sys.meta_path: |
|
858 |
+ for i, importer in enumerate(sys.meta_path): |
|
859 |
+ # Here's some real nastiness: Another "instance" of the six module might |
|
860 |
+ # be floating around. Therefore, we can't use isinstance() to check for |
|
861 |
+ # the six meta path importer, since the other six instance will have |
|
862 |
+ # inserted an importer with different class. |
|
863 |
+ if (type(importer).__name__ == "_SixMetaPathImporter" and |
|
864 |
+ importer.name == __name__): |
|
865 |
+ del sys.meta_path[i] |
|
866 |
+ break |
|
867 |
+ del i, importer |
|
868 |
+# Finally, add the importer to the meta path import hook. |
|
869 |
+sys.meta_path.append(_importer) |
... | ... |
@@ -25,10 +25,10 @@ import json |
25 | 25 |
import tempfile |
26 | 26 |
from yaml import YAMLError |
27 | 27 |
|
28 |
-from ansible.compat.six import text_type, string_types |
|
29 | 28 |
from ansible.errors import AnsibleFileNotFound, AnsibleParserError |
30 | 29 |
from ansible.errors.yaml_strings import YAML_SYNTAX_ERROR |
31 | 30 |
from ansible.module_utils.basic import is_executable |
31 |
+from ansible.module_utils.six import text_type, string_types |
|
32 | 32 |
from ansible.module_utils._text import to_bytes, to_native, to_text |
33 | 33 |
from ansible.parsing.vault import VaultLib, b_HEADER, is_encrypted, is_encrypted_file |
34 | 34 |
from ansible.parsing.quoting import unquote |
... | ... |
@@ -43,7 +43,7 @@ except ImportError: |
43 | 43 |
display = Display() |
44 | 44 |
|
45 | 45 |
|
46 |
-class DataLoader(): |
|
46 |
+class DataLoader: |
|
47 | 47 |
|
48 | 48 |
''' |
49 | 49 |
The DataLoader class is used to load and parse YAML or JSON content, |
... | ... |
@@ -19,14 +19,15 @@ |
19 | 19 |
from __future__ import (absolute_import, division, print_function) |
20 | 20 |
__metaclass__ = type |
21 | 21 |
|
22 |
-from ansible.compat.six import iteritems, string_types |
|
23 | 22 |
|
24 | 23 |
from ansible.errors import AnsibleParserError,AnsibleError |
24 |
+from ansible.module_utils.six import iteritems, string_types |
|
25 | 25 |
from ansible.module_utils._text import to_text |
26 | 26 |
from ansible.plugins import module_loader |
27 | 27 |
from ansible.parsing.splitter import parse_kv, split_args |
28 | 28 |
from ansible.template import Templar |
29 | 29 |
|
30 |
+ |
|
30 | 31 |
# For filtering out modules correctly below |
31 | 32 |
RAW_PARAM_MODULES = ([ |
32 | 33 |
'command', |
... | ... |
@@ -43,6 +44,7 @@ RAW_PARAM_MODULES = ([ |
43 | 43 |
'meta', |
44 | 44 |
]) |
45 | 45 |
|
46 |
+ |
|
46 | 47 |
class ModuleArgsParser: |
47 | 48 |
|
48 | 49 |
""" |
... | ... |
@@ -62,9 +62,9 @@ try: |
62 | 62 |
except ImportError: |
63 | 63 |
HAS_AES = False |
64 | 64 |
|
65 |
-from ansible.compat.six import PY3, binary_type |
|
66 |
-from ansible.compat.six.moves import zip |
|
67 | 65 |
from ansible.errors import AnsibleError |
66 |
+from ansible.module_utils.six import PY3, binary_type |
|
67 |
+from ansible.module_utils.six.moves import zip |
|
68 | 68 |
from ansible.module_utils._text import to_bytes, to_text |
69 | 69 |
|
70 | 70 |
try: |
... | ... |
@@ -20,8 +20,8 @@ from __future__ import (absolute_import, division, print_function) |
20 | 20 |
__metaclass__ = type |
21 | 21 |
|
22 | 22 |
import yaml |
23 |
-from ansible.compat.six import PY3 |
|
24 | 23 |
|
24 |
+from ansible.module_utils.six import PY3 |
|
25 | 25 |
from ansible.parsing.yaml.objects import AnsibleUnicode, AnsibleSequence, AnsibleMapping |
26 | 26 |
from ansible.parsing.yaml.objects import AnsibleVaultEncryptedUnicode |
27 | 27 |
from ansible.vars.hostvars import HostVars |
... | ... |
@@ -27,7 +27,7 @@ from functools import partial |
27 | 27 |
|
28 | 28 |
from jinja2.exceptions import UndefinedError |
29 | 29 |
|
30 |
-from ansible.compat.six import iteritems, string_types, with_metaclass |
|
30 |
+from ansible.module_utils.six import iteritems, string_types, with_metaclass |
|
31 | 31 |
from ansible.errors import AnsibleParserError, AnsibleUndefinedVariable |
32 | 32 |
from ansible.module_utils._text import to_text |
33 | 33 |
from ansible.playbook.attribute import Attribute, FieldAttribute |
... | ... |
@@ -25,12 +25,12 @@ import re |
25 | 25 |
from jinja2.compiler import generate |
26 | 26 |
from jinja2.exceptions import UndefinedError |
27 | 27 |
|
28 |
-from ansible.compat.six import text_type |
|
29 | 28 |
from ansible.errors import AnsibleError, AnsibleUndefinedVariable |
29 |
+from ansible.module_utils.six import text_type |
|
30 |
+from ansible.module_utils._text import to_native |
|
30 | 31 |
from ansible.playbook.attribute import FieldAttribute |
31 | 32 |
from ansible.template import Templar |
32 | 33 |
from ansible.template.safe_eval import safe_eval |
33 |
-from ansible.module_utils._text import to_native |
|
34 | 34 |
|
35 | 35 |
try: |
36 | 36 |
from __main__ import display |
... | ... |
@@ -38,6 +38,7 @@ except ImportError: |
38 | 38 |
from ansible.utils.display import Display |
39 | 39 |
display = Display() |
40 | 40 |
|
41 |
+ |
|
41 | 42 |
DEFINED_REGEX = re.compile(r'(hostvars\[.+\]|[\w_]+)\s+(not\s+is|is|is\s+not)\s+(defined|undefined)') |
42 | 43 |
LOOKUP_REGEX = re.compile(r'lookup\s*\(') |
43 | 44 |
VALID_VAR_REGEX = re.compile("^[_A-Za-z][_a-zA-Z0-9]*$") |
... | ... |
@@ -21,8 +21,8 @@ __metaclass__ = type |
21 | 21 |
import os |
22 | 22 |
|
23 | 23 |
from ansible import constants as C |
24 |
-from ansible.compat.six import string_types |
|
25 | 24 |
from ansible.errors import AnsibleParserError, AnsibleUndefinedVariable, AnsibleFileNotFound |
25 |
+from ansible.module_utils.six import string_types |
|
26 | 26 |
|
27 | 27 |
try: |
28 | 28 |
from __main__ import display |
... | ... |
@@ -21,11 +21,12 @@ __metaclass__ = type |
21 | 21 |
|
22 | 22 |
import itertools |
23 | 23 |
|
24 |
-from ansible.compat.six import string_types |
|
25 | 24 |
from ansible.errors import AnsibleError |
25 |
+from ansible.module_utils.six import string_types |
|
26 | 26 |
from ansible.playbook.attribute import FieldAttribute |
27 | 27 |
from ansible.playbook.base import Base |
28 | 28 |
|
29 |
+ |
|
29 | 30 |
class LoopControl(Base): |
30 | 31 |
|
31 | 32 |
_loop_var = FieldAttribute(isa='str') |
... | ... |
@@ -19,10 +19,10 @@ |
19 | 19 |
from __future__ import (absolute_import, division, print_function) |
20 | 20 |
__metaclass__ = type |
21 | 21 |
|
22 |
-from ansible.compat.six import string_types |
|
23 | 22 |
from ansible import constants as C |
24 | 23 |
|
25 | 24 |
from ansible.errors import AnsibleParserError |
25 |
+from ansible.module_utils.six import string_types |
|
26 | 26 |
|
27 | 27 |
from ansible.playbook.attribute import FieldAttribute |
28 | 28 |
from ansible.playbook.base import Base |
... | ... |
@@ -27,14 +27,15 @@ import random |
27 | 27 |
import re |
28 | 28 |
import string |
29 | 29 |
|
30 |
-from ansible.compat.six import iteritems, string_types |
|
31 |
-from ansible.compat.six.moves import shlex_quote |
|
32 | 30 |
from ansible import constants as C |
33 | 31 |
from ansible.errors import AnsibleError |
32 |
+from ansible.module_utils.six import iteritems, string_types |
|
33 |
+from ansible.module_utils.six.moves import shlex_quote |
|
34 | 34 |
from ansible.module_utils._text import to_bytes |
35 | 35 |
from ansible.playbook.attribute import FieldAttribute |
36 | 36 |
from ansible.playbook.base import Base |
37 | 37 |
|
38 |
+ |
|
38 | 39 |
boolean = C.mk_boolean |
39 | 40 |
|
40 | 41 |
__all__ = ['PlayContext'] |
... | ... |
@@ -21,8 +21,8 @@ __metaclass__ = type |
21 | 21 |
|
22 | 22 |
import os |
23 | 23 |
|
24 |
-from ansible.compat.six import iteritems |
|
25 | 24 |
from ansible.errors import AnsibleParserError, AnsibleError |
25 |
+from ansible.module_utils.six import iteritems |
|
26 | 26 |
from ansible.parsing.splitter import split_args, parse_kv |
27 | 27 |
from ansible.parsing.yaml.objects import AnsibleBaseYAMLObject, AnsibleMapping |
28 | 28 |
from ansible.playbook.attribute import FieldAttribute |
... | ... |
@@ -31,6 +31,7 @@ from ansible.playbook.conditional import Conditional |
31 | 31 |
from ansible.playbook.taggable import Taggable |
32 | 32 |
from ansible.template import Templar |
33 | 33 |
|
34 |
+ |
|
34 | 35 |
class PlaybookInclude(Base, Conditional, Taggable): |
35 | 36 |
|
36 | 37 |
_name = FieldAttribute(isa='string') |
... | ... |
@@ -22,8 +22,8 @@ __metaclass__ = type |
22 | 22 |
import collections |
23 | 23 |
import os |
24 | 24 |
|
25 |
-from ansible.compat.six import iteritems, binary_type, text_type |
|
26 | 25 |
from ansible.errors import AnsibleError, AnsibleParserError |
26 |
+from ansible.module_utils.six import iteritems, binary_type, text_type |
|
27 | 27 |
from ansible.playbook.attribute import FieldAttribute |
28 | 28 |
from ansible.playbook.base import Base |
29 | 29 |
from ansible.playbook.become import Become |
... | ... |
@@ -19,12 +19,11 @@ |
19 | 19 |
from __future__ import (absolute_import, division, print_function) |
20 | 20 |
__metaclass__ = type |
21 | 21 |
|
22 |
-from ansible.compat.six import iteritems, string_types |
|
23 |
- |
|
24 | 22 |
import os |
25 | 23 |
|
26 | 24 |
from ansible import constants as C |
27 | 25 |
from ansible.errors import AnsibleError |
26 |
+from ansible.module_utils.six import iteritems, string_types |
|
28 | 27 |
from ansible.parsing.yaml.objects import AnsibleBaseYAMLObject, AnsibleMapping |
29 | 28 |
from ansible.playbook.attribute import Attribute, FieldAttribute |
30 | 29 |
from ansible.playbook.base import Base |
... | ... |
@@ -19,11 +19,10 @@ |
19 | 19 |
from __future__ import (absolute_import, division, print_function) |
20 | 20 |
__metaclass__ = type |
21 | 21 |
|
22 |
-from ansible.compat.six import iteritems, string_types |
|
23 |
- |
|
24 | 22 |
import os |
25 | 23 |
|
26 | 24 |
from ansible.errors import AnsibleError, AnsibleParserError |
25 |
+from ansible.module_utils.six import iteritems, string_types |
|
27 | 26 |
from ansible.parsing.yaml.objects import AnsibleBaseYAMLObject |
28 | 27 |
from ansible.playbook.attribute import Attribute, FieldAttribute |
29 | 28 |
from ansible.playbook.role.definition import RoleDefinition |
... | ... |
@@ -21,9 +21,8 @@ __metaclass__ = type |
21 | 21 |
|
22 | 22 |
import os |
23 | 23 |
|
24 |
-from ansible.compat.six import iteritems, string_types |
|
25 |
- |
|
26 | 24 |
from ansible.errors import AnsibleParserError, AnsibleError |
25 |
+from ansible.module_utils.six import iteritems, string_types |
|
27 | 26 |
from ansible.playbook.attribute import Attribute, FieldAttribute |
28 | 27 |
from ansible.playbook.base import Base |
29 | 28 |
from ansible.playbook.helpers import load_list_of_roles |
... | ... |
@@ -19,16 +19,16 @@ |
19 | 19 |
from __future__ import (absolute_import, division, print_function) |
20 | 20 |
__metaclass__ = type |
21 | 21 |
|
22 |
-from ansible.compat.six import string_types |
|
23 |
- |
|
24 | 22 |
import os |
25 | 23 |
import shutil |
26 | 24 |
import subprocess |
27 | 25 |
import tempfile |
28 | 26 |
|
29 | 27 |
from ansible.errors import AnsibleError |
28 |
+from ansible.module_utils.six import string_types |
|
30 | 29 |
from ansible.playbook.role.definition import RoleDefinition |
31 | 30 |
|
31 |
+ |
|
32 | 32 |
__all__ = ['RoleRequirement'] |
33 | 33 |
|
34 | 34 |
|
... | ... |
@@ -21,11 +21,12 @@ __metaclass__ = type |
21 | 21 |
|
22 | 22 |
import itertools |
23 | 23 |
|
24 |
-from ansible.compat.six import string_types |
|
25 | 24 |
from ansible.errors import AnsibleError |
25 |
+from ansible.module_utils.six import string_types |
|
26 | 26 |
from ansible.playbook.attribute import FieldAttribute |
27 | 27 |
from ansible.template import Templar |
28 | 28 |
|
29 |
+ |
|
29 | 30 |
class Taggable: |
30 | 31 |
|
31 | 32 |
untagged = frozenset(['untagged']) |
... | ... |
@@ -21,8 +21,8 @@ __metaclass__ = type |
21 | 21 |
|
22 | 22 |
import os |
23 | 23 |
|
24 |
-from ansible.compat.six import iteritems, string_types |
|
25 | 24 |
from ansible.errors import AnsibleError, AnsibleParserError |
25 |
+from ansible.module_utils.six import iteritems, string_types |
|
26 | 26 |
from ansible.module_utils._text import to_native |
27 | 27 |
from ansible.parsing.mod_args import ModuleArgsParser |
28 | 28 |
from ansible.parsing.yaml.objects import AnsibleBaseYAMLObject, AnsibleMapping, AnsibleUnicode |
... | ... |
@@ -30,12 +30,12 @@ import time |
30 | 30 |
from abc import ABCMeta, abstractmethod |
31 | 31 |
|
32 | 32 |
from ansible import constants as C |
33 |
-from ansible.compat.six import binary_type, string_types, text_type, iteritems, with_metaclass |
|
34 |
-from ansible.compat.six.moves import shlex_quote |
|
35 | 33 |
from ansible.errors import AnsibleError, AnsibleConnectionFailure |
36 | 34 |
from ansible.executor.module_common import modify_module, build_windows_module_payload |
37 |
-from ansible.module_utils._text import to_bytes, to_native, to_text |
|
38 | 35 |
from ansible.module_utils.json_utils import _filter_non_json_lines |
36 |
+from ansible.module_utils.six import binary_type, string_types, text_type, iteritems, with_metaclass |
|
37 |
+from ansible.module_utils.six.moves import shlex_quote |
|
38 |
+from ansible.module_utils._text import to_bytes, to_native, to_text |
|
39 | 39 |
from ansible.parsing.utils.jsonify import jsonify |
40 | 40 |
from ansible.playbook.play_context import MAGIC_VARIABLE_MAPPING |
41 | 41 |
from ansible.release import __version__ |
... | ... |
@@ -20,11 +20,10 @@ |
20 | 20 |
from __future__ import (absolute_import, division, print_function) |
21 | 21 |
__metaclass__ = type |
22 | 22 |
|
23 |
-from ansible.compat.six import string_types |
|
24 |
- |
|
23 |
+from ansible.errors import AnsibleError |
|
24 |
+from ansible.module_utils.six import string_types |
|
25 | 25 |
from ansible.plugins.action import ActionBase |
26 | 26 |
from ansible.parsing.utils.addresses import parse_address |
27 |
-from ansible.errors import AnsibleError |
|
28 | 27 |
|
29 | 28 |
try: |
30 | 29 |
from __main__ import display |
... | ... |
@@ -18,8 +18,8 @@ |
18 | 18 |
from __future__ import (absolute_import, division, print_function) |
19 | 19 |
__metaclass__ = type |
20 | 20 |
|
21 |
-from ansible.compat.six import string_types |
|
22 | 21 |
from ansible.errors import AnsibleUndefinedVariable |
22 |
+from ansible.module_utils.six import string_types |
|
23 | 23 |
from ansible.module_utils._text import to_text |
24 | 24 |
from ansible.plugins.action import ActionBase |
25 | 25 |
|
... | ... |
@@ -23,13 +23,13 @@ import os |
23 | 23 |
import sys |
24 | 24 |
import copy |
25 | 25 |
|
26 |
-from ansible.plugins.action.normal import ActionModule as _ActionModule |
|
27 |
-from ansible.utils.path import unfrackpath |
|
28 |
-from ansible.plugins import connection_loader |
|
29 |
-from ansible.compat.six import iteritems |
|
30 |
-from ansible.module_utils.eos import eos_argument_spec |
|
31 | 26 |
from ansible.module_utils.basic import AnsibleFallbackNotFound |
27 |
+from ansible.module_utils.eos import eos_argument_spec |
|
28 |
+from ansible.module_utils.six import iteritems |
|
32 | 29 |
from ansible.module_utils._text import to_bytes |
30 |
+from ansible.plugins import connection_loader |
|
31 |
+from ansible.plugins.action.normal import ActionModule as _ActionModule |
|
32 |
+from ansible.utils.path import unfrackpath |
|
33 | 33 |
|
34 | 34 |
try: |
35 | 35 |
from __main__ import display |
... | ... |
@@ -37,6 +37,7 @@ except ImportError: |
37 | 37 |
from ansible.utils.display import Display |
38 | 38 |
display = Display() |
39 | 39 |
|
40 |
+ |
|
40 | 41 |
class ActionModule(_ActionModule): |
41 | 42 |
|
42 | 43 |
def run(self, tmp=None, task_vars=None): |
... | ... |
@@ -22,9 +22,10 @@ from os import path, walk |
22 | 22 |
import re |
23 | 23 |
|
24 | 24 |
from ansible.errors import AnsibleError |
25 |
+from ansible.module_utils.six import string_types |
|
25 | 26 |
from ansible.module_utils._text import to_native, to_text |
26 | 27 |
from ansible.plugins.action import ActionBase |
27 |
-from ansible.compat.six import string_types |
|
28 |
+ |
|
28 | 29 |
|
29 | 30 |
class ActionModule(ActionBase): |
30 | 31 |
|
... | ... |
@@ -26,9 +26,9 @@ import copy |
26 | 26 |
from ansible.plugins.action.normal import ActionModule as _ActionModule |
27 | 27 |
from ansible.utils.path import unfrackpath |
28 | 28 |
from ansible.plugins import connection_loader |
29 |
-from ansible.compat.six import iteritems |
|
30 |
-from ansible.module_utils.ios import ios_argument_spec |
|
31 | 29 |
from ansible.module_utils.basic import AnsibleFallbackNotFound |
30 |
+from ansible.module_utils.ios import ios_argument_spec |
|
31 |
+from ansible.module_utils.six import iteritems |
|
32 | 32 |
from ansible.module_utils._text import to_bytes |
33 | 33 |
|
34 | 34 |
try: |
... | ... |
@@ -37,6 +37,7 @@ except ImportError: |
37 | 37 |
from ansible.utils.display import Display |
38 | 38 |
display = Display() |
39 | 39 |
|
40 |
+ |
|
40 | 41 |
class ActionModule(_ActionModule): |
41 | 42 |
|
42 | 43 |
def run(self, tmp=None, task_vars=None): |
... | ... |
@@ -23,13 +23,13 @@ import os |
23 | 23 |
import sys |
24 | 24 |
import copy |
25 | 25 |
|
26 |
-from ansible.plugins.action.normal import ActionModule as _ActionModule |
|
26 |
+from ansible.module_utils.basic import AnsibleFallbackNotFound |
|
27 |
+from ansible.module_utils.iosxr import iosxr_argument_spec |
|
28 |
+from ansible.module_utils.six import iteritems |
|
27 | 29 |
from ansible.module_utils._text import to_bytes |
28 |
-from ansible.utils.path import unfrackpath |
|
29 | 30 |
from ansible.plugins import connection_loader |
30 |
-from ansible.compat.six import iteritems |
|
31 |
-from ansible.module_utils.iosxr import iosxr_argument_spec |
|
32 |
-from ansible.module_utils.basic import AnsibleFallbackNotFound |
|
31 |
+from ansible.plugins.action.normal import ActionModule as _ActionModule |
|
32 |
+from ansible.utils.path import unfrackpath |
|
33 | 33 |
|
34 | 34 |
try: |
35 | 35 |
from __main__ import display |
... | ... |
@@ -23,12 +23,12 @@ import os |
23 | 23 |
import sys |
24 | 24 |
import copy |
25 | 25 |
|
26 |
+from ansible.module_utils.basic import AnsibleFallbackNotFound |
|
27 |
+from ansible.module_utils.junos import junos_argument_spec |
|
28 |
+from ansible.module_utils.six import iteritems |
|
29 |
+from ansible.plugins import connection_loader, module_loader |
|
26 | 30 |
from ansible.plugins.action.normal import ActionModule as _ActionModule |
27 | 31 |
from ansible.utils.path import unfrackpath |
28 |
-from ansible.plugins import connection_loader, module_loader |
|
29 |
-from ansible.compat.six import iteritems |
|
30 |
-from ansible.module_utils.junos import junos_argument_spec |
|
31 |
-from ansible.module_utils.basic import AnsibleFallbackNotFound |
|
32 | 32 |
|
33 | 33 |
try: |
34 | 34 |
from __main__ import display |
... | ... |
@@ -36,6 +36,7 @@ except ImportError: |
36 | 36 |
from ansible.utils.display import Display |
37 | 37 |
display = Display() |
38 | 38 |
|
39 |
+ |
|
39 | 40 |
class ActionModule(_ActionModule): |
40 | 41 |
|
41 | 42 |
def run(self, tmp=None, task_vars=None): |
... | ... |
@@ -26,9 +26,9 @@ import copy |
26 | 26 |
from ansible.plugins.action.normal import ActionModule as _ActionModule |
27 | 27 |
from ansible.utils.path import unfrackpath |
28 | 28 |
from ansible.plugins import connection_loader |
29 |
-from ansible.compat.six import iteritems |
|
30 |
-from ansible.module_utils.nxos import nxos_argument_spec |
|
31 | 29 |
from ansible.module_utils.basic import AnsibleFallbackNotFound |
30 |
+from ansible.module_utils.nxos import nxos_argument_spec |
|
31 |
+from ansible.module_utils.six import iteritems |
|
32 | 32 |
from ansible.module_utils._text import to_bytes |
33 | 33 |
|
34 | 34 |
try: |
... | ... |
@@ -37,6 +37,7 @@ except ImportError: |
37 | 37 |
from ansible.utils.display import Display |
38 | 38 |
display = Display() |
39 | 39 |
|
40 |
+ |
|
40 | 41 |
class ActionModule(_ActionModule): |
41 | 42 |
|
42 | 43 |
def run(self, tmp=None, task_vars=None): |
... | ... |
@@ -21,10 +21,11 @@ __metaclass__ = type |
21 | 21 |
|
22 | 22 |
import json |
23 | 23 |
|
24 |
-from ansible.compat.six import string_types |
|
24 |
+from ansible.module_utils.six import string_types |
|
25 | 25 |
from ansible.plugins.action import ActionBase |
26 | 26 |
from ansible.plugins.action.net_template import ActionModule as NetActionModule |
27 | 27 |
|
28 |
+ |
|
28 | 29 |
class ActionModule(NetActionModule, ActionBase): |
29 | 30 |
|
30 | 31 |
def run(self, tmp=None, task_vars=None): |
... | ... |
@@ -18,12 +18,12 @@ |
18 | 18 |
from __future__ import (absolute_import, division, print_function) |
19 | 19 |
__metaclass__ = type |
20 | 20 |
|
21 |
-from ansible.compat.six import iteritems, string_types |
|
22 |
- |
|
23 | 21 |
from ansible.constants import mk_boolean as boolean |
22 |
+from ansible.module_utils.six import iteritems, string_types |
|
24 | 23 |
from ansible.plugins.action import ActionBase |
25 | 24 |
from ansible.utils.vars import isidentifier |
26 | 25 |
|
26 |
+ |
|
27 | 27 |
class ActionModule(ActionBase): |
28 | 28 |
|
29 | 29 |
TRANSFERS_FILES = False |
... | ... |
@@ -18,11 +18,12 @@ |
18 | 18 |
from __future__ import (absolute_import, division, print_function) |
19 | 19 |
__metaclass__ = type |
20 | 20 |
|
21 |
-from ansible.compat.six import iteritems, string_types |
|
22 | 21 |
from ansible.constants import mk_boolean as boolean |
22 |
+from ansible.module_utils.six import iteritems, string_types |
|
23 | 23 |
from ansible.plugins.action import ActionBase |
24 | 24 |
from ansible.utils.vars import isidentifier |
25 | 25 |
|
26 |
+ |
|
26 | 27 |
class ActionModule(ActionBase): |
27 | 28 |
|
28 | 29 |
TRANSFERS_FILES = False |
... | ... |
@@ -23,10 +23,9 @@ import pwd |
23 | 23 |
import time |
24 | 24 |
|
25 | 25 |
from ansible import constants as C |
26 |
-from ansible.compat.six import string_types |
|
27 | 26 |
from ansible.errors import AnsibleError |
27 |
+from ansible.module_utils.six import string_types |
|
28 | 28 |
from ansible.module_utils._text import to_bytes, to_native, to_text |
29 |
-from ansible.module_utils.pycompat24 import get_exception |
|
30 | 29 |
from ansible.plugins.action import ActionBase |
31 | 30 |
from ansible.utils.hashing import checksum_s |
32 | 31 |
|
... | ... |
@@ -45,8 +44,8 @@ class ActionModule(ActionBase): |
45 | 45 |
dest = os.path.join(dest, base) |
46 | 46 |
dest_stat = self._execute_remote_stat(dest, all_vars=all_vars, follow=False, tmp=tmp) |
47 | 47 |
|
48 |
- except AnsibleError: |
|
49 |
- return dict(failed=True, msg=to_native(get_exception())) |
|
48 |
+ except AnsibleError as e: |
|
49 |
+ return dict(failed=True, msg=to_native(e)) |
|
50 | 50 |
|
51 | 51 |
return dest_stat['checksum'] |
52 | 52 |
|
... | ... |
@@ -72,9 +71,9 @@ class ActionModule(ActionBase): |
72 | 72 |
else: |
73 | 73 |
try: |
74 | 74 |
source = self._find_needle('templates', source) |
75 |
- except AnsibleError: |
|
75 |
+ except AnsibleError as e: |
|
76 | 76 |
result['failed'] = True |
77 |
- result['msg'] = to_native(get_exception()) |
|
77 |
+ result['msg'] = to_native(e) |
|
78 | 78 |
|
79 | 79 |
if 'failed' in result: |
80 | 80 |
return result |
... | ... |
@@ -26,10 +26,10 @@ import copy |
26 | 26 |
from ansible.plugins.action.normal import ActionModule as _ActionModule |
27 | 27 |
from ansible.utils.path import unfrackpath |
28 | 28 |
from ansible.plugins import connection_loader |
29 |
-from ansible.compat.six import iteritems |
|
30 |
-from ansible.module_utils.vyos import vyos_argument_spec |
|
31 | 29 |
from ansible.module_utils.basic import AnsibleFallbackNotFound |
30 |
+from ansible.module_utils.six import iteritems |
|
32 | 31 |
from ansible.module_utils._text import to_bytes |
32 |
+from ansible.module_utils.vyos import vyos_argument_spec |
|
33 | 33 |
|
34 | 34 |
try: |
35 | 35 |
from __main__ import display |
... | ... |
@@ -37,6 +37,7 @@ except ImportError: |
37 | 37 |
from ansible.utils.display import Display |
38 | 38 |
display = Display() |
39 | 39 |
|
40 |
+ |
|
40 | 41 |
class ActionModule(_ActionModule): |
41 | 42 |
|
42 | 43 |
def run(self, tmp=None, task_vars=None): |
... | ... |
@@ -24,10 +24,10 @@ from abc import ABCMeta, abstractmethod |
24 | 24 |
from collections import MutableMapping |
25 | 25 |
|
26 | 26 |
from ansible import constants as C |
27 |
-from ansible.compat.six import with_metaclass |
|
28 | 27 |
from ansible.errors import AnsibleError |
29 |
-from ansible.plugins import cache_loader |
|
28 |
+from ansible.module_utils.six import with_metaclass |
|
30 | 29 |
from ansible.module_utils._text import to_bytes |
30 |
+from ansible.plugins import cache_loader |
|
31 | 31 |
|
32 | 32 |
try: |
33 | 33 |
from __main__ import display |
... | ... |
@@ -36,7 +36,6 @@ except ImportError: |
36 | 36 |
display = Display() |
37 | 37 |
|
38 | 38 |
|
39 |
- |
|
40 | 39 |
class BaseCacheModule(with_metaclass(ABCMeta, object)): |
41 | 40 |
|
42 | 41 |
# Backwards compat only. Just import the global display instead |
... | ... |
@@ -61,7 +61,6 @@ import random |
61 | 61 |
import time |
62 | 62 |
import codecs |
63 | 63 |
import uuid |
64 |
-from ansible.compat.six.moves import configparser |
|
65 | 64 |
|
66 | 65 |
try: |
67 | 66 |
import certifi |
... | ... |
@@ -75,6 +74,7 @@ try: |
75 | 75 |
except ImportError: |
76 | 76 |
HAS_FLATDICT = False |
77 | 77 |
|
78 |
+from ansible.module_utils.six.moves import configparser |
|
78 | 79 |
from ansible.plugins.callback import CallbackBase |
79 | 80 |
|
80 | 81 |
|
... | ... |
@@ -27,12 +27,14 @@ import collections |
27 | 27 |
import os |
28 | 28 |
import time |
29 | 29 |
|
30 |
+from ansible.module_utils.six.moves import reduce |
|
30 | 31 |
from ansible.plugins.callback import CallbackBase |
31 |
-from ansible.compat.six.moves import reduce |
|
32 |
+ |
|
32 | 33 |
|
33 | 34 |
# define start time |
34 | 35 |
t0 = tn = time.time() |
35 | 36 |
|
37 |
+ |
|
36 | 38 |
def secondsToStr(t): |
37 | 39 |
# http://bytes.com/topic/python/answers/635958-handy-short-cut-formatting-elapsed-time-floating-point-seconds |
38 | 40 |
rediv = lambda ll, b: list(divmod(ll[0], b)) + ll[1:] |
... | ... |
@@ -24,23 +24,21 @@ import gettext |
24 | 24 |
import os |
25 | 25 |
import shlex |
26 | 26 |
from abc import ABCMeta, abstractmethod, abstractproperty |
27 |
- |
|
28 | 27 |
from functools import wraps |
29 |
-from ansible.compat.six import with_metaclass |
|
30 | 28 |
|
31 | 29 |
from ansible import constants as C |
32 |
-from ansible.compat.six import string_types |
|
33 | 30 |
from ansible.errors import AnsibleError |
31 |
+from ansible.module_utils.six import string_types, with_metaclass |
|
34 | 32 |
from ansible.module_utils._text import to_bytes, to_text |
35 | 33 |
from ansible.plugins import shell_loader |
36 | 34 |
|
37 |
- |
|
38 | 35 |
try: |
39 | 36 |
from __main__ import display |
40 | 37 |
except ImportError: |
41 | 38 |
from ansible.utils.display import Display |
42 | 39 |
display = Display() |
43 | 40 |
|
41 |
+ |
|
44 | 42 |
__all__ = ['ConnectionBase', 'ensure_connect'] |
45 | 43 |
|
46 | 44 |
BUFSIZE = 65536 |
... | ... |
@@ -26,9 +26,9 @@ import subprocess |
26 | 26 |
import traceback |
27 | 27 |
|
28 | 28 |
from ansible import constants as C |
29 |
-from ansible.compat.six.moves import shlex_quote |
|
30 | 29 |
from ansible.errors import AnsibleError |
31 | 30 |
from ansible.module_utils.basic import is_executable |
31 |
+from ansible.module_utils.six.moves import shlex_quote |
|
32 | 32 |
from ansible.module_utils._text import to_bytes |
33 | 33 |
from ansible.plugins.connection import ConnectionBase, BUFSIZE |
34 | 34 |
|
... | ... |
@@ -33,8 +33,8 @@ import re |
33 | 33 |
from distutils.version import LooseVersion |
34 | 34 |
|
35 | 35 |
import ansible.constants as C |
36 |
-from ansible.compat.six.moves import shlex_quote |
|
37 | 36 |
from ansible.errors import AnsibleError, AnsibleFileNotFound |
37 |
+from ansible.module_utils.six.moves import shlex_quote |
|
38 | 38 |
from ansible.module_utils._text import to_bytes |
39 | 39 |
from ansible.plugins.connection import ConnectionBase, BUFSIZE |
40 | 40 |
|
... | ... |
@@ -26,8 +26,8 @@ import os.path |
26 | 26 |
import subprocess |
27 | 27 |
import traceback |
28 | 28 |
|
29 |
-from ansible.compat.six.moves import shlex_quote |
|
30 | 29 |
from ansible.errors import AnsibleError |
30 |
+from ansible.module_utils.six.moves import shlex_quote |
|
31 | 31 |
from ansible.module_utils._text import to_bytes |
32 | 32 |
from ansible.plugins.connection import ConnectionBase, BUFSIZE |
33 | 33 |
|
... | ... |
@@ -27,8 +27,8 @@ import subprocess |
27 | 27 |
import traceback |
28 | 28 |
|
29 | 29 |
from ansible import constants as C |
30 |
-from ansible.compat.six.moves import shlex_quote |
|
31 | 30 |
from ansible.errors import AnsibleError |
31 |
+from ansible.module_utils.six.moves import shlex_quote |
|
32 | 32 |
from ansible.module_utils._text import to_bytes |
33 | 33 |
from ansible.plugins.connection import ConnectionBase, BUFSIZE |
34 | 34 |
|
... | ... |
@@ -38,8 +38,8 @@ import getpass |
38 | 38 |
|
39 | 39 |
import ansible.constants as C |
40 | 40 |
from ansible.compat import selectors |
41 |
-from ansible.compat.six import text_type, binary_type |
|
42 | 41 |
from ansible.errors import AnsibleError, AnsibleFileNotFound |
42 |
+from ansible.module_utils.six import text_type, binary_type |
|
43 | 43 |
from ansible.module_utils._text import to_bytes, to_native, to_text |
44 | 44 |
from ansible.plugins.connection import ConnectionBase |
45 | 45 |
|
... | ... |
@@ -37,11 +37,10 @@ import re |
37 | 37 |
from termios import tcflush, TCIFLUSH |
38 | 38 |
from binascii import hexlify |
39 | 39 |
|
40 |
-from ansible.compat.six import iteritems |
|
41 |
- |
|
42 | 40 |
from ansible import constants as C |
43 |
-from ansible.compat.six.moves import input |
|
44 | 41 |
from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleFileNotFound |
42 |
+from ansible.module_utils.six import iteritems |
|
43 |
+from ansible.module_utils.six.moves import input |
|
45 | 44 |
from ansible.plugins.connection import ConnectionBase |
46 | 45 |
from ansible.utils.path import makedirs_safe |
47 | 46 |
from ansible.module_utils._text import to_bytes |
... | ... |
@@ -109,12 +109,12 @@ import time |
109 | 109 |
|
110 | 110 |
from functools import wraps |
111 | 111 |
from ansible import constants as C |
112 |
-from ansible.compat import selectors |
|
113 |
-from ansible.compat.six import PY3, text_type, binary_type |
|
114 |
-from ansible.compat.six.moves import shlex_quote |
|
115 | 112 |
from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleFileNotFound |
116 | 113 |
from ansible.errors import AnsibleOptionsError |
117 | 114 |
from ansible.module_utils.basic import BOOLEANS |
115 |
+from ansible.compat import selectors |
|
116 |
+from ansible.module_utils.six import PY3, text_type, binary_type |
|
117 |
+from ansible.module_utils.six.moves import shlex_quote |
|
118 | 118 |
from ansible.module_utils._text import to_bytes, to_native, to_text |
119 | 119 |
from ansible.plugins.connection import ConnectionBase, BUFSIZE |
120 | 120 |
from ansible.utils.path import unfrackpath, makedirs_safe |
... | ... |
@@ -127,6 +127,7 @@ except ImportError: |
127 | 127 |
from ansible.utils.display import Display |
128 | 128 |
display = Display() |
129 | 129 |
|
130 |
+ |
|
130 | 131 |
SSHPASS_AVAILABLE = None |
131 | 132 |
|
132 | 133 |
|
... | ... |
@@ -37,12 +37,11 @@ try: |
37 | 37 |
except ImportError: |
38 | 38 |
pass |
39 | 39 |
|
40 |
-from ansible.compat.six import string_types |
|
41 |
-from ansible.compat.six.moves.urllib.parse import urlunsplit |
|
42 | 40 |
from ansible.errors import AnsibleError, AnsibleConnectionFailure |
43 | 41 |
from ansible.errors import AnsibleFileNotFound |
42 |
+from ansible.module_utils.six import string_types |
|
43 |
+from ansible.module_utils.six.moves.urllib.parse import urlunsplit |
|
44 | 44 |
from ansible.module_utils._text import to_bytes, to_native, to_text |
45 |
-from ansible.module_utils.pycompat24 import get_exception |
|
46 | 45 |
from ansible.plugins.connection import ConnectionBase |
47 | 46 |
from ansible.plugins.shell.powershell import exec_wrapper, become_wrapper, leaf_exec |
48 | 47 |
from ansible.utils.hashing import secure_hash |
... | ... |
@@ -52,14 +51,12 @@ try: |
52 | 52 |
import winrm |
53 | 53 |
from winrm import Response |
54 | 54 |
from winrm.protocol import Protocol |
55 |
-except ImportError: |
|
56 |
- e = get_exception() |
|
55 |
+except ImportError as e: |
|
57 | 56 |
raise AnsibleError("winrm or requests is not installed: %s" % str(e)) |
58 | 57 |
|
59 | 58 |
try: |
60 | 59 |
import xmltodict |
61 |
-except ImportError: |
|
62 |
- e = get_exception() |
|
60 |
+except ImportError as e: |
|
63 | 61 |
raise AnsibleError("xmltodict is not installed: %s" % str(e)) |
64 | 62 |
|
65 | 63 |
try: |
... | ... |
@@ -28,10 +28,10 @@ import subprocess |
28 | 28 |
import traceback |
29 | 29 |
|
30 | 30 |
from ansible import constants as C |
31 |
-from ansible.compat.six.moves import shlex_quote |
|
32 | 31 |
from ansible.errors import AnsibleError |
33 |
-from ansible.plugins.connection import ConnectionBase, BUFSIZE |
|
32 |
+from ansible.module_utils.six.moves import shlex_quote |
|
34 | 33 |
from ansible.module_utils._text import to_bytes |
34 |
+from ansible.plugins.connection import ConnectionBase, BUFSIZE |
|
35 | 35 |
|
36 | 36 |
|
37 | 37 |
try: |
... | ... |
@@ -19,21 +19,21 @@ |
19 | 19 |
from __future__ import (absolute_import, division, print_function) |
20 | 20 |
__metaclass__ = type |
21 | 21 |
|
22 |
-import sys |
|
23 | 22 |
import base64 |
23 |
+import crypt |
|
24 |
+import glob |
|
25 |
+import hashlib |
|
24 | 26 |
import itertools |
25 | 27 |
import json |
26 |
-import os.path |
|
27 | 28 |
import ntpath |
28 |
-import glob |
|
29 |
+import os.path |
|
29 | 30 |
import re |
30 |
-import crypt |
|
31 |
-import hashlib |
|
32 | 31 |
import string |
32 |
+import sys |
|
33 |
+import uuid |
|
34 |
+from datetime import datetime |
|
33 | 35 |
from functools import partial |
34 | 36 |
from random import Random, SystemRandom, shuffle |
35 |
-from datetime import datetime |
|
36 |
-import uuid |
|
37 | 37 |
|
38 | 38 |
import yaml |
39 | 39 |
from jinja2.filters import environmentfilter, do_groupby as _do_groupby |
... | ... |
@@ -45,9 +45,8 @@ except: |
45 | 45 |
HAS_PASSLIB = False |
46 | 46 |
|
47 | 47 |
from ansible import errors |
48 |
-from ansible.compat.six import iteritems, string_types, integer_types |
|
49 |
-from ansible.compat.six.moves import reduce |
|
50 |
-from ansible.compat.six.moves import shlex_quote |
|
48 |
+from ansible.module_utils.six import iteritems, string_types, integer_types |
|
49 |
+from ansible.module_utils.six.moves import reduce, shlex_quote |
|
51 | 50 |
from ansible.module_utils._text import to_bytes, to_text |
52 | 51 |
from ansible.parsing.yaml.dumper import AnsibleDumper |
53 | 52 |
from ansible.utils.hashing import md5s, checksum_s |
... | ... |
@@ -58,6 +57,7 @@ from ansible.vars.hostvars import HostVars |
58 | 58 |
|
59 | 59 |
UUID_NAMESPACE_ANSIBLE = uuid.UUID('361E6D51-FAEC-444A-9079-341386DA8E2E') |
60 | 60 |
|
61 |
+ |
|
61 | 62 |
class AnsibleJSONEncoder(json.JSONEncoder): |
62 | 63 |
''' |
63 | 64 |
Simple encoder class to deal with JSON encoding of internal |
... | ... |
@@ -122,10 +122,11 @@ import os |
122 | 122 |
|
123 | 123 |
from jinja2.exceptions import UndefinedError |
124 | 124 |
|
125 |
-from ansible.compat.six import string_types |
|
125 |
+from ansible.constants import mk_boolean as boolean |
|
126 | 126 |
from ansible.errors import AnsibleFileNotFound, AnsibleLookupError, AnsibleUndefinedVariable |
127 |
+from ansible.module_utils.six import string_types |
|
127 | 128 |
from ansible.plugins.lookup import LookupBase |
128 |
-from ansible.constants import mk_boolean as boolean |
|
129 |
+ |
|
129 | 130 |
|
130 | 131 |
class LookupModule(LookupBase): |
131 | 132 |
|
... | ... |
@@ -17,11 +17,12 @@ |
17 | 17 |
from __future__ import (absolute_import, division, print_function) |
18 | 18 |
__metaclass__ = type |
19 | 19 |
|
20 |
-from ansible.compat.six import string_types |
|
21 | 20 |
from ansible.errors import AnsibleError |
21 |
+from ansible.module_utils.six import string_types |
|
22 | 22 |
from ansible.plugins.lookup import LookupBase |
23 | 23 |
from ansible.utils.listify import listify_lookup_plugin_terms |
24 | 24 |
|
25 |
+ |
|
25 | 26 |
class LookupModule(LookupBase): |
26 | 27 |
|
27 | 28 |
def _check_list_of_one_list(self, term): |
... | ... |
@@ -21,10 +21,10 @@ from io import StringIO |
21 | 21 |
import os |
22 | 22 |
import re |
23 | 23 |
|
24 |
-from ansible.compat.six.moves import configparser |
|
25 | 24 |
from ansible.errors import AnsibleError |
26 |
-from ansible.plugins.lookup import LookupBase |
|
25 |
+from ansible.module_utils.six.moves import configparser |
|
27 | 26 |
from ansible.module_utils._text import to_bytes, to_text |
27 |
+from ansible.plugins.lookup import LookupBase |
|
28 | 28 |
|
29 | 29 |
|
30 | 30 |
def _parse_params(term): |
... | ... |
@@ -24,8 +24,8 @@ import string |
24 | 24 |
import random |
25 | 25 |
|
26 | 26 |
from ansible import constants as C |
27 |
-from ansible.compat.six import text_type |
|
28 | 27 |
from ansible.errors import AnsibleError |
28 |
+from ansible.module_utils.six import text_type |
|
29 | 29 |
from ansible.module_utils._text import to_bytes, to_native, to_text |
30 | 30 |
from ansible.parsing.splitter import parse_kv |
31 | 31 |
from ansible.plugins.lookup import LookupBase |
... | ... |
@@ -19,11 +19,12 @@ __metaclass__ = type |
19 | 19 |
|
20 | 20 |
from re import compile as re_compile, IGNORECASE |
21 | 21 |
|
22 |
-from ansible.compat.six.moves import xrange |
|
23 | 22 |
from ansible.errors import AnsibleError |
23 |
+from ansible.module_utils.six.moves import xrange |
|
24 | 24 |
from ansible.parsing.splitter import parse_kv |
25 | 25 |
from ansible.plugins.lookup import LookupBase |
26 | 26 |
|
27 |
+ |
|
27 | 28 |
# shortcut format |
28 | 29 |
NUM = "(0?x?[0-9a-f]+)" |
29 | 30 |
SHORTCUT = re_compile( |
... | ... |
@@ -17,11 +17,12 @@ |
17 | 17 |
from __future__ import (absolute_import, division, print_function) |
18 | 18 |
__metaclass__ = type |
19 | 19 |
|
20 |
-from ansible.compat.six import string_types |
|
20 |
+from ansible.constants import mk_boolean as boolean |
|
21 | 21 |
from ansible.errors import AnsibleError |
22 |
+from ansible.module_utils.six import string_types |
|
22 | 23 |
from ansible.plugins.lookup import LookupBase |
23 | 24 |
from ansible.utils.listify import listify_lookup_plugin_terms |
24 |
-from ansible.constants import mk_boolean as boolean |
|
25 |
+ |
|
25 | 26 |
|
26 | 27 |
FLAGS = ('skip_missing',) |
27 | 28 |
|
... | ... |
@@ -17,11 +17,12 @@ |
17 | 17 |
from __future__ import (absolute_import, division, print_function) |
18 | 18 |
__metaclass__ = type |
19 | 19 |
|
20 |
-from ansible.compat.six.moves import zip_longest |
|
21 | 20 |
from ansible.errors import AnsibleError |
21 |
+from ansible.module_utils.six.moves import zip_longest |
|
22 | 22 |
from ansible.plugins.lookup import LookupBase |
23 | 23 |
from ansible.utils.listify import listify_lookup_plugin_terms |
24 | 24 |
|
25 |
+ |
|
25 | 26 |
class LookupModule(LookupBase): |
26 | 27 |
""" |
27 | 28 |
Transpose a list of arrays: |
... | ... |
@@ -18,8 +18,8 @@ from __future__ import (absolute_import, division, print_function) |
18 | 18 |
__metaclass__ = type |
19 | 19 |
|
20 | 20 |
|
21 |
-from ansible.compat.six.moves.urllib.error import HTTPError, URLError |
|
22 | 21 |
from ansible.errors import AnsibleError |
22 |
+from ansible.module_utils.six.moves.urllib.error import HTTPError, URLError |
|
23 | 23 |
from ansible.module_utils._text import to_text |
24 | 24 |
from ansible.module_utils.urls import open_url, ConnectionError, SSLValidationError |
25 | 25 |
from ansible.plugins.lookup import LookupBase |
... | ... |
@@ -23,8 +23,8 @@ import ansible.constants as C |
23 | 23 |
import time |
24 | 24 |
import random |
25 | 25 |
|
26 |
-from ansible.compat.six import text_type |
|
27 |
-from ansible.compat.six.moves import shlex_quote |
|
26 |
+from ansible.module_utils.six import text_type |
|
27 |
+from ansible.module_utils.six.moves import shlex_quote |
|
28 | 28 |
|
29 | 29 |
_USER_HOME_PATH_RE = re.compile(r'^~[_.A-Za-z0-9][-_.A-Za-z0-9]*$') |
30 | 30 |
|
... | ... |
@@ -17,9 +17,9 @@ |
17 | 17 |
from __future__ import (absolute_import, division, print_function) |
18 | 18 |
__metaclass__ = type |
19 | 19 |
|
20 |
+from ansible.module_utils.six import text_type |
|
21 |
+from ansible.module_utils.six.moves import shlex_quote |
|
20 | 22 |
from ansible.plugins.shell.sh import ShellModule as ShModule |
21 |
-from ansible.compat.six import text_type |
|
22 |
-from ansible.compat.six.moves import shlex_quote |
|
23 | 23 |
|
24 | 24 |
|
25 | 25 |
class ShellModule(ShModule): |
... | ... |
@@ -18,7 +18,7 @@ from __future__ import (absolute_import, division, print_function) |
18 | 18 |
__metaclass__ = type |
19 | 19 |
|
20 | 20 |
|
21 |
-from ansible.compat.six.moves import shlex_quote |
|
21 |
+from ansible.module_utils.six.moves import shlex_quote |
|
22 | 22 |
from ansible.plugins.shell import ShellBase |
23 | 23 |
|
24 | 24 |
|
... | ... |
@@ -27,14 +27,15 @@ from multiprocessing import Lock |
27 | 27 |
from jinja2.exceptions import UndefinedError |
28 | 28 |
|
29 | 29 |
from ansible import constants as C |
30 |
-from ansible.compat.six.moves import queue as Queue |
|
31 |
-from ansible.compat.six import iteritems, string_types |
|
32 | 30 |
from ansible.errors import AnsibleError, AnsibleParserError, AnsibleUndefinedVariable |
33 | 31 |
from ansible.executor import action_write_locks |
34 | 32 |
from ansible.executor.process.worker import WorkerProcess |
35 | 33 |
from ansible.executor.task_result import TaskResult |
36 | 34 |
from ansible.inventory.host import Host |
37 | 35 |
from ansible.inventory.group import Group |
36 |
+from ansible.module_utils.six.moves import queue as Queue |
|
37 |
+from ansible.module_utils.six import iteritems, string_types |
|
38 |
+from ansible.module_utils._text import to_text |
|
38 | 39 |
from ansible.playbook.helpers import load_list_of_blocks |
39 | 40 |
from ansible.playbook.included_file import IncludedFile |
40 | 41 |
from ansible.playbook.task_include import TaskInclude |
... | ... |
@@ -42,7 +43,6 @@ from ansible.playbook.role_include import IncludeRole |
42 | 42 |
from ansible.plugins import action_loader, connection_loader, filter_loader, lookup_loader, module_loader, test_loader |
43 | 43 |
from ansible.template import Templar |
44 | 44 |
from ansible.vars import combine_vars, strip_internal_keys |
45 |
-from ansible.module_utils._text import to_text |
|
46 | 45 |
|
47 | 46 |
|
48 | 47 |
try: |
... | ... |
@@ -29,8 +29,8 @@ import cmd |
29 | 29 |
import pprint |
30 | 30 |
import sys |
31 | 31 |
|
32 |
+from ansible.module_utils.six.moves import reduce |
|
32 | 33 |
from ansible.plugins.strategy.linear import StrategyModule as LinearStrategyModule |
33 |
-from ansible.compat.six.moves import reduce |
|
34 | 34 |
|
35 | 35 |
try: |
36 | 36 |
from __main__ import display |
... | ... |
@@ -31,17 +31,16 @@ DOCUMENTATION: |
31 | 31 |
from __future__ import (absolute_import, division, print_function) |
32 | 32 |
__metaclass__ = type |
33 | 33 |
|
34 |
-from ansible.compat.six import iteritems |
|
35 |
- |
|
36 | 34 |
from ansible.errors import AnsibleError |
37 | 35 |
from ansible.executor.play_iterator import PlayIterator |
36 |
+from ansible.module_utils.six import iteritems |
|
37 |
+from ansible.module_utils._text import to_text |
|
38 | 38 |
from ansible.playbook.block import Block |
39 | 39 |
from ansible.playbook.included_file import IncludedFile |
40 | 40 |
from ansible.playbook.task import Task |
41 | 41 |
from ansible.plugins import action_loader |
42 | 42 |
from ansible.plugins.strategy import StrategyBase |
43 | 43 |
from ansible.template import Templar |
44 |
-from ansible.module_utils._text import to_text |
|
45 | 44 |
|
46 | 45 |
|
47 | 46 |
try: |
... | ... |
@@ -23,8 +23,8 @@ import re |
23 | 23 |
|
24 | 24 |
from abc import ABCMeta, abstractmethod |
25 | 25 |
|
26 |
-from ansible.compat.six import with_metaclass |
|
27 | 26 |
from ansible.errors import AnsibleConnectionFailure |
27 |
+from ansible.module_utils.six import with_metaclass |
|
28 | 28 |
|
29 | 29 |
|
30 | 30 |
class TerminalBase(with_metaclass(ABCMeta, object)): |
... | ... |
@@ -27,25 +27,25 @@ import re |
27 | 27 |
from io import StringIO |
28 | 28 |
from numbers import Number |
29 | 29 |
|
30 |
+try: |
|
31 |
+ from hashlib import sha1 |
|
32 |
+except ImportError: |
|
33 |
+ from sha import sha as sha1 |
|
34 |
+ |
|
30 | 35 |
from jinja2 import Environment |
31 | 36 |
from jinja2.loaders import FileSystemLoader |
32 | 37 |
from jinja2.exceptions import TemplateSyntaxError, UndefinedError |
33 | 38 |
from jinja2.utils import concat as j2_concat, missing |
34 | 39 |
from jinja2.runtime import Context, StrictUndefined |
40 |
+ |
|
35 | 41 |
from ansible import constants as C |
36 |
-from ansible.compat.six import string_types, text_type |
|
37 | 42 |
from ansible.errors import AnsibleError, AnsibleFilterError, AnsibleUndefinedVariable |
43 |
+from ansible.module_utils.six import string_types, text_type |
|
44 |
+from ansible.module_utils._text import to_native, to_text |
|
38 | 45 |
from ansible.plugins import filter_loader, lookup_loader, test_loader |
39 | 46 |
from ansible.template.safe_eval import safe_eval |
40 | 47 |
from ansible.template.template import AnsibleJ2Template |
41 | 48 |
from ansible.template.vars import AnsibleJ2Vars |
42 |
-from ansible.module_utils._text import to_native, to_text |
|
43 |
- |
|
44 |
-try: |
|
45 |
- from hashlib import sha1 |
|
46 |
-except ImportError: |
|
47 |
- from sha import sha as sha1 |
|
48 |
- |
|
49 | 49 |
|
50 | 50 |
try: |
51 | 51 |
from __main__ import display |
... | ... |
@@ -53,6 +53,7 @@ except ImportError: |
53 | 53 |
from ansible.utils.display import Display |
54 | 54 |
display = Display() |
55 | 55 |
|
56 |
+ |
|
56 | 57 |
__all__ = ['Templar'] |
57 | 58 |
|
58 | 59 |
# A regex for checking to see if a variable we're trying to |
... | ... |
@@ -20,12 +20,12 @@ __metaclass__ = type |
20 | 20 |
import ast |
21 | 21 |
import sys |
22 | 22 |
|
23 |
-from ansible.compat.six import string_types |
|
24 |
-from ansible.compat.six.moves import builtins |
|
25 |
- |
|
26 | 23 |
from ansible import constants as C |
24 |
+from ansible.module_utils.six import string_types |
|
25 |
+from ansible.module_utils.six.moves import builtins |
|
27 | 26 |
from ansible.plugins import filter_loader, test_loader |
28 | 27 |
|
28 |
+ |
|
29 | 29 |
def safe_eval(expr, locals={}, include_exceptions=False): |
30 | 30 |
''' |
31 | 31 |
This is intended for allowing things like: |
... | ... |
@@ -19,8 +19,9 @@ |
19 | 19 |
from __future__ import (absolute_import, division, print_function) |
20 | 20 |
__metaclass__ = type |
21 | 21 |
|
22 |
-from ansible.compat.six import iteritems |
|
23 | 22 |
from jinja2.utils import missing |
23 |
+ |
|
24 |
+from ansible.module_utils.six import iteritems |
|
24 | 25 |
from ansible.module_utils._text import to_native |
25 | 26 |
|
26 | 27 |
|
... | ... |
@@ -24,9 +24,10 @@ import shlex |
24 | 24 |
import subprocess |
25 | 25 |
import select |
26 | 26 |
|
27 |
-from ansible.compat.six import PY2, PY3 |
|
27 |
+from ansible.module_utils.six import PY2, PY3 |
|
28 | 28 |
from ansible.module_utils._text import to_bytes |
29 | 29 |
|
30 |
+ |
|
30 | 31 |
def run_cmd(cmd, live=False, readsize=10): |
31 | 32 |
|
32 | 33 |
#readsize = 10 |
... | ... |
@@ -19,7 +19,8 @@ |
19 | 19 |
from __future__ import (absolute_import, division, print_function) |
20 | 20 |
__metaclass__ = type |
21 | 21 |
|
22 |
-from ansible.compat.six import string_types |
|
22 |
+from ansible.module_utils.six import string_types |
|
23 |
+ |
|
23 | 24 |
|
24 | 25 |
def pct_to_int(value, num_items, min_value=1): |
25 | 26 |
''' |
... | ... |
@@ -21,13 +21,14 @@ __metaclass__ = type |
21 | 21 |
|
22 | 22 |
from collections import Iterable |
23 | 23 |
|
24 |
-from ansible.compat.six import string_types |
|
25 |
- |
|
24 |
+from ansible.module_utils.six import string_types |
|
26 | 25 |
from ansible.template import Templar |
27 | 26 |
from ansible.template.safe_eval import safe_eval |
28 | 27 |
|
28 |
+ |
|
29 | 29 |
__all__ = ['listify_lookup_plugin_terms'] |
30 | 30 |
|
31 |
+ |
|
31 | 32 |
def listify_lookup_plugin_terms(terms, templar, loader, fail_on_undefined=True, convert_bare=False): |
32 | 33 |
|
33 | 34 |
if isinstance(terms, string_types): |
... | ... |
@@ -25,7 +25,7 @@ import yaml |
25 | 25 |
|
26 | 26 |
from collections import MutableMapping, MutableSet, MutableSequence |
27 | 27 |
|
28 |
-from ansible.compat.six import string_types |
|
28 |
+from ansible.module_utils.six import string_types |
|
29 | 29 |
from ansible.parsing.yaml.loader import AnsibleLoader |
30 | 30 |
from ansible.plugins import fragment_loader |
31 | 31 |
|
... | ... |
@@ -35,6 +35,7 @@ except ImportError: |
35 | 35 |
from ansible.utils.display import Display |
36 | 36 |
display = Display() |
37 | 37 |
|
38 |
+ |
|
38 | 39 |
# modules that are ok that they do not have documentation strings |
39 | 40 |
BLACKLIST = { |
40 | 41 |
'MODULE': frozenset(('async_wrapper',)), |
... | ... |
@@ -20,7 +20,7 @@ from __future__ import (absolute_import, division, print_function) |
20 | 20 |
__metaclass__ = type |
21 | 21 |
|
22 | 22 |
import shlex |
23 |
-from ansible.compat.six import PY3 |
|
23 |
+from ansible.module_utils.six import PY3 |
|
24 | 24 |
from ansible.module_utils._text import to_bytes, to_text |
25 | 25 |
|
26 | 26 |
|
... | ... |
@@ -26,18 +26,20 @@ import uuid |
26 | 26 |
from json import dumps |
27 | 27 |
from collections import MutableMapping |
28 | 28 |
|
29 |
-from ansible.compat.six import iteritems, string_types |
|
29 |
+from ansible.module_utils.six import iteritems, string_types |
|
30 | 30 |
|
31 | 31 |
from ansible import constants as C |
32 | 32 |
from ansible.errors import AnsibleError, AnsibleOptionsError |
33 | 33 |
from ansible.parsing.splitter import parse_kv |
34 | 34 |
from ansible.module_utils._text import to_native, to_text |
35 | 35 |
|
36 |
+ |
|
36 | 37 |
_MAXSIZE = 2**32 |
37 | 38 |
cur_id = 0 |
38 | 39 |
node_mac = ("%012x" % uuid.getnode())[:12] |
39 | 40 |
random_int = ("%08x" % random.randint(0, _MAXSIZE))[:8] |
40 | 41 |
|
42 |
+ |
|
41 | 43 |
def get_unique_id(): |
42 | 44 |
global cur_id |
43 | 45 |
cur_id += 1 |
... | ... |
@@ -24,19 +24,18 @@ import sys |
24 | 24 |
|
25 | 25 |
from collections import defaultdict, MutableMapping |
26 | 26 |
|
27 |
-from ansible.compat.six import iteritems |
|
28 |
-from jinja2.exceptions import UndefinedError |
|
29 |
- |
|
30 | 27 |
try: |
31 | 28 |
from hashlib import sha1 |
32 | 29 |
except ImportError: |
33 | 30 |
from sha import sha as sha1 |
34 | 31 |
|
32 |
+from jinja2.exceptions import UndefinedError |
|
33 |
+ |
|
35 | 34 |
from ansible import constants as C |
36 | 35 |
from ansible.cli import CLI |
37 |
-from ansible.compat.six import string_types, text_type |
|
38 | 36 |
from ansible.errors import AnsibleError, AnsibleParserError, AnsibleUndefinedVariable, AnsibleFileNotFound |
39 | 37 |
from ansible.inventory.host import Host |
38 |
+from ansible.module_utils.six import iteritems, string_types, text_type |
|
40 | 39 |
from ansible.plugins import lookup_loader |
41 | 40 |
from ansible.plugins.cache import FactCache |
42 | 41 |
from ansible.template import Templar |
... | ... |
@@ -51,14 +50,17 @@ except ImportError: |
51 | 51 |
from ansible.utils.display import Display |
52 | 52 |
display = Display() |
53 | 53 |
|
54 |
-VARIABLE_CACHE = dict() |
|
55 |
-HOSTVARS_CACHE = dict() |
|
54 |
+ |
|
55 |
+VARIABLE_CACHE = {} |
|
56 |
+HOSTVARS_CACHE = {} |
|
57 |
+ |
|
56 | 58 |
|
57 | 59 |
class AnsibleInventoryVarsData(dict): |
58 | 60 |
def __init__(self, *args, **kwargs): |
59 | 61 |
super(AnsibleInventoryVarsData, self).__init__(*args, **kwargs) |
60 | 62 |
self.path = None |
61 | 63 |
|
64 |
+ |
|
62 | 65 |
def preprocess_vars(a): |
63 | 66 |
''' |
64 | 67 |
Ensures that vars contained in the parameter passed in are |
... | ... |
@@ -54,7 +54,7 @@ from __future__ import (absolute_import, division, print_function) |
54 | 54 |
__metaclass__ = type |
55 | 55 |
|
56 | 56 |
import json |
57 |
-from ansible.compat.six import string_types, text_type |
|
57 |
+from ansible.module_utils.six import string_types, text_type |
|
58 | 58 |
from ansible.module_utils._text import to_text |
59 | 59 |
|
60 | 60 |
|
... | ... |
@@ -6,7 +6,7 @@ future1=$(find ./bin -type f -exec grep -HL 'from __future__ import (absolute_im |
6 | 6 |
metaclass2=$(find ./lib/ansible -path ./lib/ansible/modules -prune \ |
7 | 7 |
-o -path ./lib/ansible/modules/__init__.py \ |
8 | 8 |
-o -path ./lib/ansible/module_utils -prune \ |
9 |
- -o -path ./lib/ansible/compat/six/_six.py -prune \ |
|
9 |
+ -o -path ./lib/ansible/module_utils/six/_six.py -prune \ |
|
10 | 10 |
-o -path ./lib/ansible/compat/selectors/_selectors2.py -prune \ |
11 | 11 |
-o -path ./lib/ansible/utils/module_docs_fragments -prune \ |
12 | 12 |
-o -name '*.py' -exec grep -HL '__metaclass__ = type' '{}' '+') |
... | ... |
@@ -14,7 +14,7 @@ metaclass2=$(find ./lib/ansible -path ./lib/ansible/modules -prune \ |
14 | 14 |
future2=$(find ./lib/ansible -path ./lib/ansible/modules -prune \ |
15 | 15 |
-o -path ./lib/ansible/modules/__init__.py \ |
16 | 16 |
-o -path ./lib/ansible/module_utils -prune \ |
17 |
- -o -path ./lib/ansible/compat/six/_six.py -prune \ |
|
17 |
+ -o -path ./lib/ansible/module_utils/six/_six.py -prune \ |
|
18 | 18 |
-o -path ./lib/ansible/compat/selectors/_selectors2.py -prune \ |
19 | 19 |
-o -path ./lib/ansible/utils/module_docs_fragments -prune \ |
20 | 20 |
-o -name '*.py' -exec grep -HL 'from __future__ import (absolute_import, division, print_function)' '{}' '+') |
... | ... |
@@ -6,8 +6,7 @@ BASESTRING_USERS=$(grep -r basestring . \ |
6 | 6 |
| grep isinstance \ |
7 | 7 |
| grep -v \ |
8 | 8 |
-e test/results/ \ |
9 |
- -e lib/ansible/compat/six/_six.py \ |
|
10 |
- -e lib/ansible/module_utils/six.py \ |
|
9 |
+ -e lib/ansible/module_utils/six/_six.py \ |
|
11 | 10 |
-e lib/ansible/modules/ \ |
12 | 11 |
-e '^[^:]*:#' |
13 | 12 |
) |
... | ... |
@@ -6,8 +6,7 @@ ITERITEMS_USERS=$(grep -rI '\.iteritems' . \ |
6 | 6 |
--exclude-dir docsite \ |
7 | 7 |
| grep -v \ |
8 | 8 |
-e 'six\.iteritems' \ |
9 |
- -e lib/ansible/compat/six/_six.py \ |
|
10 |
- -e lib/ansible/module_utils/six.py \ |
|
9 |
+ -e lib/ansible/module_utils/six/_six.py \ |
|
11 | 10 |
-e test/sanity/code-smell/no-dict-iteritems.sh \ |
12 | 11 |
) |
13 | 12 |
|
... | ... |
@@ -15,7 +14,6 @@ if [ "${ITERITEMS_USERS}" ]; then |
15 | 15 |
echo 'iteritems has been removed in python3. Alternatives:' |
16 | 16 |
echo ' for KEY, VALUE in DICT.items():' |
17 | 17 |
echo ' from ansible.module_utils.six import iteritems ; for KEY, VALUE in iteritems(DICT):' |
18 |
- echo ' from ansible.compat.six import iteritems ; for KEY, VALUE in iteritems(DICT):' |
|
19 | 18 |
echo "${ITERITEMS_USERS}" |
20 | 19 |
exit 1 |
21 | 20 |
fi |
... | ... |
@@ -6,8 +6,7 @@ ITERVALUES_USERS=$(grep -rI '\.itervalues' . \ |
6 | 6 |
--exclude-dir docsite \ |
7 | 7 |
| grep -v \ |
8 | 8 |
-e 'six\.itervalues' \ |
9 |
- -e lib/ansible/compat/six/_six.py \ |
|
10 |
- -e lib/ansible/module_utils/six.py \ |
|
9 |
+ -e lib/ansible/module_utils/six/_six.py \ |
|
11 | 10 |
-e test/sanity/code-smell/no-dict-itervalues.sh \ |
12 | 11 |
) |
13 | 12 |
|
... | ... |
@@ -15,7 +14,6 @@ if [ "${ITERVALUES_USERS}" ]; then |
15 | 15 |
echo 'itervalues has been removed in python3. Alternatives:' |
16 | 16 |
echo ' for VALUE in DICT.values():' |
17 | 17 |
echo ' from ansible.module_utils.six import itervalues ; for VALUE in itervalues(DICT):' |
18 |
- echo ' from ansible.compat.six import itervalues ; for VALUE in itervalues(DICT):' |
|
19 | 18 |
echo "${ITERVALUES_USERS}" |
20 | 19 |
exit 1 |
21 | 20 |
fi |
... | ... |
@@ -7,8 +7,7 @@ ITERKEYS_USERS=$(grep -r -I iterkeys . \ |
7 | 7 |
--exclude-dir docsite \ |
8 | 8 |
--exclude-dir results \ |
9 | 9 |
| grep -v \ |
10 |
- -e lib/ansible/compat/six/_six.py \ |
|
11 |
- -e lib/ansible/module_utils/six.py \ |
|
10 |
+ -e lib/ansible/module_utils/six/_six.py \ |
|
12 | 11 |
-e test/sanity/code-smell/no-iterkeys.sh \ |
13 | 12 |
-e '^[^:]*:#' |
14 | 13 |
) |
... | ... |
@@ -3,8 +3,7 @@ |
3 | 3 |
urllib_users=$(find . -name '*.py' -exec grep -H urlopen '{}' '+' | grep -v \ |
4 | 4 |
-e '^[^:]*/.tox/' \ |
5 | 5 |
-e '^\./lib/ansible/module_utils/urls.py:' \ |
6 |
- -e '^\./lib/ansible/module_utils/six.py:' \ |
|
7 |
- -e '^\./lib/ansible/compat/six/_six.py:' \ |
|
6 |
+ -e '^\./lib/ansible/module_utils/six/_six.py:' \ |
|
8 | 7 |
-e '^[^:]*:#' |
9 | 8 |
) |
10 | 9 |
|
... | ... |
@@ -10,8 +10,8 @@ WHITELIST='(lib/ansible/modules/cloud/digital_ocean/digital_ocean.py)' |
10 | 10 |
|
11 | 11 |
SIX_USERS=$(find "$BASEDIR" -name '*.py' -exec grep -wH six '{}' '+' \ |
12 | 12 |
| grep import \ |
13 |
- | grep -v ansible.compat \ |
|
14 | 13 |
| grep -v ansible.module_utils.six \ |
14 |
+ | grep -v 'ansible.module_utils import six' \ |
|
15 | 15 |
| egrep -v "^$WHITELIST:" |
16 | 16 |
) |
17 | 17 |
|
... | ... |
@@ -57,8 +57,6 @@ lib/ansible/cli/pull.py |
57 | 57 |
lib/ansible/cli/vault.py |
58 | 58 |
lib/ansible/compat/__init__.py |
59 | 59 |
lib/ansible/compat/selectors/__init__.py |
60 |
-lib/ansible/compat/six/__init__.py |
|
61 |
-lib/ansible/compat/six/_six.py |
|
62 | 60 |
lib/ansible/compat/tests/__init__.py |
63 | 61 |
lib/ansible/constants.py |
64 | 62 |
lib/ansible/errors/__init__.py |
... | ... |
@@ -135,7 +133,7 @@ lib/ansible/module_utils/pycompat24.py |
135 | 135 |
lib/ansible/module_utils/redhat.py |
136 | 136 |
lib/ansible/module_utils/service.py |
137 | 137 |
lib/ansible/module_utils/shell.py |
138 |
-lib/ansible/module_utils/six.py |
|
138 |
+lib/ansible/module_utils/six/_six.py |
|
139 | 139 |
lib/ansible/module_utils/splitter.py |
140 | 140 |
lib/ansible/module_utils/sros.py |
141 | 141 |
lib/ansible/module_utils/univention_umc.py |
... | ... |
@@ -887,12 +885,9 @@ lib/ansible/plugins/action/copy.py |
887 | 887 |
lib/ansible/plugins/action/dellos10_config.py |
888 | 888 |
lib/ansible/plugins/action/dellos6_config.py |
889 | 889 |
lib/ansible/plugins/action/dellos9_config.py |
890 |
-lib/ansible/plugins/action/eos.py |
|
891 | 890 |
lib/ansible/plugins/action/eos_template.py |
892 | 891 |
lib/ansible/plugins/action/fetch.py |
893 | 892 |
lib/ansible/plugins/action/group_by.py |
894 |
-lib/ansible/plugins/action/include_vars.py |
|
895 |
-lib/ansible/plugins/action/ios.py |
|
896 | 893 |
lib/ansible/plugins/action/ios_template.py |
897 | 894 |
lib/ansible/plugins/action/iosxr_template.py |
898 | 895 |
lib/ansible/plugins/action/junos.py |
... | ... |
@@ -908,13 +903,11 @@ lib/ansible/plugins/action/patch.py |
908 | 908 |
lib/ansible/plugins/action/pause.py |
909 | 909 |
lib/ansible/plugins/action/script.py |
910 | 910 |
lib/ansible/plugins/action/service.py |
911 |
-lib/ansible/plugins/action/set_fact.py |
|
912 | 911 |
lib/ansible/plugins/action/set_stats.py |
913 | 912 |
lib/ansible/plugins/action/sros_config.py |
914 | 913 |
lib/ansible/plugins/action/synchronize.py |
915 | 914 |
lib/ansible/plugins/action/template.py |
916 | 915 |
lib/ansible/plugins/action/unarchive.py |
917 |
-lib/ansible/plugins/action/vyos.py |
|
918 | 916 |
lib/ansible/plugins/cache/__init__.py |
919 | 917 |
lib/ansible/plugins/cache/base.py |
920 | 918 |
lib/ansible/plugins/cache/jsonfile.py |
... | ... |
@@ -1056,7 +1049,6 @@ test/units/executor/test_task_result.py |
1056 | 1056 |
test/units/inventory/test_inventory.py |
1057 | 1057 |
test/units/mock/generator.py |
1058 | 1058 |
test/units/mock/loader.py |
1059 |
-test/units/mock/yaml_helper.py |
|
1060 | 1059 |
test/units/module_utils/basic/test__log_invocation.py |
1061 | 1060 |
test/units/module_utils/basic/test_deprecate_warn.py |
1062 | 1061 |
test/units/module_utils/basic/test_exit_json.py |
... | ... |
@@ -25,9 +25,9 @@ import tarfile |
25 | 25 |
import tempfile |
26 | 26 |
import yaml |
27 | 27 |
|
28 |
-from ansible.compat.six import PY3 |
|
29 | 28 |
from ansible.compat.tests import unittest |
30 | 29 |
from ansible.compat.tests.mock import call, patch |
30 |
+from ansible.module_utils.six import PY3 |
|
31 | 31 |
|
32 | 32 |
import ansible |
33 | 33 |
from ansible.errors import AnsibleError, AnsibleOptionsError |
... | ... |
@@ -28,10 +28,10 @@ from io import BytesIO, StringIO |
28 | 28 |
import pytest |
29 | 29 |
|
30 | 30 |
import ansible.errors |
31 |
-from ansible.compat.six import PY2 |
|
32 |
-from ansible.compat.six.moves import builtins |
|
33 | 31 |
|
34 | 32 |
from ansible.executor.module_common import recursive_finder |
33 |
+from ansible.module_utils.six import PY2 |
|
34 |
+from ansible.module_utils.six.moves import builtins |
|
35 | 35 |
|
36 | 36 |
|
37 | 37 |
original_find_module = imp.find_module |
... | ... |
@@ -113,22 +113,22 @@ class TestRecursiveFinder(object): |
113 | 113 |
name = 'ping' |
114 | 114 |
data = b'#!/usr/bin/python\nfrom ansible.module_utils import six' |
115 | 115 |
recursive_finder(name, data, *finder_containers) |
116 |
- assert finder_containers.py_module_names == set((('six',),)) |
|
116 |
+ assert finder_containers.py_module_names == set((('six', '__init__'), ('six', '_six'))) |
|
117 | 117 |
assert finder_containers.py_module_cache == {} |
118 |
- assert frozenset(finder_containers.zf.namelist()) == frozenset(('ansible/module_utils/six.py',)) |
|
118 |
+ assert frozenset(finder_containers.zf.namelist()) == frozenset(('ansible/module_utils/six/__init__.py', 'ansible/module_utils/six/_six.py')) |
|
119 | 119 |
|
120 | 120 |
def test_import_six(self, finder_containers): |
121 | 121 |
name = 'ping' |
122 | 122 |
data = b'#!/usr/bin/python\nimport ansible.module_utils.six' |
123 | 123 |
recursive_finder(name, data, *finder_containers) |
124 |
- assert finder_containers.py_module_names == set((('six',),)) |
|
124 |
+ assert finder_containers.py_module_names == set((('six', '__init__'), ('six', '_six'))) |
|
125 | 125 |
assert finder_containers.py_module_cache == {} |
126 |
- assert frozenset(finder_containers.zf.namelist()) == frozenset(('ansible/module_utils/six.py',)) |
|
126 |
+ assert frozenset(finder_containers.zf.namelist()) == frozenset(('ansible/module_utils/six/__init__.py', 'ansible/module_utils/six/_six.py')) |
|
127 | 127 |
|
128 | 128 |
def test_import_six_from_many_submodules(self, finder_containers): |
129 | 129 |
name = 'ping' |
130 | 130 |
data = b'#!/usr/bin/python\nfrom ansible.module_utils.six.moves.urllib.parse import urlparse' |
131 | 131 |
recursive_finder(name, data, *finder_containers) |
132 |
- assert finder_containers.py_module_names == set((('six',),)) |
|
132 |
+ assert finder_containers.py_module_names == set((('six', '__init__'), ('six', '_six'))) |
|
133 | 133 |
assert finder_containers.py_module_cache == {} |
134 |
- assert frozenset(finder_containers.zf.namelist()) == frozenset(('ansible/module_utils/six.py',)) |
|
134 |
+ assert frozenset(finder_containers.zf.namelist()) == frozenset(('ansible/module_utils/six/__init__.py', 'ansible/module_utils/six/_six.py')) |
... | ... |
@@ -18,11 +18,11 @@ |
18 | 18 |
# for __setstate__/__getstate__ tests |
19 | 19 |
import pickle |
20 | 20 |
|
21 |
-from ansible.compat.six import string_types |
|
22 | 21 |
from ansible.compat.tests import unittest |
23 | 22 |
|
24 | 23 |
from ansible.inventory.group import Group |
25 | 24 |
from ansible.inventory.host import Host |
25 |
+from ansible.module_utils.six import string_types |
|
26 | 26 |
|
27 | 27 |
|
28 | 28 |
class TestHost(unittest.TestCase): |
... | ... |
@@ -25,8 +25,8 @@ import json |
25 | 25 |
|
26 | 26 |
from contextlib import contextmanager |
27 | 27 |
from io import BytesIO, StringIO |
28 |
-from ansible.compat.six import PY3 |
|
29 | 28 |
from ansible.compat.tests import unittest |
29 |
+from ansible.module_utils.six import PY3 |
|
30 | 30 |
from ansible.module_utils._text import to_bytes |
31 | 31 |
|
32 | 32 |
|
... | ... |
@@ -1,10 +1,10 @@ |
1 | 1 |
import io |
2 | 2 |
import yaml |
3 | 3 |
|
4 |
+from ansible.module_utils.six import PY3 |
|
4 | 5 |
from ansible.parsing.yaml.loader import AnsibleLoader |
5 | 6 |
from ansible.parsing.yaml.dumper import AnsibleDumper |
6 | 7 |
|
7 |
-from ansible.compat.six import PY3 |
|
8 | 8 |
|
9 | 9 |
class YamlTestUtils(object): |
10 | 10 |
"""Mixin class to combine with a unittest.TestCase subclass.""" |
... | ... |
@@ -27,7 +27,7 @@ from io import BytesIO, StringIO |
27 | 27 |
|
28 | 28 |
import pytest |
29 | 29 |
|
30 |
-from ansible.compat.six import PY3 |
|
30 |
+from ansible.module_utils.six import PY3 |
|
31 | 31 |
from ansible.compat.tests import unittest |
32 | 32 |
from ansible.compat.tests.mock import call, MagicMock, Mock, patch, sentinel |
33 | 33 |
|
... | ... |
@@ -29,9 +29,9 @@ from io import BytesIO, StringIO |
29 | 29 |
|
30 | 30 |
from units.mock.procenv import ModuleTestCase, swap_stdin_and_argv |
31 | 31 |
|
32 |
-from ansible.compat.six.moves import builtins |
|
33 | 32 |
from ansible.compat.tests import unittest |
34 | 33 |
from ansible.compat.tests.mock import patch, MagicMock, mock_open, Mock, call |
34 |
+from ansible.module_utils.six.moves import builtins |
|
35 | 35 |
|
36 | 36 |
realimport = builtins.__import__ |
37 | 37 |
|
... | ... |
@@ -3,10 +3,10 @@ import sys |
3 | 3 |
|
4 | 4 |
from ansible.compat.tests import unittest |
5 | 5 |
from ansible.compat.tests.mock import patch, MagicMock |
6 |
-from ansible.compat.six.moves import builtins |
|
7 | 6 |
|
8 |
-from ansible.module_utils._text import to_native |
|
9 | 7 |
from ansible.module_utils.basic import AnsibleModule |
8 |
+from ansible.module_utils.six.moves import builtins |
|
9 |
+from ansible.module_utils._text import to_native |
|
10 | 10 |
from units.mock.procenv import swap_stdin_and_argv |
11 | 11 |
|
12 | 12 |
|
... | ... |
@@ -20,8 +20,8 @@ |
20 | 20 |
from __future__ import (absolute_import, division) |
21 | 21 |
__metaclass__ = type |
22 | 22 |
|
23 |
-from ansible.compat.six import PY3 |
|
24 | 23 |
from ansible.compat.tests import unittest |
24 |
+from ansible.module_utils.six import PY3 |
|
25 | 25 |
from units.mock.generator import add_method |
26 | 26 |
|
27 | 27 |
|
... | ... |
@@ -19,12 +19,11 @@ |
19 | 19 |
from __future__ import (absolute_import, division, print_function) |
20 | 20 |
__metaclass__ = type |
21 | 21 |
|
22 |
-from six import PY3 |
|
23 |
- |
|
24 | 22 |
from ansible.compat.tests import unittest |
25 | 23 |
from ansible.compat.tests.mock import patch, mock_open |
26 | 24 |
from ansible.errors import AnsibleParserError |
27 | 25 |
from ansible.errors import yaml_strings |
26 |
+from ansible.module_utils.six import PY3 |
|
28 | 27 |
|
29 | 28 |
from ansible.parsing.dataloader import DataLoader |
30 | 29 |
|
... | ... |
@@ -21,8 +21,6 @@ |
21 | 21 |
from __future__ import (absolute_import, division, print_function) |
22 | 22 |
__metaclass__ = type |
23 | 23 |
|
24 |
-import six |
|
25 |
- |
|
26 | 24 |
import binascii |
27 | 25 |
import io |
28 | 26 |
import os |
... | ... |
@@ -33,9 +31,10 @@ from nose.plugins.skip import SkipTest |
33 | 33 |
from ansible.compat.tests import unittest |
34 | 34 |
|
35 | 35 |
from ansible import errors |
36 |
+from ansible.module_utils import six |
|
37 |
+from ansible.module_utils._text import to_bytes, to_text |
|
36 | 38 |
from ansible.parsing.vault import VaultLib |
37 | 39 |
from ansible.parsing import vault |
38 |
-from ansible.module_utils._text import to_bytes, to_text |
|
39 | 40 |
|
40 | 41 |
|
41 | 42 |
# Counter import fails for 2.0.1, requires >= 2.6.1 from pip |
... | ... |
@@ -22,12 +22,12 @@ __metaclass__ = type |
22 | 22 |
|
23 | 23 |
from io import StringIO |
24 | 24 |
|
25 |
-from six import text_type, binary_type |
|
26 | 25 |
from collections import Sequence, Set, Mapping |
27 | 26 |
|
28 | 27 |
from ansible.compat.tests import unittest |
29 | 28 |
|
30 | 29 |
from ansible import errors |
30 |
+from ansible.module_utils.six import text_type, binary_type |
|
31 | 31 |
from ansible.parsing.yaml.loader import AnsibleLoader |
32 | 32 |
from ansible.parsing import vault |
33 | 33 |
from ansible.parsing.yaml.objects import AnsibleVaultEncryptedUnicode |
... | ... |
@@ -21,8 +21,8 @@ __metaclass__ = type |
21 | 21 |
|
22 | 22 |
from ansible.compat.tests import unittest |
23 | 23 |
|
24 |
-from ansible.compat.six import string_types |
|
25 | 24 |
from ansible.errors import AnsibleParserError |
25 |
+from ansible.module_utils.six import string_types |
|
26 | 26 |
from ansible.playbook.attribute import FieldAttribute |
27 | 27 |
from ansible.template import Templar |
28 | 28 |
from ansible.playbook import base |
... | ... |
@@ -25,9 +25,9 @@ from ansible.compat.tests import unittest |
25 | 25 |
from ansible.compat.tests.mock import patch, MagicMock |
26 | 26 |
|
27 | 27 |
from ansible import constants as C |
28 |
-from ansible.compat.six.moves import shlex_quote |
|
29 | 28 |
from ansible.cli import CLI |
30 | 29 |
from ansible.errors import AnsibleError, AnsibleParserError |
30 |
+from ansible.module_utils.six.moves import shlex_quote |
|
31 | 31 |
from ansible.playbook.play_context import PlayContext |
32 | 32 |
|
33 | 33 |
from units.mock.loader import DictDataLoader |
... | ... |
@@ -23,18 +23,19 @@ __metaclass__ = type |
23 | 23 |
import os |
24 | 24 |
|
25 | 25 |
from ansible import constants as C |
26 |
-from ansible.compat.six import text_type |
|
27 |
-from ansible.compat.six.moves import shlex_quote, builtins |
|
28 | 26 |
from ansible.compat.tests import unittest |
29 | 27 |
from ansible.compat.tests.mock import patch, MagicMock, mock_open |
30 | 28 |
|
31 | 29 |
from ansible.errors import AnsibleError |
30 |
+from ansible.module_utils.six import text_type |
|
31 |
+from ansible.module_utils.six.moves import shlex_quote, builtins |
|
32 |
+from ansible.module_utils._text import to_bytes |
|
32 | 33 |
from ansible.playbook.play_context import PlayContext |
33 | 34 |
from ansible.plugins.action import ActionBase |
34 | 35 |
from ansible.template import Templar |
35 | 36 |
|
36 | 37 |
from units.mock.loader import DictDataLoader |
37 |
-from ansible.module_utils._text import to_bytes |
|
38 |
+ |
|
38 | 39 |
|
39 | 40 |
python_module_replacers = b""" |
40 | 41 |
#!/usr/bin/python |
... | ... |
@@ -29,8 +29,8 @@ from ansible.compat.tests.mock import patch, MagicMock, PropertyMock |
29 | 29 |
|
30 | 30 |
from ansible import constants as C |
31 | 31 |
from ansible.compat.selectors import SelectorKey, EVENT_READ |
32 |
-from ansible.compat.six.moves import shlex_quote |
|
33 | 32 |
from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleFileNotFound |
33 |
+from ansible.module_utils.six.moves import shlex_quote |
|
34 | 34 |
from ansible.playbook.play_context import PlayContext |
35 | 35 |
from ansible.plugins.connection import ssh |
36 | 36 |
from ansible.module_utils._text import to_bytes |
... | ... |
@@ -19,14 +19,15 @@ |
19 | 19 |
from __future__ import (absolute_import, division, print_function) |
20 | 20 |
__metaclass__ = type |
21 | 21 |
|
22 |
+from argparse import ArgumentParser |
|
23 |
+ |
|
22 | 24 |
from ansible.compat.tests import unittest |
25 |
+from ansible.compat.tests.mock import patch |
|
23 | 26 |
|
24 |
-from ansible.plugins.lookup.lastpass import LookupModule, LPass, LPassException |
|
25 | 27 |
from ansible.errors import AnsibleError |
26 |
-from argparse import ArgumentParser |
|
27 |
-import six |
|
28 |
+from ansible.module_utils import six |
|
29 |
+from ansible.plugins.lookup.lastpass import LookupModule, LPass, LPassException |
|
28 | 30 |
|
29 |
-from ansible.compat.tests.mock import patch |
|
30 | 31 |
|
31 | 32 |
MOCK_ENTRIES = [{'username': 'user', |
32 | 33 |
'name': 'Mock Entry', |
... | ... |
@@ -23,11 +23,11 @@ __metaclass__ = type |
23 | 23 |
import passlib |
24 | 24 |
from passlib.handlers import pbkdf2 |
25 | 25 |
|
26 |
-from ansible.compat.six import text_type |
|
27 |
-from ansible.compat.six.moves import builtins |
|
28 | 26 |
from ansible.compat.tests import unittest |
29 | 27 |
from ansible.compat.tests.mock import mock_open, patch |
30 | 28 |
from ansible.errors import AnsibleError |
29 |
+from ansible.module_utils.six import text_type |
|
30 |
+from ansible.module_utils.six.moves import builtins |
|
31 | 31 |
from ansible.plugins import PluginLoader |
32 | 32 |
from ansible.utils import encrypt |
33 | 33 |
|
... | ... |
@@ -25,15 +25,15 @@ from ansible.compat.tests import unittest |
25 | 25 |
from ansible.compat.tests.mock import patch, MagicMock |
26 | 26 |
|
27 | 27 |
from ansible.errors import AnsibleError, AnsibleParserError |
28 |
-from ansible.plugins.strategy import StrategyBase |
|
29 | 28 |
from ansible.executor.process.worker import WorkerProcess |
30 | 29 |
from ansible.executor.task_queue_manager import TaskQueueManager |
31 | 30 |
from ansible.executor.task_result import TaskResult |
31 |
+from ansible.inventory.host import Host |
|
32 |
+from ansible.module_utils.six.moves import queue as Queue |
|
32 | 33 |
from ansible.playbook.block import Block |
33 | 34 |
from ansible.playbook.handler import Handler |
34 |
-from ansible.inventory.host import Host |
|
35 |
+from ansible.plugins.strategy import StrategyBase |
|
35 | 36 |
|
36 |
-from six.moves import queue as Queue |
|
37 | 37 |
from units.mock.loader import DictDataLoader |
38 | 38 |
|
39 | 39 |
class TestStrategyBase(unittest.TestCase): |
... | ... |
@@ -23,10 +23,10 @@ from jinja2.runtime import Context |
23 | 23 |
|
24 | 24 |
from ansible.compat.tests import unittest |
25 | 25 |
from ansible.compat.tests.mock import patch |
26 |
-from ansible.compat.six import string_types |
|
27 | 26 |
|
28 | 27 |
from ansible import constants as C |
29 | 28 |
from ansible.errors import AnsibleError, AnsibleUndefinedVariable |
29 |
+from ansible.module_utils.six import string_types |
|
30 | 30 |
from ansible.template import Templar, AnsibleContext, AnsibleEnvironment |
31 | 31 |
from ansible.vars.unsafe_proxy import AnsibleUnsafe, wrap_var |
32 | 32 |
#from ansible.unsafe_proxy import AnsibleUnsafe, wrap_var |
... | ... |
@@ -26,8 +26,8 @@ import os |
26 | 26 |
import pytest |
27 | 27 |
|
28 | 28 |
from ansible import constants |
29 |
-from ansible.compat.six import StringIO |
|
30 |
-from ansible.compat.six.moves import configparser |
|
29 |
+from ansible.module_utils.six import StringIO |
|
30 |
+from ansible.module_utils.six.moves import configparser |
|
31 | 31 |
from ansible.module_utils._text import to_text |
32 | 32 |
|
33 | 33 |
|
... | ... |
@@ -21,11 +21,11 @@ __metaclass__ = type |
21 | 21 |
|
22 | 22 |
from collections import defaultdict |
23 | 23 |
|
24 |
-from ansible.compat.six import iteritems |
|
25 |
-from ansible.compat.six.moves import builtins |
|
26 | 24 |
from ansible.compat.tests import unittest |
27 | 25 |
from ansible.compat.tests.mock import MagicMock, mock_open, patch |
28 | 26 |
from ansible.inventory import Inventory |
27 |
+from ansible.module_utils.six import iteritems |
|
28 |
+from ansible.module_utils.six.moves import builtins |
|
29 | 29 |
from ansible.playbook.play import Play |
30 | 30 |
|
31 | 31 |
from units.mock.loader import DictDataLoader |