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 4
4
- 2022.08.28
5
5
- add ` -q ` for quiet mode
6
6
- ` -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" `
8
9
- 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+)?$' `
10
11
11
12
- 2022.04.27
12
13
- handle PermissionError for chmod
Original file line number Diff line number Diff line change @@ -324,9 +324,7 @@ def prepare_active_zipapps(self):
324
324
325
325
def make_runner ():
326
326
if self .main :
327
- if ';' in self .main :
328
- return self .main
329
- else :
327
+ if re .match (r'^\w+(\.\w+)?(:\w+)?$' , self .main ):
330
328
module , _ , function = self .main .partition (':' )
331
329
if module :
332
330
# main may be: 'module.py:main' or 'module.submodule:main'
@@ -337,7 +335,15 @@ def make_runner():
337
335
runner = f'import { module } '
338
336
if function :
339
337
runner += f'; { module } .{ function } ()'
338
+ self ._log (
339
+ f"[INFO]: -m: matches re.match(r'^\w+(\.\w+)?(:\w+)?$', self.main), add as `{ runner } `."
340
+ )
340
341
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
341
347
return ''
342
348
343
349
kwargs = {
You can’t perform that action at this time.
0 commit comments