1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Change to python3 syntax

This commit is contained in:
Kevin Houdebert 2015-08-31 02:35:14 +02:00
parent 5a65dce6fb
commit b8c9391d0c
3 changed files with 24 additions and 23 deletions

View file

@ -22,7 +22,7 @@ import ansible.constants as C
import sys import sys
def main(): def main():
print C.DEFAULT_MODULE_PATH print(C.DEFAULT_MODULE_PATH)
return 0 return 0
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -18,6 +18,7 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>. # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# #
from __future__ import print_function
import os import os
import glob import glob
import sys import sys
@ -120,7 +121,7 @@ def write_data(text, options, outputname, module):
f.write(text.encode('utf-8')) f.write(text.encode('utf-8'))
f.close() f.close()
else: else:
print text print(text)
##################################################################################### #####################################################################################
@ -249,7 +250,7 @@ def process_module(module, options, env, template, outputname, module_map, alias
deprecated = True deprecated = True
module = module.replace("_","",1) module = module.replace("_","",1)
print "rendering: %s" % module print("rendering: %s" % module)
# use ansible core library to parse out doc metadata YAML and plaintext examples # use ansible core library to parse out doc metadata YAML and plaintext examples
doc, examples, returndocs = module_docs.get_docstring(fname, verbose=options.verbose) doc, examples, returndocs = module_docs.get_docstring(fname, verbose=options.verbose)
@ -345,7 +346,7 @@ def process_category(category, categories, options, env, template, outputname):
category_file_path = os.path.join(options.output_dir, "list_of_%s_modules.rst" % category) category_file_path = os.path.join(options.output_dir, "list_of_%s_modules.rst" % category)
category_file = open(category_file_path, "w") category_file = open(category_file_path, "w")
print "*** recording category %s in %s ***" % (category, category_file_path) print("*** recording category %s in %s ***" % (category, category_file_path))
# start a new category file # start a new category file
@ -419,13 +420,13 @@ def validate_options(options):
''' validate option parser options ''' ''' validate option parser options '''
if not options.module_dir: if not options.module_dir:
print >>sys.stderr, "--module-dir is required" print("--module-dir is required", file=sys.stderr)
sys.exit(1) sys.exit(1)
if not os.path.exists(options.module_dir): if not os.path.exists(options.module_dir):
print >>sys.stderr, "--module-dir does not exist: %s" % options.module_dir print("--module-dir does not exist: %s" % options.module_dir, file=sys.stderr)
sys.exit(1) sys.exit(1)
if not options.template_dir: if not options.template_dir:
print "--template-dir must be specified" print("--template-dir must be specified")
sys.exit(1) sys.exit(1)
##################################################################################### #####################################################################################

View file

@ -119,7 +119,7 @@ def boilerplate_module(modfile, args, interpreter, check, destfile):
task_vars = {} task_vars = {}
if interpreter: if interpreter:
if '=' not in interpreter: if '=' not in interpreter:
print 'interpreter must by in the form of ansible_python_interpreter=/usr/bin/python' print("interpreter must by in the form of ansible_python_interpreter=/usr/bin/python")
sys.exit(1) sys.exit(1)
interpreter_type, interpreter_path = interpreter.split('=') interpreter_type, interpreter_path = interpreter.split('=')
if not interpreter_type.startswith('ansible_'): if not interpreter_type.startswith('ansible_'):
@ -138,8 +138,8 @@ def boilerplate_module(modfile, args, interpreter, check, destfile):
) )
modfile2_path = os.path.expanduser(destfile) modfile2_path = os.path.expanduser(destfile)
print "* including generated source, if any, saving to: %s" % modfile2_path print("* including generated source, if any, saving to: %s" % modfile2_path)
print "* this may offset any line numbers in tracebacks/debuggers!" print("* this may offset any line numbers in tracebacks/debuggers!")
modfile2 = open(modfile2_path, 'w') modfile2 = open(modfile2_path, 'w')
modfile2.write(module_data) modfile2.write(module_data)
modfile2.close() modfile2.close()
@ -160,21 +160,21 @@ def runtest( modfile, argspath):
(out, err) = cmd.communicate() (out, err) = cmd.communicate()
try: try:
print "***********************************" print("***********************************")
print "RAW OUTPUT" print("RAW OUTPUT")
print out print(out)
print err print(err)
results = json.loads(out) results = json.loads(out)
except: except:
print "***********************************" print("***********************************")
print "INVALID OUTPUT FORMAT" print("INVALID OUTPUT FORMAT")
print out print(out)
traceback.print_exc() traceback.print_exc()
sys.exit(1) sys.exit(1)
print "***********************************" print("***********************************")
print "PARSED OUTPUT" print("PARSED OUTPUT")
print jsonify(results,format=True) print(jsonify(results,format=True))
def rundebug(debugger, modfile, argspath): def rundebug(debugger, modfile, argspath):
"""Run interactively with console debugger.""" """Run interactively with console debugger."""