From f34b55ac2bcfd71640b3db91f3c4e177f723cd03 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Mon, 19 Oct 2015 18:36:19 -0700 Subject: [PATCH] Add python3-compat boilerplate to all .py files in lib/ansible --- .travis.yml | 2 ++ bin/ansible | 2 +- lib/ansible/__init__.py | 5 +++++ lib/ansible/cli/adhoc.py | 3 +++ lib/ansible/cli/doc.py | 3 +++ lib/ansible/cli/galaxy.py | 3 +++ lib/ansible/cli/playbook.py | 4 ++++ lib/ansible/cli/pull.py | 3 +++ lib/ansible/cli/vault.py | 3 +++ lib/ansible/constants.py | 2 +- lib/ansible/galaxy/__init__.py | 3 +++ lib/ansible/galaxy/api.py | 4 ++++ lib/ansible/galaxy/role.py | 3 +++ lib/ansible/inventory/vars_plugins/__init__.py | 4 ++++ lib/ansible/plugins/cache/jsonfile.py | 4 ++++ lib/ansible/plugins/callback/__init__.py | 2 +- lib/ansible/plugins/callback/context_demo.py | 4 ++++ lib/ansible/plugins/callback/hipchat.py | 4 ++++ lib/ansible/plugins/callback/log_plays.py | 4 ++++ lib/ansible/plugins/callback/mail.py | 4 ++++ lib/ansible/plugins/callback/osx_say.py | 4 ++++ lib/ansible/plugins/callback/profile_tasks.py | 4 ++++ lib/ansible/plugins/callback/syslog_json.py | 4 ++++ lib/ansible/plugins/callback/timer.py | 4 ++++ lib/ansible/plugins/filter/__init__.py | 5 +++++ lib/ansible/plugins/filter/core.py | 5 ++++- lib/ansible/plugins/filter/ipaddr.py | 4 ++++ lib/ansible/plugins/filter/mathstuff.py | 5 ++++- lib/ansible/plugins/lookup/list.py | 4 +++- lib/ansible/plugins/test/__init__.py | 3 +++ lib/ansible/plugins/test/core.py | 4 ++++ lib/ansible/plugins/test/files.py | 4 ++++ lib/ansible/utils/cmd_functions.py | 4 +++- lib/ansible/utils/module_docs.py | 4 ++++ lib/ansible/utils/shlex.py | 4 +++- lib/ansible/vars/unsafe_proxy.py | 3 +++ 36 files changed, 123 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 29ed7d3d0f..21d0177fb9 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 a117856d89..70e6863f6b 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 704b6456f7..ad6193463a 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 ff5e512402..6b0437c177 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 02ede78359..05f26abae5 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 716eac9616..42f3cf2b50 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 306c134790..417c41c6e9 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 0c33568d3d..6caa8525db 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 ce017650d1..f3367ea28f 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 b883ec3835..4687185510 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 99876f0806..3b63b2df9c 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 5b67d9d6c9..4a61af878c 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 4e6cdc9d15..dc9da5d79c 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 e69de29bb2..83a17728e2 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 4004288471..71a30e8f86 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 c75cc3d710..6b937ef99a 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 ad22ead07d..3a5cd844cd 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 139b450866..53551ba82c 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 8b82586df9..d8a834cadc 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 f6ec212966..3895fbaddd 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 36b053026e..da1044c2b1 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 4824ef4a87..669d6f05c0 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 5d22dbd300..71deb4f976 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 f75b55e4be..8694b281e7 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 e69de29bb2..cbbbd64118 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 d469550f0f..d5e1a12e53 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 b2de8759e1..432de6031b 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 341c2aa2d8..599d9982d7 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 cd92718b38..76b86dd167 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 e69de29bb2..980f84a225 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 daf2240211..1bd789260f 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 0c46b53160..5ab5788e01 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 31b120e225..99f0483b59 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 0e25e565ec..4a90c3caca 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 dd845e0e4e..2dee15816b 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 19707e10b3..ff48292ba1 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']