@@ -612,17 +612,20 @@ def __getstate__(self):
612612class Map (Resource ):
613613 url_template = 'http://{0}.depot.battle.net:1119/{1}.s2ma'
614614
615- #: The localized (only enUS supported right now) map name
616- name = str ( )
615+ def __init__ ( self , map_file , filename = None , region = None , map_hash = None , ** options ):
616+ super ( Map , self ). __init__ ( map_file , filename , ** options )
617617
618- #: The map's author
619- author = str ()
618+ #: The localized (only enUS supported right now) map name.
619+ self . name = str ()
620620
621- #: The map description as written by author
622- description = str ()
621+ #: The localized (only enUS supported right now) map author.
622+ self . author = str ()
623623
624- def __init__ (self , map_file , filename = None , region = None , map_hash = None , ** options ):
625- super (Map , self ).__init__ (map_file , filename , ** options )
624+ #: The localized (only enUS supported right now) map description.
625+ self .description = str ()
626+
627+ #: The localized (only enUS supported right now) map website.
628+ self .website = str ()
626629
627630 #: The unique hash used to identify this map on bnet's depots.
628631 self .hash = map_hash
@@ -643,9 +646,9 @@ def __init__(self, map_file, filename=None, region=None, map_hash=None, **option
643646 # Clearly this isn't a great solution but we can't be throwing exceptions
644647 # just because US English wasn't a concern of the map author.
645648 # TODO: Make this work regardless of the localizations available.
646- game_strings = self .archive .read_file ('enUS.SC2Data\LocalizedData\GameStrings.txt' ). decode ( 'utf8 ' )
647- if game_strings :
648- for line in game_strings .split ('\r \n ' ):
649+ game_strings_file = self .archive .read_file ('enUS.SC2Data\LocalizedData\GameStrings.txt' )
650+ if game_strings_file :
651+ for line in game_strings_file . decode ( 'utf8' ) .split ('\r \n ' ):
649652 if len (line ) == 0 :
650653 continue
651654
@@ -660,21 +663,26 @@ def __init__(self, map_file, filename=None, region=None, map_hash=None, **option
660663 self .website = value
661664
662665 #: A reference to the map's :class:`~sc2reader.objects.MapInfo` object
663- self .map_info = MapInfo (self .archive .read_file ('MapInfo' ))
664-
665- doc_info = ElementTree .fromstring (self .archive .read_file ('DocumentInfo' ).decode ('utf8' ))
666-
667- icon_path_node = doc_info .find ('Icon/Value' )
668- #: (Optional) The path to the icon for the map, relative to the archive root
669- self .icon_path = icon_path_node .text if icon_path_node is not None else None
670-
671- #: (Optional) The icon image for the map in tga format
672- self .icon = self .archive .read_file (self .icon_path ) if self .icon_path is not None else None
673-
674- #: A list of module names this map depends on
675- self .dependencies = list ()
676- for dependency_node in doc_info .findall ('Dependencies/Value' ):
677- self .dependencies .append (dependency_node .text )
666+ self .map_info = None
667+ map_info_file = self .archive .read_file ('MapInfo' )
668+ if map_info_file :
669+ self .map_info = MapInfo (map_info_file )
670+
671+ doc_info_file = self .archive .read_file ('DocumentInfo' )
672+ if doc_info_file :
673+ doc_info = ElementTree .fromstring (doc_info_file .decode ('utf8' ))
674+
675+ icon_path_node = doc_info .find ('Icon/Value' )
676+ #: (Optional) The path to the icon for the map, relative to the archive root
677+ self .icon_path = icon_path_node .text if icon_path_node is not None else None
678+
679+ #: (Optional) The icon image for the map in tga format
680+ self .icon = self .archive .read_file (self .icon_path ) if self .icon_path is not None else None
681+
682+ #: A list of module names this map depends on
683+ self .dependencies = list ()
684+ for dependency_node in doc_info .findall ('Dependencies/Value' ):
685+ self .dependencies .append (dependency_node .text )
678686
679687 @classmethod
680688 def get_url (cls , region , map_hash ):
0 commit comments