Skip to content

Commit

Permalink
fix python 3.12 regex pattern and f-string
Browse files Browse the repository at this point in the history
  • Loading branch information
lidong committed Jun 4, 2024
1 parent 43872df commit ab73d1b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions zipapps/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 ""
Expand Down

0 comments on commit ab73d1b

Please sign in to comment.