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: Optional[igittigitt.IgnoreParser] = None, include_files_in_hash: Optional[Sequence[Path]] = None, project_root: Optional[StrPath] = 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.

gitignore_filter: igittigitt.igittigitt.IgnoreParser

Filter to use when zipping dependencies. If file/folder matches the filter, it should be ignored.

root_directory: pathlib.Path

The root directory containing the source code.

project_root: pathlib.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.

property md5_hash: str

Calculate the md5 hash of the directory contents.

This can be resource intensive depending on the size of the project.

add_filter_rule(pattern: str) None[source]

Add rule to ignore filter.

Parameters

pattern – The gitignore pattern to add to the filter.

__new__(**kwargs)
sorted(*, reverse: bool = False) List[pathlib.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.

__eq__(other: object) bool[source]

Compare if self is equal to another object.

__fspath__() Union[str, bytes][source]

Return the file system path representation of the object.

__iter__() Iterator[pathlib.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.