aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfuzzyray <fuzzyray@gentoo.org>2009-05-20 21:44:13 +0000
committerfuzzyray <fuzzyray@gentoo.org>2009-05-20 21:44:13 +0000
commit10e55d71bd5914fc7c9082adadf7bde2bec14ae3 (patch)
tree4b22ea2c4ecc6ee0469e2df3cafa0b7ed4fb7ed1 /pym/gentoolkit
parentHandle unicode encoding when dumping to stdout and start migration to using S... (diff)
downloadgentoolkit-10e55d71bd5914fc7c9082adadf7bde2bec14ae3.tar.gz
gentoolkit-10e55d71bd5914fc7c9082adadf7bde2bec14ae3.tar.bz2
gentoolkit-10e55d71bd5914fc7c9082adadf7bde2bec14ae3.zip
Some python tweaks to speed glsa-check
svn path=/trunk/gentoolkit/; revision=646
Diffstat (limited to 'pym/gentoolkit')
-rw-r--r--pym/gentoolkit/glsa/__init__.py37
1 files changed, 12 insertions, 25 deletions
diff --git a/pym/gentoolkit/glsa/__init__.py b/pym/gentoolkit/glsa/__init__.py
index b325bd5..cc80517 100644
--- a/pym/gentoolkit/glsa/__init__.py
+++ b/pym/gentoolkit/glsa/__init__.py
@@ -18,6 +18,7 @@ import sys
import urllib
import codecs
import re
+import operator
import xml.dom.minidom
from StringIO import StringIO
@@ -153,7 +154,7 @@ def get_glsa_list(repository, myconfig):
for f in dirlist:
try:
- if f[:len(prefix)] == prefix:
+ if f[:len(prefix)] == prefix and f[-1*len(suffix):] == suffix:
rValue.append(f[len(prefix):-1*len(suffix)])
except IndexError:
pass
@@ -168,13 +169,11 @@ def getListElements(listnode):
@rtype: List of Strings
@return: a list that contains the value of the <li> elements
"""
- rValue = []
if not listnode.nodeName in ["ul", "ol"]:
raise GlsaFormatException("Invalid function call: listnode is not <ul> or <ol>")
- for li in listnode.childNodes:
- if li.nodeType != xml.dom.Node.ELEMENT_NODE:
- continue
- rValue.append(getText(li, format="strip"))
+ rValue = [getText(li, format="strip") \
+ for li in listnode.childNodes \
+ if li.nodeType == xml.dom.Node.ELEMENT_NODE]
return rValue
def getText(node, format, textfd = None):
@@ -262,9 +261,8 @@ def getMultiTagsText(rootnode, tagname, format):
@rtype: List of Strings
@return: a list containing the text of all I{tagname} childnodes
"""
- rValue = []
- for e in rootnode.getElementsByTagName(tagname):
- rValue.append(getText(e, format))
+ rValue = [getText(e, format) \
+ for e in rootnode.getElementsByTagName(tagname)]
return rValue
def makeAtom(pkgname, versionNode):
@@ -396,13 +394,8 @@ def getMinUpgrade(vulnerableList, unaffectedList, minimize=True):
the installed version.
"""
rValue = None
- v_installed = []
- u_installed = []
- for v in vulnerableList:
- v_installed += match(v, "vartree")
-
- for u in unaffectedList:
- u_installed += match(u, "vartree")
+ v_installed = reduce(operator.add, [match(v, "vartree") for v in vulnerableList], [])
+ u_installed = reduce(operator.add, [match(u, "vartree") for u in unaffectedList], [])
install_unaffected = True
for i in v_installed:
@@ -636,21 +629,15 @@ class Glsa:
pass
if len(self.bugs) > 0:
outstream.write("\nRelated bugs: ")
- for i in range(0, len(self.bugs)):
- outstream.write(self.bugs[i])
- if i < len(self.bugs)-1:
- outstream.write(", ")
- else:
- outstream.write("\n")
+ outstream.write(", ".join(self.bugs))
+ outstream.write("\n")
if self.background:
outstream.write("\n"+wrap(self.background, width, caption="Background: "))
outstream.write("\n"+wrap(self.description, width, caption="Description: "))
outstream.write("\n"+wrap(self.impact_text, width, caption="Impact: "))
outstream.write("\n"+wrap(self.workaround, width, caption="Workaround: "))
outstream.write("\n"+wrap(self.resolution, width, caption="Resolution: "))
- myreferences = ""
- for r in self.references:
- myreferences += (r.replace(" ", SPACE_ESCAPE)+NEWLINE_ESCAPE+" ")
+ myreferences = " ".join(r.replace(" ", SPACE_ESCAPE)+NEWLINE_ESCAPE for r in self.references)
outstream.write("\n"+wrap(myreferences, width, caption="References: "))
outstream.write("\n")