conf Package

conf Package

Tools for processing configuration files.

class pyfusion.conf.PyfusionConfigParser(defaults=None, dict_type=<class 'collections.OrderedDict'>, allow_no_value=False)[source]

Bases: ConfigParser.ConfigParser

Customised parser to facilitate [Type:Name] config sections.

Inherited ConfigParser methods are extended, and prefixed with pf_ to allow separate arguments for section type and section name, for example:

ConfigParser.has_section(sectionname) -> PyfusionConfigParser.pf_has_section(sectiontype, name)

The inherited ConfigParser methods are still available, so the following are identical:

PyfusionConfigParser.has_section(‘Device:TJII’) PyfusionConfigParser.pf_has_section(‘Device’,’TJII’)
check_section_syntax()[source]

Make sure config file sections follow [Type:Name] syntax.

check_section_types(type_list)[source]

Make sure section types listed in config file are allowed.

pf_get(sectiontype, sectionname, option)[source]
pf_has_option(sectiontype, sectionname, option)[source]
pf_has_section(sectiontype, sectionname)[source]
pf_options(sectiontype, sectionname)[source]

exceptions Module

Exceptions for the pyfusion config parser.

exception pyfusion.conf.exceptions.ConfigSectionSyntaxError(section_name)[source]

Bases: exceptions.Exception

Config file has a malformed section label.

exception pyfusion.conf.exceptions.DisallowedSectionType(section_name)[source]

Bases: exceptions.Exception

Config file includes a section type which is not allowed.

exception pyfusion.conf.exceptions.UnknownVariableTypeError[source]

Bases: exceptions.Exception

Cannot recognise requested variable type in conifg.

tests Module

Tests for pyfusion configuration files and parser.

class pyfusion.conf.tests.CheckConfigFileSectionNames[source]

Bases: pyfusion.test.tests.PfTestBase

Check section name conformity in configuration files.

Allowed config section names must correspond to those described in the documentation (which should be the same list as pyfusion.conf.allowed_section_types).

testSectionNames()[source]
class pyfusion.conf.tests.CheckConfigUtils[source]

Bases: pyfusion.test.tests.PfTestBase

Test utilities for handling config files

test_config_as_dict()[source]
class pyfusion.conf.tests.CheckImportFromString[source]

Bases: pyfusion.test.tests.PfTestBase

Test import_from_str fuction.

test_import_from_str()[source]
class pyfusion.conf.tests.CheckImportSetting[source]

Bases: pyfusion.test.tests.PfTestBase

Test import_setting function.

test_import_setting_with_fakedata_acquisition()[source]
class pyfusion.conf.tests.CheckKeywordArgConfigHandler[source]

Bases: pyfusion.test.tests.PfTestBase

Test the function which chooses from kwargs oor config vars.

test_kwarg_config_handler()[source]
class pyfusion.conf.tests.CheckPyfusionConfigParser[source]

Bases: pyfusion.test.tests.PfTestBase

Test pyfusion customised config file parser.

testBaseClass()[source]
test_pf_has_section()[source]
class pyfusion.conf.tests.CheckVariableTypes[source]

Bases: pyfusion.test.tests.PfTestBase

Check that config parser returns correct types for settings.

test_return_correct_type()[source]

utils Module

Useful functions for manipulating config files.

pyfusion.conf.utils.CannotImportFromConfigError(Exception)[source]

Failed to import a module, class or method from config setting.

pyfusion.conf.utils.clear_config()[source]

Clear pyfusion.config.

pyfusion.conf.utils.diff(dumpa=None, dumpb=None, eol='\n')[source]

use /usr/bin/diff or alternative in PYFUSION_DIFF to show the differences adding a config file made.

With no args, the last two differences are shown. Otherwise args must be history dict entries (not just keys) e.g. pyfusion.conf.utils.diff(pyfusion.conf.history[0],pyfusion.conf.history[1])

key gives the read sequence of files - this would be lost in a dictionary key = 0 is the first read

pyfusion.conf.utils.dump(eol='\n')[source]

dump the present state of the config data with the history of config file names loaded at the end

pyfusion.conf.utils.get_config_as_dict(component_type, component_name)[source]
pyfusion.conf.utils.import_from_str(string_value)[source]
pyfusion.conf.utils.import_setting(component, component_name, setting)[source]

Attempt to import and return a config setting.

pyfusion.conf.utils.kwarg_config_handler(component_type, component_name, **kwargs)[source]
pyfusion.conf.utils.read_config(config_files)[source]

Read config files.

Argument is either a single file object, or a list of filenames.