diff --git a/README.es.md b/README.es.md index 6c46c77..1187494 100644 --- a/README.es.md +++ b/README.es.md @@ -149,7 +149,7 @@ structure: #!/bin/bash echo "Hello, {{@ author_name @}}!" - LICENSE: - file: https://raw.githubusercontent.com/nishanths/license/master/LICENSE + remote_file: https://raw.githubusercontent.com/nishanths/license/master/LICENSE - src/main.py: content: | print("Hello, World!") diff --git a/README.md b/README.md index 4657aaa..5a802d1 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ structure: #!/bin/bash echo "Hello, {{@ author_name @}}!" - LICENSE: - file: https://raw.githubusercontent.com/nishanths/license/master/LICENSE + remote_file: https://raw.githubusercontent.com/nishanths/license/master/LICENSE - src/main.py: content: | print("Hello, World!") diff --git a/struct_module/file_item.py b/struct_module/file_item.py index 74c8a91..4648b23 100644 --- a/struct_module/file_item.py +++ b/struct_module/file_item.py @@ -20,7 +20,7 @@ def __init__(self, properties): self.name = properties.get("name") self.file_directory = self._get_file_directory() self.content = properties.get("content") - self.remote_location = properties.get("file") + self.content_location = properties.get("file") self.permissions = properties.get("permissions") self.system_prompt = properties.get("system_prompt") or properties.get("global_system_prompt") @@ -69,13 +69,24 @@ def process_prompt(self, dry_run=False): self.logger.debug(f"Generated content: {self.content}") def fetch_content(self): - if self.remote_location: - self.logger.debug(f"Fetching content from: {self.remote_location}") - response = requests.get(self.remote_location) - self.logger.debug(f"Response status code: {response.status_code}") - response.raise_for_status() - self.content = response.text - self.logger.debug(f"Fetched content: {self.content}") + if self.content_location: + self.logger.debug(f"Fetching content from: {self.content_location}") + + if self.content_location.startswith("file://"): + file_path = self.content_location[len("file://"):] + with open(file_path, 'r') as file: + self.content = file.read() + self.logger.debug(f"Fetched content from local file: {self.content}") + + elif self.content_location.startswith("https://"): + response = requests.get(self.content_location) + self.logger.debug(f"Response status code: {response.status_code}") + response.raise_for_status() + self.content = response.text + self.logger.debug(f"Fetched content from URL: {self.content}") + + else: + self.logger.warning(f"Unsupported protocol in content_location: {self.content_location}") def _merge_default_template_vars(self, template_vars): default_vars = {