Skip to content

Commit 82297d9

Browse files
committed
Fix a couple typos in rarely used code branches.
1 parent 3e57bed commit 82297d9

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

sc2reader/factories.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ def load_resource(self, resource, options=None, **new_options):
157157
directory = options.get('directory','')
158158
location = os.path.join(directory, resource)
159159

160+
# Extract the contents so we can close the file
160161
with open(location, 'rb') as resource_file:
161162
contents = resource_file.read()
162163

@@ -168,11 +169,9 @@ def load_resource(self, resource, options=None, **new_options):
168169
# Totally not designed for large files!!
169170
# We need a multiread resource, so wrap it in StringIO
170171
if not hasattr(resource,'seek'):
171-
resource = StringIO(replay_file.read())
172-
else:
173-
resource = replay_file
172+
resource = StringIO(resource.read())
174173

175-
resource_name = getattr(resource,'name','Unknown')
174+
resource_name = getattr(resource, 'name', 'Unknown')
176175

177176
return (resource, resource_name)
178177

sc2reader/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,8 @@ def read_header(replay_file):
616616

617617
#Sanity check that the input is in fact an MPQ file
618618
if buffer.empty or buffer.read_hex(4).upper() != "4D50511B":
619-
raise exceptions.FileError("File '%s' is not an MPQ file" % file.name)
619+
msg = "File '{0}' is not an MPQ file";
620+
raise exceptions.FileError(msg.format(replay_file.name))
620621

621622
max_data_size = buffer.read_int(LITTLE_ENDIAN)
622623
header_offset = buffer.read_int(LITTLE_ENDIAN)

0 commit comments

Comments
 (0)