Skip to content

Commit 49cf8bc

Browse files
committed
Factor out load_map into a callable method.
1 parent f2786ce commit 49cf8bc

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

sc2reader/resources.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,7 @@ def __init__(self, replay_file, filename=None, load_level=4, **options):
164164

165165
# Can only be effective if map data has been loaded
166166
if options.get('load_map', False):
167-
map_url = Map.get_url(self.gateway, self.map_hash)
168-
map_file = StringIO(urllib2.urlopen(map_url).read())
169-
self.map = Map(map_file, filename=self.map, gateway=self.gateway, map_hash=self.map_hash)
170-
167+
self.load_map()
171168

172169
# Load players if requested
173170
if load_level >= 2:
@@ -221,6 +218,11 @@ def load_details(self):
221218
self.start_time = datetime.utcfromtimestamp(self.unix_timestamp-self.real_length.seconds)
222219
self.date = self.end_time #backwards compatibility
223220

221+
def load_map(self):
222+
map_url = Map.get_url(self.gateway, self.map_hash)
223+
map_file = StringIO(urllib2.urlopen(map_url).read())
224+
self.map = Map(map_file, filename=self.map, gateway=self.gateway, map_hash=self.map_hash)
225+
224226
def load_players(self):
225227
#If we don't at least have details and attributes_events we can go no further
226228
if 'replay.details' not in self.raw_data:

0 commit comments

Comments
 (0)