Migration guide¶
Migration from version 0.3 to 0.4¶
Shell commands¶
Shell command configtree
is deprecated in favor of ctdump
.
The latter one uses new loader infrastructure and new formatters.
The following pairs of commands give the identical result:
configtree
ctdump json --json-sort --json-indent=4
configtree --format json
ctdump json --json-sort --json-indent=4
configtree --format rare-json
ctdump json --json-sort --json-indent=4 --json-rare
configtree --format shell
ctdump shell --shell-sort --shell-capitalize
loaderconf.py
¶
The following functions are deprecated:
configtree.loader.make_walk()
in favor ofconfigtree.loader.Walker
;configtree.loader.make_update()
in favor ofconfigtree.loader.Updater
;
Simple replacement gives the same result:
# This code...
from configtree import make_walk, make_update
walk = make_walk(envname)
update = make_update(namespace)
# ...should be replaced by this one
# Take a notice, that positional arguments is not acceptable.
# Use named ones.
from configtree import Walker, Updater
walk = Walker(env=envname)
update = Updater(namespace=namespace)
Function postprocess
should be created using class configtree.loader.PostProcessor
.
If there is no built-in features you need, consider extending of the class.
# This code...
def postprocess(tree):
for key, value in tree.items():
if condition(key):
tree[key] = transform(value)
# ...should be replaced by this one
from configtree import PostProcessor, Pipeline
class MyPostProcessor(PostProcessor):
@Pipeline.worker(100)
def apply_transform(self, tree, key, value):
if condition(key):
tree[key] = transform(value)
postprocess = MyPostProcessor()
Module configtree.conv
and its plugins¶
Module configtree.conv
is deprecated in favor of configtree.formatter
.
The latter one is used by new ctdump
script. See Shell commands section.
Plugins that use configtree.conv
entry point are deprecated, consider configtree.formatter
entry point.