From d5bd77c4c61c49589616cbe9c854b5cba19b5193 Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Fri, 21 Oct 2011 15:25:49 -0400 Subject: [PATCH] use sfa.util.xml.XML instead for xml.util.rspec.RecordSpec --- sfa/server/interface.py | 2 +- sfa/util/storage.py | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/sfa/server/interface.py b/sfa/server/interface.py index baeb2e79..b7111e2a 100644 --- a/sfa/server/interface.py +++ b/sfa/server/interface.py @@ -64,7 +64,7 @@ class Interfaces(dict): # load config file self.interface_info = XmlStorage(conf_file, self.default_dict) self.interface_info.load() - records = self.interface_info.values()[0].values()[0] + records = self.interface_info.values()[0] if not isinstance(records, list): records = [records] diff --git a/sfa/util/storage.py b/sfa/util/storage.py index f80e2ff8..ee2e41b8 100644 --- a/sfa/util/storage.py +++ b/sfa/util/storage.py @@ -1,5 +1,5 @@ import os - +from sfa.util.xml import XML class SimpleStorage(dict): """ Handles storing and loading python dictionaries. The storage file created @@ -44,10 +44,9 @@ class XmlStorage(SimpleStorage): """ Parse an xml file and store it as a dict """ - data = RecordSpec() if os.path.exists(self.db_filename) and os.path.isfile(self.db_filename): - data.parseFile(self.db_filename) - dict.__init__(self, data.toDict()) + xml = XML(self.db_filename) + dict.__init__(self, xml.todict()) elif os.path.exists(self.db_filename) and not os.path.isfile(self.db_filename): raise IOError, '%s exists but is not a file. please remove it and try again' \ % self.db_filename @@ -56,8 +55,8 @@ class XmlStorage(SimpleStorage): self.load() def write(self): - data = RecordSpec() - data.parseDict(self) + xml = XML() + xml.parseDict(self) db_file = open(self.db_filename, 'w') db_file.write(data.toprettyxml()) db_file.close() -- 2.43.0