def create_team_list(settings): # Create a set of Team ID #'s if type(settings) != list: log.error("Gym names must be specified in an array. EX: " + "[\"Valor\", \"Instinct\"]" ) sys.exit(1) s = set() for team in settings: team_id = get_team_id(team) if team_id is not None: s.add(team_id) else: # If no team ID log.error("{} is not a valid team name.".format(team) + "Please see documentation for accepted team names and correct your Filters file.") sys.exit(1) return s
def set_gyms(self, settings): gyms = { "enabled": bool(parse_boolean(settings.pop('enabled', None)) or False), "ignore_neutral": bool(parse_boolean(settings.pop('ignore_neutral', None)) or False) } defaults = { "min_dist": float(settings.pop('min_dist', None) or 0), "max_dist": float(settings.pop('max_dist', None) or 'inf') } log.info("Gym distance: {:.2f} to {:.2f}. Ignoring Neutral set to {}". format(defaults['min_dist'], defaults['max_dist'], gyms['ignore_neutral'])) for name in settings: team_id = get_team_id(name) if team_id is None: log.error("Unable to find team named {}...".format(name)) continue if parse_boolean(settings[name] ) is False: # If set to false, skip altogether. log.debug("{} name set to 'false'. Skipping...".format(name)) continue else: try: info = settings[name] if parse_boolean(info): # Allow all defaults info = {} gyms[team_id] = { "min_dist": float( info.get('min_dist', None) or defaults['min_dist']), "max_dist": float( info.get('max_dist', None) or defaults['max_dist']), } except Exception as e: log.error("Trying to set gym {} gave error: \n {}".format( team_id, e)) log.debug("Stack trace: \n {}".format( traceback.format_exc())) for key in sorted(gyms.iterkeys()): # Output the pokemon in order log.debug("Team #{} was set to the following: \n{}".format( key, json.dumps(gyms[key], sort_keys=True, indent=4))) self.__gym_filter = gyms