From e825d589c7cf55c95029d99822e71437fd3a79c6 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Fri, 29 Oct 2004 15:13:44 +0000 Subject: make hierarchical files work (Logical change 1.123) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@552 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Structures/Base.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/lib/Server/Structures/Base.py b/src/lib/Server/Structures/Base.py index 9c6eaf573..16719e424 100644 --- a/src/lib/Server/Structures/Base.py +++ b/src/lib/Server/Structures/Base.py @@ -14,14 +14,17 @@ class BaseFile(SingleXMLFileBacked): def Index(self): '''Store XML data in reasonable structures''' - self.store = {} + self.store = {'Class':{'all':[]}, 'Image':{'all':[]}, 'all':[]} for entry in XML(self.data).getchildren(): - self.store[entry.tag][entry.get('name')] = {'all':[], 'Class':{}} - for child in entry.getchildren(): - if child.tag in ['Image', 'Class']: - self.store[entry.tag][child.tag][child.get('name')] = child.getchildren() - else: - self.store[entry.tag]['all'].append(child) + self.store[entry.tag][entry.get('name')] = {'all':[], 'Class':{}, 'Image':{}} + if entry.tag in ['Image', 'Class']: + for child in entry.getchildren(): + if child.tag in ['Image', 'Class']: + self.store[entry.tag][entry.get('name')][child.tag][child.get('name')] = child.getchildren() + else: + self.store[entry.tag][entry.get('name')]['all'].append(child) + else: + self.store[entry.tag]['all'].append(child) def Construct(self, metadata): '''Build structures for client described by metadata''' -- cgit v1.2.3-1-g7c22