1import sys,os,lldb
2def check_has_dir_in_path(dirname):
3	return sys.path.__contains__(dirname);
4
5def ensure_has_dir_in_path(dirname):
6	dirname = os.path.abspath(dirname)
7	if not (check_has_dir_in_path(dirname)):
8		sys.path.append(dirname);
9
10def do_import(debugger,modname):
11	if (len(modname) > 4 and modname[-4:] == '.pyc'):
12		modname = modname[:-4]
13	if (len(modname) > 3 and modname[-3:] == '.py'):
14		modname = modname[:-3]
15	debugger.HandleCommand("script import " + modname)
16
17def pyimport_cmd(debugger, args, result, dict):
18	"""Import a Python module given its full path"""
19	print 'WARNING: obsolete feature - use native command "command script import"'
20	if args == "":
21		return "no module path given";
22	if not (os.sep in args):
23		modname = args
24		ensure_has_dir_in_path('.')
25	else:
26		endofdir = args.rfind(os.sep)
27		modname = args[endofdir+1:]
28		args = args[0:endofdir]
29		ensure_has_dir_in_path(args)
30	do_import(debugger,modname)
31	return None
32