Skip to content

Commit

Permalink
Added some exception handling to check_icon_state_limit.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Apr 27, 2024
1 parent d7ad375 commit 5cd86ad
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tools/check_icon_state_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,18 @@
if not filename.endswith('.dmi'):
continue
file_path = path.join(root, filename)
dmi = DMI(file_path)
dmi.loadMetadata()
number_of_icon_states = len(dmi.states)
if number_of_icon_states > 512:
try:
dmi = DMI(file_path)
dmi.loadMetadata()
number_of_icon_states = len(dmi.states)
if number_of_icon_states > 512:
failed = True
print("{0} had too many icon states. {1}/512".format(file_path, number_of_icon_states))
except AttributeError as e:
failed = True
print("{0} had too many icon states. {1}/512".format(file_path, number_of_icon_states))
print("AttributeError when processing {0}. This may indicate an empty icon file.\nException was: {1}".format(file_path, e))
except Exception as e:
failed = True
print("Exception when processing {0}: {1}".format(file_path, e))
if failed:
sys.exit(1)

0 comments on commit 5cd86ad

Please sign in to comment.