MCPcopy Create free account
hub / github.com/catboost/catboost / repl

Function repl

library/python/runtime/entry_points.py:6–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4
5
6def repl():
7 user_ns = {}
8 py_main = __res.find('PY_MAIN')
9
10 if py_main:
11 py_main_split = py_main.split(':', 1)
12 if len(py_main_split) == 2:
13 mod_name, func_name = py_main_split
14 else:
15 mod_name, func_name = py_main_split[0], 'main'
16
17 if not mod_name:
18 mod_name = 'library.python.runtime.entry_points'
19
20 try:
21 import importlib
22 mod = importlib.import_module(mod_name)
23 user_ns = mod.__dict__
24 except: # noqa E722
25 import traceback
26 traceback.print_exc()
27
28 if '__main__' not in user_ns:
29 def run(args):
30 if isinstance(args, basestring):
31 import shlex
32 args = shlex.split(args)
33
34 import sys
35 sys.argv = [sys.argv[0]] + args
36 getattr(mod, func_name)()
37
38 user_ns['__main__'] = run
39 else:
40 try:
41 mod = __res.importer.load_module('__main__', fix_name='__main_real')
42 user_ns = mod.__dict__
43 except ImportError:
44 pass
45
46 try:
47 import IPython
48 except ImportError:
49 import code
50 code.interact(local=user_ns)
51 else:
52 IPython.start_ipython(user_ns=user_ns)
53
54
55def resource_files():

Callers

nothing calls this directly

Calls 4

lenFunction · 0.85
load_moduleMethod · 0.80
findMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected