ksconf.conf package

Submodules

ksconf.conf.delta module

class ksconf.conf.delta.DiffGlobal(type)

Bases: tuple

type

Alias for field number 0

class ksconf.conf.delta.DiffOp(tag, location, a, b)

Bases: tuple

a

Alias for field number 2

b

Alias for field number 3

location

Alias for field number 1

tag

Alias for field number 0

class ksconf.conf.delta.DiffStanza(type, stanza)

Bases: tuple

stanza

Alias for field number 1

type

Alias for field number 0

class ksconf.conf.delta.DiffStzKey(type, stanza, key)

Bases: tuple

key

Alias for field number 2

stanza

Alias for field number 1

type

Alias for field number 0

ksconf.conf.delta.compare_cfgs(a, b, allow_level0=True)

Opcode tags borrowed from difflib.SequenceMatcher

Return list of 5-tuples describing how to turn a into b. Each tuple is of the form

(tag, location, a, b)

tag:

Value Meaning ‘replace’ same element in both, but different values. ‘delete’ remove value b ‘insert’ insert value a ‘equal’ same values in both

location is a tuple that can take the following forms:

(level, pos0, … posN) (0) Global file level context (e.g., both files are the same) (1, stanza) Stanzas are the same, or completely different (no shared keys) (2, stanza, key) Key level, indicating

Possible alternatives:

https://dictdiffer.readthedocs.io/en/latest/#dictdiffer.patch

ksconf.conf.delta.show_diff(stream, diffs, headers=None)
ksconf.conf.delta.show_text_diff(stream, a, b)
ksconf.conf.delta.summarize_cfg_diffs(delta, stream)

Summarize a delta into a human readable format. The input delta is in the format produced by the compare_cfgs() function.

ksconf.conf.merge module

ksconf.conf.merge.merge_conf_dicts(*dicts)
ksconf.conf.merge.merge_conf_files(dest, configs, dry_run=False, banner_comment=None)

ksconf.conf.parser module

exception ksconf.conf.parser.ConfParserException

Bases: exceptions.Exception

exception ksconf.conf.parser.DuplicateKeyException

Bases: ksconf.conf.parser.ConfParserException

exception ksconf.conf.parser.DuplicateStanzaException

Bases: ksconf.conf.parser.ConfParserException

class ksconf.conf.parser.Token

Bases: object

Immutable token object. deepcopy returns the same object

ksconf.conf.parser.cont_handler(iterable, continue_re=<_sre.SRE_Pattern object>, breaker=u'\n')
ksconf.conf.parser.detect_by_bom(path)
ksconf.conf.parser.inject_section_comments(section, prepend=None, append=None)
ksconf.conf.parser.parse_conf(stream, profile={'dup_key': u'overwrite', 'dup_stanza': u'exception', 'keep_comments': True, 'strict': True}, encoding=None)
ksconf.conf.parser.parse_conf_stream(stream, keys_lower=False, handle_conts=True, keep_comments=False, dup_stanza=u'exception', dup_key=u'overwrite', strict=False)
ksconf.conf.parser.section_reader(stream, section_re=<_sre.SRE_Pattern object>)

Break a configuration file stream into 2 components sections. Each section is yielded as (section_name, lines_of_text)

Sections that have no entries may be dropped. Any lines before the first section are send back with the section name of None.

ksconf.conf.parser.smart_write_conf(filename, conf, stanza_delim=u'\n', sort=True, temp_suffix=u'.tmp')
ksconf.conf.parser.splitup_kvpairs(lines, comments_re=<_sre.SRE_Pattern object>, keep_comments=False, strict=False)
ksconf.conf.parser.write_conf(stream, conf, stanza_delim=u'\n', sort=True)
ksconf.conf.parser.write_conf_stream(stream, conf, stanza_delim=u'\n', sort=True)

Module contents