Skip to content

Commit

Permalink
Add check for .mo files and more verbose errors (#6419)
Browse files Browse the repository at this point in the history
  • Loading branch information
rcalixte authored Sep 14, 2024
1 parent f581a67 commit 0b12ebe
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions validate-spice
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ if len(sys.argv) != 2:
print("./validate-spice --all")
sys.exit(1)

SPICE_TYPE="applet"
SPICE_TYPE = "applet"


class CheckError(Exception):
pass


# function with checks for an xlet
def validate_xlet(uuid):
valid = False
Expand All @@ -41,7 +43,9 @@ def validate_xlet(uuid):
found = False
for root, dirs, files in os.walk("files/%s" % uuid):
if any(ext.endswith(".po") for ext in files) and not any(ext.endswith(".pot") for ext in files):
raise CheckError("[%s] Invalid location for translation files!" % (uuid))
raise CheckError("[%s] Invalid location for translation files! (Move any .po or .pot to files/%s/po)" % (uuid, uuid))
if any(ext.endswith(".mo") for ext in files):
raise CheckError("[%s] Translation files should not be compiled! (Delete any .mo files in %s)" % (uuid, uuid))
for file in files:
if file == "%s.js" % SPICE_TYPE:
found = True
Expand Down Expand Up @@ -133,7 +137,8 @@ def validate_xlet(uuid):
os.chdir("..")
return valid

def quit(valid):

def exit_status(valid):
if (valid):
print ("No errors found. Everything looks good.")
sys.exit(0)
Expand All @@ -142,6 +147,7 @@ def quit(valid):
"'validate-spice <uuid>'' to check for further errors.")
sys.exit(1)


if sys.argv[1] == "--all":
valid = True
for uuid in os.listdir("."):
Expand All @@ -150,4 +156,4 @@ if sys.argv[1] == "--all":
else:
valid = validate_xlet(sys.argv[1])

quit(valid)
exit_status(valid)

0 comments on commit 0b12ebe

Please sign in to comment.