yaml_workflow.tasks.file_tasks¶
yaml_workflow.tasks.file_tasks
¶
File operation tasks for working with files and directories.
Classes¶
Functions¶
append_file_direct(file_path: str, content: str, workspace: Path, encoding: str = 'utf-8', step_name: str = 'append_file') -> str
¶
Append content to a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
Path to the file |
required |
content
|
str
|
Content to append |
required |
workspace
|
Path
|
Workspace directory |
required |
encoding
|
str
|
File encoding (default: utf-8) |
'utf-8'
|
step_name
|
str
|
Name of the step for error reporting |
'append_file'
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Path to the file |
Raises:
Type | Description |
---|---|
TaskExecutionError
|
If file cannot be appended to |
Source code in src/yaml_workflow/tasks/file_tasks.py
append_file_task(config: TaskConfig) -> Optional[Dict[str, Any]]
¶
Append content to a file.
Source code in src/yaml_workflow/tasks/file_tasks.py
copy_file_direct(source: str, destination: str, workspace: Path, step_name: str = 'copy_file') -> str
¶
Copy a file from source to destination.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
str
|
Source file path |
required |
destination
|
str
|
Destination file path |
required |
workspace
|
Path
|
Workspace directory |
required |
step_name
|
str
|
Name of the step for error reporting |
'copy_file'
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Path to destination file |
Raises:
Type | Description |
---|---|
TaskExecutionError
|
If file cannot be copied |
Source code in src/yaml_workflow/tasks/file_tasks.py
copy_file_task(config: TaskConfig) -> Optional[Dict[str, Any]]
¶
Copy a file from source to destination.
Source code in src/yaml_workflow/tasks/file_tasks.py
delete_file_direct(file_path: str, workspace: Path, step_name: str = 'delete_file') -> str
¶
Delete a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
Path to the file |
required |
workspace
|
Path
|
Workspace directory |
required |
step_name
|
str
|
Name of the step for error reporting |
'delete_file'
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Path to deleted file |
Raises:
Type | Description |
---|---|
TaskExecutionError
|
If file cannot be deleted |
Source code in src/yaml_workflow/tasks/file_tasks.py
delete_file_task(config: TaskConfig) -> Optional[Dict[str, Any]]
¶
Delete a file.
Source code in src/yaml_workflow/tasks/file_tasks.py
ensure_directory(file_path: Path, step_name: str) -> None
¶
Ensure the directory exists for the given file path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
Path
|
Path to the file |
required |
step_name
|
str
|
Name of the step for error reporting |
required |
Raises:
Type | Description |
---|---|
TaskExecutionError
|
If directory cannot be created |
Source code in src/yaml_workflow/tasks/file_tasks.py
move_file_direct(source: str, destination: str, workspace: Path, step_name: str = 'move_file') -> str
¶
Move a file from source to destination.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
str
|
Source file path |
required |
destination
|
str
|
Destination file path |
required |
workspace
|
Path
|
Workspace directory |
required |
step_name
|
str
|
Name of the step for error reporting |
'move_file'
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Path to destination file |
Raises:
Type | Description |
---|---|
TaskExecutionError
|
If file cannot be moved |
Source code in src/yaml_workflow/tasks/file_tasks.py
move_file_task(config: TaskConfig) -> Optional[Dict[str, Any]]
¶
Move a file from source to destination.
Source code in src/yaml_workflow/tasks/file_tasks.py
process_templates(data: Any, context: Dict[str, Any]) -> Any
¶
Process template strings in data structure.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Any
|
Data structure to process |
required |
context
|
Dict[str, Any]
|
Template context |
required |
Returns:
Name | Type | Description |
---|---|---|
Any |
Any
|
Processed data structure |
Raises:
Type | Description |
---|---|
TemplateError
|
If template resolution fails |
Source code in src/yaml_workflow/tasks/file_tasks.py
read_file_direct(file_path: str, workspace: Path, encoding: str = 'utf-8', step_name: str = 'read_file', logger=None) -> str
¶
Read content from a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
Path to the file |
required |
workspace
|
Path
|
Workspace directory |
required |
encoding
|
str
|
File encoding (default: utf-8) |
'utf-8'
|
step_name
|
str
|
Name of the step for error reporting |
'read_file'
|
logger
|
Optional logger for debug output |
None
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
File content |
Raises:
Type | Description |
---|---|
TaskExecutionError
|
If file cannot be read or decoded |
Source code in src/yaml_workflow/tasks/file_tasks.py
read_file_task(config: TaskConfig) -> Optional[Dict[str, Any]]
¶
Read content from a file.
Source code in src/yaml_workflow/tasks/file_tasks.py
read_json(file_path: str, workspace: Path, encoding: str = 'utf-8') -> Dict[str, Any]
¶
Read JSON content from a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
Path to the file |
required |
workspace
|
Path
|
Workspace directory |
required |
encoding
|
str
|
File encoding (default: utf-8) |
'utf-8'
|
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Any]: Parsed JSON content |
Raises:
Type | Description |
---|---|
TaskExecutionError
|
If file cannot be read or JSON is invalid |
Source code in src/yaml_workflow/tasks/file_tasks.py
read_json_task(config: TaskConfig) -> Optional[Dict[str, Any]]
¶
Task handler for reading JSON files.
Source code in src/yaml_workflow/tasks/file_tasks.py
read_yaml(file_path: str, workspace: Path, encoding: str = 'utf-8') -> Dict[str, Any]
¶
Read YAML content from a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
Path to the file |
required |
workspace
|
Path
|
Workspace directory |
required |
encoding
|
str
|
File encoding (default: utf-8) |
'utf-8'
|
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
Dict[str, Any]: Parsed YAML content |
Raises:
Type | Description |
---|---|
TaskExecutionError
|
If file cannot be read or YAML is invalid |
Source code in src/yaml_workflow/tasks/file_tasks.py
read_yaml_task(config: TaskConfig) -> Optional[Dict[str, Any]]
¶
Task handler for reading YAML files.
Source code in src/yaml_workflow/tasks/file_tasks.py
write_file_direct(file_path: str, content: str, workspace: Path, encoding: str = 'utf-8', step_name: str = 'write_file') -> str
¶
Write content to a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
Path to the file |
required |
content
|
str
|
Content to write |
required |
workspace
|
Path
|
Workspace directory |
required |
encoding
|
str
|
File encoding (default: utf-8) |
'utf-8'
|
step_name
|
str
|
Name of the step for error reporting |
'write_file'
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Path to written file |
Raises:
Type | Description |
---|---|
TaskExecutionError
|
If file cannot be written or encoded |
Source code in src/yaml_workflow/tasks/file_tasks.py
write_file_task(config: TaskConfig) -> Optional[Dict[str, Any]]
¶
Write content to a file.
Source code in src/yaml_workflow/tasks/file_tasks.py
write_json_direct(file_path: str, data: Union[Dict[str, Any], List[Any]], indent: int = 2, workspace: Path = Path('.'), encoding: str = 'utf-8', step_name: str = 'write_json', logger=None) -> str
¶
Write JSON data to a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
Path to the file |
required |
data
|
Union[Dict[str, Any], List[Any]]
|
Data to write |
required |
indent
|
int
|
Indentation level (default: 2) |
2
|
workspace
|
Path
|
Optional workspace directory |
Path('.')
|
encoding
|
str
|
File encoding (default: utf-8) |
'utf-8'
|
step_name
|
str
|
Name of the step for error reporting |
'write_json'
|
logger
|
Optional logger for debug output |
None
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Path to written file |
Raises:
Type | Description |
---|---|
TemplateError
|
If file cannot be written |
Source code in src/yaml_workflow/tasks/file_tasks.py
write_json_task(config: TaskConfig) -> Optional[Dict[str, Any]]
¶
Write JSON data to a file.
Source code in src/yaml_workflow/tasks/file_tasks.py
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 |
|
write_yaml_direct(file_path: str, data: Dict[str, Any], workspace: Path = Path('.'), encoding: str = 'utf-8', step_name: str = 'write_yaml') -> str
¶
Write YAML data to a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
Path to the file |
required |
data
|
Dict[str, Any]
|
Data to write |
required |
workspace
|
Path
|
Optional workspace directory |
Path('.')
|
encoding
|
str
|
File encoding (default: utf-8) |
'utf-8'
|
step_name
|
str
|
Name of the step for error reporting |
'write_yaml'
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Path to written file |
Raises:
Type | Description |
---|---|
TemplateError
|
If file cannot be written |
Source code in src/yaml_workflow/tasks/file_tasks.py
write_yaml_task(config: TaskConfig) -> Optional[Dict[str, Any]]
¶
Write YAML data to a file.