datalad.support.configparserinc

class datalad.support.configparserinc.SafeConfigParserWithIncludes(*args, **kwargs)[source]

Bases: configparser.ConfigParser

Class adds functionality to SafeConfigParser to handle included other configuration files (or may be urls, whatever in the future)

File should have section [includes] and only 2 options implemented are ‘files_before’ and ‘files_after’ where files are listed 1 per line.

Example:

[INCLUDES]
before = 1.conf
         3.conf

after = 1.conf

It is a simple implementation, so just basic care is taken about recursion. Includes preserve right order, ie new files are inserted to the list of read configs before original, and their includes correspondingly so the list should follow the leaves of the tree.

I wasn’t sure what would be the right way to implement generic (aka c++ template) so we could base at any *configparser class… so I will leave it for the future

SECTION_NAME = 'INCLUDES'
static getIncludes(resource, seen=[])[source]

Given 1 config resource returns list of included files (recursively) with the original one as well Simple loops are taken care about

read(filenames)[source]

Read and parse a filename or an iterable of filenames.

Files that cannot be opened are silently ignored; this is designed so that you can specify an iterable of potential configuration file locations (e.g. current directory, user’s home directory, systemwide directory), and all existing configuration files in the iterable will be read. A single filename may also be given.

Return list of successfully read files.