Skip to content

Commit

Permalink
base: Allow nested imports
Browse files Browse the repository at this point in the history
  • Loading branch information
marv7000 committed Jan 28, 2025
1 parent c43874b commit 71bb003
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions xbstrap/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 71bb003

Please sign in to comment.