def get_avatar_conf(aux_files=[]): conf = None cm = ContentManager.from_local() for k in cm.list_local_objects(spec='kano-character-v2'): content_dir.register_path( 'CHARACTER_DIR', k.get_data('character_base').get_dir()) content_dir.register_path( 'CHARACTER_OVERWORLD_DIR', k.get_data('character_overworld_base').get_dir()) content_dir.register_path( 'PREVIEW_ICONS', k.get_data('character_thumb').get_dir()) content_dir.register_path( 'ACTIVE_CATEGORY_ICONS', k.get_data('active_cat_icon').get_dir()) content_dir.register_path( 'INACTIVE_CATEGORY_ICONS', k.get_data('inactive_cat_icon').get_dir()) content_dir.register_path( 'PREVIEW_ICONS', k.get_data('previews').get_dir()) content_dir.register_path('ITEM_DIR', k.get_data('assets').get_dir()) content_dir.register_path('ITEM_OVERWORLD_DIR', k.get_data('assets_overworld').get_dir()) aux_files.append(k.get_data('').get_content()[0]) for k in cm.list_local_objects(spec='kano-character-category-v2'): content_dir.register_path( 'ACTIVE_CATEGORY_ICONS', k.get_data('active_cat_icon').get_dir()) content_dir.register_path( 'INACTIVE_CATEGORY_ICONS', k.get_data('inactive_cat_icon').get_dir()) content_dir.register_path( 'PREVIEW_ICONS', k.get_data('previews').get_dir()) content_dir.register_path('ITEM_DIR', k.get_data('assets').get_dir()) content_dir.register_path('ITEM_OVERWORLD_DIR', k.get_data('assets_overworld').get_dir()) aux_files.append(k.get_data('').get_content()[0]) for k in cm.list_local_objects(spec='kano-character-items-v2'): content_dir.register_path( 'PREVIEW_ICONS', k.get_data('previews').get_dir()) content_dir.register_path('ITEM_DIR', k.get_data('assets').get_dir()) content_dir.register_path('ITEM_OVERWORLD_DIR', k.get_data('assets_overworld').get_dir()) aux_files.append(k.get_data('').get_content()[0]) with open(AVATAR_CONF_FILE) as f: conf = load(f) if conf is None: logger.error("Default Conf file {} not found".format(AVATAR_CONF_FILE)) else: if not is_valid_configuration(conf): logger.error("Default configuration file is not in valid format") return dict() if aux_files: logger.debug( "Auxiliary configuration files to be used: {}".format(aux_files)) for con_fname in aux_files: if os.path.isfile(con_fname): # Attempt to decode as JSON try: f = open(con_fname) except IOError as e: logger.error( "Error opening the aux conf file {}".format(e)) continue else: with f: try: aux_conf = load(f) except ValueError as e: logger.info("Conf file not a JSON {}".format(e)) continue if is_valid_configuration(aux_conf): if not merge_conf_files(conf, aux_conf): logger.error( "Can't integrate conf file {}".format(con_fname)) else: logger.error( "Parsed auxiliary film doesn't contain valid conf") else: logger.warn( "Auxiliary conf file {} doen't exist".format(con_fname)) return conf
ACTIVE_CATEGORY_ICONS = os.path.join(CATEGORY_ICONS, 'active') INACTIVE_CATEGORY_ICONS = os.path.join(CATEGORY_ICONS, 'inactive') SPECIAL_CATEGORY_ICONS = os.path.join( AVATAR_ASSET_FOLDER, 'special_category_icons') ACTIVE_SPECIAL_CATEGORY_ICONS = os.path.join(SPECIAL_CATEGORY_ICONS, 'active') INACTIVE_SPECIAL_CATEGORY_ICONS = os.path.join( SPECIAL_CATEGORY_ICONS, 'inactive') PREVIEW_ICONS = os.path.join(AVATAR_ASSET_FOLDER, 'preview') CIRC_ASSET_MASK = os.path.join( AVATAR_ASSET_FOLDER, 'helper_assets', 'circle_mask.png') RING_ASSET = os.path.join( AVATAR_ASSET_FOLDER, 'helper_assets', 'grey_ring.png') PLAIN_MASK = os.path.join( AVATAR_ASSET_FOLDER, 'helper_assets', 'plain_mask.png') # Register the paths that we will use content_dir.register_path('ACTIVE_CATEGORY_ICONS', ACTIVE_CATEGORY_ICONS) content_dir.register_path('INACTIVE_CATEGORY_ICONS', INACTIVE_CATEGORY_ICONS) content_dir.register_path('PREVIEW_ICONS', PREVIEW_ICONS) content_dir.register_path( 'ACTIVE_SPECIAL_CATEGORY_ICONS', ACTIVE_SPECIAL_CATEGORY_ICONS) content_dir.register_path( 'INACTIVE_SPECIAL_CATEGORY_ICONS', INACTIVE_SPECIAL_CATEGORY_ICONS) content_dir.register_path('CHARACTER_DIR', CHARACTER_DIR) content_dir.register_path('CHARACTER_OVERWORLD_DIR', CHARACTER_OVERWORLD_DIR) content_dir.register_path('ITEM_DIR', ITEM_DIR) content_dir.register_path('ITEM_OVERWORLD_DIR', ITEM_OVERWORLD_DIR) content_dir.register_path('ENVIRONMENT_DIR', ENVIRONMENT_DIR)