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

Method open

Lib/idlelib/iomenu.py:77–119  ·  view source on GitHub ↗
(self, event=None, editFile=None)

Source from the content-addressed store, hash-verified

75 self.filename_change_hook()
76
77 def open(self, event=None, editFile=None):
78 flist = self.editwin.flist
79 # Save in case parent window is closed (ie, during askopenfile()).
80 if flist:
81 if not editFile:
82 filename = self.askopenfile()
83 else:
84 filename=editFile
85 if filename:
86 # If editFile is valid and already open, flist.open will
87 # shift focus to its existing window.
88 # If the current window exists and is a fresh unnamed,
89 # unmodified editor window (not an interpreter shell),
90 # pass self.loadfile to flist.open so it will load the file
91 # in the current window (if the file is not already open)
92 # instead of a new window.
93 if (self.editwin and
94 not getattr(self.editwin, 'interp', None) and
95 not self.filename and
96 self.get_saved()):
97 flist.open(filename, self.loadfile)
98 else:
99 flist.open(filename)
100 else:
101 if self.text:
102 self.text.focus_set()
103 return "break"
104
105 # Code for use outside IDLE:
106 if self.get_saved():
107 reply = self.maybesave()
108 if reply == "cancel":
109 self.text.focus_set()
110 return "break"
111 if not editFile:
112 filename = self.askopenfile()
113 else:
114 filename=editFile
115 if filename:
116 self.loadfile(filename)
117 else:
118 self.text.focus_set()
119 return "break"
120
121 eol_convention = os.linesep # default
122

Callers 1

loadfileMethod · 0.45

Calls 5

askopenfileMethod · 0.95
get_savedMethod · 0.95
maybesaveMethod · 0.95
loadfileMethod · 0.95
focus_setMethod · 0.45

Tested by

no test coverage detected