Bases: object
A setting and associated value stored in the astropy configuration files.
These objects are typically defined at the top of astropy subpackages or affiliated packages, and store values or option settings that can be modified by the user to
Parameters : | name : str
defaultvalue :
description : str or None
cfgtype : str or None
module : str or None
|
---|---|
Raises : | RuntimeError :
|
Examples
The following example will create an item ‘cfgoption = 42’ in the ‘[configuration]’ section of astropy.cfg (located in the directory that astropy.config.paths.get_config_dir returns), or if the option is already set, it will take the value from the configuration file:
from astropy.config import ConfigurationItem
CFG_OPTION = ConfigurationItem('cfgoption',42,module='astropy.configuration')
If called as CFG_OPTION(), this will return the value 42, or some other integer if the astropy.cfg file specifies a different value.
If this were a file astropy/configuration/__init__.py, the module option would not be necessary, as it would automatically detect the correct module.
Methods Summary
set(value) | Sets the current value of this ConfigurationItem. |
reload() | Reloads the value of this ConfigurationItem from the relevant configuration file. |
save([value]) | Writes a value for this ConfigurationItem to the relevant configuration file. |
set_temp(*args, **kwds) | Sets this item to a specified value only inside a while loop. |
Methods Documentation
Sets the current value of this ConfigurationItem.
This also updates the comments that give the description and type information.
Note
This does not save the value of this ConfigurationItem to the configuration file. To do that, use ConfigurationItem.save or save_config.
Parameters : | value :
|
---|---|
Raises : | TypeError :
|
Reloads the value of this ConfigurationItem from the relevant configuration file.
Returns : | val :
|
---|
Writes a value for this ConfigurationItem to the relevant configuration file.
This also writes updated versions of the comments that give the description and type information.
Note
This only saves the value of this particular ConfigurationItem. To save all configuration settings for this package at once, see save_config.
Parameters : | value :
|
---|---|
Raises : | TypeError :
|
Sets this item to a specified value only inside a while loop.
ITEM = ConfigurationItem(‘ITEM’, ‘default’, ‘description’)
... do something that wants ITEM’s value to be ‘newval’ ...
# ITEM is now ‘default’ after the with block
Parameters : | value :
|
---|