sync with genscripts rev 343. This adds the initial py3k support and the analyse...
authorPaul Varner <fuzzyray@gentoo.org>
Tue, 9 Mar 2010 16:42:04 +0000 (16:42 +0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 19 Jan 2013 04:59:00 +0000 (20:59 -0800)
svn path=/trunk/gentoolkit/; revision=751

http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=2f90a4b9ceff920f793541376da21d313af083d9

bin/glsa-check [changed mode: 0644->0755]
pym/portage/glsa.py

old mode 100644 (file)
new mode 100755 (executable)
index 2b21d71..3d047b5
@@ -142,6 +142,13 @@ for p in params[:]:
 glsalist.extend([g for g in params if g not in glsalist])
 
 def summarylist(myglsalist, fd1=sys.stdout, fd2=sys.stderr, encoding="utf-8"):
+       # Get to the raw streams in py3k before wrapping them with an encoded writer
+       # to avoid writing bytes to a text stream (stdout/stderr are text streams
+       # by default in py3k)
+       if hasattr(fd1, "buffer"):
+               fd1 = fd1.buffer
+       if hasattr(fd2, "buffer"):
+               fd2 = fd2.buffer
        fd1 = codecs.getwriter(encoding)(fd1)
        fd2 = codecs.getwriter(encoding)(fd2)
        fd2.write(white("[A]")+" means this GLSA was marked as applied (injected),\n")
index 155d3e5436509d53c0a297384b5adc271d118b9b..c0c69dd2d383bc59718ea45222fd5b95537a8e62 100644 (file)
@@ -14,6 +14,7 @@ import re
 import operator
 import xml.dom.minidom
 from io import StringIO
+from functools import reduce
 
 import portage
 from portage import os
@@ -526,17 +527,17 @@ class Glsa:
                self.synopsis = getText(myroot.getElementsByTagName("synopsis")[0], format="strip")
                self.announced = format_date(getText(myroot.getElementsByTagName("announced")[0], format="strip"))
 
-               count = 1
                # Support both formats of revised:
                # <revised>December 30, 2007: 02</revised>
                # <revised count="2">2007-12-30</revised>
                revisedEl = myroot.getElementsByTagName("revised")[0]
                self.revised = getText(revisedEl, format="strip")
-               if ((sys.hexversion >= 0x3000000 and "count" in revisedEl.attributes) or
-                       (sys.hexversion < 0x3000000 and revisedEl.attributes.has_key("count"))):
-                       count = revisedEl.getAttribute("count")
-               elif (self.revised.find(":") >= 0):
-                       (self.revised, count) = self.revised.split(":")
+               count = revisedEl.attributes.get("count")
+               if count is None:
+                       if self.revised.find(":") >= 0:
+                               (self.revised, count) = self.revised.split(":")
+                       else:
+                               count = 1
 
                self.revised = format_date(self.revised)