From 88dbb5a630c96a87e72f4bc5712ea008bc9820de Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Thu, 3 Nov 2016 15:46:12 -0700 Subject: [PATCH] Python 3 fixes for ansible-doc. --- lib/ansible/cli/doc.py | 4 ++-- lib/ansible/utils/module_docs.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/ansible/cli/doc.py b/lib/ansible/cli/doc.py index a49dba04ab..eef133803a 100644 --- a/lib/ansible/cli/doc.py +++ b/lib/ansible/cli/doc.py @@ -101,7 +101,7 @@ class DocCLI(CLI): try: doc, plainexamples, returndocs = module_docs.get_docstring(filename, verbose=(self.options.verbosity > 0)) except: - display.vvv(traceback.print_exc()) + display.vvv(traceback.format_exc()) display.error("module %s has a documentation error formatting or is missing documentation\nTo see exact traceback use -vvv" % module) continue @@ -134,7 +134,7 @@ class DocCLI(CLI): # probably a quoting issue. raise AnsibleError("Parsing produced an empty object.") except Exception as e: - display.vvv(traceback.print_exc()) + display.vvv(traceback.format_exc()) raise AnsibleError("module %s missing documentation (or could not parse documentation): %s\n" % (module, str(e))) if text: diff --git a/lib/ansible/utils/module_docs.py b/lib/ansible/utils/module_docs.py index 31908ed224..729b81c713 100755 --- a/lib/ansible/utils/module_docs.py +++ b/lib/ansible/utils/module_docs.py @@ -97,10 +97,10 @@ def get_docstring(filename, verbose=False): fragment_yaml = getattr(fragment_class, fragment_var, '{}') fragment = AnsibleLoader(fragment_yaml, file_name=filename).get_single_data() - if fragment.has_key('notes'): + if 'notes' in fragment: notes = fragment.pop('notes') if notes: - if not doc.has_key('notes'): + if 'notes' not in doc: doc['notes'] = [] doc['notes'].extend(notes) @@ -108,7 +108,7 @@ def get_docstring(filename, verbose=False): raise Exception("missing options in fragment, possibly misformatted?") for key, value in fragment.items(): - if not doc.has_key(key): + if key not in doc: doc[key] = value else: if isinstance(doc[key], MutableMapping):