jgdv.structs.strang._interface
The Interface for Strang.
Strang Enums: - StrangMarkAbstract_e
Describes the internal data structs: - Sec_d : A Single section spec - Sections_d : Collects the sec_d’s. ClassVar - Strang_d : Instance data of a strang beyond the normal str’s
Type Aliases
Enums
Enum where members are also (and must be) strings |
Protocols
Marks a class as able to import code. Userd for CodeRef's. |
|
A string.Formatter with some Strang-specific methods |
|
Base class for protocol classes. |
|
Base class for protocol classes. |
|
The Main protocol describing a Strang. |
Classes
Available Group values of CodeRef strang's |
|
Markers Used in a base Strang's body |
|
Markers used in a Strang's head |
|
Data of a named Strang section |
|
An object to hold information about word separation and sections, |
|
Extra Data of a Strang. |
Module Contents
- jgdv.structs.strang._interface.FindSlice: TypeAlias = str | StrangMarkAbstract_e | WordIndex | MarkIndex
- jgdv.structs.strang._interface.FullSlice: TypeAlias = slice[None, None, None]
- jgdv.structs.strang._interface.ItemIndex: TypeAlias = SectionIndex | FullSlice | MSlice | tuple[ItemIndex, ...]
- jgdv.structs.strang._interface.MSlice: TypeAlias = slice[Maybe[int], Maybe[int], Maybe[int]]
- jgdv.structs.strang._interface.MarkIndex: TypeAlias = tuple[SectionIndex, StrangMarkAbstract_e]
- jgdv.structs.strang._interface.PushVal: TypeAlias = Maybe[str | StrangMarkAbstract_e | UUID]
- jgdv.structs.strang._interface.SectionIndex: TypeAlias = str | int
- jgdv.structs.strang._interface.WordIndex: TypeAlias = tuple[SectionIndex, int]
- class jgdv.structs.strang._interface.StrangMarkAbstract_e[source]
Bases:
enum.StrEnumEnum where members are also (and must be) strings
- class jgdv.structs.strang._interface.Importable_p[source]
Bases:
ProtocolMarks a class as able to import code. Userd for CodeRef’s.
- class jgdv.structs.strang._interface.StrangFormatter_p[source]
Bases:
ProtocolA string.Formatter with some Strang-specific methods
- convert_field(value, conversion) <Unknown>[source]
- Parameters:
value (Any)
conversion (Any)
- Return type:
- class jgdv.structs.strang._interface.StrangMod_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.strang._interface.StrangUUIDs_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.strang._interface.Strang_p[source]
Bases:
StrangUUIDs_p,StrangMod_p,jgdv._abstract.protocols.str.String_p,ProtocolThe Main protocol describing a Strang.
- index(*sub, start=None, end=None) <Unknown>[source]
index
Extended str.index, to handle marks and word slices
- _formatter: ClassVar[string.Formatter]
- _processor: ClassVar[jgdv._abstract.protocols.pre_processable.PreProcessor_p]
- _sections: ClassVar[Sections_d]
- class jgdv.structs.strang._interface.CodeRefHeadMarks_e[source]
Bases:
StrangMarkAbstract_eAvailable Group values of CodeRef strang’s
- cls = 'cls'
- fn = 'fn'
- module = 'module'
- val = 'value'
- value = 'value'
The value of the Enum member.
- class jgdv.structs.strang._interface.DefaultBodyMarks_e[source]
Bases:
StrangMarkAbstract_eMarkers Used in a base Strang’s body
- classmethod skip() <Unknown>[source]
- Return type:
jgdv.Maybe[DefaultBodyMarks_e]
- empty = ''
- extend = '+'
- gen = '$gen$'
- head = '$head$'
- hide = '_'
- class jgdv.structs.strang._interface.DefaultHeadMarks_e[source]
Bases:
StrangMarkAbstract_eMarkers used in a Strang’s head
- basic = '$basic$'
- class jgdv.structs.strang._interface.Sec_d(
- name,
- case,
- end,
- types,
- marks,
- required=True,
- *,
- idx=-1,
Data of a named Strang section
for an example section ‘a.2.c.+::d’ - case : the word boundary. = ‘.’ - end : the rhs end str. = ‘::’ - types : allowed types. = str|int - marks : StrangMarkAbstract_e of words with a meta meaning. = ‘+’ - required : a strang errors if a required section isnt found
idx : the index of the section
TODO Maybe ‘type_re’ and ‘mark_re’
- Parameters:
name (str)
case (jgdv.Maybe[str])
end (jgdv.Maybe[str])
types (type | types.UnionType)
marks (jgdv.Maybe[type[StrangMarkAbstract_e]])
required (bool)
idx (int)
- marks: Final[jgdv.Maybe[type[StrangMarkAbstract_e]]]
- types: Final[type | types.UnionType]
- class jgdv.structs.strang._interface.Sections_d(*sections)[source]
An object to hold information about word separation and sections, a strang type is structured into these
Each Section is a Sec_d TODO add format conversion specs
- types: type | types.UnionType
- class jgdv.structs.strang._interface.Strang_d(uuid=None)[source]
Extra Data of a Strang. Sections are accessed by their index, so use cls._sections.named[name] to get the index
sections : tuple[slice, …] - Section boundaries
sec_words : tuple[tuple[int, …]] - lookup of (sec, word) -> WordIndex
words : tuple[slice, …] - Word Slices
meta : tuple[Maybe, …] - Flat word level meta data
- Parameters:
uuid (jgdv.Maybe[uuid.UUID])