Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
19950187 authored and 19950187 committed Mar 19, 2024
1 parent d87efe9 commit 51b8f92
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
16 changes: 5 additions & 11 deletions core/unified_template/unified_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import core.logging.logger_constants as log_const
from core.logging.logger_utils import log
from core.monitoring.monitoring import monitoring
from core.utils.loader import load_file

UNIFIED_TEMPLATE_TYPE_NAME = "unified_template"

Expand Down Expand Up @@ -98,19 +99,12 @@ def __init__(self, input):
file_name = input["file"]
from smart_kit.configs import get_app_config
app_config = get_app_config()
templates_dir = os.path.join(app_config.STATIC_PATH, 'templates')
templates_dir = os.path.join(app_config.STATIC_PATH, "references/templates")
for root, dirs, files in os.walk(templates_dir):
if file_name in files:
input["template"] = self.load_file(os.path.join(root, file_name))
super(UnifiedTemplateMultiLoader, self).__init__(input)
input["template"] = load_file(os.path.join(root, file_name))
super().__init__(input)
return
raise Exception(f"Template {file_name} does not exist in templates directory {templates_dir}")

else:
super(UnifiedTemplateMultiLoader, self).__init__(input)

@staticmethod
def load_file(file_path):
with open(file_path) as f:
file_content = f.read()
return file_content
super().__init__(input)
6 changes: 6 additions & 0 deletions core/utils/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ def reverse_json_dict(data):
for value in values:
result[value] = key
return result


def load_file(file_path):
with open(file_path) as f:
file_content = f.read()
return file_content
3 changes: 1 addition & 2 deletions smart_kit/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,7 @@ def init_actions(self):
actions["self_service_with_state"] = SelfServiceActionWithState
actions["set_local_variable"] = SetLocalVariableAction
actions["set_variable"] = SetVariableAction
actions["string"] = StringAction
actions["string_file_template"] = StringFileUnifiedTemplateAction
actions["string"] = StringFileUnifiedTemplateAction
actions["push"] = PushAction
actions["push_authentication"] = PushAuthenticationActionHttp
actions["push_http"] = PushActionHttp
Expand Down

0 comments on commit 51b8f92

Please sign in to comment.