diff --git a/.travis.yml b/.travis.yml index 29ed7d3d0f9..21d0177fb9f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,8 @@ install: script: # urllib2's defaults are not secure enough for us - ./test/code-smell/replace-urlopen.sh . +- ./test/code-smell/use-compat-six.sh . +- ./test/code-smell/boilerplate.sh . - if test x"$TOXENV" != x'py24' ; then tox ; fi - if test x"$TOXENV" = x'py24' ; then python2.4 -V && python2.4 -m compileall -fq -x 'module_utils/(a10|rax|openstack|ec2|gce).py' lib/ansible/module_utils ; fi #- make -C docsite all diff --git a/bin/ansible b/bin/ansible index a117856d899..70e6863f6bf 100755 --- a/bin/ansible +++ b/bin/ansible @@ -18,7 +18,7 @@ # along with Ansible. If not, see . ######################################################## -from __future__ import (absolute_import, print_function) +from __future__ import (absolute_import, division, print_function) __metaclass__ = type __requires__ = ['ansible'] diff --git a/lib/ansible/__init__.py b/lib/ansible/__init__.py index 704b6456f74..ad6193463a4 100644 --- a/lib/ansible/__init__.py +++ b/lib/ansible/__init__.py @@ -14,5 +14,10 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + __version__ = '2.0.0' __author__ = 'Ansible, Inc.' diff --git a/lib/ansible/cli/adhoc.py b/lib/ansible/cli/adhoc.py index ff5e512402d..6b0437c1774 100644 --- a/lib/ansible/cli/adhoc.py +++ b/lib/ansible/cli/adhoc.py @@ -15,6 +15,9 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + ######################################################## from ansible import constants as C from ansible.cli import CLI diff --git a/lib/ansible/cli/doc.py b/lib/ansible/cli/doc.py index 02ede783597..05f26abae5b 100644 --- a/lib/ansible/cli/doc.py +++ b/lib/ansible/cli/doc.py @@ -16,6 +16,9 @@ # ansible-vault is a script that encrypts/decrypts YAML files. See # http://docs.ansible.com/playbooks_vault.html for more details. +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import fcntl import datetime import os diff --git a/lib/ansible/cli/galaxy.py b/lib/ansible/cli/galaxy.py index 716eac9616d..42f3cf2b50f 100644 --- a/lib/ansible/cli/galaxy.py +++ b/lib/ansible/cli/galaxy.py @@ -19,6 +19,9 @@ # ######################################################################## +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import os import os.path import sys diff --git a/lib/ansible/cli/playbook.py b/lib/ansible/cli/playbook.py index 306c134790c..417c41c6e93 100644 --- a/lib/ansible/cli/playbook.py +++ b/lib/ansible/cli/playbook.py @@ -18,6 +18,10 @@ # along with Ansible. If not, see . ######################################################## + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import os import stat diff --git a/lib/ansible/cli/pull.py b/lib/ansible/cli/pull.py index 0c33568d3d0..6caa8525dbf 100644 --- a/lib/ansible/cli/pull.py +++ b/lib/ansible/cli/pull.py @@ -15,6 +15,9 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + ######################################################## import datetime import os diff --git a/lib/ansible/cli/vault.py b/lib/ansible/cli/vault.py index ce017650d17..f3367ea28f5 100644 --- a/lib/ansible/cli/vault.py +++ b/lib/ansible/cli/vault.py @@ -16,6 +16,9 @@ # ansible-vault is a script that encrypts/decrypts YAML files. See # http://docs.ansible.com/playbooks_vault.html for more details. +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import os import sys import traceback diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py index b883ec3835e..4687185510c 100644 --- a/lib/ansible/constants.py +++ b/lib/ansible/constants.py @@ -16,7 +16,7 @@ # along with Ansible. If not, see . # Make coding more python3-ish -from __future__ import (absolute_import, division) +from __future__ import (absolute_import, division, print_function) __metaclass__ = type import os diff --git a/lib/ansible/galaxy/__init__.py b/lib/ansible/galaxy/__init__.py index 99876f08066..3b63b2df9c9 100644 --- a/lib/ansible/galaxy/__init__.py +++ b/lib/ansible/galaxy/__init__.py @@ -20,6 +20,9 @@ ######################################################################## ''' This manages remote shared Ansible objects, mainly roles''' +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import os from ansible.compat.six import string_types diff --git a/lib/ansible/galaxy/api.py b/lib/ansible/galaxy/api.py index 5b67d9d6c92..4a61af878cc 100644 --- a/lib/ansible/galaxy/api.py +++ b/lib/ansible/galaxy/api.py @@ -20,6 +20,10 @@ # along with Ansible. If not, see . # ######################################################################## + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import json from urllib2 import quote as urlquote, HTTPError from urlparse import urlparse diff --git a/lib/ansible/galaxy/role.py b/lib/ansible/galaxy/role.py index 4e6cdc9d151..dc9da5d79ce 100644 --- a/lib/ansible/galaxy/role.py +++ b/lib/ansible/galaxy/role.py @@ -19,6 +19,9 @@ # ######################################################################## +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import datetime import os import tarfile diff --git a/lib/ansible/inventory/vars_plugins/__init__.py b/lib/ansible/inventory/vars_plugins/__init__.py index e69de29bb2d..83a17728e23 100644 --- a/lib/ansible/inventory/vars_plugins/__init__.py +++ b/lib/ansible/inventory/vars_plugins/__init__.py @@ -0,0 +1,4 @@ +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + diff --git a/lib/ansible/plugins/cache/jsonfile.py b/lib/ansible/plugins/cache/jsonfile.py index 4004288471a..71a30e8f86a 100644 --- a/lib/ansible/plugins/cache/jsonfile.py +++ b/lib/ansible/plugins/cache/jsonfile.py @@ -15,6 +15,10 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import os import time import errno diff --git a/lib/ansible/plugins/callback/__init__.py b/lib/ansible/plugins/callback/__init__.py index c75cc3d710b..6b937ef99ab 100644 --- a/lib/ansible/plugins/callback/__init__.py +++ b/lib/ansible/plugins/callback/__init__.py @@ -16,7 +16,7 @@ # along with Ansible. If not, see . # Make coding more python3-ish -from __future__ import (absolute_import, division) +from __future__ import (absolute_import, division, print_function) __metaclass__ = type import json diff --git a/lib/ansible/plugins/callback/context_demo.py b/lib/ansible/plugins/callback/context_demo.py index ad22ead07df..3a5cd844cdc 100644 --- a/lib/ansible/plugins/callback/context_demo.py +++ b/lib/ansible/plugins/callback/context_demo.py @@ -15,6 +15,10 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + from ansible.plugins.callback import CallbackBase class CallbackModule(CallbackBase): diff --git a/lib/ansible/plugins/callback/hipchat.py b/lib/ansible/plugins/callback/hipchat.py index 139b450866d..53551ba82c7 100644 --- a/lib/ansible/plugins/callback/hipchat.py +++ b/lib/ansible/plugins/callback/hipchat.py @@ -15,6 +15,10 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import os import urllib diff --git a/lib/ansible/plugins/callback/log_plays.py b/lib/ansible/plugins/callback/log_plays.py index 8b82586df92..d8a834cadce 100644 --- a/lib/ansible/plugins/callback/log_plays.py +++ b/lib/ansible/plugins/callback/log_plays.py @@ -15,6 +15,10 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import os import time import json diff --git a/lib/ansible/plugins/callback/mail.py b/lib/ansible/plugins/callback/mail.py index f6ec212966a..3895fbaddd0 100644 --- a/lib/ansible/plugins/callback/mail.py +++ b/lib/ansible/plugins/callback/mail.py @@ -16,6 +16,10 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import os import smtplib import json diff --git a/lib/ansible/plugins/callback/osx_say.py b/lib/ansible/plugins/callback/osx_say.py index 36b053026e2..da1044c2b1f 100644 --- a/lib/ansible/plugins/callback/osx_say.py +++ b/lib/ansible/plugins/callback/osx_say.py @@ -16,6 +16,10 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import subprocess import os diff --git a/lib/ansible/plugins/callback/profile_tasks.py b/lib/ansible/plugins/callback/profile_tasks.py index 4824ef4a87a..669d6f05c01 100644 --- a/lib/ansible/plugins/callback/profile_tasks.py +++ b/lib/ansible/plugins/callback/profile_tasks.py @@ -18,6 +18,10 @@ # Provides per-task timing, ongoing playbook elapsed time and # ordered list of top 20 longest running tasks at end +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import time from ansible.plugins.callback import CallbackBase diff --git a/lib/ansible/plugins/callback/syslog_json.py b/lib/ansible/plugins/callback/syslog_json.py index 5d22dbd300f..71deb4f9762 100644 --- a/lib/ansible/plugins/callback/syslog_json.py +++ b/lib/ansible/plugins/callback/syslog_json.py @@ -1,3 +1,7 @@ +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import os import json diff --git a/lib/ansible/plugins/callback/timer.py b/lib/ansible/plugins/callback/timer.py index f75b55e4be6..8694b281e70 100644 --- a/lib/ansible/plugins/callback/timer.py +++ b/lib/ansible/plugins/callback/timer.py @@ -1,3 +1,7 @@ +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import os import datetime from datetime import datetime, timedelta diff --git a/lib/ansible/plugins/filter/__init__.py b/lib/ansible/plugins/filter/__init__.py index e69de29bb2d..cbbbd641184 100644 --- a/lib/ansible/plugins/filter/__init__.py +++ b/lib/ansible/plugins/filter/__init__.py @@ -0,0 +1,5 @@ +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + diff --git a/lib/ansible/plugins/filter/core.py b/lib/ansible/plugins/filter/core.py index d469550f0fa..d5e1a12e531 100644 --- a/lib/ansible/plugins/filter/core.py +++ b/lib/ansible/plugins/filter/core.py @@ -15,7 +15,10 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . -from __future__ import absolute_import +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import sys import base64 diff --git a/lib/ansible/plugins/filter/ipaddr.py b/lib/ansible/plugins/filter/ipaddr.py index b2de8759e12..432de6031b1 100644 --- a/lib/ansible/plugins/filter/ipaddr.py +++ b/lib/ansible/plugins/filter/ipaddr.py @@ -15,6 +15,10 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + from functools import partial import types diff --git a/lib/ansible/plugins/filter/mathstuff.py b/lib/ansible/plugins/filter/mathstuff.py index 341c2aa2d8c..599d9982d7b 100644 --- a/lib/ansible/plugins/filter/mathstuff.py +++ b/lib/ansible/plugins/filter/mathstuff.py @@ -15,7 +15,10 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . -from __future__ import absolute_import +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import math import collections diff --git a/lib/ansible/plugins/lookup/list.py b/lib/ansible/plugins/lookup/list.py index cd92718b384..76b86dd1679 100644 --- a/lib/ansible/plugins/lookup/list.py +++ b/lib/ansible/plugins/lookup/list.py @@ -14,7 +14,9 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . -from __future__ import (absolute_import, division) + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) __metaclass__ = type from ansible.plugins.lookup import LookupBase diff --git a/lib/ansible/plugins/test/__init__.py b/lib/ansible/plugins/test/__init__.py index e69de29bb2d..980f84a225b 100644 --- a/lib/ansible/plugins/test/__init__.py +++ b/lib/ansible/plugins/test/__init__.py @@ -0,0 +1,3 @@ +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type diff --git a/lib/ansible/plugins/test/core.py b/lib/ansible/plugins/test/core.py index daf2240211e..1bd789260f7 100644 --- a/lib/ansible/plugins/test/core.py +++ b/lib/ansible/plugins/test/core.py @@ -15,6 +15,10 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import re from ansible import errors diff --git a/lib/ansible/plugins/test/files.py b/lib/ansible/plugins/test/files.py index 0c46b53160b..5ab5788e01b 100644 --- a/lib/ansible/plugins/test/files.py +++ b/lib/ansible/plugins/test/files.py @@ -15,6 +15,10 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + from os.path import isdir, isfile, isabs, exists, lexists, islink, samefile, ismount from ansible import errors diff --git a/lib/ansible/utils/cmd_functions.py b/lib/ansible/utils/cmd_functions.py index 31b120e2255..99f0483b599 100644 --- a/lib/ansible/utils/cmd_functions.py +++ b/lib/ansible/utils/cmd_functions.py @@ -14,7 +14,9 @@ # # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . -from __future__ import absolute_import + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import os import sys diff --git a/lib/ansible/utils/module_docs.py b/lib/ansible/utils/module_docs.py index 0e25e565ec4..4a90c3caca1 100755 --- a/lib/ansible/utils/module_docs.py +++ b/lib/ansible/utils/module_docs.py @@ -17,6 +17,10 @@ # along with Ansible. If not, see . # +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import os import sys import ast diff --git a/lib/ansible/utils/shlex.py b/lib/ansible/utils/shlex.py index dd845e0e4ef..2dee15816bf 100644 --- a/lib/ansible/utils/shlex.py +++ b/lib/ansible/utils/shlex.py @@ -15,7 +15,9 @@ # You should have received a copy of the GNU General Public License # alongwith Ansible. If not, see . -from __future__ import absolute_import +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type import shlex from ansible.compat.six import PY3 diff --git a/lib/ansible/vars/unsafe_proxy.py b/lib/ansible/vars/unsafe_proxy.py index 19707e10b32..ff48292ba1a 100644 --- a/lib/ansible/vars/unsafe_proxy.py +++ b/lib/ansible/vars/unsafe_proxy.py @@ -50,6 +50,9 @@ # http://code.activestate.com/recipes/496741-object-proxying/ # Author: Tomer Filiba +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + __all__ = ['UnsafeProxy', 'AnsibleUnsafe', 'wrap_var']