minor cleanups

removed redundant print/exits
removed unused import and var
This commit is contained in:
Brian Coca 2017-01-19 19:01:58 -05:00
parent b4fb4420bb
commit bcdfdc0cc3

View file

@ -38,7 +38,6 @@ from six import iteritems
from ansible.errors import AnsibleError from ansible.errors import AnsibleError
from ansible.module_utils._text import to_bytes from ansible.module_utils._text import to_bytes
from ansible.utils import module_docs from ansible.utils import module_docs
from ansible.utils.vars import merge_hash
##################################################################################### #####################################################################################
# constants and paths # constants and paths
@ -254,16 +253,13 @@ def process_module(module, options, env, template, outputname, module_map, alias
# crash if module is missing documentation and not explicitly hidden from docs index # crash if module is missing documentation and not explicitly hidden from docs index
if doc is None: if doc is None:
sys.stderr.write("*** ERROR: MODULE MISSING DOCUMENTATION: %s, %s ***\n" % (fname, module)) sys.exit("*** ERROR: MODULE MISSING DOCUMENTATION: %s, %s ***\n" % (fname, module))
sys.exit(1)
if metadata is None: if metadata is None:
sys.stderr.write("*** ERROR: MODULE MISSING METADATA: %s, %s ***\n" % (fname, module)) sys.exit("*** ERROR: MODULE MISSING METADATA: %s, %s ***\n" % (fname, module))
sys.exit(1)
if deprecated and 'deprecated' not in doc: if deprecated and 'deprecated' not in doc:
sys.stderr.write("*** ERROR: DEPRECATED MODULE MISSING 'deprecated' DOCUMENTATION: %s, %s ***\n" % (fname, module)) sys.exit("*** ERROR: DEPRECATED MODULE MISSING 'deprecated' DOCUMENTATION: %s, %s ***\n" % (fname, module))
sys.exit(1)
if module in aliases: if module in aliases:
doc['aliases'] = aliases[module] doc['aliases'] = aliases[module]
@ -271,8 +267,7 @@ def process_module(module, options, env, template, outputname, module_map, alias
all_keys = [] all_keys = []
if not 'version_added' in doc: if not 'version_added' in doc:
sys.stderr.write("*** ERROR: missing version_added in: %s ***\n" % module) sys.exit("*** ERROR: missing version_added in: %s ***\n" % module)
sys.exit(1)
added = 0 added = 0
if doc['version_added'] == 'historical': if doc['version_added'] == 'historical':
@ -429,14 +424,11 @@ def validate_options(options):
''' validate option parser options ''' ''' validate option parser options '''
if not options.module_dir: if not options.module_dir:
print("--module-dir is required", file=sys.stderr) sys.exit("--module-dir is required", file=sys.stderr)
sys.exit(1)
if not os.path.exists(options.module_dir): if not os.path.exists(options.module_dir):
print("--module-dir does not exist: %s" % options.module_dir, file=sys.stderr) sys.exit("--module-dir does not exist: %s" % options.module_dir, file=sys.stderr)
sys.exit(1)
if not options.template_dir: if not options.template_dir:
print("--template-dir must be specified") sys.exit("--template-dir must be specified")
sys.exit(1)
##################################################################################### #####################################################################################
@ -471,7 +463,6 @@ def main():
# Import all the docs into memory # Import all the docs into memory
# #
module_map = mod_info.copy() module_map = mod_info.copy()
skipped_modules = set()
for modname in module_map: for modname in module_map:
result = process_module(modname, options, env, template, outputname, module_map, aliases) result = process_module(modname, options, env, template, outputname, module_map, aliases)