@ -999,59 +999,38 @@ class MetadataFile(DataFile):
extra_template_vars [ " event_id " ] = event_id
extra_template_vars [ " event_id " ] = event_id
if event_id not in self . config . IMDb . events_validation :
if event_id not in self . config . IMDb . events_validation :
raise Failed ( f " Config Error: { map_name } data only specific Event IDs work with imdb_awards. Event Options: [ { ' , ' . join ( [ k for k in self . config . IMDb . events_validation ] ) } ] " )
raise Failed ( f " Config Error: { map_name } data only specific Event IDs work with imdb_awards. Event Options: [ { ' , ' . join ( [ k for k in self . config . IMDb . events_validation ] ) } ] " )
current_year = datetime . now ( ) . year
_ , event_years = self . config . IMDb . get_event_years ( event_id )
_ , year_options = self . config . IMDb . get_event_years ( event_id )
year_options = [ event_years [ len ( event_years ) - i ] for i in range ( 1 , len ( event_years ) + 1 ) ]
min_year = None
max_year = None
def get_position ( attr , pos_add = 0 ) :
for option in year_options :
if attr not in award_methods :
year = int ( option . split ( " - " ) [ 0 ] if " - " in option else option )
return 0 if attr == " starting " else len ( year_options )
if min_year is None or year < min_year :
position_value = str ( dynamic_data [ award_methods [ attr ] ] )
min_year = year
if not position_value :
if max_year is None or year > max_year :
raise Failed ( f " Config Error: { map_name } data { attr } attribute is blank " )
max_year = year
if position_value . startswith ( ( " first " , " latest " ) ) :
int_values = position_value . split ( " + " if position_value . startswith ( " first " ) else " - " )
if " starting " in award_methods :
try :
starting_value = str ( dynamic_data [ award_methods [ " starting " ] ] )
if len ( int_values ) == 1 :
if not starting_value :
return 0 if position_value . startswith ( " first " ) else len ( year_options )
raise Failed ( f " Config Error: { map_name } data starting attribute is blank " )
else :
if starting_value . startswith ( " first " ) :
return int ( int_values [ 1 ] . strip ( ) ) * ( - 1 if position_value . startswith ( " latest " ) else 1 )
year_values = starting_value . split ( " + " )
except ValueError :
starting = None
raise Failed ( f " Config Error: { map_name } data { attr } attribute modifier invalid ' { int_values [ 1 ] } ' " )
elif position_value in year_options :
return year_options . index ( position_value ) + pos_add
else :
raise Failed ( f " Config Error: { map_name } data { attr } attribute invalid: { position_value } " )
#and str(dynamic_data[award_methods["starting"]]).startswith("current"):
year_values = str ( dynamic_data [ award_methods [ " starting " ] ] ) . split ( " - " )
found_options = year_options [ get_position ( " starting " ) : get_position ( " ending " ) ]
try :
starting = current_year - ( 0 if len ( year_values ) == 1 else int ( year_values [ 1 ] . strip ( ) ) )
if not found_options :
except ValueError :
raise Failed ( f " Config Error: { map_name } data starting/ending range found no valid events " )
raise Failed ( f " Config Error: { map_name } data starting attribute modifier invalid ' { year_values [ 1 ] } ' " )
for option in event_years :
else :
try :
starting = util . parse ( " Config " , " starting " , dynamic_data , parent = f " { map_name } data " , methods = award_methods , datatype = " int " , minimum = min_year )
except Failed :
raise Failed ( f " Config Error: { map_name } data starting attribute invalid ' { year_values [ 1 ] } ' " )
if not starting :
starting = current_year
if " ending " in award_methods and str ( dynamic_data [ award_methods [ " ending " ] ] ) . startswith ( " current_year " ) :
year_values = str ( dynamic_data [ award_methods [ " ending " ] ] ) . split ( " - " )
try :
ending = current_year - ( 0 if len ( year_values ) == 1 else int ( year_values [ 1 ] . strip ( ) ) )
except ValueError :
raise Failed ( f " Config Error: { map_name } data ending attribute modifier invalid ' { year_values [ 1 ] } ' " )
else :
ending = util . parse ( " Config " , " ending " , dynamic_data , parent = f " { map_name } data " , methods = award_methods , datatype = " int " , default = 0 , minimum = 1 )
if not ending :
ending = current_year - 5
if starting > ending :
raise Failed ( f " Config Error: { map_name } data ending must be greater than starting " )
_ , year_options = self . config . IMDb . get_event_years ( event_id )
for option in year_options :
all_keys [ option ] = option
all_keys [ option ] = option
if option not in exclude and starting < = int ( option . split ( " - " ) [ 0 ] if " - " in option else option ) < = ending :
if option not in exclude and option in found_options :
auto_list [ option ] = option
auto_list [ option ] = option
default_template = { " imdb_award " : { " event_id " : " < event_id>>" , " event_year " : " <<value>> " , " winning " : True } }
default_template = { " imdb_award " : { " event_id " : " <<event_id>> " , " event_year " : " <<value>> " , " winning " : True } }
elif auto_type == " number " :
elif auto_type == " number " :
if " data " not in methods :
if " data " not in methods :
raise Failed ( f " Config Error: { map_name } data attribute not found " )
raise Failed ( f " Config Error: { map_name } data attribute not found " )