runway.cfngin.hooks.awslambda.source_code module

Source code.

class runway.cfngin.hooks.awslambda.source_code.SourceCode[source]

Bases: object

Source code iterable.

__eq__(other: object) bool[source]

Compare if self is equal to another object.

__fspath__() str | bytes[source]

Return the file system path representation of the object.

__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.

__str__() str[source]

Return the string representation of the object.

__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.

project_root: Path

Top-level directory containing the project metadata files and source code root directory. The value can be the same as root_directory. If it is not, it must be a parent of root_directory.

root_directory: Path

The root directory containing the source code.

sorted(*, reverse: bool = False) list[Path][source]

Sorted list of source code files.

Parameters:

reverse – Sort the list in reverse.

Returns:

Sorted list of source code files excluding those that match the ignore filter.