runway.cfngin.hooks.awslambda.source_code module¶
Source code.
- class runway.cfngin.hooks.awslambda.source_code.SourceCode[source]¶
Bases:
object
Source code iterable.
- __init__(root_directory: StrPath, *, gitignore_filter: igittigitt.IgnoreParser | None = None, include_files_in_hash: Sequence[Path] | None = None, project_root: StrPath | None = None) None [source]¶
Instantiate class.
- Parameters:
root_directory – The root directory containing the source code.
gitignore_filter – Object that has been pre-populated with rules/patterns to determine if a file should be ignored.
include_files_in_hash – Files that should be included in hash calculation even if they are filtered by gitignore (e.g.
poetry.lock
).project_root – Optional project root if the source code is located within a larger project. This should only be used if the contents of value of
include_files_in_hash
contains paths that exist outside of the root directory. If this is provided, it must be a parent of the root directory.
- __iter__() Iterator[Path] [source]¶
Iterate over the source code files.
- Yields:
Files that do not match the ignore filter. Order in arbitrary.
- __truediv__(other: StrPath) Path [source]¶
Create a new path object from source code’s root directory.
- add_filter_rule(pattern: str) None [source]¶
Add rule to ignore filter.
- Parameters:
pattern – The gitignore pattern to add to the filter.
- gitignore_filter: IgnoreParser¶
Filter to use when zipping dependencies. If file/folder matches the filter, it should be ignored.
- property md5_hash: str¶
Calculate the md5 hash of the directory contents.
This can be resource intensive depending on the size of the project.