file_processing
File reading and writing actions.
CLASS | DESCRIPTION |
---|---|
IncrementalFileInsert |
Replace the start of a file with text. |
ReadFile |
Return a file’s contents when called. |
WriteFile |
Write the passed string to a file when called. |
FUNCTION | DESCRIPTION |
---|---|
stdout |
Write content to stdout. |
Attributes¶
Classes¶
IncrementalFileInsert
dataclass
¶
IncrementalFileInsert(
filename: StrOrCallable, last_heading_pattern: StrOrCallable
)
Replace the start of a file with text.
METHOD | DESCRIPTION |
---|---|
__call__ |
Replace the beginning of the file up to |
ATTRIBUTE | DESCRIPTION |
---|---|
filename |
The file name to write when called.
TYPE:
|
last_heading_pattern |
A regular expression to detect the last heading. Content before this position is re-rendered and inserted.
TYPE:
|
Attributes¶
last_heading_pattern
instance-attribute
¶
last_heading_pattern: StrOrCallable
A regular expression to detect the last heading. Content before this position is re-rendered and inserted.
Functions¶
__call__
¶
__call__(input_text: StrOrCallable) -> StrOrCallable
Replace the beginning of the file up to last_heading_pattern
with input_text
.
PARAMETER | DESCRIPTION |
---|---|
input_text
|
The text to insert.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
StrOrCallable
|
The same |
ReadFile
dataclass
¶
ReadFile(filename: StrOrCallable, create_if_missing: bool = True)
Return a file’s contents when called.
METHOD | DESCRIPTION |
---|---|
__call__ |
Return the contents of the file. |
ATTRIBUTE | DESCRIPTION |
---|---|
create_if_missing |
When True, create a missing file. Otherwise returns an error.
TYPE:
|
filename |
The file name to read when called.
TYPE:
|
WriteFile
dataclass
¶
WriteFile(filename: StrOrCallable)
Write the passed string to a file when called.
METHOD | DESCRIPTION |
---|---|
__call__ |
Writes input_text to the pre-configured file. |
ATTRIBUTE | DESCRIPTION |
---|---|
filename |
The file name to write when called.
TYPE:
|
Attributes¶
Functions¶
__call__
¶
__call__(input_text: StrOrCallable) -> StrOrCallable
Writes input_text to the pre-configured file.