def get_addon_ini(addon): # If the INI is the main GunGame INI, return the path to the INI if addon == "gungame": return get_game_dir("addons/eventscripts/gungame51/gungame.ini") # The INI must be either included or custom at this point from gungame51.core.addons.valid import ValidAddons # Get the addon type addon_type = ValidAddons.get_addon_type(addon) # Return the path to the addon INI return get_game_dir("addons/eventscripts/gungame51/scripts/" + "%s/%s/%s.ini" % (addon_type, addon, addon))
def __getitem__(self, item): '''Verify that the given item is a config file instance and store it''' # Is the item already in the dictionary? if item in self: # Return the item return super(_LoadedConfigs, self).__getitem__(item) # Get the path if the item is an addon addon = item.replace('_config', '') # Is the item a Valid Addon? if addon in ValidAddons.all: # Set the path to import import_path = 'gungame51.scripts.%s.%s.%s' % ( ValidAddons.get_addon_type(addon), addon, item) # Is the item a base config? elif _base_configs.joinpath(item + '.py').isfile(): # Set the path to import import_path = 'gungame51.core.cfg.files.%s' % item # Is the given item neither a Valid Addon nor a base config? else: # Raise an error raise ValueError('"%s" is an invalid config file' % item) # Import the config file config = self[item] = __import__(import_path, globals(), locals(), ['']) # Reload the config file reload(config) # Does the config have a load function? if 'load' in config.__dict__: # Execute the load function config.load() # Return the imported config file return config
def __getitem__(self, item): '''Verify that the given item is a config file instance and store it''' # Is the item already in the dictionary? if item in self: # Return the item return super(_LoadedConfigs, self).__getitem__(item) # Get the path if the item is an addon addon = item.replace('_config', '') # Is the item a Valid Addon? if addon in ValidAddons.all: # Set the path to import import_path = 'gungame51.scripts.%s.%s.%s' % ( ValidAddons.get_addon_type(addon), addon, item) # Is the item a base config? elif _base_configs.joinpath(item + '.py').isfile(): # Set the path to import import_path = 'gungame51.core.cfg.files.%s' % item # Is the given item neither a Valid Addon nor a base config? else: # Raise an error raise ValueError('"%s" is an invalid config file' % item) # Import the config file config = self[item] = __import__( import_path, globals(), locals(), ['']) # Reload the config file reload(config) # Does the config have a load function? if 'load' in config.__dict__: # Execute the load function config.load() # Return the imported config file return config