Skip to content

Commit 2d8bc4d

Browse files
committed
Allow for files to be missing from the SC2Replay archive.
1 parent 76a1426 commit 2d8bc4d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sc2reader/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ def make_replay(self, replay_file, **options):
117117

118118
# These files are configured for either full or partial parsing
119119
for file in options.files:
120+
reference_name = '_'.join(file.split('.')[1:])
120121

121122
# To wrap mpyq exceptions we have to do this try hack.
122123
try:
@@ -136,6 +137,11 @@ def make_replay(self, replay_file, **options):
136137
except:
137138
raise exceptions.MPQError("Unable to extract file: {0}".format(file))
138139

140+
#It is possible that the file doesnt exist, e.g.
141+
# Single Player vs AI games with no chat events
142+
if not filedata:
143+
continue
144+
139145
# For each file, we build a smart buffer object from the
140146
# utf-8 encoded bitstream that mpyq extracts.
141147
buffer = utils.ReplayBuffer(filedata)
@@ -156,7 +162,6 @@ def make_replay(self, replay_file, **options):
156162
# use in post processing because correct interpretation of
157163
# the information often requires data from other files.
158164
reader = config.readers[replay.build][file]
159-
reference_name = '_'.join(file.split('.')[1:])
160165
replay.raw[reference_name] = reader(buffer, replay)
161166

162167
# Now that the replay has been loaded with the "raw" data from

0 commit comments

Comments
 (0)