From 47b2956ec3bec6b8687205ea56c4b46ab08756a0 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Tue, 1 Oct 2024 08:06:58 +0100 Subject: [PATCH 1/2] Set the ``state.toml`` filename based upon ``--select-output`` --- build_docs.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/build_docs.py b/build_docs.py index 12c1319..377bbe5 100755 --- a/build_docs.py +++ b/build_docs.py @@ -929,7 +929,10 @@ def should_rebuild(self): return False def load_state(self) -> dict: - state_file = self.build_root / "state.toml" + if self.select_output is None: + state_file = self.build_root / "state.toml" + else: + state_file = self.build_root / f"state-{self.select_output}.toml" try: return tomlkit.loads(state_file.read_text(encoding="UTF-8"))[ f"/{self.language.tag}/{self.version.name}/" @@ -942,7 +945,10 @@ def save_state(self, build_start: dt, build_duration: float, trigger: str): Using this we can deduce if a rebuild is needed or not. """ - state_file = self.build_root / "state.toml" + if self.select_output is None: + state_file = self.build_root / "state.toml" + else: + state_file = self.build_root / f"state-{self.select_output}.toml" try: states = tomlkit.parse(state_file.read_text(encoding="UTF-8")) except FileNotFoundError: From 06b4b83c816be391465174dde119d8ebe5fb979f Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Date: Tue, 1 Oct 2024 10:14:09 +0100 Subject: [PATCH 2/2] Invert condition Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- build_docs.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build_docs.py b/build_docs.py index 377bbe5..076875a 100755 --- a/build_docs.py +++ b/build_docs.py @@ -929,10 +929,10 @@ def should_rebuild(self): return False def load_state(self) -> dict: - if self.select_output is None: - state_file = self.build_root / "state.toml" - else: + if self.select_output is not None: state_file = self.build_root / f"state-{self.select_output}.toml" + else: + state_file = self.build_root / "state.toml" try: return tomlkit.loads(state_file.read_text(encoding="UTF-8"))[ f"/{self.language.tag}/{self.version.name}/" @@ -945,10 +945,10 @@ def save_state(self, build_start: dt, build_duration: float, trigger: str): Using this we can deduce if a rebuild is needed or not. """ - if self.select_output is None: - state_file = self.build_root / "state.toml" - else: + if self.select_output is not None: state_file = self.build_root / f"state-{self.select_output}.toml" + else: + state_file = self.build_root / "state.toml" try: states = tomlkit.parse(state_file.read_text(encoding="UTF-8")) except FileNotFoundError: