From a4403842390ca80797b5c090f3530ff57dfea55f Mon Sep 17 00:00:00 2001
From: sanj <67624670+iodrift@users.noreply.github.com>
Date: Thu, 8 Aug 2024 21:28:32 -0700
Subject: [PATCH] Auto-update: Thu Aug  8 21:28:32 PDT 2024

---
 sijapi/classes.py | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/sijapi/classes.py b/sijapi/classes.py
index 3265822..4c06752 100644
--- a/sijapi/classes.py
+++ b/sijapi/classes.py
@@ -232,26 +232,30 @@ class DirConfig(BaseModel):
     @classmethod
     def load(cls, yaml_path: Union[str, Path]) -> 'DirConfig':
         yaml_path = cls._resolve_path(yaml_path, 'config')
-
+    
         try:
             with yaml_path.open('r') as file:
                 config_data = yaml.safe_load(file)
-
+    
             print(f"Loaded configuration data from {yaml_path}")
-
+    
             # Ensure HOME is set
             if 'HOME' not in config_data:
                 config_data['HOME'] = str(Path.home())
                 print(f"HOME was not in config, set to default: {config_data['HOME']}")
-
-            instance = cls.create_dynamic_model(**config_data)
-            resolved_data = instance.resolve_placeholders(config_data)
+    
+            # Create a temporary instance to resolve placeholders
+            temp_instance = cls.create_dynamic_model(**config_data)
+            resolved_data = temp_instance.resolve_placeholders(config_data)
+    
+            # Create the final instance with resolved data
             return cls.create_dynamic_model(**resolved_data)
-
+    
         except Exception as e:
             print(f"Error loading configuration: {str(e)}")
             raise
 
+
     @classmethod
     def _resolve_path(cls, path: Union[str, Path], default_dir: str) -> Path:
         base_path = Path(__file__).parent.parent
@@ -282,19 +286,24 @@ class DirConfig(BaseModel):
     def resolve_string_placeholders(self, value: str) -> Path:
         pattern = r'\{\{\s*([^}]+)\s*\}\}'
         matches = re.findall(pattern, value)
-
+        
         for match in matches:
             if match == 'HOME':
                 replacement = str(self.HOME)
+            elif match == 'BASE':
+                replacement = str(Path(__file__).parent.parent)
+            elif match == 'DATA':
+                replacement = str(Path(__file__).parent.parent / "data")
             elif hasattr(self, match):
                 replacement = str(getattr(self, match))
             else:
                 replacement = value
-
+        
             value = value.replace('{{' + match + '}}', replacement)
-
+        
         return Path(value).expanduser()
 
+
     @classmethod
     def create_dynamic_model(cls, **data):
         DynamicModel = create_model(