jgdv.structs.strang.processor
Functions
|
Classes
A processor for basic strangs, |
Module Contents
- class jgdv.structs.strang.processor.StrangBasicProcessor[source]
Bases:
jgdv._abstract.protocols.pre_processable.PreProcessor_pA 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
- _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]}
- _implicit_mark(
- val,
- *,
- sec,
- data,
- index,
- maxcount,
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.
- _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,
Set the slices of a section, return the index where the section ends
- _slice_section(
- obj,
- *,
- case,
- start=0,
- max=-1,
Get a list of word slices of a section, with an offset.
- _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.
- 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,
run before str.__new__ is called, to do early modification of the string Filters out extraneous duplicated separators
- prep_word(val, *, fallback='') <Unknown>[source]
- Parameters:
val (jgdv.structs.strang._interface.PushVal)
fallback (str | jgdv.structs.strang._interface.StrangMarkAbstract_e)
- Return type: