pycnfg.run

pycnfg.run(cnfg, dcnfg=None, objects=None, oid=None, resolve_none=False, update_expl=False, mutable=False, beep=False, debug=False)[source]

Wrapper over configuration handler.

Parameters
  • cnfg (dict or str) – Configuration to pass in pycnfg.Handler.read(): {‘section_id’: {‘configuration_id’: configuration,}}. If str, absolute path to the file with CNFG variable or relative to work dir.

  • dcnfg (dict, str, optional (default=None)) – Default configurations to pass in pycnfg.Handler.read(). If str, absolute path to file with CNFG variable or relative to work dir.

  • objects (dict, optional (default=None)) – Dict of initial objects to pass in pycnfg.Handler.exec(): {‘object_id’: object}. If None, set {}.

  • oid (str, optional (default=None)) – Unique identifier of cnfg. If None, use str(time.time()).

  • resolve_none (bool, optional (default=False)) – If True, try to resolve None values for step kwargs. If kwarg name matches with section name, substitute either with conf_id on zero position or val, depending on if _id prefix in kwarg_name.

  • update_expl (bool, optional (default=True)) – If True apply global values to update explicitly set kwargs for target step, otherwise update only unset kwargs.

  • mutable (bool, optional (default=False)) – If True, rewrite existed object when configuration id already in objects. Otherwise skip execution and remain original.

  • beep (bool, optional (default=False)) – If True, play sound notification on ending.

  • debug (bool, optional (default=False)) – If True, print executed configuration.

Returns

objects – Dict of objects created by execution all configurations: {‘section_id__configuration_id’: object}.

Return type

dict

Notes

cnfg could be executed as sub-configuration itself:

  • init = cnfg

  • steps = [(‘read’, {..}), (‘exec’, {..})]

  • producer = pycnfg.Handler(objects, oid)

objects[oid] = producer.run(init, steps)

See also

pycnfg.Handler

Reads configurations, executes steps.