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)
| 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 | |
| 145 | class IdleConf: |
| 146 | """Hold config parsers for all idle config files in singleton instance. |