def pull_and_write_endpoint(api_client, action, file_name_suffix=''): action_json = api_client.action(action) file_name = '{}{}.json'.format(action.value.name, file_name_suffix) output_file = os.path.join(output_dir, file_name) print('writing', file_name) with open(output_file, 'w') as outfile: pad_util.json_file_dump(action_json, outfile)
api_client.load_player_data() player_data = api_client.player_data bonus_data = bonus.load_bonus_data(data_dir=output_dir, data_group=user_group, server=server) # Egg machine extraction egg_machines = extra_egg_machine.load_from_player_data( data_json=player_data.egg_data, server=server) egg_machines.extend( extra_egg_machine.machine_from_bonuses(server, bonus_data, 'rem_event', 'Rare Egg Machine')) egg_machines.extend( extra_egg_machine.machine_from_bonuses(server, bonus_data, 'pem_event', 'Pal Egg Machine')) for em in egg_machines: if not em.is_open(): # Can only pull rates when the machine is live. continue grow = em.egg_machine_row gtype = em.egg_machine_type page = api_client.get_egg_machine_page(gtype, grow) extra_egg_machine.scrape_machine_contents(page, em) output_file = os.path.join(output_dir, extra_egg_machine.FILE_NAME) with open(output_file, 'w') as outfile: pad_util.json_file_dump(egg_machines, outfile, pretty=True)
def save(self, output_dir: str, file_name: str, obj: object, pretty: bool): output_file = os.path.join(output_dir, '{}.json'.format(file_name)) with open(output_file, 'w', encoding='utf-8') as f: pad_util.json_file_dump(obj, f, pretty)
def save(self, output_dir: str, file_name: str, obj: object, pretty: bool): output_file = os.path.join( output_dir, '{}_{}.json'.format(self.server.name, file_name)) with open(output_file, 'w') as f: pad_util.json_file_dump(obj, f, pretty)
def save_object(dir_path, file_name, obj): file_path = os.path.join(dir_path, file_name) with open(file_path, 'w', encoding='utf-8') as f: pad_util.json_file_dump(obj, f, pretty=True)