craft_parts.sources.base module¶
Base classes for source type handling.
- class craft_parts.sources.base.FileSourceHandler(source, part_src_dir, *, cache_dir, project_dirs, source_tag=None, source_commit=None, source_branch=None, source_depth=None, source_checksum=None, source_submodules=None, command=None, ignore_patterns=None)[source]¶
Bases:
SourceHandler
Base class for file source types.
- Parameters:
source (
str
) –part_src_dir (
Path
) –cache_dir (
Path
) –project_dirs (
ProjectDirs
) –source_tag (
Optional
[str
]) –source_commit (
Optional
[str
]) –source_branch (
Optional
[str
]) –source_depth (
Optional
[int
]) –source_checksum (
Optional
[str
]) –source_submodules (
Optional
[List
[str
]]) –command (
Optional
[str
]) –ignore_patterns (
Optional
[List
[str
]]) –
- download(filepath=None)[source]¶
Download the URL from a remote location.
- Parameters:
filepath (
Optional
[Path
]) – the destination file to download to.- Return type:
Path
- class craft_parts.sources.base.SourceHandler(source, part_src_dir, *, cache_dir, project_dirs, source_tag=None, source_commit=None, source_branch=None, source_depth=None, source_checksum=None, source_submodules=None, command=None, ignore_patterns=None)[source]¶
Bases:
ABC
The base class for source type handlers.
Methods
check_if_outdated()
andupdate_source()
can be overridden by subclasses to implement verification and update of source files.- Parameters:
source (
str
) –part_src_dir (
Path
) –cache_dir (
Path
) –project_dirs (
ProjectDirs
) –source_tag (
Optional
[str
]) –source_commit (
Optional
[str
]) –source_branch (
Optional
[str
]) –source_depth (
Optional
[int
]) –source_checksum (
Optional
[str
]) –source_submodules (
Optional
[List
[str
]]) –command (
Optional
[str
]) –ignore_patterns (
Optional
[List
[str
]]) –
- check_if_outdated(target, *, ignore_files=None)[source]¶
Check if pulled sources have changed since target was created.
- Parameters:
target (
str
) – Path to target file.ignore_files (
Optional
[List
[str
]]) – Files excluded from verification.
- Return type:
bool
- Returns:
Whether the sources are outdated.
- Raises:
errors.SourceUpdateUnsupported – If the source handler can’t check if files are outdated.
- get_outdated_files()[source]¶
Obtain lists of outdated files and directories.
- Return type:
Tuple
[List
[str
],List
[str
]]- Returns:
The lists of outdated files and directories.
- Raises:
errors.SourceUpdateUnsupported – If the source handler can’t check if files are outdated.
- update()[source]¶
Update pulled source.
- Raises:
errors.SourceUpdateUnsupported – If the source can’t update its files.
- Return type:
None