jgdv.structs.dkey.processor

Classes

DKeyProcessor

The Metaclass for keys, which ensures that subclasses of DKeyBase

Module Contents

class jgdv.structs.dkey.processor.DKeyProcessor[source]

Bases: jgdv._abstract.protocols.pre_processable.PreProcessor_p

The Metaclass for keys, which ensures that subclasses of DKeyBase are API.Key_p’s, despite there not being an actual subclass relation between them.

This allows DKeyBase to actually bottom out at str

consume_format_params(spec) <Unknown>[source]

return (remaining, wrap, direct)

Parameters:

spec (str)

Return type:

tuple[str, bool, bool]

extract_raw_keys(
data,
*,
implicit=False,
) <Unknown>[source]

Calls the Python format string parser to extract keys and their formatting/conversion specs, then wraps them in jgdv.structs.dkey._util.parser.API.RawKey_d’s for convenience

if ‘implicit’ then will parse the entire string as {str}

Parameters:

data (str)

Return type:

tuple[jgdv.structs.dkey._interface.RawKey_d, Ellipsis]

inspect_raw(raw_keys, kdata) <Unknown>[source]

Take extracted keys of the text, and determine features of them. can return modified text, and a mark

Parameters:
Return type:

tuple[jgdv.Maybe[str], jgdv.Maybe[jgdv.structs.dkey._interface.KeyMark]]

post_process(obj, data=None) <Unknown>[source]

Build subkeys if necessary

Parameters:
  • obj (T)

  • data (jgdv.Maybe[dict])

Return type:

jgdv.Maybe[T]

pre_process(
cls,
input,
*args,
strict=False,
**kwargs,
) <Unknown>[source]

Pre-process the Key text,

Extracts subkeys, and refines the type of key to build

Parameters:
  • cls (type[T])

  • input (Any)

  • args (Any)

  • strict (bool)

  • kwargs (Any)

Return type:

jgdv._abstract.protocols.pre_processable.PreProcessResult[T]

process(obj, *, data=None) <Unknown>[source]

The key constructed, build slices

Parameters:
  • obj (T)

  • data (jgdv.Maybe[dict])

Return type:

jgdv.Maybe[T]

register_convert_param(cls, convert) <Unknown>[source]
Parameters:
Return type:

None

select_ctor(
cls,
*,
mark,
force,
insist,
) <Unknown>[source]

Select the appropriate key ctor, which can be forced if necessary, otherwise uses the mark and multi params

Parameters:
  • cls (jgdv.Ctor[T])

  • mark (jgdv.structs.dkey._interface.KeyMark)

  • force (jgdv.Maybe[jgdv.Ctor[T]])

  • insist (bool)

Return type:

jgdv.Ctor[T]

validate_init_kwargs(ctor, kwargs) <Unknown>[source]

returns any keys not expected by a dkey or dkey subclass

Parameters:
Return type:

None

_expected_init_keys: ClassVar[list[str]]
convert_mapping: dict[str, jgdv.structs.dkey._interface.KeyMark]
expected_kwargs: Final[list[str]]
parser: ClassVar[jgdv.structs.dkey._util.parser.DKeyParser]