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

Method Save

Lib/idlelib/config.py:126–143  ·  view source on GitHub ↗

Update user configuration file. If self not empty after removing empty sections, write the file to disk. Otherwise, remove the file from disk if it exists.

(self)

Source from the content-addressed store, hash-verified

124 return not self.sections()
125
126 def Save(self):
127 """Update user configuration file.
128
129 If self not empty after removing empty sections, write the file
130 to disk. Otherwise, remove the file from disk if it exists.
131 """
132 fname = self.file
133 if fname and fname[0] != '#':
134 if not self.IsEmpty():
135 try:
136 cfgFile = open(fname, 'w')
137 except OSError:
138 os.unlink(fname)
139 cfgFile = open(fname, 'w')
140 with cfgFile:
141 self.write(cfgFile)
142 elif os.path.exists(self.file):
143 os.remove(self.file)
144
145class IdleConf:
146 """Hold config parsers for all idle config files in singleton instance.

Callers 5

SaveUserCfgFilesMethod · 0.80
save_allMethod · 0.80
delete_sectionMethod · 0.80
test_saveMethod · 0.80

Calls 6

IsEmptyMethod · 0.95
openFunction · 0.50
unlinkMethod · 0.45
writeMethod · 0.45
existsMethod · 0.45
removeMethod · 0.45

Tested by 1

test_saveMethod · 0.64