6 def check_has_dir_in_path(dirname
):
7 return sys
.path
.__contains
__(dirname
)
10 def ensure_has_dir_in_path(dirname
):
11 dirname
= os
.path
.abspath(dirname
)
12 if not (check_has_dir_in_path(dirname
)):
13 sys
.path
.append(dirname
)
16 def do_import(debugger
, modname
):
17 if len(modname
) > 4 and modname
[-4:] == ".pyc":
18 modname
= modname
[:-4]
19 if len(modname
) > 3 and modname
[-3:] == ".py":
20 modname
= modname
[:-3]
21 debugger
.HandleCommand("script import " + modname
)
24 def pyimport_cmd(debugger
, args
, result
, dict):
25 """Import a Python module given its full path"""
26 print('WARNING: obsolete feature - use native command "command script import"')
28 return "no module path given"
29 if not (os
.sep
in args
):
31 ensure_has_dir_in_path(".")
33 endofdir
= args
.rfind(os
.sep
)
34 modname
= args
[endofdir
+ 1 :]
35 args
= args
[0:endofdir
]
36 ensure_has_dir_in_path(args
)
37 do_import(debugger
, modname
)