# create a JSON config and dump it to stdout configJson = config.defaultConfig merge_dict(configJson, { "server": { "sources": [ { "path": args.server, "worldName": args.world, } ], "customName": args.server_name, }, "client": { "playersPerPage": args.players_per_page, "playerCacheUUIDPrefix": args.player_cache_q, }, "players": { "profileUpdateInterval": args.profile_update_interval, "updateInactive": args.update_inactive, "inactiveDays": args.inactive_days, "minPlaytime": args.min_playtime, }, "crown": { "gold": args.crown_gold, "silver": args.crown_silver, "bronze": args.crown_bronze }, }) print(json.dumps(configJson, indent=4))
# Parse command-line arguments parser = argparse.ArgumentParser(description='Update MinecraftStats') parser.add_argument('config', type=str, help='the configuration to use') args = parser.parse_args() # load config if os.path.isfile(args.config): with open(args.config, 'r', encoding="utf8") as configFile: try: loadedConfigJson = json.load(configFile) except Exception as e: print('ERROR: failed to load config JSON') handle_error(e, True) merge_dict(configJson, loadedConfigJson) else: # save default print('writing default config to ' + args.config) with open(args.config, 'w') as configFile: json.dump(configJson, configFile, indent=4) config = RecursiveNamespace(**configJson) # get sources sources = [] if hasattr(config.server, 'path') and config.server.path: handle_error('server.path is deprecated, please use server.sources instead to configure your paths') worldName = config.server.worldName if isinstance(config.server.path, list):
# name->stat statByName = dict() for mcstat in mcstats.registry: statByName[mcstat.name] = mcstat # Parse command-line arguments parser = argparse.ArgumentParser(description='Update MinecraftStats') parser.add_argument('config', type=str, help='the configuration to use') args = parser.parse_args() # load config if os.path.isfile(args.config): with open(args.config, 'r', encoding="utf8") as configFile: merge_dict(configJson, json.load(configFile)) else: # save default print('writing default config to ' + args.config) with open(args.config, 'w') as configFile: json.dump(configJson, configFile, indent=4) config = RecursiveNamespace(**configJson) # get sources sources = [] if hasattr(config.server, 'path') and config.server.path: handle_error( 'server.path is deprecated, please use server.sources instead to configure your paths' )