craft_parts.sources.local_source module¶
The local source handler and helpers.
- class craft_parts.sources.local_source.LocalSource(*args, project_dirs, copy_function=<function link_or_copy>, **kwargs)[source]¶
Bases:
SourceHandler
The local source handler.
- Parameters:
args (
Any
)project_dirs (
ProjectDirs
)copy_function (
Callable
[...
,None
])kwargs (
Any
)
- 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.
- 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.
- source_model¶
alias of
LocalSourceModel
- update()[source]¶
Update pulled source.
Call method
check_if_outdated()
before updating to populate the lists of files and directories to copy.- Return type:
None
- class craft_parts.sources.local_source.LocalSourceModel(**data)[source]¶
Bases:
BaseSourceModel
Pydantic model for a generic local source.
- Parameters:
data (
Any
)
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function get_model_config.<locals>.<lambda>>, 'extra': 'forbid', 'frozen': True, 'json_schema_extra': {'if': {'not': {'required': ['source-type']}}, 'then': {'properties': {'source': {'pattern': '^\\./?'}}}}}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'source': FieldInfo(annotation=Path, required=True, alias='source', alias_priority=1, metadata=[AfterValidator(func=<function LocalSourceModel.<lambda>>)]), 'source_type': FieldInfo(annotation=Literal['local'], required=False, default='local', alias='source-type', alias_priority=1)}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
-
source:
Annotated
[Path
]¶
-
source_type:
Literal
['local'
]¶