summaryrefslogtreecommitdiff
path: root/src/hydrilla/builder/build.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/hydrilla/builder/build.py')
-rw-r--r--src/hydrilla/builder/build.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/hydrilla/builder/build.py b/src/hydrilla/builder/build.py
index 58225d4..8a97a20 100644
--- a/src/hydrilla/builder/build.py
+++ b/src/hydrilla/builder/build.py
@@ -101,7 +101,7 @@ class FileRef:
self.contents_hash = sha256(contents).digest().hex()
- def make_ref_dict(self) -> dict[str, str]:
+ def make_ref_dict(self) -> t.Dict[str, str]:
"""
Represent the file reference through a dict that can be included in JSON
defintions.
@@ -154,9 +154,9 @@ class Build:
if piggyback_default_path.exists():
self.piggyback_files = piggyback_default_path
- self.files_by_path: dict[PurePosixPath, FileRef] = {}
- self.resource_list: list[dict] = []
- self.mapping_list: list[dict] = []
+ self.files_by_path: t.Dict[PurePosixPath, FileRef] = {}
+ self.resource_list: t.List[dict] = []
+ self.mapping_list: t.List[dict] = []
if not index_json_path.is_absolute():
index_json_path = (self.srcdir / index_json_path)
@@ -170,14 +170,14 @@ class Build:
FileRef(index_desired_path, index_json_path.read_bytes())
# We know from successful validation that instance is a dict.
- self._process_index_json(t.cast('dict[str, t.Any]', index_obj))
+ self._process_index_json(t.cast('t.Dict[str, t.Any]', index_obj))
def _process_file(
self,
filename: t.Union[str, PurePosixPath],
piggybacked: Piggybacked,
include_in_distribution: bool = True
- ) -> dict[str, str]:
+ ) -> t.Dict[str, str]:
"""
Resolve 'filename' relative to srcdir, load it to memory (if not loaded
before), compute its hash and store its information in
@@ -207,7 +207,9 @@ class Build:
path = piggybacked.resolve_file(desired_path)
if path is None:
path = (self.srcdir / desired_path).resolve()
- if not path.is_relative_to(self.srcdir):
+ try:
+ path.relative_to(self.srcdir)
+ except ValueError:
raise FileReferenceError(_('loading_{}_outside_package_dir')
.format(filename))
@@ -270,7 +272,7 @@ class Build:
as_what: str,
item_def: dict,
piggybacked: Piggybacked
- ) -> dict[str, t.Any]:
+ ) -> t.Dict[str, t.Any]:
"""
Process 'item_def' as definition of a resource or mapping (determined by
'as_what' param) and store in memory its processed form and files used