From 2c82a65d1b79b898b2bc27fc5b1e0362fc160c46 Mon Sep 17 00:00:00 2001 From: tassaron Date: Sun, 25 Jun 2017 15:50:31 -0400 Subject: needs more tuples --- src/core.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'src/core.py') diff --git a/src/core.py b/src/core.py index 341aa01..2994a24 100644 --- a/src/core.py +++ b/src/core.py @@ -180,16 +180,14 @@ class Core(): if errcode == 0: try: if hasattr(loader, 'window'): - for pair in data['WindowFields']: - widget, value = pair.split('=', 1) + for widget, value in data['WindowFields']: widget = eval('loader.window.%s' % widget) widget.blockSignals(True) - widget.setText(value.strip()) + widget.setText(value) widget.blockSignals(False) - for pair in data['Settings']: - key, value = pair.split('=', 1) - self.settings.setValue(key, value.strip()) + for key, value in data['Settings']: + self.settings.setValue(key, value) for tup in data['Components']: name, vers, preset = tup @@ -264,16 +262,16 @@ class Core(): Returns dictionary with section names as the keys, each one contains a list of tuples: (compName, version, compPresetDict) ''' - data = {} + validSections = ( + 'Components', + 'Settings', + 'WindowFields' + ) + data = {sect: [] for sect in validSections} try: with open(filepath, 'r') as f: def parseLine(line): '''Decides if a file line is a section header''' - validSections = ( - 'Components', - 'Settings', - 'WindowFields' - ) line = line.strip() newSection = '' @@ -289,7 +287,6 @@ class Core(): line, newSection = parseLine(line) if newSection: section = str(newSection) - data[section] = [] continue if line and section == 'Components': if i == 0: @@ -307,7 +304,9 @@ class Core(): )) i = 0 elif line and section: - data[section].append(line) + key, value = line.split('=', 1) + data[section].append((key, value.strip())) + return 0, data except: return 1, sys.exc_info() -- cgit v1.2.3