def writeConfiguration(module): """ Uses Cfglib to write module configuration to disk module: module name (usually automatically provided) return: nothing """ # Write our configuration to disk using cfglib config = cfglib.AddonCFG('%s/cfg/xamodules.cfg' % xa.gamedir()) config.text('******************************') config.text(' XA Module Configuration', True) config.text(' Timestamp: %s' % time.strftime('%a, %d %b %Y %H:%M:%S', time.localtime())) config.text('******************************') # Loop through all modules for module in sorted(xa.modules()): # Find the module instance module = xa.find(module) # Does the module have variables? if module.variables: # Add the module to the AddonCFG instance config.text('') config.text('******************************') config.text(' Module: %s' % (module.name if module.name else module)) config.text('******************************') # Loop through all variables of the module for variable in sorted(module.variables): # Get the variable instance variable = module.variables[variable] # Is this a valid variable name? if variable.getName().replace('_', '').isalnum(): # Add our variable to the AddonCFG instance config.cvar(variable.getName(), variable._def, variable._descr) # Loop through all commands of the module for command in sorted(module.commands): config.text('') config.text(module.commands[command].usage) config.text(module.commands[command].description) config.text("Insert commands below the lines") config.text('-' * 77) config.command(command) config.text('-' * 77) # Finally write the file to disk config.write()
def getVariables(module=None, submodule=None): varlist = [] if submodule: module = submodule if xa.exists(module): module = xa.find(module) for variable in sorted(module.variables): varlist.append(module.variables[variable]) else: for module in sorted(xa.modules()): module = xa.find(module) for variable in sorted(module.variables): varlist.append(module.variables[variable]) return varlist
def getVariables(module = None, submodule = None): varlist = [] if submodule: module = submodule if xa.exists(module): module = xa.find(module) for variable in sorted(module.variables): varlist.append(module.variables[variable]) else: for module in sorted(xa.modules()): module = xa.find(module) for variable in sorted(module.variables): varlist.append(module.variables[variable]) return varlist
def writeConfiguration(module = None): config = cfglib.AddonCFG("%s/cfg/xamodules.cfg" % xa.gamedir()) config.text('******************************') config.text(' XA Module Configuration', True) config.text(' Timestamp: %s' % time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())) config.text('******************************') for module in sorted(xa.modules()): module = xa.find(module) if module.variables: config.text('') config.text('******************************') config.text(' Module: %s' % (module.name if module.name else module)) config.text('******************************') for variable in sorted(module.variables): variable = module.variables[variable] if variable.getName().replace('_', '').isalnum(): config.cvar(variable.getName(), variable._def, variable._descr) config.write()
def getVariables(module, submodule=None): """ Retrieve a list of the variables registered to a module module: module name (usually automatically provided) submodule: used to specify another module to retrieve variables from return: list of ServerVar instances Because of how this is used you usually call: <xa instance>.settings.getVariables() to retrieve your own module's variables. And: <xa instance>.settings.getVariables("othermodule") to retrieve another modules variables. """ # Return variable varlist = [] # Do we want to get the list of another module? if submodule: module = submodule # Does our module exist? if xa.exists(module): # Find the module instance module = xa.find(module) # Fill our variable list for variable in sorted(module.variables): varlist.append(module.variables[variable]) else: # No, we just return a variable list of all modules for module in sorted(xa.modules()): # Find the module instance module = xa.find(module) # Fill our variable list for variable in sorted(module.variables): varlist.append(module.variables[variable]) # Return our variable list return varlist
def getVariables(module, submodule = None): """ Retrieve a list of the variables registered to a module module: module name (usually automatically provided) submodule: used to specify another module to retrieve variables from return: list of ServerVar instances Because of how this is used you usually call: <xa instance>.settings.getVariables() to retrieve your own module's variables. And: <xa instance>.settings.getVariables("othermodule") to retrieve another modules variables. """ # Return variable varlist = [] # Do we want to get the list of another module? if submodule: module = submodule # Does our module exist? if xa.exists(module): # Find the module instance module = xa.find(module) # Fill our variable list for variable in sorted(module.variables): varlist.append(module.variables[variable]) else: # No, we just return a variable list of all modules for module in sorted(xa.modules()): # Find the module instance module = xa.find(module) # Fill our variable list for variable in sorted(module.variables): varlist.append(module.variables[variable]) # Return our variable list return varlist
def writeConfiguration(module=None): config = cfglib.AddonCFG("%s/cfg/xamodules.cfg" % xa.gamedir()) config.text('******************************') config.text(' XA Module Configuration', True) config.text(' Timestamp: %s' % time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())) config.text('******************************') for module in sorted(xa.modules()): module = xa.find(module) if module.variables: config.text('') config.text('******************************') config.text(' Module: %s' % (module.name if module.name else module)) config.text('******************************') for variable in sorted(module.variables): variable = module.variables[variable] if variable.getName().replace('_', '').isalnum(): config.cvar(variable.getName(), variable._def, variable._descr) config.write()