wmllint: fixed an error when trying to check if a file is a savegame

The error was caused by the fact that opening a file with codecs.open() is much stricter than using open(mode=rb), and throws a UnicodeDecodeError if a file can't be read as UTF-8 - which is the case for binary files.
This commit is contained in:
Elvish_Hunter 2015-08-25 14:06:49 +02:00
parent a55bc98630
commit def724816f

View file

@ -199,8 +199,12 @@ def issave(filename):
with gzip.open(filename) as content:
firstline = content.readline()
else:
with codecs.open(filename, "r", "utf8") as content:
firstline = content.readline()
try:
with codecs.open(filename, "r", "utf8") as content:
firstline = content.readline()
except UnicodeDecodeError:
# our saves are in UTF-8, so this file shouldn't be one
return False
return firstline.startswith("label=")
def isresource(filename):