Skip to content

Commit b52094a

Browse files
committed
[enh] change_level.py uses int not and have sanity checks for that
1 parent 95e7426 commit b52094a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

change_level.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222
print "Error: app '%s' is not present in %s" % (app_id, app_list_name)
2323
sys.exit(1)
2424

25-
app_list[app_id]["level"] = level
25+
if not level.isdigit():
26+
print "Error: app level must be a number, it's '%s'" % level
27+
sys.exit(1)
28+
29+
if not 0 <= int(level) <= 10:
30+
print "Error: app level must be between 0 and 10, it's '%s'" % level
31+
sys.exit(1)
32+
33+
app_list[app_id]["level"] = int(level)
2634

2735
open(app_list_name, "w").write("\n".join(json.dumps(app_list, indent=4, sort_keys=True).split(" \n")) + "\n")

0 commit comments

Comments
 (0)