# kheops package

## Subpackages

- kheops.plugin package
  - Subpackages
    - kheops.plugin.backend package
      - Submodules
      - kheops.plugin.backend.file module
    - kheops.plugin.scope package
      - Submodules
      - kheops.plugin.scope.hier module
      - kheops.plugin.scope.loop module
    - kheops.plugin.strategy package
      - Submodules
      - kheops.plugin.strategy.last module
      - kheops.plugin.strategy.merge_deep module
      - kheops.plugin.strategy.merge_schema module
  - Submodules
  - kheops.plugin.common module

## Submodules

## kheops.app module

Kheops App interface

class kheops.app.GenericInstance

  Bases: `object`

  GenericInstance class

  Variables

    - name (str or None) – Name of the instace.

    - run (dict) – Json compatible dict for instance runtime data.

  name = None
  run = {}

class kheops.app.Kheops(config='kheops.yml', namespace='default')

  Bases: `kheops.app.GenericInstance`

  Kheops Application Class

  lookup(keys=None, policy=None, scope=None, trace=False, explain=False, validate_schema=False, namespace=None, namespace_prefix=False)

    Lookup a key in hierarchy

    For a given lookup: * keys= [<namespace>:<key>]

    Parameters

      - keys (list[str]) – List of keys to query.

      - scope (dict) – Scope key.

  parse_conf(config='kheops.yml')

    Parse Kheops configuration

    Parameters

      config (dict or str or None) – Kheops configuration, can either be a file path or a dict.

    Returns

      The parsed configuration.

    Return type

      dict

class kheops.app.KheopsNamespace(app, name, config=None)

  Bases: `kheops.app.GenericInstance`, `kheops.controllers.QueryProcessor`

  Kheops Namespace Class

## kheops.cli module

Kheops CLI interface

class kheops.cli.OutputFormat(value)

  Bases: `str`, `enum.Enum`

  An enumeration.

  json = 'json'
  toml = 'toml'
  yaml = 'yaml'

kheops.cli.config()

kheops.cli.get_logger(logger_name=None, create_file=False, verbose=0)

  Create CmdApp logger

kheops.cli.lookup(ctx: typer.models.Context, namespace: str = <typer.models.OptionInfo object>, keys: typing.List[str] = <typer.models.ArgumentInfo object>, scope_param: typing.Optional[typing.List[str]] = <typer.models.OptionInfo object>, file: pathlib.Path = <typer.models.OptionInfo object>, format: kheops.cli.OutputFormat = <typer.models.OptionInfo object>, trace: bool = <typer.models.OptionInfo object>, explain: bool = <typer.models.OptionInfo object>)

  Lookup database

kheops.cli.main(ctx: typer.models.Context, verbose: int = <typer.models.OptionInfo object>, config: pathlib.Path = <typer.models.OptionInfo object>)

  Manage users in the awesome CLI app.

## kheops.controllers module

Kheops controller

Main Kheops model classes

class kheops.controllers.BackendCandidate(path=None, data=None, run=None, status=None)

  Bases: `object`

  Backend Candidate

  This object represents a backend candidate. It holds the value of the requested key, but also so source path, the status and some other metadata.

class kheops.controllers.LoadPlugin(plugins)

  Bases: `object`

  Kheops plugins loader

  This plugin loader is a helper to load a python module (Kheops Plugin) from a plugin kind and name.

  load(kind, name)

    Load a plugin

class kheops.controllers.Query(key, scope)

  Bases: `object`

  Query object

  Object that hold key and scope.

  key = None
  scope = None

class kheops.controllers.QueryProcessor(config)

  Bases: `object`

  This class helps to do queries for a given key and scope. It provides a single public method. It also implement an explain mechanism to help to troubleshoot query lookup issues.

  The query process consists in: * Create a new query with the key and th scope * Fetch and expand the lookup list (_exec_assemble_lookups) * Fetch the rule that match the key (_exec_get_rule) * Fetch the strategy that match the key * Query all backends with lookup list (_exec_backend_plugins) * Return result

  default_lookup_item = {'backend': 'file', 'continue': True, 'path': None}
  default_match_rule = {'continue': False, 'key': None, 'strategy': 'merge_schema'}
  query(key=None, scope=None, explain=False)

    Query key with scope

## kheops.utils module

Utils class

class kheops.utils.Default

  Bases: `dict`

kheops.utils.glob_files(path, pattern)

  Return a list of path that match a glob

kheops.utils.path_assemble_hier(path, sep='/', reverse=False, start_index=0)

  Append the previous

kheops.utils.render_template(text, params)

  Render template for a given string

kheops.utils.render_template_python(text, params, ignore_missing=True)

  Render template for a given string

kheops.utils.schema_validate(config, schema)

  Validate a config against a jsonschema

kheops.utils.str_ellipsis(txt, length=60)

  Truncate with ellipsis too wide texts