From 12ce0c701b041790662e10074e6905e1e11b77e1 Mon Sep 17 00:00:00 2001 From: Casey McGinley Date: Wed, 19 Nov 2025 17:42:34 -0800 Subject: [PATCH 1/3] adds FBDs to conf --- contentctl/actions/build.py | 3 + contentctl/output/conf_output.py | 57 +++++++++++++++++++ .../output/templates/savedsearches_fbds.j2 | 9 +++ 3 files changed, 69 insertions(+) create mode 100644 contentctl/output/templates/savedsearches_fbds.j2 diff --git a/contentctl/actions/build.py b/contentctl/actions/build.py index 64bcad4e..fd9a1b35 100644 --- a/contentctl/actions/build.py +++ b/contentctl/actions/build.py @@ -30,6 +30,9 @@ def execute(self, input_dto: BuildInputDto) -> DirectorOutputDto: updated_conf_files.update( conf_output.writeDetections(input_dto.director_output_dto.detections) ) + updated_conf_files.update( + conf_output.writeFbds() + ) updated_conf_files.update( conf_output.writeStories(input_dto.director_output_dto.stories) ) diff --git a/contentctl/output/conf_output.py b/contentctl/output/conf_output.py index df8c0d8a..2508e27c 100644 --- a/contentctl/output/conf_output.py +++ b/contentctl/output/conf_output.py @@ -110,6 +110,63 @@ def writeDetections(self, objects: list[Detection]) -> set[pathlib.Path]: ) return written_files + def writeFbds(self) -> set[pathlib.Path]: + written_files: set[pathlib.Path] = set() + + # Path to the static FBD configuration file + fbd_config_path = self.config.path / "static_configs" / "savedsearches_fbd.conf" + + if not fbd_config_path.exists(): + # If the file doesn't exist, just return empty set - no FBDs to write + return written_files + + # Read and parse the FBD configuration file + fbd_stanzas = self._parse_fbd_config_file(fbd_config_path) + + if fbd_stanzas: # Only write if there are actual stanzas + written_files.add( + ConfWriter.writeConfFile( + pathlib.Path("default/savedsearches.conf"), + "savedsearches_fbds.j2", + self.config, + fbd_stanzas, + ) + ) + + return written_files + + def _parse_fbd_config_file(self, file_path: pathlib.Path) -> list: + """Parse the FBD configuration file into individual stanza objects.""" + stanzas = [] + current_stanza_lines = [] + + with open(file_path, 'r', encoding='utf-8') as f: + for line in f: + stripped_line = line.strip() + + # Skip comment lines (lines starting with # after stripping whitespace) + if stripped_line.startswith('#'): + continue + + # If we hit a blank line and have accumulated stanza content, finalize the current stanza + if not stripped_line: + if current_stanza_lines: + stanza_content = '\n'.join(current_stanza_lines) + stanza_obj = type('FbdStanza', (), {'content': stanza_content})() + stanzas.append(stanza_obj) + current_stanza_lines = [] + continue + + # Accumulate non-empty, non-comment lines for the current stanza + current_stanza_lines.append(line.rstrip()) + # Handle the last stanza if the file doesn't end with a blank line + if current_stanza_lines: + stanza_content = '\n'.join(current_stanza_lines) + stanza_obj = type('FbdStanza', (), {'content': stanza_content})() + stanzas.append(stanza_obj) + + return stanzas + def writeStories(self, objects: list[Story]) -> set[pathlib.Path]: written_files: set[pathlib.Path] = set() written_files.add( diff --git a/contentctl/output/templates/savedsearches_fbds.j2 b/contentctl/output/templates/savedsearches_fbds.j2 new file mode 100644 index 00000000..859a5cff --- /dev/null +++ b/contentctl/output/templates/savedsearches_fbds.j2 @@ -0,0 +1,9 @@ + + +### {{app.label}} FBDS ### + +{% for fbd_stanza in objects %} +{{ fbd_stanza.content }} + +{% endfor %} +### END {{app.label}} FBDS ### From e10690fcfc250d067c7a3d4f7d7338e0e0d40796 Mon Sep 17 00:00:00 2001 From: Casey McGinley Date: Wed, 14 Jan 2026 10:46:42 -0800 Subject: [PATCH 2/3] formatting --- contentctl/actions/build.py | 4 +--- contentctl/output/conf_output.py | 14 ++++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/contentctl/actions/build.py b/contentctl/actions/build.py index fd9a1b35..b1c0979b 100644 --- a/contentctl/actions/build.py +++ b/contentctl/actions/build.py @@ -30,9 +30,7 @@ def execute(self, input_dto: BuildInputDto) -> DirectorOutputDto: updated_conf_files.update( conf_output.writeDetections(input_dto.director_output_dto.detections) ) - updated_conf_files.update( - conf_output.writeFbds() - ) + updated_conf_files.update(conf_output.writeFbds()) updated_conf_files.update( conf_output.writeStories(input_dto.director_output_dto.stories) ) diff --git a/contentctl/output/conf_output.py b/contentctl/output/conf_output.py index 2508e27c..af1a261e 100644 --- a/contentctl/output/conf_output.py +++ b/contentctl/output/conf_output.py @@ -140,19 +140,21 @@ def _parse_fbd_config_file(self, file_path: pathlib.Path) -> list: stanzas = [] current_stanza_lines = [] - with open(file_path, 'r', encoding='utf-8') as f: + with open(file_path, "r", encoding="utf-8") as f: for line in f: stripped_line = line.strip() # Skip comment lines (lines starting with # after stripping whitespace) - if stripped_line.startswith('#'): + if stripped_line.startswith("#"): continue # If we hit a blank line and have accumulated stanza content, finalize the current stanza if not stripped_line: if current_stanza_lines: - stanza_content = '\n'.join(current_stanza_lines) - stanza_obj = type('FbdStanza', (), {'content': stanza_content})() + stanza_content = "\n".join(current_stanza_lines) + stanza_obj = type( + "FbdStanza", (), {"content": stanza_content} + )() stanzas.append(stanza_obj) current_stanza_lines = [] continue @@ -161,8 +163,8 @@ def _parse_fbd_config_file(self, file_path: pathlib.Path) -> list: current_stanza_lines.append(line.rstrip()) # Handle the last stanza if the file doesn't end with a blank line if current_stanza_lines: - stanza_content = '\n'.join(current_stanza_lines) - stanza_obj = type('FbdStanza', (), {'content': stanza_content})() + stanza_content = "\n".join(current_stanza_lines) + stanza_obj = type("FbdStanza", (), {"content": stanza_content})() stanzas.append(stanza_obj) return stanzas From c034bdce8c7a3ada1dbf8ecb164dde6a932c0935 Mon Sep 17 00:00:00 2001 From: Casey McGinley Date: Wed, 14 Jan 2026 11:33:41 -0800 Subject: [PATCH 3/3] adding log lines --- contentctl/output/conf_output.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contentctl/output/conf_output.py b/contentctl/output/conf_output.py index af1a261e..06768c63 100644 --- a/contentctl/output/conf_output.py +++ b/contentctl/output/conf_output.py @@ -118,7 +118,9 @@ def writeFbds(self) -> set[pathlib.Path]: if not fbd_config_path.exists(): # If the file doesn't exist, just return empty set - no FBDs to write + print("No FBD configuration file found; skipping FBD writing to conf.") return written_files + print(f"Reading FBD configuration from {fbd_config_path}") # Read and parse the FBD configuration file fbd_stanzas = self._parse_fbd_config_file(fbd_config_path)