jgdv.structs.strang.processor

Functions

name_to_hook(val)

Classes

StrangBasicProcessor

A processor for basic strangs,

Module Contents

jgdv.structs.strang.processor.name_to_hook(val) <Unknown>[source]
Parameters:

val (str)

Return type:

str

class jgdv.structs.strang.processor.StrangBasicProcessor[source]

Bases: jgdv._abstract.protocols.pre_processable.PreProcessor_p

A processor for basic strangs, the instance is assigned into Strang._processor

If the strang type implements _{call}_h, the processor uses that for a stage instead

_build_mark(val, *, sec, data) <Unknown>[source]

converts applicable words to mark enum values Matches using strang._interface.MARK_RE

Parameters:
Return type:

jgdv.Maybe[jgdv.structs.strang._interface.StrangMarkAbstract_e]

_calc_obj_meta(obj) <Unknown>[source]

Set object level meta dict

ie: mark the obj as an instance

Parameters:

obj (T)

Return type:

None

_clean_separators(cls, val) <Unknown>[source]

Clean even repetitions of the separator down to single uses

eg: for sep=’.’, a..b::c….d -> a.b::c.d but: a.b::c…d -> a.b::c..d

Parameters:
Return type:

str

_compress_types(cls, val) <Unknown>[source]

Extract values of explicitly typed words.

allows the base str of the Strang to be readable, and for post-process to insert types as necessary

eg: a.b.c::d.e.<uuid:….> -> (a.b.c::d.e.<uuid>, {uuids:[UUIDstr]}

Parameters:
Return type:

tuple[str, dict]

_get_args(val) <Unknown>[source]
Parameters:

val (str)

Return type:

jgdv.Maybe[int]

_implicit_mark(
val,
*,
sec,
data,
index,
maxcount,
) <Unknown>[source]

Builds certain implicit marks, but only for the first and last words of a section

# TODO handle combined marks like val::+_.blah

Parameters:
Return type:

jgdv.Maybe[jgdv.structs.strang._interface.StrangMarkAbstract_e]

_make_type(val, *, sec, data, obj) <Unknown>[source]

Handle <type> words, which may have had data extracted during pre-processing.

Parameters:
Return type:

jgdv.Maybe[Any]

_post_process_section(obj, idx, data) <Unknown>[source]
Parameters:
Return type:

list

_process_args(obj, *, data) <Unknown>[source]

Extract args and set values as necessary

Parameters:
  • obj (T)

  • data (dict)

Return type:

None

_process_section(
obj,
section,
*,
start=-1,
) <Unknown>[source]

Set the slices of a section, return the index where the section ends

Parameters:
Return type:

tuple[slice, tuple[slice, Ellipsis], int]

_slice_section(
obj,
*,
case,
start=0,
max=-1,
) <Unknown>[source]

Get a list of word slices of a section, with an offset.

Parameters:
Return type:

tuple[slice]

_validate_marks(obj) <Unknown>[source]

Check marks make sense. eg: +|_ are only at obj[1:0]

Parameters:

obj (T)

Return type:

None

_verify_structure(cls, val) <Unknown>[source]

Verify basic strang structure.

ie: all necessary sections are, provisionally, there.

Parameters:
Return type:

bool

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

With the strang cleaned and slices, build meta data for words

takes the data extracted during pre-processing.

Parameters:
  • obj (T)

  • data (jgdv._abstract.protocols.pre_processable.PostInstanceData)

Return type:

jgdv.Maybe[T]

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

run before str.__new__ is called, to do early modification of the string Filters out extraneous duplicated separators

Parameters:
  • cls (type[T])

  • input (Any)

  • args (Any)

  • strict (bool)

  • kwargs (Any)

Return type:

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

prep_word(val, *, fallback='') <Unknown>[source]
Parameters:
Return type:

str

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

slice the sections of the strang

populates obj.data: - slices - flat - bounds

Parameters:
  • obj (T)

  • data (jgdv._abstract.protocols.pre_processable.PostInstanceData)

Return type:

jgdv.Maybe[T]

use_hook(cls, stage, *args, **kwargs) <Unknown>[source]
Parameters:
  • cls (type[T] | T)

  • stage (str)

  • args (Any)

  • kwargs (Any)

Return type:

jgdv.MaybeT[bool, Any]