summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDag Wieers <dag@wieers.com>2017-05-16 19:52:07 +0200
committerJohn R Barker <john@johnrbarker.com>2017-05-16 18:52:07 +0100
commit9a5a61bdcad1b4a61797cfd73bd52048bcc072c3 (patch)
treee8b7c0ceee434862825c0515183ab8ee6d07160a
parent4f29662a9edf41187f779b7a1283b298a0c08ab7 (diff)
downloadansible-9a5a61bdcad1b4a61797cfd73bd52048bcc072c3.tar.gz
hacking/: PEP8 compliancy (#24683)
- Make PEP8 compliant
-rwxr-xr-xhacking/cherrypick.py9
-rwxr-xr-xhacking/get_library.py1
-rwxr-xr-xhacking/metadata-tool.py21
-rwxr-xr-xhacking/tests/gen_distribution_version_testcase.py3
-rw-r--r--test/sanity/pep8/legacy-files.txt4
5 files changed, 18 insertions, 20 deletions
diff --git a/hacking/cherrypick.py b/hacking/cherrypick.py
index 9a810101dd..0f1b4b8d2a 100755
--- a/hacking/cherrypick.py
+++ b/hacking/cherrypick.py
@@ -1,13 +1,15 @@
#!/usr/bin/env python3
import os
+import sh
import sys
import tempfile
-import sh
+REPO_PATH = {
+ 'extras': '/srv/ansible/stable-2.2/lib/ansible/modules/extras',
+ 'core': '/srv/ansible/stable-2.2/lib/ansible/modules/core'
+}
-REPO_PATH = {'extras': '/srv/ansible/stable-2.2/lib/ansible/modules/extras',
- 'core': '/srv/ansible/stable-2.2/lib/ansible/modules/core'}
if __name__ == '__main__':
commit_hash = sys.argv[1]
@@ -49,4 +51,3 @@ if __name__ == '__main__':
print("Problem occurred. Patch saved in: {}".format(patchfilename))
else:
os.remove(patchfilename)
-
diff --git a/hacking/get_library.py b/hacking/get_library.py
index bdb96f680f..121e2dc2e9 100755
--- a/hacking/get_library.py
+++ b/hacking/get_library.py
@@ -21,6 +21,7 @@
import ansible.constants as C
import sys
+
def main():
print(C.DEFAULT_MODULE_PATH)
return 0
diff --git a/hacking/metadata-tool.py b/hacking/metadata-tool.py
index b37fe445af..893dad5021 100755
--- a/hacking/metadata-tool.py
+++ b/hacking/metadata-tool.py
@@ -39,7 +39,7 @@ NONMODULE_PY_FILES = frozenset(('async_wrapper.py',))
NONMODULE_MODULE_NAMES = frozenset(os.path.splitext(p)[0] for p in NONMODULE_PY_FILES)
# Default metadata
-DEFAULT_METADATA = {'metadata_version': '1.0', 'status': ['preview'], 'supported_by':'community'}
+DEFAULT_METADATA = {'metadata_version': '1.0', 'status': ['preview'], 'supported_by': 'community'}
class ParseError(Exception):
@@ -86,6 +86,7 @@ def parse_args(arg_string):
return action, {'version': version, 'overwrite': overwrite, 'csvfile': csvfile}
+
def seek_end_of_dict(module_data, start_line, start_col, next_node_line, next_node_col):
"""Look for the end of a dict in a set of lines
@@ -222,7 +223,7 @@ def extract_metadata(module_data):
try:
# Determine where the next node starts
- next_node = mod_ast_tree.body[root_idx+1]
+ next_node = mod_ast_tree.body[root_idx + 1]
next_lineno = next_node.lineno
next_col_offset = next_node.col_offset
except IndexError:
@@ -232,8 +233,10 @@ def extract_metadata(module_data):
# Determine where the current metadata ends
end_line, end_col = seek_end_of_dict(module_data,
- child.lineno - 1, child.col_offset, next_lineno,
- next_col_offset)
+ child.lineno - 1,
+ child.col_offset,
+ next_lineno,
+ next_col_offset)
elif isinstance(child.value, ast.Str):
metadata = yaml.safe_load(child.value.s)
@@ -483,9 +486,8 @@ def metadata_summary(plugins, version=None):
return list(no_metadata.values()), list(has_metadata.values()), supported_by, status
-#
# Filters to convert between metadata versions
-#
+
def convert_metadata_pre_1_0_to_1_0(metadata):
"""
@@ -511,9 +513,8 @@ def convert_metadata_pre_1_0_to_1_0(metadata):
return new_metadata
-#
# Subcommands
-#
+
def add_from_csv(csv_file, version=None, overwrite=False):
"""Implement the subcommand to add metadata from a csv file
@@ -670,9 +671,9 @@ def report(version=None):
print('== Summary ==')
print('No Metadata: {0} Has Metadata: {1}'.format(len(no_metadata), len(has_metadata)))
print('Supported by core: {0} Supported by community: {1} Supported by value curated: {2}'.format(len(support['core']),
- len(support['community']), len(support['curated'])))
+ len(support['community']), len(support['curated'])))
print('Status StableInterface: {0} Status Preview: {1} Status Deprecated: {2} Status Removed: {3}'.format(len(status['stableinterface']),
- len(status['preview']), len(status['deprecated']), len(status['removed'])))
+ len(status['preview']), len(status['deprecated']), len(status['removed'])))
return 0
diff --git a/hacking/tests/gen_distribution_version_testcase.py b/hacking/tests/gen_distribution_version_testcase.py
index 7560c5fe0a..bc2ab3c09c 100755
--- a/hacking/tests/gen_distribution_version_testcase.py
+++ b/hacking/tests/gen_distribution_version_testcase.py
@@ -60,7 +60,7 @@ parsed = json.loads(ansible_out[ansible_out.index('{'):])
ansible_facts = {}
for fact in facts:
try:
- ansible_facts[fact] = parsed['ansible_facts']['ansible_'+fact]
+ ansible_facts[fact] = parsed['ansible_facts']['ansible_' + fact]
except:
ansible_facts[fact] = "N/A"
@@ -74,4 +74,3 @@ output = {
}
print(json.dumps(output, indent=4))
-
diff --git a/test/sanity/pep8/legacy-files.txt b/test/sanity/pep8/legacy-files.txt
index d53f5f045e..efe9069170 100644
--- a/test/sanity/pep8/legacy-files.txt
+++ b/test/sanity/pep8/legacy-files.txt
@@ -6,10 +6,6 @@ docs/bin/dump_keywords.py
docs/bin/plugin_formatter.py
docs/docsite/rst/conf.py
examples/scripts/uptime.py
-hacking/cherrypick.py
-hacking/get_library.py
-hacking/metadata-tool.py
-hacking/tests/gen_distribution_version_testcase.py
lib/ansible/cli/__init__.py
lib/ansible/cli/adhoc.py
lib/ansible/cli/console.py