Package: kurde
kurdeSimple configuration language based on Python.FeaturesPython syntaxFlexible EnumsEasily created nested dictionariesDirect addess to environment variablesCalling/capturing shell commandsPath manipulationModulereimmediately availableConceptsKurde is pure Python with some built-ins added for your convenience (see below).After invoking your script, any JSON-serializable variable defined in the global scope will be serialized and printed to stdout.Alternatively you can defineROOTvariable in the global scope. It will be considered as the root object to be serialized.After installing Kurde, commandkurdebecomes available. Use it as:kurdepath/to/your/script.pyFor clarity it is recommended to add kurde in the shebang of your script:#!/usr/bin/env kurde.For more information see examples below.Built-InsVariableValuePathpathlib.PathDictaddict.DictEnumsimplenum.Enumenumsimplenumenvaddict.Dict(**os.environ)cmdplumbum.local.cmdrereFor reference see:addictsimple-enumplumbumExamplesSimple Example#!/usr/bin/env kurdeuser=dict(name='admin',password='admin123',)remotes=['192.168.0.100','192.168.0.101','192.168.0.102',]timeout=100Renders as:{"user":{"name":"admin","password":"admin123"},"remotes":["192.168.0.100","192.168.0.101","192.168.0.102"],"timeout":100}Advanced Example#!/usr/bin/env kurde# Enum from `simple-enum` package is available.# By default enum items are serialized by names.classColor(Enum):redgreenbluewhiteblack# Alternatively, enum items can be replaced by numbers assigned automatically.classPriority(Enum,values=enum.from_zero):lowmediumhigh# In the simple cases, standard dictionary is sufficient.# It is serialized as JSON object.theme=dict(foreground=Color.black,background=Color.green,)# Dictionary can be also created by assigning the the attributes.# Dict comes from `addicts` package.user=Dict()# Environment variables can be accessed directly.user.name=env.USERor'admin'user.full_name="Tom Brown"# Module re immediately available.user.last_name=re.findall('[^ ]+',user.full_name)[-1]# lists, dicts, sets are serialized as JSON arrays.user.aliases=('tommy','tbrown','brown')user.nick=Nonenetwork=Dict()# Non-existing attributes are created on the fly.network.local.priority=Priority.medium# Shell commands can be easily invoked.# Behind `cmd` we get `plumbum.local.cmd`.network.local.name=cmd.hostname().strip()# pathlib.Path immediately available.network.local.cert_path=Path(__file__).parent.absolute()/'cert.pem'# Closures and other constructs available.network.remotes={f"proxy{n}":f'192.168.0.{100+n}'forninrange(3)}network.remotes['localhost']='127.0.0.1'Renders as:{"theme":{"foreground":"black","background":"green"},"user":{"name":"kendo","full_name":"Tom Brown","last_name":"Brown","aliases":["tommy","tbrown","brown"],"nick":null},"network":{"local":{"priority":1,"name":"precision","cert_path":"/home/kendo/wrk/kurde/examples/cert.pem"},"remotes":{"proxy0":"192.168.0.100","proxy1":"192.168.0.101","proxy2":"192.168.0.102","localhost":"127.0.0.1"}}}Example with ROOT defined#!/usr/bin/env kurdemin_value=2max_value=6ROOT=Dict()ROOT.numbers=list(range(min_value,max_value+1))Renders as:{"numbers":[2,3,4,5,6]}DisclaimerKurde doesn't do any sandboxing. Invoke the scripts only if you absolutely trust them. You are doing it on your own responsibility.Known IssuesThere is an issue between addict and simplenum when callingDictwith enum items as arguments, e.g.:theme=Dict(foreground=Color.white,background=Color.green,)