Cleanup: use context-manager for opening files

This commit is contained in:
Campbell Barton
2025-01-04 22:26:18 +11:00
parent 0f1e1bcdae
commit c5203ef7fd
4 changed files with 19 additions and 24 deletions

View File

@@ -15,12 +15,11 @@ import os
def main():
xpm_ls = [f for f in sys.argv[1:] if f.lower().endswith(".xpm")]
print("Converting: " + " ".join(xpm_ls))
print("Converting:", " ".join(xpm_ls))
for xpm in xpm_ls:
f = open(xpm, "r")
data = f.read()
f.close()
with open(xpm, "r", encoding="utf-8") as fh:
data = fh.read()
# all after first {
data = data.split("{", 1)[1]