vdat.config – The configuration functionality and files

vdat.config.core – The Core

Manage configuration

Mostly copied from vhc/libvhc/config.py

exception vdat.config.core.ConfigurationError[source]

Generic error raised by the configuration sub-package

exception vdat.config.core.MissingConfigurationError[source]

Raised when a configuration item does not exist

exception vdat.config.core.MissingConfigurationSectionError[source]

Raised when a configuration section does not exist

vdat.config.core.load_all_configs(args)[source]

Convenience function to load the vdat configuration files.

It loads:

  • "main": the standard configuration file vdat_conf_fname; given from the command line
  • "command": the YAML file(s) defining the commands
  • "tasks": the YAML file(s) that instruct the GUI how to display the files; the names are in the tasks_config of the general section of the “default” configuration
Parameters:
args : Namespace

Command line arguments

vdat.config.core.load_std_conf(name, args, *fnames)[source]

Load standard configuration files

Parameters:
name : string

name to associate to the configurations

args : Namespace

Command line arguments

fnames : list of strings

the filename(s) of the configuration files

Returns:
flist : list

files successfully loaded

vdat.config.core.load_yaml(name, *fnames)[source]

Load YAML configuration files. Skip non existing files.

Parameters:
name : string

name to associate to the configurations

fnames : list of strings

the filename(s) of the configuration files

Returns:
flist : list

files successfully loaded

vdat.config.core.default_dict()[source]

Default values of the configuration object

Returns:
defaults : dict

options-values pairs

vdat.config.core.get_config(name, section=None)[source]

Returns the configuration file with the specified name.

Parameters:
name : string, optional

name associated with the configuration object; by default returns the main configuration

section : string, optional

optionally returns only one section

Returns:
configuration object

can be either a ConfigParser or a dictionary(-like) object

vdat.config.entry_point – The vdat_config executable

Implementation of the vdat_config entry point

vdat.config.entry_point.main(argv=None)[source]

Main function of the implementation of the vdat_config executable

Parameters:
argv : list

command line, if None taken from sys.argv

vdat.config.entry_point.parse(argv=None)[source]

Create the parser and parse the command line arguments

Parameters:
argv : list

command line, if None taken from sys.argv

Returns:
Namespace

parsed command line

vdat.config.entry_point.resource_replace(file_content, filename, path)[source]

Replace in the file content the <++>CONFIG_DIR<++> and <++>VERSION<++> placeholders.

Parameters:
file_content : string

content of resource

filename : string

name of the file from which the resource is coming

path : string

path where the file will be copied

Returns:
resource : string

modified resource

class vdat.config.entry_point.VDATCopyResource(name, backup=False, force=False, verbose=False)[source]

Overrides manipulate_resource() to replace placeholders

manipulate_resource(file_content)[source]

call resource_replace()

vdat.config.entry_point.copy(args)[source]

Copy the configuration files

Parameters:
args : Namespace

arguments to make the copy run

vdat.config.entry_point.compare(args)[source]

Compare the configuration files

Parameters:
args : Namespace

arguments to make the copy run

vdat.config.entry_point._existing_files(args)[source]

Check which files exist and which not.

Parameters:
args : Namespace

arguments to make the copy run

Returns:
existing_files : list of strings

existing files

vdat.config.entry_point._compare_versions(fnames, args)[source]

Check the version of the files.

Parameters:
fnames : list of strings

list of files for which to check the version

args : Namespace

arguments to make the copy run

Returns:
remaining_files : list of strings

files for which no version is expected

vdat.config.entry_point._file_diff(fnames, args)[source]

Make a diff for all the files

Parameters:
fnames : list of strings

list of files for which to check the version

args : Namespace

arguments to make the copy run

Returns:
equal_files, diff_files : list of strings

files that are the same and that are different

vdat.config.entry_point._file_load(fnames, args)[source]

Try to load the files with the appropriate function to check if they are reasonable

Parameters:
fnames : list of strings

list of files for which to check the version

args : Namespace

arguments to make the copy run

Returns:
success_files, failed_files, skipped_files : list of strings

files that where successfully loaded, failed or where skipped

vdat.config.versions – Versioning the configuration files

Configuration and support files versioning and checking

vdat.config.versions.COPY_FILES = ['vdat_setting.cfg', 'vdat_commands.yml', 'tasks.yml', 'fplane.txt', 'extra_files/defaultL.dist', 'extra_files/defaultR.dist', 'extra_files/dither_positions.txt', 'extra_files/IFUcen_HETDEX.txt', 'extra_files/lines_L.par', 'extra_files/lines_R.par']

files to copy

vdat.config.versions.IMPORTANT_FILES = ['vdat_setting.cfg', 'vdat_commands.yml', 'tasks.yml', 'fplane.txt']

Files essential to run VDAT but that can have different names and be however passed to the code via configuration or command line options

vdat.config.versions.VERSION_VDAT_SETTING = '2.0.0'

version of the vdat_setting file

vdat.config.versions.VERSION_VDAT_COMMANDS = '1.3.0'

version of the vdat_commands file

vdat.config.versions.VERSION_TASKS = '1.3.0'

version of the tasks file

vdat.config.versions.version_name(filename)[source]

Return the name of the variable storing the version of filename

Parameters:
filename : string

name of the file for which to find the version

Returns:
string

name of the variable storing the configuration file

vdat.config.versions.version_of_file(filename)[source]

If available, returns the version string for the filename as defined in vdat.config.versions

Parameters:
filename : string

name of the file for which to find the version

Returns:
version : string

version or None, if no version is available

vdat.config.versions.version_from_file(path, filename)[source]

Try to extract the version number from path + filename

Parameters:
path : string

path where the file resides

filename : string

name of the file

Returns:
version : string

version as extracted from the file or None, if no version is found

vdat.config.versions.files_with_version()[source]

Return the list of file names, that can be copied, that have an associated version.

Returns:
list of strings

file names

exception vdat.config.versions.LoaderError[source]

Raised when a loader fails for any reason

vdat.config.versions.configparser_loader(fname)[source]

Try to load the file using configparser

Parameters:
fname : string

file to load

Raises:
LoaderError

if it fails to load

vdat.config.versions.yaml_loader(fname)[source]

Try to load the file using yaml

Parameters:
fname : string

file to load

Raises:
LoaderError

if it fails to load

vdat.config.versions.fplane_loader(fname)[source]

Try to load the file as a fplane file.

Parameters:
fname : string

file to load

Raises:
LoaderError

if it fails to load

vdat.config.versions.dist_loader(fname)[source]

Try to load the file as a distortion file.

Parameters:
fname : string

file to load

Raises:
LoaderError

if it fails to load

vdat.config.versions.ifucent_loader(fname)[source]

Try to load the file as an ifu center file.

Parameters:
fname : string

file to load

Raises:
LoaderError

if it fails to load

vdat.config.versions.lines_loader(fname)[source]

Try to load the file as an line file.

Parameters:
fname : string

file to load

Raises:
LoaderError

if it fails to load

vdat.config.versions.dither_position_loader(fname)[source]

Try to load the file as dither position file.

Parameters:
fname : string

file to load

Raises:
LoaderError

if it fails to load