From 0c8d70daae4c4dfc989edad465db94ffc665416d Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Tue, 11 Oct 2022 10:26:55 +0200 Subject: [builder][server] restore compatibility with python 3.7 --- src/hydrilla/builder/piggybacking.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/hydrilla/builder/piggybacking.py') diff --git a/src/hydrilla/builder/piggybacking.py b/src/hydrilla/builder/piggybacking.py index 3e4084f..c152135 100644 --- a/src/hydrilla/builder/piggybacking.py +++ b/src/hydrilla/builder/piggybacking.py @@ -52,10 +52,10 @@ class Piggybacked: """ def __init__( self, - archives: dict[str, Path] = {}, - roots: dict[str, Path] = {}, - package_license_files: list[PurePosixPath] = [], - resource_must_depend: list[dict] = [] + archives: t.Dict[str, Path] = {}, + roots: t.Dict[str, Path] = {}, + package_license_files: t.List[PurePosixPath] = [], + resource_must_depend: t.List[dict] = [] ) -> None: """ Initialize this Piggybacked object. @@ -106,13 +106,15 @@ class Piggybacked: path = path.resolve() - if not path.is_relative_to(root_path): + try: + path.relative_to(root_path) + except ValueError: raise FileReferenceError(_('loading_{}_outside_piggybacked_dir') .format(file_ref_name)) return path - def archive_files(self) -> t.Iterator[tuple[PurePosixPath, Path]]: + def archive_files(self) -> t.Iterator[t.Tuple[PurePosixPath, Path]]: """ Yield all archive files in use. Each yielded tuple holds file's desired path relative to the piggybacked archives directory to be created and -- cgit v1.2.3