MCPcopy Index your code
hub / github.com/bpython/bpython / main

Function main

bpdb/__init__.py:70–121  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

68
69
70def main():
71 parser = OptionParser(usage="Usage: %prog [options] [file [args]]")
72 parser.add_option(
73 "--version", "-V", action="store_true", help="Print version and exit."
74 )
75 options, args = parser.parse_args(sys.argv)
76 if options.version:
77 print(version_banner(base="bpdb"))
78 print(copyright_banner())
79 return 0
80
81 if len(args) < 2:
82 print("usage: bpdb scriptfile [arg] ...")
83 return 2
84
85 # The following code is based on Python's pdb.py.
86 mainpyfile = args[1]
87 if not os.path.exists(mainpyfile):
88 print(f"Error: {mainpyfile} does not exist.")
89 return 1
90
91 # Hide bpdb from argument list.
92 del sys.argv[0]
93
94 # Replace bpdb's dir with script's dir in front of module search path.
95 sys.path[0] = os.path.dirname(mainpyfile)
96
97 pdb = BPdb()
98 while True:
99 try:
100 pdb._runscript(mainpyfile)
101 if pdb._user_requested_quit:
102 break
103 print("The program finished and will be restarted.")
104 except Restart:
105 print(f"Restarting {mainpyfile} with arguments:")
106 print("\t" + " ".join(sys.argv[1:]))
107 except SystemExit:
108 # In most cases SystemExit does not warrant a post-mortem session.
109 print(
110 "The program exited via sys.exit(). Exit status: ",
111 )
112 print(sys.exc_info()[1])
113 except:
114 traceback.print_exc()
115 print("Uncaught exception. Entering post mortem debugging.")
116 print("Running 'cont' or 'step' will restart the program.")
117 t = sys.exc_info()[2]
118 pdb.interaction(None, t)
119 print(
120 f"Post mortem debugger finished. The {mainpyfile} will be restarted."
121 )

Callers 1

__main__.pyFile · 0.70

Calls 3

version_bannerFunction · 0.90
copyright_bannerFunction · 0.90
BPdbClass · 0.85

Tested by

no test coverage detected