jgdv.structs.dkey._util._interface
Type Aliases
Protocols
An expandable, like a DKey, |
|
Base class for protocol classes. |
|
Base class for protocol classes. |
|
Base class for protocol classes. |
Classes
The lightweight holder of expansion instructions, passed through the |
|
The core logic to lookup a key from a sequence of sources |
Module Contents
- jgdv.structs.dkey._util._interface.LitFalse: TypeAlias = Literal[False]
- class jgdv.structs.dkey._util._interface.Expandable_p[source]
Bases:
ProtocolAn expandable, like a DKey, uses these hooks to customise the expansion
- class jgdv.structs.dkey._util._interface.Expander_p[source]
Bases:
ProtocolBase class for protocol classes.
Protocol classes are defined as:
class Proto(Protocol): def meth(self) -> int: ...
Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).
For example:
class C: def meth(self) -> int: return 0 def func(x: Proto) -> int: return x.meth() func(C()) # Passes static type check
See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:
class GenProto[T](Protocol): def meth(self) -> T: ...
- coerce_result(inst, opts, *, source) <Unknown>[source]
- Parameters:
inst (ExpInst_d)
opts (ExpOpts)
source (jgdv.structs.dkey._interface.Key_p)
- Return type:
jgdv.Maybe[ExpInst_d]
- class jgdv.structs.dkey._util._interface.ExpansionHooks_p[source]
Bases:
ProtocolBase class for protocol classes.
Protocol classes are defined as:
class Proto(Protocol): def meth(self) -> int: ...
Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).
For example:
class C: def meth(self) -> int: return 0 def func(x: Proto) -> int: return x.meth() func(C()) # Passes static type check
See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:
class GenProto[T](Protocol): def meth(self) -> T: ...
- exp_coerce_h(inst, factory, opts) <Unknown>[source]
- Parameters:
inst (ExpInst_d)
factory (InstructionFactory_p)
opts (dict)
- Return type:
jgdv.Maybe[ExpInst_d]
- exp_extra_sources_h(current) <Unknown>[source]
- Parameters:
current (SourceChain_d)
- Return type:
- exp_final_h(
- inst,
- root,
- factory,
- opts,
- Parameters:
inst (ExpInst_d)
root (jgdv.Maybe[ExpInst_d])
factory (InstructionFactory_p)
opts (dict)
- Return type:
jgdv.Maybe[ExpInst_d]
- exp_flatten_h(values, factory, opts) <Unknown>[source]
- Parameters:
factory (InstructionFactory_p)
opts (dict)
- Return type:
jgdv.Maybe[ExpInst_d]
- exp_generate_chains_h(
- root,
- factory,
- opts,
- Parameters:
root (ExpInst_d)
factory (InstructionFactory_p)
opts (ExpOpts)
- Return type:
- exp_to_inst_h(
- root,
- factory,
- **kwargs,
- Parameters:
root (ExpInst_d)
factory (InstructionFactory_p)
kwargs (Any)
- Return type:
jgdv.Maybe[ExpInst_d]
- class jgdv.structs.dkey._util._interface.InstructionFactory_p[source]
Bases:
ProtocolBase class for protocol classes.
Protocol classes are defined as:
class Proto(Protocol): def meth(self) -> int: ...
Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).
For example:
class C: def meth(self) -> int: return 0 def func(x: Proto) -> int: return x.meth() func(C()) # Passes static type check
See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:
class GenProto[T](Protocol): def meth(self) -> T: ...
- class jgdv.structs.dkey._util._interface.ExpInstChain_d(*chain, root, merge=None)[source]
- class jgdv.structs.dkey._util._interface.ExpInst_d(**kwargs)[source]
The lightweight holder of expansion instructions, passed through the expander mixin. Uses slots to make it as lightweight as possible
fallback : the value to use if expansion fails
convert : controls type coercion of expansion result
lift : says to lift expanded values into keys themselves (using !L in the key str)
literal : signals the value needs no more expansion
rec : the remaining recursive expansions available. -1 is unrestrained.
total_recs : tracks the number of expansions have occured
- value: Any
- class jgdv.structs.dkey._util._interface.SourceChain_d(*args)[source]
The core logic to lookup a key from a sequence of sources
Doesn’t perform repeated expansions.Tries sources in order.A Source that is a list is copied and each retrieval pops a value off itTODO replace this with collections.ChainMap ?
- Parameters:
args (jgdv.Maybe[SourceBases | SourceChain_d])
- get(key, fallback=None) <Unknown>[source]
Get a key’s value from an ordered sequence of potential sources.
- Parameters:
key (str)
fallback (jgdv.Maybe)
- Return type:
jgdv.Maybe
- lookup(target) <Unknown>[source]
Look up alternatives
pass through DKeys and (DKey, ..) for recursionlift (str(), True, fallback)don’t lift (str(), False, fallback)- Parameters:
target (ExpInstChain_d)
- Return type:
- sources: list[collections.abc.Mapping | list]