ConfigurableForServerSidePath¶
- class ConfigurableForServerSidePath.ConfigurableForServerSidePath¶
Bases:
Configurable
Configuration file functionality incorporating a server side path.
This is a version of MiscUtils.Configurable.Configurable that provides a customized setting method for classes which have a serverSidePath method. If a setting’s name ends with
Filename
orDir
, its value is passed through serverSidePath before being returned.In other words, relative filenames and directory names are expanded with the location of the object, not the current directory.
Application is a prominent class that uses this mix-in. Any class that has a serverSidePath method and a Configurable base class, should inherit this class instead.
This is used for MakeAppWorkDir, which changes the serverSidePath.
- __init__()¶
- commandLineConfig()¶
Return the settings that came from the command-line.
These settings come via addCommandLineSetting().
- config()¶
Return the configuration of the object as a dictionary.
This is a combination of defaultConfig() and userConfig(). This method caches the config.
- configFilename()¶
Return the full name of the user config file.
Users can override the configuration by this config file. Subclasses must override to specify a name. Returning None is valid, in which case no user config file will be loaded.
- configName()¶
Return the name of the configuration file without the extension.
This is the portion of the config file name before the ‘.config’. This is used on the command-line.
- configReplacementValues()¶
Return a dictionary for substitutions in the config file.
This must be a dictionary suitable for use with “string % dict” that should be used on the text in the config file. If an empty dictionary (or None) is returned, then no substitution will be attempted.
- defaultConfig()¶
Return a dictionary with all the default values for the settings.
This implementation returns {}. Subclasses should override.
- hasSetting(name)¶
Check whether a configuration setting has been changed.
- printConfig(dest=None)¶
Print the configuration to the given destination.
The default destination is stdout. A fixed with font is assumed for aligning the values to start at the same column.
- static readConfig(filename)¶
Read the configuration from the file with the given name.
Raises an UIError if the configuration cannot be read.
This implementation assumes the file is stored in utf-8 encoding with possible BOM at the start, but also tries to read as latin-1 if it cannot be decoded as utf-8. Subclasses can override this behavior.
- setSetting(name, value)¶
Set a particular configuration setting.
- setting(name, default=<class 'MiscUtils.NoDefault'>)¶
Return setting, using the server side path when indicated.
Returns the setting, filtered by self.serverSidePath(), if the name ends with
Filename
orDir
.
- userConfig()¶
Return the user config overrides.
These settings can be found in the optional config file. Returns {} if there is no such file.
The config filename is taken from configFilename().