diff --git a/tools/build-addon-index.py b/tools/build-addon-index.py index d2bb7aacc31..8d574634e34 100755 --- a/tools/build-addon-index.py +++ b/tools/build-addon-index.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # SuperTux # Copyright (C) 2014 Ingo Ruhnke @@ -31,7 +31,8 @@ def escape_str(string): return "\"%s\"" % string.replace("\"", "\\\"") -class Addon(object): +class Addon: + def __init__(self, filename): lst = sexpr.parse(filename) if lst[0][0] != "supertux-addoninfo": @@ -95,7 +96,7 @@ def generate_index(fout, directory, base_url, zipdir): for addon_dir in os.listdir(directory): addon_dir = os.path.join(directory, addon_dir) if os.path.isdir(addon_dir): - print addon_dir + # print(addon_dir) nfos = glob.glob(os.path.join(addon_dir, "*.nfo")) if len(nfos) == 0: raise Exception(".nfo file missing from %s" % addon_dir) @@ -104,13 +105,20 @@ def generate_index(fout, directory, base_url, zipdir): else: try: process_addon(fout, addon_dir, nfos[0], base_url, zipdir) - except Exception, e: + except Exception as e: sys.stderr.write("%s: ignoring addon because: %s\n" % (addon_dir, e)) fout.write(")\n\n;; EOF ;;\n") +EXAMPLE_TEXT="""Example: + + ./build-addon-index.py -z ../../addons/repository/ ../../addons/src/""" + + if __name__ == "__main__": - parser = argparse.ArgumentParser(description='Addon Index/Zip Generator') + parser = argparse.ArgumentParser(description="Addon Index/Zip Generator", + epilog=EXAMPLE_TEXT, + formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('DIRECTORY', type=str, nargs=1, help="directory containing the mods") parser.add_argument('-o', '--output', metavar='FILE', type=str, required=False, @@ -129,4 +137,5 @@ def generate_index(fout, directory, base_url, zipdir): with open(args.output, "w") as fout: generate_index(fout, args.DIRECTORY[0], args.url, args.zipdir) + # EOF # diff --git a/tools/sexpr.py b/tools/sexpr.py index 98d2e7b09ae..cc1669396c2 100755 --- a/tools/sexpr.py +++ b/tools/sexpr.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2014 Ingo Ruhnke # @@ -97,15 +97,15 @@ def parse(text): raise Exception("error: list not closed") if __name__ == "__main__": - print "parsing..." + print("parsing...") result = parse(r'(() ("bar" foo) ()) () bar ') - print "1.", result - print "2.", parse(""";;comment - ("Hello World" 5 1 123) ("Hello" 123 123 "foobar") ;; comment""") - print "3.", parse(r'(8(8)8)') - print "4.", parse(r'') - print "5.", parse(r' ') + print("1.", result) + print("2.", parse(""";;comment + ("Hello World" 5 1 123) ("Hello" 123 123 "foobar") ;; comment""")) + print("3.", parse(r'(8(8)8)')) + print("4.", parse(r'')) + print("5.", parse(r' ')) with codecs.open("white.stf", encoding='utf-8') as fin: - print "6.", parse(fin.read()) + print("6.", parse(fin.read())) # EOF #