diff --git a/zipapps/main.py b/zipapps/main.py index b3c0a1a..fa7cae9 100644 --- a/zipapps/main.py +++ b/zipapps/main.py @@ -370,7 +370,8 @@ def prepare_active_zipapps(self): def make_runner(): if self.main: - if re.match(r"^\w+(\.\w+)?(:\w+)?$", self.main): + pattern = r"^\w+(\.\w+)?(:\w+)?$" + if re.match(pattern, self.main): module, _, function = self.main.partition(":") if module: # main may be: 'module.py:main' or 'module.submodule:main' @@ -382,12 +383,12 @@ def make_runner(): if function: runner += f"; {module}.{function}()" self._log( - f"[INFO]: -m: matches re.match(r'^\w+(\.\w+)?(:\w+)?$', self.main), add as `{runner}`." + f"[INFO]: -m: matches re.match(r'{pattern}', self.main), add as `{runner}`." ) return runner else: self._log( - f"[INFO]: -m: not matches re.match(r'^\w+(\.\w+)?(:\w+)?$', self.main), add as raw code `{self.main}`." + f"[INFO]: -m: not matches re.match(r'{pattern}', self.main), add as raw code `{self.main}`." ) return self.main return ""