ksconf.util package

Submodules

ksconf.util.compare module

ksconf.util.compare.cmp_sets(a, b)

Result tuples in format (a-only, common, b-only)

ksconf.util.compare.file_compare(fn1, fn2)
ksconf.util.compare.fileobj_compare(f1, f2)

ksconf.util.completers module

ksconf.util.completers.DirectoriesCompleter(*args, **kwargs)
ksconf.util.completers.FilesCompleter(*args, **kwargs)
ksconf.util.completers.autocomplete(*args, **kwargs)

ksconf.util.file module

class ksconf.util.file.ReluctantWriter(path, *args, **kwargs)

Bases: object

Context manager to intelligently handle updates to an existing file. New content is written to a temp file, and then compared to the current file’s content. The file file will be overwritten only if the contents changed.

ksconf.util.file.dir_exists(directory)

Ensure that the directory exists

ksconf.util.file.expand_glob_list(iterable, do_sort=False)
ksconf.util.file.file_fingerprint(path, compare_to=None)
ksconf.util.file.file_hash(path, algorithm='sha256')
ksconf.util.file.match_bwlist(value, bwlist, escape=True)
ksconf.util.file.pathlib_compat(f)
ksconf.util.file.relwalk(top, topdown=True, onerror=None, followlinks=False)

Relative path walker Like os.walk() except that it doesn’t include the “top” prefix in the resulting ‘dirpath’.

ksconf.util.file.smart_copy(src, dest)

Copy (overwrite) file only if the contents have changed.

ksconf.util.rest module

ksconf.util.rest.build_rest_namespace(base, owner=None, app=None)
ksconf.util.rest.build_rest_url(base, service, owner=None, app=None)

ksconf.util.terminal module

class ksconf.util.terminal.TermColor(stream)

Bases: object

Simple color setting helper class that’s a context manager wrapper around a stream. This ensure that the color is always reset at the end of a session.

color(*codes)
reset()
write(content)
ksconf.util.terminal.tty_color(stream, *codes)

Module contents

ksconf.util.debug_traceback()

If the ‘KSCONF_DEBUG’ environmental variable is set, then show a stack trace.