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 3a4b087
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions xbstrap/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ def __init__(
self._tasks = dict()
self._site_archs = set()
self._cached_repodata = dict()
self._included_files = set()

self._bootstrap_path = changed_source_root or os.path.join(
path, os.path.dirname(os.readlink(os.path.join(path, "bootstrap.link")))
Expand Down Expand Up @@ -423,9 +424,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.add(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 3a4b087

Please sign in to comment.