From 7ee84470e93a374996776aa4cd75c5cfdc006afa Mon Sep 17 00:00:00 2001 From: Jiri Kalvoda Date: Tue, 1 Oct 2024 21:15:22 +0200 Subject: [PATCH] Workaround module import --- src/formatitko/transform_processor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/formatitko/transform_processor.py b/src/formatitko/transform_processor.py index 5451fc7..ac5def9 100644 --- a/src/formatitko/transform_processor.py +++ b/src/formatitko/transform_processor.py @@ -228,12 +228,12 @@ class TransformProcessor(NOPProcessor): importedDoc = import_md(open(filename, "r").read()) self.transform(importedDoc.content) elif e.attributes["type"] == "module": - matches = re.match(r"^(\w+)(?: as (\w+))?$", e.content[0].text[1:]) + matches = re.match(r"^([\w\.]+)(?: as (\w+))?$", e.content[0].text[1:]) if not matches: raise SyntaxError(f"`{e.content[0].text[1:]}`: invalid syntax") module = importlib.import_module(matches.group(1)) module_name = matches.group(1) if matches.group(2) is None else matches.group(2) - self.context.add_commands_from_module(module, module_name) + self.context.add_commands_from_module(module, "") elif e.attributes["type"] == "metadata": filename = self.context.dir + "/" + e.content[0].text[1:] self.context.add_dep(filename)