PyA’s root configuration¶
- class PyAstronomy.pyaC.pyaPermanent.PyAConfig¶
Provide access to permanent PyA configuration.
Permanent configuration and data created by/for PyAstronomy are stored in a data directory appointed to PyAstronomy. The directory name is stored in a file named “.pyaConfigWhere”, which is located in the user’s home directory (defined by environment variable home). This file contains only a single line, which is exactly the name of the PyA data directory.
In the PyA data directory, this class creates a stub configuration file named “pyaConfig.cfg”, if the file does not already exist.
- Attributes
- dpathstring
The name of PyA’s data directory (defined by the content of the file “.pyaConfigWhere” in the home directory). None if no valid directory could be found or created. .
- configWherestring
The full name of the “.pyaConfigWhere” file.
Methods
Provides access to PyA's root configuration file.
Access the root path to PyA's permanent data and configuration.
remove_option
(section, option)Remove option
remove_section
(section)Remove section
Save current state of configuration to file 'pyaConfig.cfg'.
set
(section, option, value)Add an entry to the global configuration file.
- accessRootConfig()¶
Provides access to PyA’s root configuration file.
- Returns
- ConfigurationConfigParser object
The content of the root configuration file “pyaConfig.cfg”.
- getDataRoot()¶
Access the root path to PyA’s permanent data and configuration.
- Returns
- Pathstring
The root path as defined in the file “.pyaConfigWhere” in the home directory.
- remove_option(section, option)¶
Remove option
- remove_section(section)¶
Remove section
- saveConfigToFile()¶
Save current state of configuration to file ‘pyaConfig.cfg’.
- set(section, option, value)¶
Add an entry to the global configuration file.
If the specified section does not already exist, it is created.
Example session¶
When PyAConfig is called without a configured data path, it will ask for a location where PyA is allowed to store its data and configuration. This will look something like this:
>>> from PyAstronomy.pyaC import pyaPermanent
>>> pc = pyaPermanent.PyAConfig()
Please provide a directory where PyA can store data (may already exist):
Press enter to accept default.
Path (default = /pathToHome/PyAData): another/Path/I/Like
PyA data path configured successfully. Using path:
another/Path/I/Like
Note
The data path is not a subdirectory of the path you specify, but exactly the path you specify.