File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 44- 2022.08.28
55 - add ` -q ` for quiet mode
66 - ` -qqqqq ` to mute all the logs
7- - ` -m ` support source code with ';' like python -c
7+ - ` -m ` support source code mode while not matched ` module.submodule:function ` format
8+ - like ` python -c "python code" `
89 - demo: ` python -m zipapps -m "import six; print(six.__file__)" `
9- - WARN: source code should contains ` ; `
10+ - WARN: only when ` -m ` not matched regex ` r'^\w+(\.\w+)?(:\w+)?$' `
1011
1112- 2022.04.27
1213 - handle PermissionError for chmod
Original file line number Diff line number Diff line change @@ -324,9 +324,7 @@ def prepare_active_zipapps(self):
324324
325325 def make_runner ():
326326 if self .main :
327- if ';' in self .main :
328- return self .main
329- else :
327+ if re .match (r'^\w+(\.\w+)?(:\w+)?$' , self .main ):
330328 module , _ , function = self .main .partition (':' )
331329 if module :
332330 # main may be: 'module.py:main' or 'module.submodule:main'
@@ -337,7 +335,15 @@ def make_runner():
337335 runner = f'import { module } '
338336 if function :
339337 runner += f'; { module } .{ function } ()'
338+ self ._log (
339+ f"[INFO]: -m: matches re.match(r'^\w+(\.\w+)?(:\w+)?$', self.main), add as `{ runner } `."
340+ )
340341 return runner
342+ else :
343+ self ._log (
344+ f"[INFO]: -m: not matches re.match(r'^\w+(\.\w+)?(:\w+)?$', self.main), add as raw code `{ self .main } `."
345+ )
346+ return self .main
341347 return ''
342348
343349 kwargs = {
You can’t perform that action at this time.
0 commit comments