MCPcopy Index your code
hub / github.com/python/cpython / open

Method open

Lib/idlelib/filelist.py:18–42  ·  view source on GitHub ↗
(self, filename, action=None)

Source from the content-addressed store, hash-verified

16 self.vars = {} # For EditorWindow.getrawvar (shared Tcl variables)
17
18 def open(self, filename, action=None):
19 assert filename
20 filename = self.canonize(filename)
21 if os.path.isdir(filename):
22 # This can happen when bad filename is passed on command line:
23 messagebox.showerror(
24 "File Error",
25 f"{filename!r} is a directory.",
26 master=self.root)
27 return None
28 key = os.path.normcase(filename)
29 if key in self.dict:
30 edit = self.dict[key]
31 edit.top.wakeup()
32 return edit
33 if action:
34 # Don't create window, perform 'action', e.g. open in same window
35 return action(filename)
36 else:
37 edit = self.EditorWindow(self, filename, key)
38 if edit.good_load:
39 return edit
40 else:
41 edit._close()
42 return None
43
44 def gotofileline(self, filename, lineno=None):
45 edit = self.open(filename)

Callers 1

gotofilelineMethod · 0.95

Calls 6

canonizeMethod · 0.95
_closeMethod · 0.95
normcaseMethod · 0.80
isdirMethod · 0.45
showerrorMethod · 0.45
wakeupMethod · 0.45

Tested by

no test coverage detected