rw
assert_file_exists(path)
¶
Assert that a file exists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
The path to the file. |
required |
Returns:
Type | Description |
---|---|
OneOf[Issue, Path]
|
A |
Source code in m/core/rw.py
insert_to_file(filename, start, text, end)
¶
Insert content to a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
The file to insert to. |
required |
start |
str
|
The start delimiter where the insertion will take place. |
required |
text |
str
|
The main content to insert. |
required |
end |
str
|
The end delimiter. |
required |
Returns:
Type | Description |
---|---|
OneOf[Issue, int]
|
None if successful, else an issue. |
Source code in m/core/rw.py
read_file(filename)
¶
FP version of open to read the contents of a file.
If None
is provided it will attempt to read from sys.stdin
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str | None
|
The file path to read. |
required |
Returns:
Type | Description |
---|---|
OneOf[Issue, str]
|
A |
Source code in m/core/rw.py
write_file(filename, text, mode='w')
¶
Write contents to a file in a functional programming style.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
The file path where contents will be written. |
required |
text |
str
|
The contents of the file. |
required |
mode |
str
|
The mode to open the file in. |
'w'
|
Returns:
Type | Description |
---|---|
OneOf[Issue, int]
|
A |