#NEWLINE# def load_build( expansion , version ) : #NEWLINE# #INDENT# build = Build ( version ) #NEWLINE# unit_file = '{0}/{1}_units.csv' . format ( expansion , version ) #NEWLINE# for entry in pkgutil . get_data ( 'sc2reader.data' , unit_file ) . decode ( 'utf8' ) . split ( '\n' ) : #NEWLINE# #INDENT# if ( not entry ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# ( int_id , str_id ) = entry . strip ( ) . split ( ',' ) #NEWLINE# unit_type = int ( int_id , 10 ) #NEWLINE# title = UNIT_LOOKUP [ str_id ] #NEWLINE# values = dict ( type_id = unit_type , str_id = str_id , name = title ) #NEWLINE# for race in ( 'Protoss' , 'Terran' , 'Zerg' ) : #NEWLINE# #INDENT# if ( title . lower ( ) in unit_lookup [ race ] ) : #NEWLINE# #INDENT# values . update ( unit_lookup [ race ] [ title . lower ( ) ] ) #NEWLINE# values [ 'race' ] = race #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# build . add_unit_type ( ** values ) #NEWLINE# #UNINDENT# abil_file = '{0}/{1}_abilities.csv' . format ( expansion , version ) #NEWLINE# build . add_ability ( ability_id = 0 , name = 'RightClick' , title = 'Right Click' ) #NEWLINE# for entry in pkgutil . get_data ( 'sc2reader.data' , abil_file ) . decode ( 'utf8' ) . split ( '\n' ) : #NEWLINE# #INDENT# if ( not entry ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# ( int_id_base , str_id ) = entry . strip ( ) . split ( ',' ) #NEWLINE# int_id_base = ( int ( int_id_base , 10 ) << 5 ) #NEWLINE# abils = ABIL_LOOKUP [ str_id ] #NEWLINE# real_abils = [ ( i , abil ) for ( i , abil ) in enumerate ( abils ) if ( abil . strip ( ) != '' ) ] #NEWLINE# if ( len ( real_abils ) == 0 ) : #NEWLINE# #INDENT# real_abils = [ ( 0 , str_id ) ] #NEWLINE# #UNINDENT# for ( index , ability_name ) in real_abils : #NEWLINE# #INDENT# ( unit_name , build_time ) = train_commands . get ( ability_name , ( '' , 0 ) ) #NEWLINE# if ( 'Hallucinated' in unit_name ) : #NEWLINE# #INDENT# unit_name = unit_name [ 12 : ] #NEWLINE# #UNINDENT# build . add_ability ( ability_id = ( int_id_base | index ) , name = ability_name , is_build = bool ( unit_name ) , build_unit = getattr ( build , unit_name , None ) , build_time = build_time ) #NEWLINE# #UNINDENT# #UNINDENT# return build