diff options
| author | tassaron | 2017-06-03 11:08:52 -0400 |
|---|---|---|
| committer | tassaron | 2017-06-03 11:08:52 -0400 |
| commit | f0ab2f53d6e5b44fa4e763a204b0c5034808551b (patch) | |
| tree | 1d01a6cbecd6b93e0951493337b5d2402e79accf /main.py | |
| parent | 0bef283f8d4538a6a3cff740a530973e745ad9c8 (diff) | |
section structure in avp files
Diffstat (limited to 'main.py')
| -rw-r--r-- | main.py | 38 |
1 files changed, 27 insertions, 11 deletions
@@ -473,6 +473,7 @@ class Main(QtCore.QObject): if not filepath.endswith(".avp"): filepath += '.avp' with open(filepath, 'w') as f: + f.write('[Components]\n') for comp in self.selectedComponents: saveValueStore = comp.savePreset() f.write('%s\n' % str(comp)) @@ -496,20 +497,35 @@ class Main(QtCore.QObject): self.settings.setValue("lastProject", filepath) self.settings.setValue("projectDir", os.path.dirname(filepath)) compNames = [mod.Component.__doc__ for mod in self.modules] + with open(filepath, 'r') as f: + validSections = ('Components') + section = '' + def parseLine(line): + line = line.strip() + newSection = '' + if line.startswith('[') and line.endswith(']') and line[1:-1] in validSections: + newSection = line[1:-1] + return line, newSection + i = 0 for line in f: - if i == 0: - compIndex = compNames.index(line.strip()) - self.addComponent(compIndex) - i += 1 - elif i == 1: - # version, not used yet - i += 1 - elif i == 2: - saveValueStore = eval(line.strip()) - self.selectedComponents[-1].loadPreset(saveValueStore) - i = 0 + line, newSection = parseLine(line) + if newSection: + section = str(newSection) + continue + if line and section == 'Components': + if i == 0: + compIndex = compNames.index(line.strip()) + self.addComponent(compIndex) + i += 1 + elif i == 1: + # version, not used yet + i += 1 + elif i == 2: + saveValueStore = eval(line.strip()) + self.selectedComponents[-1].loadPreset(saveValueStore) + i = 0 def showMessage(self, string, icon=QtGui.QMessageBox.Information, showCancel=False): msg = QtGui.QMessageBox() |
