forked from SuperTux/supertux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert
build-addon-index.py
and sexpr.py
to Python3
- Loading branch information
Showing
2 changed files
with
23 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env python | ||
#!/usr/bin/env python3 | ||
# | ||
# SuperTux | ||
# Copyright (C) 2014 Ingo Ruhnke <[email protected]> | ||
|
@@ -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 # |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env python | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright (c) 2014 Ingo Ruhnke <[email protected]> | ||
# | ||
|
@@ -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 # |