Show More
@@ -19,6 +19,7 b' import os' | |||||
19 | import sys |
|
19 | import sys | |
20 | import time |
|
20 | import time | |
21 | from StringIO import StringIO |
|
21 | from StringIO import StringIO | |
|
22 | from glob import glob | |||
22 |
|
23 | |||
23 | # cProfile was added in Python2.5 |
|
24 | # cProfile was added in Python2.5 | |
24 | try: |
|
25 | try: | |
@@ -48,6 +49,17 b' from IPython.utils.path import get_py_filename, unquote_filename' | |||||
48 | from IPython.utils.timing import clock, clock2 |
|
49 | from IPython.utils.timing import clock, clock2 | |
49 | from IPython.utils.warn import warn, error |
|
50 | from IPython.utils.warn import warn, error | |
50 |
|
51 | |||
|
52 | ||||
|
53 | def globlist(args): | |||
|
54 | """ | |||
|
55 | Do glob expansion for each element in `args` and return concatenated list. | |||
|
56 | """ | |||
|
57 | expanded = [] | |||
|
58 | for a in args: | |||
|
59 | expanded.extend(glob(a)) | |||
|
60 | return expanded | |||
|
61 | ||||
|
62 | ||||
51 | #----------------------------------------------------------------------------- |
|
63 | #----------------------------------------------------------------------------- | |
52 | # Magic implementation classes |
|
64 | # Magic implementation classes | |
53 | #----------------------------------------------------------------------------- |
|
65 | #----------------------------------------------------------------------------- | |
@@ -447,10 +459,14 b' python-profiler package from non-free.""")' | |||||
447 |
|
459 | |||
448 | will run the example module. |
|
460 | will run the example module. | |
449 |
|
461 | |||
|
462 | -g: enables shell-like glob expansion of arguments to the script | |||
|
463 | to run. Patterns '*', '?', '[seq]' and '[!seq]' can be used. | |||
|
464 | ||||
450 | """ |
|
465 | """ | |
451 |
|
466 | |||
452 | # get arguments and set sys.argv for program to be run. |
|
467 | # get arguments and set sys.argv for program to be run. | |
453 |
opts, arg_lst = self.parse_options(parameter_s, |
|
468 | opts, arg_lst = self.parse_options(parameter_s, | |
|
469 | 'nidtN:b:pD:l:rs:T:em:g', | |||
454 | mode='list', list_all=1) |
|
470 | mode='list', list_all=1) | |
455 | if "m" in opts: |
|
471 | if "m" in opts: | |
456 | modulename = opts["m"][0] |
|
472 | modulename = opts["m"][0] | |
@@ -487,6 +503,10 b' python-profiler package from non-free.""")' | |||||
487 | # simulate shell expansion on arguments, at least tilde expansion |
|
503 | # simulate shell expansion on arguments, at least tilde expansion | |
488 | args = [ os.path.expanduser(a) for a in arg_lst[1:] ] |
|
504 | args = [ os.path.expanduser(a) for a in arg_lst[1:] ] | |
489 |
|
505 | |||
|
506 | # glob expansion | |||
|
507 | if 'g' in opts: | |||
|
508 | args = globlist(args) | |||
|
509 | ||||
490 | sys.argv = [filename] + args # put in the proper filename |
|
510 | sys.argv = [filename] + args # put in the proper filename | |
491 | # protect sys.argv from potential unicode strings on Python 2: |
|
511 | # protect sys.argv from potential unicode strings on Python 2: | |
492 | if not py3compat.PY3: |
|
512 | if not py3compat.PY3: |
General Comments 0
You need to be logged in to leave comments.
Login now