ordeq_common
BytesBuffer
dataclass
¶
Bases: IO[bytes]
IO that uses an in-memory bytes buffer to load and save data. Useful for buffering data across nodes without writing to disk.
Example:
1 2 3 4 | |
The buffer is initially empty, unless provided with initial data:
1 2 3 | |
Saving to the buffer appends data to the existing content:
1 2 3 | |
Example in a node:
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Dataclass
dataclass
¶
Bases: Input['DataclassInstance']
IO that parses data as Python dataclass on load.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
For nested models, or other more sophisticated parsing requirements
consider using ordeq-pydantic instead.
Literal
dataclass
¶
Bases: Input[T]
IO that returns a pre-defined value on load. Mostly useful for testing purposes.
Example:
1 2 3 4 5 6 | |
LoggerHook
¶
Bases: InputHook, OutputHook, NodeHook
Hook that prints the calls to the methods. Typically only used for test purposes.
Print
dataclass
¶
Bases: Output[Any]
Output that prints data on save. Mostly useful for debugging purposes.
The difference between other utilities like StringBuffer and Pass is
that Print shows the output of the node directly on the console.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
SpyHook
¶
Bases: InputHook, OutputHook, NodeHook
Hook that stores the arguments it is called with in a list. Typically only used for test purposes.
StringBuffer
dataclass
¶
Bases: IO[str]
IO that uses an in-memory string buffer to load and save data. Useful for buffering data across nodes without writing to disk.
Example:
1 2 3 4 | |
The buffer is initially empty, unless provided with initial data:
1 2 3 | |
Saving to the buffer appends data to the existing content:
1 2 3 | |
Example in a node:
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Iterate(*ios)
¶
IO for loading and saving iteratively. This can be useful when processing multiple IOs using the same node, while only requiring to have one of them in memory at the same time.
Examples:
The load function returns a generator:
1 2 3 4 5 6 7 | |
The load function returns the contents of the files in this case:
1 2 | |
By iterating over the contents, each file will be loaded and saved without the need to keep multiple files in memory at the same time:
1 2 3 4 | |
We can achieve the same by passing a generator to the Iterate.save
method:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
Returns:
| Type | Description |
|---|---|
_Iterate[T]
|
_Iterate |
Match(io=None)
¶
Match(io: Input[Tkey]) -> MatchOnLoad[Tval, Tkey]
Match() -> MatchOnSave[Tval, Tkey]
Utility IO that allows dynamic switching between IO, like the match-case statement in Python.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
If a default is provided, it will be used when no cases match:
1 2 3 | |
Otherwise, it raises an error when none of the provided cases are matched:
1 2 3 4 5 | |
Match on save works as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
Example in a node:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Returns:
| Type | Description |
|---|---|
MatchOnLoad | MatchOnSave
|
MatchOnLoad or MatchOnSave |