From 71bb003f4a99aa3ceb8ff9c1b700e41385b903c2 Mon Sep 17 00:00:00 2001 From: Marvin Friedrich Date: Tue, 28 Jan 2025 19:41:38 +0100 Subject: [PATCH] base: Allow nested imports --- xbstrap/base.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xbstrap/base.py b/xbstrap/base.py index 9917e0f..aefc092 100644 --- a/xbstrap/base.py +++ b/xbstrap/base.py @@ -276,6 +276,8 @@ def __init__( self.source_root = os.path.abspath(self._bootstrap_path) + self.included_files = list() + root_path = os.path.join(self._bootstrap_path, "bootstrap.yml") self._root_yml = self._read_yml(root_path, is_root=True) @@ -423,9 +425,11 @@ def _parse_yml( filter_pkgs=None, filter_tasks=None, ): + current_realpath = os.path.realpath(current_path) + if current_realpath in self.included_files: + raise GenericError(f"Can't import {current_realpath} because it's already imported") + self.included_files.append(current_realpath) if "imports" in current_yml and isinstance(current_yml["imports"], list): - if current_yml is not self._root_yml: - raise GenericError("Nested imports are not supported") for import_def in current_yml["imports"]: if "from" not in import_def and "file" not in import_def: raise GenericError("Unexpected data in import")