* [gentoo-commits] gentoolkit r644 - branches/gentoolkit-0.2.4/src/glsa-check
@ 2009-05-20 21:12 Paul Varner (fuzzyray)
0 siblings, 0 replies; only message in thread
From: Paul Varner (fuzzyray) @ 2009-05-20 21:12 UTC (permalink / raw
To: gentoo-commits
Author: fuzzyray
Date: 2009-05-20 21:12:34 +0000 (Wed, 20 May 2009)
New Revision: 644
Modified:
branches/gentoolkit-0.2.4/src/glsa-check/glsa-check
branches/gentoolkit-0.2.4/src/glsa-check/glsa.py
Log:
Some python tweaks to speed glsa-check
Modified: branches/gentoolkit-0.2.4/src/glsa-check/glsa-check
===================================================================
--- branches/gentoolkit-0.2.4/src/glsa-check/glsa-check 2009-05-20 21:10:44 UTC (rev 643)
+++ branches/gentoolkit-0.2.4/src/glsa-check/glsa-check 2009-05-20 21:12:34 UTC (rev 644)
@@ -132,7 +132,7 @@
sys.stderr.write("\n" + msg)
sys.exit(1)
-# we need root priviledges for write access
+# we need root privileges for write access
if mode in ["fix", "inject"] and os.geteuid() != 0:
sys.stderr.write(__program__ + ": root access is needed for \""+mode+"\" mode\n")
sys.exit(2)
Modified: branches/gentoolkit-0.2.4/src/glsa-check/glsa.py
===================================================================
--- branches/gentoolkit-0.2.4/src/glsa-check/glsa.py 2009-05-20 21:10:44 UTC (rev 643)
+++ branches/gentoolkit-0.2.4/src/glsa-check/glsa.py 2009-05-20 21:12:34 UTC (rev 644)
@@ -18,6 +18,7 @@
import urllib
import codecs
import re
+import operator
import xml.dom.minidom
from StringIO import StringIO
@@ -153,7 +154,7 @@
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 @@
@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 @@
@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 @@
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 @@
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")
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-05-20 21:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-20 21:12 [gentoo-commits] gentoolkit r644 - branches/gentoolkit-0.2.4/src/glsa-check Paul Varner (fuzzyray)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox