filesystem¶
filesystem ¶
read_env_var ¶
Reads an environment variable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var_name | str | Name of the environment variable. | required |
Returns:
| Name | Type | Description |
|---|---|---|
str | str | The value of the environment variable if valid. |
Raises:
| Type | Description |
|---|---|
KeyError | If the environment variable does not exist. |
ValueError | If the environment variable is empty or contains only whitespace. |
Source code in source/src/imarina_load_researchers/core/filesystem.py
read_file_content ¶
Reads a file and returns its content, rejecting an empty result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path | str | Path | Path to the file. | required |
Returns:
| Name | Type | Description |
|---|---|---|
str | str | The content of the file. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError | If the file does not exist. |
PermissionError | If the file cannot be read due to permission issues. |
ValueError | If the file exists but is empty. |
Source code in source/src/imarina_load_researchers/core/filesystem.py
read_file ¶
Reads a file and returns its content. Handles edge cases such as the file not existing or being unreadable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path | str | Path to the token file. | required |
Returns:
| Name | Type | Description |
|---|---|---|
str | str | The content of the file. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError | If the file does not exist. |
PermissionError | If the file cannot be read due to permission issues. |
Source code in source/src/imarina_load_researchers/core/filesystem.py
ensure_gitignore ¶
Writes a .gitignore into directory that excludes everything but itself.
Used for local directories (like input/) that hold fresh, per-run files that must never be committed, while still keeping the directory itself tracked in git.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory | str | Path | Directory to write the | required |