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:
objectContext 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.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.file.splglob_simple(pattern)¶ Return a splglob that either matches a full path or match a simple file
-
ksconf.util.file.splglob_to_regex(pattern, re_flags=None)¶
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¶
Module contents¶
-
ksconf.util.debug_traceback()¶ If the ‘KSCONF_DEBUG’ environmental variable is set, then show a stack trace.
-
ksconf.util.handle_py3_kw_only_args(kw, *default_args)¶ Python 2.7 workaround for Python 3 style kw arg after ‘*’ arg.
Example Python 3 syntax:
def f(arg, *args, a=True, b=False): ...
Example Python 2 syntax with this helper function:
def f(arg, *args, **kw_only): a, b = handle_py3_kw_only_args(kw_only, ("a", True), ("b", False)) ...
Parameters: - kw (dict) – keyword arguments provided to the calling function. Be aware that this dict will be empty after this function is done.
- default_args (tuple) – pairs of keyword argument to the caller function in argument (arg_name, default_value) order.
Raises: TypeError – if
kwcontains any keys not defined inargsThis mirrors Python’s native behavior when an unexpected argument is passed to a function.