def fill_section(section, acquire_settings, log_printer, bears):
 prel_needed_settings = {}
 for bear in bears:
  needed = bear.get_non_optional_settings()
  for key in needed:
   if (key in prel_needed_settings):
    prel_needed_settings[key].append(bear.name)
   else:
    prel_needed_settings[key] = [needed[key][0], bear.name]
 needed_settings = {}
 for (setting, help_text) in prel_needed_settings.items():
  if (setting not in section):
   needed_settings[setting] = help_text
 if (len(needed_settings) > 0):
  new_vals = acquire_settings(log_printer, needed_settings, section)
  for (setting, help_text) in new_vals.items():
   section.append(Setting(setting, help_text))
 return section

def fill_section ( section , acquire_settings , log_printer , bears ) : prel_needed_settings = { } for bear in bears : needed = bear . get_non_optional_settings ( ) for key in needed : if ( key in prel_needed_settings ) : prel_needed_settings [ key ] . append ( bear . name ) else : prel_needed_settings [ key ] = [ needed [ key ] [ 0 ] , bear . name ] needed_settings = { } for ( setting , help_text ) in prel_needed_settings . items ( ) : if ( setting not in section ) : needed_settings [ setting ] = help_text if ( len ( needed_settings ) > 0 ) : new_vals = acquire_settings ( log_printer , needed_settings , section ) for ( setting , help_text ) in new_vals . items ( ) : section . append ( Setting ( setting , help_text ) ) return section
retrieves needed settings from given bears and asks the user for missing values .