ConfigAlias¶
-
class
astropy.config.ConfigAlias[source] [edit on github]¶ Bases:
astropy.config.ConfigItemA class that exists to support backward compatibility only.
This is an alias for a
ConfigItemthat has been moved elsewhere. It inherits fromConfigItemonly because it implements the same interface, not because any of the methods are reused.Parameters: since : str
The version in which the configuration item was moved.
old_name : str
The old name of the configuration item. This should be the name of the variable in Python, not in the configuration file.
new_name : str
The new name of the configuration item. This is both the name of the item in Python and in the configuration file (since as of astropy 0.4, those are always the same thing).
old_module : str, optional
A fully-qualified, dot-separated path to the module in which the configuration item used to be defined. If not provided, it is the name of the module in which
ConfigAliasis called.new_module : str, optional
A fully-qualified, dot-separated path to the module in which the configuration item is now defined. If not provided, it is the name of the module in which
ConfigAliasis called. This string should not contain the.confobject. For example, if the new configuration item is inastropy.conf.use_unicode, this value only needs to be'astropy'.Methods Summary
__call__()Returns the value of this ConfigItemreload()Reloads the value of this ConfigItemfrom the relevant configuration file.save([value])set(value)Sets the current value of this ConfigItem.set_temp(value)Sets this item to a specified value only inside a with block. Methods Documentation
-
__call__()[source] [edit on github]¶ Returns the value of this
ConfigItemReturns: val
This item’s value, with a type determined by the
cfgtypeattribute.Raises: TypeError
If the configuration value as stored is not this item’s type.
-
reload()[source] [edit on github]¶ Reloads the value of this
ConfigItemfrom the relevant configuration file.Returns: val
The new value loaded from the configuration file.
-
save(value=None)[source] [edit on github]¶
-
set(value)[source] [edit on github]¶ Sets the current value of this
ConfigItem.This also updates the comments that give the description and type information.
Parameters: value
The value this item should be set to.
Raises: TypeError
If the provided
valueis not valid for thisConfigItem.
-
set_temp(value)[source] [edit on github]¶ Sets this item to a specified value only inside a with block.
Use as:
ITEM = ConfigItem('ITEM', 'default', 'description') with ITEM.set_temp('newval'): #... do something that wants ITEM's value to be 'newval' ... print(ITEM) # ITEM is now 'default' after the with block
Parameters: value
The value to set this item to inside the with block.
-