Skip to content

Commit 88e1dcf

Browse files
committed
Move Map construction logic into __init__.
1 parent 49cf8bc commit 88e1dcf

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

sc2reader/resources.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -470,19 +470,9 @@ def __init__(self, map_file, filename=None, gateway=None, map_hash=None, **optio
470470
self.archive = MPQArchive(map_file)
471471
self.minimap = self.archive.read_file('Minimap.tga')
472472

473-
@classmethod
474-
def get_url(cls, gateway, map_hash):
475-
if gateway and map_hash:
476-
return cls.url_template.format(gateway, map_hash)
477-
else:
478-
return None
479-
480-
def load(self):
481-
self.read_game_strings()
482-
483-
def read_game_strings(self):
484-
self.game_strings = self.archive.read_file('enUS.SC2Data\LocalizedData\GameStrings.txt')
485-
for line in self.game_strings.split('\r\n'):
473+
# TODO: We probably shouldn't favor enUS here?
474+
game_strings = self.archive.read_file('enUS.SC2Data\LocalizedData\GameStrings.txt')
475+
for line in game_strings.split('\r\n'):
486476
parts = line.split('=')
487477
if parts[0] == 'DocInfo/Name':
488478
self.name = parts[1]
@@ -491,6 +481,14 @@ def read_game_strings(self):
491481
elif parts[0] == 'DocInfo/DescLong':
492482
self.description = parts[1]
493483

484+
@classmethod
485+
def get_url(cls, gateway, map_hash):
486+
"""Builds a download URL for the map from its components."""
487+
if gateway and map_hash:
488+
return cls.url_template.format(gateway, map_hash)
489+
else:
490+
return None
491+
494492

495493
class GameSummary(Resource):
496494
base_url_template = 'http://{0}.depot.battle.net:1119/{1}.{2}'

0 commit comments

Comments
 (0)