File tree 1 file changed +4
-10
lines changed
1 file changed +4
-10
lines changed Original file line number Diff line number Diff line change 4
4
5
5
from __future__ import print_function
6
6
import os
7
- import os .path
8
7
import sys
9
8
import code
10
9
from optparse import OptionParser , OptionGroup
@@ -111,15 +110,10 @@ def exec_code(interpreter, args):
111
110
Helper to execute code in a given interpreter. args should be a [faked]
112
111
sys.argv
113
112
"""
114
- plusmain = os .path .join (args [0 ], '__main__.py' )
115
- if os .path .isdir (args [0 ]) and os .path .exists (plusmain ):
116
- path = plusmain
117
- else :
118
- path = args [0 ]
119
- with open (path , 'r' ) as sourcefile :
113
+ with open (args [0 ], 'r' ) as sourcefile :
120
114
source = sourcefile .read ()
121
115
old_argv , sys .argv = sys .argv , args
122
- sys .path .insert (0 , os .path .abspath (os .path .dirname (path )))
123
- interpreter .locals ['__file__' ] = path
124
- interpreter .runsource (source , path , 'exec' )
116
+ sys .path .insert (0 , os .path .abspath (os .path .dirname (args [ 0 ] )))
117
+ interpreter .locals ['__file__' ] = args [ 0 ]
118
+ interpreter .runsource (source , args [ 0 ] , 'exec' )
125
119
sys .argv = old_argv
You can’t perform that action at this time.
0 commit comments