summaryrefslogtreecommitdiffstats
path: root/src/lib/Server
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2008-06-12 02:42:22 +0000
committerNarayan Desai <desai@mcs.anl.gov>2008-06-12 02:42:22 +0000
commitea1933c469bdef124288010ec8992fbbf840cb83 (patch)
tree2433c6613d59ef7bc09b91d04bd38da5a112b586 /src/lib/Server
parent93baa718c3182f3b2b59280ac141e71a4a75b29c (diff)
downloadbcfg2-ea1933c469bdef124288010ec8992fbbf840cb83.tar.gz
bcfg2-ea1933c469bdef124288010ec8992fbbf840cb83.tar.bz2
bcfg2-ea1933c469bdef124288010ec8992fbbf840cb83.zip
Switch Pkgmgr to using sets (for a 10X startup improvement)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4694 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server')
-rw-r--r--src/lib/Server/Plugins/Pkgmgr.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/lib/Server/Plugins/Pkgmgr.py b/src/lib/Server/Plugins/Pkgmgr.py
index 27f5b44b1..667664bf3 100644
--- a/src/lib/Server/Plugins/Pkgmgr.py
+++ b/src/lib/Server/Plugins/Pkgmgr.py
@@ -5,6 +5,14 @@ import logging, re, Bcfg2.Server.Plugin
logger = logging.getLogger('Bcfg2.Plugins.Pkgmgr')
+try:
+ pdlist = set
+except:
+ class pdlist(list):
+ def add(self, item):
+ if item not in self:
+ self.append(item)
+
class FuzzyDict(dict):
fuzzy = re.compile('(?P<name>.*):(?P<alist>\S+(,\S+)*)')
def __getitem__(self, key):
@@ -53,7 +61,7 @@ class PNode(Bcfg2.Server.Plugin.INode):
def __init__(self, data, pdict, parent=None):
# copy local attributes to all child nodes if no local attribute exists
if not pdict.has_key('Package'):
- pdict['Package'] = []
+ pdict['Package'] = pdlist()
for child in data.getchildren():
for attr in [key for key in data.attrib.keys() \
if key != 'name' and not child.attrib.has_key(key)]:
@@ -67,7 +75,7 @@ class PNode(Bcfg2.Server.Plugin.INode):
self.contents['Package'] = FuzzyDict()
for pkg in data.findall('./Package'):
if pkg.attrib.has_key('name') and pkg.get('name') not in pdict['Package']:
- pdict['Package'].append(pkg.get('name'))
+ pdict['Package'].add(pkg.get('name'))
if pkg.get('name') != None:
self.contents['Package'][pkg.get('name')] = {}
if pkg.getchildren():