section structure in avp files
This commit is contained in:
parent
0bef283f8d
commit
f0ab2f53d6
38
main.py
38
main.py
|
@ -473,6 +473,7 @@ class Main(QtCore.QObject):
|
||||||
if not filepath.endswith(".avp"):
|
if not filepath.endswith(".avp"):
|
||||||
filepath += '.avp'
|
filepath += '.avp'
|
||||||
with open(filepath, 'w') as f:
|
with open(filepath, 'w') as f:
|
||||||
|
f.write('[Components]\n')
|
||||||
for comp in self.selectedComponents:
|
for comp in self.selectedComponents:
|
||||||
saveValueStore = comp.savePreset()
|
saveValueStore = comp.savePreset()
|
||||||
f.write('%s\n' % str(comp))
|
f.write('%s\n' % str(comp))
|
||||||
|
@ -496,20 +497,35 @@ class Main(QtCore.QObject):
|
||||||
self.settings.setValue("lastProject", filepath)
|
self.settings.setValue("lastProject", filepath)
|
||||||
self.settings.setValue("projectDir", os.path.dirname(filepath))
|
self.settings.setValue("projectDir", os.path.dirname(filepath))
|
||||||
compNames = [mod.Component.__doc__ for mod in self.modules]
|
compNames = [mod.Component.__doc__ for mod in self.modules]
|
||||||
|
|
||||||
with open(filepath, 'r') as f:
|
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
|
i = 0
|
||||||
for line in f:
|
for line in f:
|
||||||
if i == 0:
|
line, newSection = parseLine(line)
|
||||||
compIndex = compNames.index(line.strip())
|
if newSection:
|
||||||
self.addComponent(compIndex)
|
section = str(newSection)
|
||||||
i += 1
|
continue
|
||||||
elif i == 1:
|
if line and section == 'Components':
|
||||||
# version, not used yet
|
if i == 0:
|
||||||
i += 1
|
compIndex = compNames.index(line.strip())
|
||||||
elif i == 2:
|
self.addComponent(compIndex)
|
||||||
saveValueStore = eval(line.strip())
|
i += 1
|
||||||
self.selectedComponents[-1].loadPreset(saveValueStore)
|
elif i == 1:
|
||||||
i = 0
|
# 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):
|
def showMessage(self, string, icon=QtGui.QMessageBox.Information, showCancel=False):
|
||||||
msg = QtGui.QMessageBox()
|
msg = QtGui.QMessageBox()
|
||||||
|
|
Reference in New Issue