[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r9991 - trunk/gnue-common/src/apps
From: |
reinhard |
Subject: |
[gnue] r9991 - trunk/gnue-common/src/apps |
Date: |
Thu, 22 Oct 2009 04:54:31 -0500 (CDT) |
Author: reinhard
Date: 2009-10-22 04:54:30 -0500 (Thu, 22 Oct 2009)
New Revision: 9991
Modified:
trunk/gnue-common/src/apps/GConfig.py
Log:
Removed duplicated functions.
Modified: trunk/gnue-common/src/apps/GConfig.py
===================================================================
--- trunk/gnue-common/src/apps/GConfig.py 2009-10-21 18:49:53 UTC (rev
9990)
+++ trunk/gnue-common/src/apps/GConfig.py 2009-10-22 09:54:30 UTC (rev
9991)
@@ -58,28 +58,24 @@
def __init__(self, section, defaults=None, configFilename="gnue.conf",
homeConfigDir=".gnue"):
- self._default_config_filename = configFilename
+ self._default_configFilename = configFilename
self._default_section = section
self._loadedConfigs = {}
- self.load_application_config(configFilename, homeConfigDir, section,
+ self.loadApplicationConfig(configFilename, homeConfigDir, section,
defaults)
# Add global gConfig function to application namespace
import __builtin__
- # Deprecated versions
__builtin__.__dict__['gConfig'] = self.gConfig
__builtin__.__dict__['gConfigDict'] = self.gConfigDict
- # New versions
- __builtin__.__dict__['gconfig'] = self.gconfig
- __builtin__.__dict__['gconfig_dict'] = self.gconfig_dict
# -------------------------------------------------------------------------
# Register an alias
# -------------------------------------------------------------------------
- def register_alias(self, name, section):
+ def registerAlias(self, name, section):
"""
Register an alias for retrieving options of a given section in the
configration file.
@@ -91,29 +87,18 @@
@type section: string
"""
- alias = GConfigAlias(self.gconfig, section)
+ alias = GConfigAlias(self.gConfig, section)
import __builtin__
- __builtin__.__dict__[name] = alias.gconfig
+ __builtin__.__dict__[name] = alias.gConfig
# -------------------------------------------------------------------------
- # Register an alias
- # -------------------------------------------------------------------------
-
- def registerAlias(self, name, section):
- """
- This method is deprecated. Please use register_alias() instead
- """
- return self.register_alias(name, section)
-
-
- # -------------------------------------------------------------------------
# Load the specified file
# -------------------------------------------------------------------------
- def load_application_config(self, config_filename="gnue.conf",
- home_config_dir=".gnue", section="DEFAULT", defaults=None):
+ def loadApplicationConfig(self, configFilename="gnue.conf",
+ homeConfigDir=".gnue", section="DEFAULT", defaults=None):
"""
Load the specified file only once. Subsequent calls setup the defaults
for any missing values.
@@ -123,16 +108,16 @@
"""
assert log.debug('Reading configuration info from %s section %s' %
- (config_filename, section))
+ (configFilename, section))
# Create parser and populate it if it doesn't exist
- if not self._loadedConfigs.has_key(config_filename):
+ if not self._loadedConfigs.has_key(configFilename):
if defaults is None:
parser = GConfigParser(GCConfig.ConfigOptions)
else:
parser = GConfigParser(defaults + GCConfig.ConfigOptions)
- self._loadedConfigs[config_filename] = parser
+ self._loadedConfigs[configFilename] = parser
# Build valid file list
@@ -141,19 +126,19 @@
# system config file
if etc_base:
- file_locations.append(os.path.join(etc_base, config_filename))
+ file_locations.append(os.path.join(etc_base, configFilename))
# user config file
try:
file_locations.append(os.path.join(os.environ['HOME'],
- home_config_dir, config_filename))
+ homeConfigDir, configFilename))
except KeyError:
pass
# system fixed config file
if etc_base:
file_locations.append(os.path.join(etc_base,
- config_filename + '.fixed'))
+ configFilename + '.fixed'))
# Load the values from the files specified
try:
@@ -175,35 +160,21 @@
sys.exc_value
# Common only needs checked once, load any [common] defaults
- self.__integrate_default_dict(config_filename, 'common',
+ self.__integrate_default_dict(configFilename, 'common',
_build_defaults(GCConfig.ConfigOptions))
# Load anything set in the DEFAULT section
- self.__integrate_default_dict(config_filename, section,
- self._loadedConfigs[config_filename].defaults())
+ self.__integrate_default_dict(configFilename, section,
+ self._loadedConfigs[configFilename].defaults())
# If any values are still blank after loading from file's specific
# section and then the default section then load the defaults specified
# by the application itself.
- self.__integrate_default_dict(config_filename, section,
+ self.__integrate_default_dict(configFilename, section,
_build_defaults(defaults))
# -------------------------------------------------------------------------
- # Load the specified file
- # -------------------------------------------------------------------------
-
- def loadApplicationConfig(self, configFilename="gnue.conf",
- homeConfigDir=".gnue", section="DEFAULT", defaults=None):
- """
- This method is deprecated. Please use load_application_config()
- instead.
- """
- return self.load_application_config(configFilename, homeConfigDir,
- section, defaults)
-
-
- # -------------------------------------------------------------------------
# Integrate default values from a dictionary into a configuration section
# -------------------------------------------------------------------------
@@ -229,16 +200,16 @@
# Retrieve an option value from a configuration files' section
# -------------------------------------------------------------------------
- def gconfig(self, var_name, config_filename=None, section=None):
+ def gConfig(self, var_name, configFilename=None, section=None):
"""
Retrieve an option from a section in a configuration file
@param var_name: name of the option to retrieve
@type var_name: string
- @param config_filename: name of the configuration file to retrieve the
+ @param configFilename: name of the configuration file to retrieve the
option from. If None, the default configuration file will be used.
- @type config_filename: string
+ @type configFilename: string
@param section: name of the section to retrieve the option from. If
None, the default section will be used.
@@ -246,12 +217,12 @@
@returns: the retrieve option value
"""
- if not config_filename:
- config_filename = self._default_config_filename
+ if not configFilename:
+ configFilename = self._default_configFilename
if not section:
section = self._default_section
- cfg_parser = self._loadedConfigs[config_filename]
+ cfg_parser = self._loadedConfigs[configFilename]
try:
return cfg_parser.get(section, var_name)
@@ -271,29 +242,18 @@
# -------------------------------------------------------------------------
- # Retrieve an option value from a configuration files' section
- # -------------------------------------------------------------------------
-
- def gConfig(self, var_name, configFilename=None, section=None):
- """
- This method is deprecated. Please use gconfig() instead.
- """
- return self.gconfig(var_name, configFilename, section)
-
-
- # -------------------------------------------------------------------------
# Get a dictionary with all configuration options in a section
# -------------------------------------------------------------------------
- def gconfig_dict(self, config_filename=None, section=None):
+ def gConfigDict(self, configFilename=None, section=None):
"""
Build a dictionary containing all configuration options of a given
section within a given configuration file.
- @param config_filename: name of the configuration file to retrieve the
+ @param configFilename: name of the configuration file to retrieve the
options from. If None, the default configuration file will be
used.
- @type config_filename: string
+ @type configFilename: string
@param section: name of the section to retrieve the options from. If
None, the default section will be used.
@@ -301,12 +261,12 @@
@rtype: dict
"""
- if not config_filename:
- config_filename = self._default_config_filename
+ if not configFilename:
+ configFilename = self._default_configFilename
if not section:
section = self._default_section
- cfg_parser = self._loadedConfigs[config_filename]
+ cfg_parser = self._loadedConfigs[configFilename]
result = {}
if cfg_parser.has_section(section):
@@ -316,18 +276,6 @@
return result
- # -------------------------------------------------------------------------
- # Get a dictionary with all configuration options in a section
- # -------------------------------------------------------------------------
-
- def gConfigDict(self, configFilename=None, section=None):
- """
- This method is deprecated. Please use gconfig_dict() instead.
- """
-
- return self.gconfig_dict(configFilename, section)
-
-
# =============================================================================
# GNUe Config Parser class supporting the GTypecast system
# =============================================================================
@@ -419,16 +367,16 @@
# Retrieve an option value
# -------------------------------------------------------------------------
- def gconfig(self, var_name, config_filename=None, section=None):
+ def gConfig(self, var_name, configFilename=None, section=None):
"""
Retrieve an option from a section in a configuration file
@param var_name: name of the option to retrieve
@type var_name: string
- @param config_filename: name of the configuration file to retrieve the
+ @param configFilename: name of the configuration file to retrieve the
option from. If None, the default configuration file will be used.
- @type config_filename: string
+ @type configFilename: string
@param section: name of the section to retrieve the option from. If
None, the default section will be used.
@@ -439,25 +387,14 @@
if not section:
section = self.__section
- return self.__gconfig(var_name, config_filename, section)
+ return self.__gconfig(var_name, configFilename, section)
- # -------------------------------------------------------------------------
- # Retrieve an option value
- # -------------------------------------------------------------------------
-
- def gConfig(self, var_name, configFilename=None, section=None):
- """
- This method is deprecated. Please use gconfig() instead.
- """
- return self.gconfig(var_name, configFilename, section)
-
-
# -----------------------------------------------------------------------------
# get the install location of a given group
# -----------------------------------------------------------------------------
-def get_installed_base(*parameters):
+def getInstalledBase(*parameters):
"""
Returns the first matching item of the arguments in the _site_config
dictionary.
@@ -470,17 +407,6 @@
# -----------------------------------------------------------------------------
-# get the install location of a given group
-# -----------------------------------------------------------------------------
-
-def getInstalledBase(*parameters):
- """
- This method is deprecated. Please use get_installed_base() instead.
- """
- return get_installed_base(*parameters)
-
-
-# -----------------------------------------------------------------------------
# Create a printable description of configuration options
# -----------------------------------------------------------------------------
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r9991 - trunk/gnue-common/src/apps,
reinhard <=