Skip to content

Commit

Permalink
Merge branch 'main' into dsl
Browse files Browse the repository at this point in the history
  • Loading branch information
aszs committed Oct 24, 2023
2 parents d9bf5c1 + d207898 commit 7f97225
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
24 changes: 15 additions & 9 deletions tosca-package/tosca/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ def find_spec(cls, fullname: str, path=None, target=None, modules=None):
if len(names) == 1:
return ModuleSpec(fullname, None, origin=dir_path, is_package=True)
else:
origin_path = os.path.join(dir_path, *names[1:]) + ".py"
origin_path = os.path.join(dir_path, *names[1:])
if os.path.isdir(origin_path):
return ModuleSpec(fullname, None, origin=origin_path, is_package=True)
origin_path += ".py"
loader = ToscaYamlLoader(fullname, origin_path, modules)
spec = spec_from_loader(fullname, loader, origin=origin_path)
return spec
Expand Down Expand Up @@ -195,14 +198,17 @@ def load_private_module(base_dir: str, modules: Dict[str, ModuleType], name: str
if name in ALLOWED_PRIVATE_PACKAGES or parent == "service_template":
spec = ModuleSpec(name, None, origin=origin_path, is_package=True)
else:
origin_path += ".py"
if not os.path.isfile(origin_path):
raise ModuleNotFoundError(
f"No module named {name} at {origin_path}", name=name
)
loader = ToscaYamlLoader(name, origin_path, modules)
spec = spec_from_loader(name, loader, origin=origin_path)
assert spec and spec.loader
if os.path.isdir(origin_path):
spec = ModuleSpec(name, None, origin=origin_path, is_package=True)
else:
origin_path += ".py"
if not os.path.isfile(origin_path):
raise ModuleNotFoundError(
f"No module named {name} at {origin_path}", name=name
)
loader = ToscaYamlLoader(name, origin_path, modules)
spec = spec_from_loader(name, loader, origin=origin_path)
assert spec and spec.loader
module = module_from_spec(spec)
modules[name] = module
if not spec.loader:
Expand Down
3 changes: 2 additions & 1 deletion unfurl/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ def filter(self, record: logging.LogRecord) -> bool:
else:
if record.args is not None:
record.args = tuple(self.redact(a) for a in record.args)
record.msg = self.sanitize_urls(record.msg)
if isinstance(record.msg, str):
record.msg = self.sanitize_urls(record.msg)
return True

@staticmethod
Expand Down

0 comments on commit 7f97225

Please sign in to comment.