From 98b1ae6ee93f392f5f727683297ae237d9fa2966 Mon Sep 17 00:00:00 2001 From: Kenneth Belitzky Date: Sun, 3 Nov 2024 11:45:15 -0300 Subject: [PATCH 1/2] Refactor FileItem class to include skip property for skipping file creation --- struct_module/file_item.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/struct_module/file_item.py b/struct_module/file_item.py index 811a8e6..6ff7b2d 100644 --- a/struct_module/file_item.py +++ b/struct_module/file_item.py @@ -23,6 +23,7 @@ def __init__(self, properties): self.content_location = properties.get("file") self.permissions = properties.get("permissions") self.input_store = properties.get("input_store") + self.skip = properties.get("skip", False) self.system_prompt = properties.get("system_prompt") or properties.get("global_system_prompt") self.user_prompt = properties.get("user_prompt") @@ -118,6 +119,11 @@ def apply_template_variables(self, template_vars): def create(self, base_path, dry_run=False, backup_path=None, file_strategy='overwrite'): file_path = os.path.join(base_path, self.name) + + if self.skip: + self.logger.info(f"Skipping file creation: {file_path}") + return + if dry_run: self.logger.info(f"[DRY RUN] Would create file: {file_path} with content: \n\n{self.content}") return From 294e8373eb5f42973f7c3d8157ba930c2c2a3ff2 Mon Sep 17 00:00:00 2001 From: Kenneth Belitzky Date: Mon, 4 Nov 2024 18:35:53 -0300 Subject: [PATCH 2/2] Refactor structure.yaml to include skip property for skipping file creation --- example/structure.yaml | 1 + struct_module/commands/validate.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/example/structure.yaml b/example/structure.yaml index c5c29a6..f1ef33c 100644 --- a/example/structure.yaml +++ b/example/structure.yaml @@ -1,5 +1,6 @@ structure: - README.md: + skip: true content: | # {{@ project_name @}} This is a template repository. diff --git a/struct_module/commands/validate.py b/struct_module/commands/validate.py index c4e0cf8..24de1fa 100644 --- a/struct_module/commands/validate.py +++ b/struct_module/commands/validate.py @@ -46,7 +46,7 @@ def _validate_folders_config(self, folders): raise ValueError(f"The content of '{name}' must be a dictionary.") if 'struct' not in content: raise ValueError(f"Dictionary item '{name}' must contain a 'struct' key.") - if not isinstance(content['struct'], str): + if not isinstance(content['struct'], str) and not isinstance(content['struct'], list): raise ValueError(f"The 'struct' value for '{name}' must be a string.") @@ -104,7 +104,8 @@ def _validate_structure_config(self, structure): # Check if 'prompt' key is present and its value is a string if 'prompt' in content and not isinstance(content['prompt'], str): raise ValueError(f"The 'prompt' value for '{name}' must be a string.") - # Check if 'prompt' key is present but no OpenAI API key is found + if 'skip' in content and not isinstance(content['skip'], bool): + raise ValueError(f"The 'skip' value for '{name}' must be a string.") elif not isinstance(content, str): raise ValueError(f"The content of '{name}' must be a string or dictionary.") self.logger.info("Configuration validation passed.")