jgdv.structs.chainguard.mixins.proxy_m

Classes

GuardProxyEntry_m

A Mixin to add to GuardBase.

Module Contents

class jgdv.structs.chainguard.mixins.proxy_m.GuardProxyEntry_m[source]

A Mixin to add to GuardBase. enables handling a number of conditions when accessing values in the underlying data. eg: tg.on_fail(2, int).a.value() # either get a.value, or 2. whichever returns has to be an int.

abstractmethod all_of(fallback, types=None) <Unknown>[source]
Parameters:
  • fallback (Any)

  • types (jgdv.Maybe)

Return type:

jgdv.structs.chainguard.proxies.base.GuardProxy

abstractmethod first_of(fallback, types=None) <Unknown>[source]

get the first non-None value from a index path, even across arrays of tables so instead of: data.a.b.c[0].d just: data.first_of().a.b.c.d()

Parameters:
  • fallback (Any)

  • types (jgdv.Maybe)

Return type:

jgdv.structs.chainguard.proxies.base.GuardProxy

abstractmethod flatten_on(fallback) <Unknown>[source]

combine all dicts at the call site to form a single dict

Parameters:

fallback (Any)

Return type:

jgdv.structs.chainguard.proxies.base.GuardProxy

abstractmethod match_on(**kwargs) <Unknown>[source]
Parameters:

kwargs (tuple[str, Any])

Return type:

jgdv.structs.chainguard.proxies.base.GuardProxy

on_fail(
fallback=(),
types=None,
*,
non_root=False,
) <Unknown>[source]

use a fallback value in an access chain, eg: doot.config.on_fail(“blah”).this.doesnt.exist() -> “blah”

without throwing a GuardedAccessError

Parameters:
  • fallback (Any)

  • types (jgdv.Maybe)

  • non_root (bool)

Return type:

jgdv.structs.chainguard.proxies.failure.GuardFailureProxy