Toolbox containing helper functions for prepare-assignment actions
Project description
Toolbox
This repository contains helper functions for:
- Interacting with a run in
prepare_assignment- Retrieving input
- Setting output
- Finding files based on globs
- Creating zip files
Interacting with prepare_assignment
To help a prepare_assignment action interact with a run, a couple of helper functions are defined in core.py.
To retrieve input use the get_input function, this has the following parameters:
key: str: The key of the input to retrieve, this is the same as the key as defined in theaction.ymlrequired: bool= False: if true and the key is not present it will raise an exceptiontrim_whitespace: bool: if true it will automatically trim whitespace from the retrieved value
To set output that can be used by other actions in the run, use the set_output function. This function has the following parameters:
name: str: the key that other actions can use to retrieve the valuevalue: Any: the value
Furthermore it defines helper methods for logging:
set_failed: log exception/message with levelERRORand exit the processset_error: log exception/message with levelERRORset_warning: log message with levelWARNINGinfo: log message with levelINFOdebug: log message with levelDEBUG
Finding files
A common task for actions is to find files based on a glob. To make this repetitive task easier a helper function is defined in file.py. The function get_matching_files returns a list of paths (as strings) that match the files, given the parameters. The following parameters are available:
included: Union[str, List[str]]: Glob(s) that should be matchedexcluded: Union[str, List[str], None]: Glob(s) that should be excluded from being matched. I.e. if a path matches theincludedglob, it should not be processed if it also matches theexcludedglob. Default:Nonerelative_to: : Union[str, None]: Set relative path from where the globs should be matched. IfNonethe current working directory is used. Default:Noneallow_outside_working_dir: bool: Allowrelative_toto be outside the current working directory. Allow the matched glob(s) to be outside therelative_todirectory. Default:Falserecursive: bool: If true the glob should recurse directories. Default:True
Creating zip files
To help with creating zip files the zip.py adds a helper method create_zip to easily create a simple zip archive. It takes the following parameters:
name: str: name of the archivefiles: List[str]: paths to the files to includeoutput: Optional[str]: the output directory to write to (default to current working directory). Default:None
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prepare_toolbox-0.4.0.tar.gz.
File metadata
- Download URL: prepare_toolbox-0.4.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.8.18 Linux/6.2.0-1015-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
825f50b9bccefcaf091d0e29b7881c311ce7c9a2f510ec481951beffd29871b9
|
|
| MD5 |
65a22108c5f6228d06c908354b5aabb3
|
|
| BLAKE2b-256 |
1dc3b6d5ad3819fa8f9149a3cbd3653dbcb9208103f91fec3a379d528602e7eb
|
File details
Details for the file prepare_toolbox-0.4.0-py3-none-any.whl.
File metadata
- Download URL: prepare_toolbox-0.4.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.8.18 Linux/6.2.0-1015-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15f694af2883463ec83cb568885f85bca4a4225816d86846b296da69c027c5e8
|
|
| MD5 |
11efd9bd2513574c739d40db26ba2020
|
|
| BLAKE2b-256 |
813d9569c6585515e637f32e3ca691ce5df85a01903ca7aa0ce9e4f75580640e
|