diff options
| author | genone <genone@gentoo.org> | 2004-12-08 10:13:33 +0000 |
|---|---|---|
| committer | genone <genone@gentoo.org> | 2004-12-08 10:13:33 +0000 |
| commit | 2f296d8ba4086481933cdf88f12fd7a159f11499 (patch) | |
| tree | fafa5dd2bb371b088d93b01d9b39747c6dfd2f88 /trunk/src/glsa-check | |
| parent | 0a60845755448c92c818a8a3c9d70b1c6c8f7ff3 (diff) | |
| download | gentoolkit-2f296d8ba4086481933cdf88f12fd7a159f11499.tar.gz | |
change the outfile parameter for Glsa.dump() from filename to filehandle
svn path=/; revision=178
Diffstat (limited to 'trunk/src/glsa-check')
| -rw-r--r-- | trunk/src/glsa-check/glsa.py | 56 |
1 files changed, 26 insertions, 30 deletions
diff --git a/trunk/src/glsa-check/glsa.py b/trunk/src/glsa-check/glsa.py index c142088..feef19f 100644 --- a/trunk/src/glsa-check/glsa.py +++ b/trunk/src/glsa-check/glsa.py @@ -494,61 +494,57 @@ class Glsa: self.services = self.affected.getElementsByTagName("service") return None - def dump(self, outfile="/dev/stdout", encoding="latin1"): + def dump(self, outstream=sys.stdout): """ Dumps a plaintext representation of this GLSA to I{outfile} or B{stdout} if it is ommitted. You can specify an alternate I{encoding} if needed (default is latin1). - @type outfile: String - @param outfile: Filename to dump the output in - (defaults to "/dev/stdout") - @type encoding: The encoding that should be used when writing - to I{outfile}. + @type outstream: File + @param outfile: Stream that should be used for writing + (defaults to sys.stdout) """ - myfile = codecs.open(outfile, "w", encoding) width = int(self.config["PRINTWIDTH"]) - myfile.write(center("GLSA %s: \n%s" % (self.nr, self.title), width)+"\n") - myfile.write((width*"=")+"\n") - myfile.write(wrap(self.synopsis, width, caption="Synopsis: ")+"\n") - myfile.write("Announced on: %s\n" % self.announced) - myfile.write("Last revised on: %s\n\n" % self.revised) + outstream.write(center("GLSA %s: \n%s" % (self.nr, self.title), width)+"\n") + outstream.write((width*"=")+"\n") + outstream.write(wrap(self.synopsis, width, caption="Synopsis: ")+"\n") + outstream.write("Announced on: %s\n" % self.announced) + outstream.write("Last revised on: %s\n\n" % self.revised) if self.glsatype == "ebuild": for k in self.packages.keys(): pkg = self.packages[k] for path in pkg: vul_vers = string.join(path["vul_vers"]) unaff_vers = string.join(path["unaff_vers"]) - myfile.write("Affected package: %s\n" % k) - myfile.write("Affected archs: ") + outstream.write("Affected package: %s\n" % k) + outstream.write("Affected archs: ") if path["arch"] == "*": - myfile.write("All\n") + outstream.write("All\n") else: - myfile.write("%s\n" % path["arch"]) - myfile.write("Vulnerable: %s\n" % vul_vers) - myfile.write("Unaffected: %s\n\n" % unaff_vers) + outstream.write("%s\n" % path["arch"]) + outstream.write("Vulnerable: %s\n" % vul_vers) + outstream.write("Unaffected: %s\n\n" % unaff_vers) elif self.glsatype == "infrastructure": pass if len(self.bugs) > 0: - myfile.write("\nRelated bugs: ") + outstream.write("\nRelated bugs: ") for i in range(0, len(self.bugs)): - myfile.write(self.bugs[i]) + outstream.write(self.bugs[i]) if i < len(self.bugs)-1: - myfile.write(", ") + outstream.write(", ") else: - myfile.write("\n") + outstream.write("\n") if self.background: - myfile.write("\n"+wrap(self.background, width, caption="Background: ")) - myfile.write("\n"+wrap(self.description, width, caption="Description: ")) - myfile.write("\n"+wrap(self.impact_text, width, caption="Impact: ")) - myfile.write("\n"+wrap(self.workaround, width, caption="Workaround: ")) - myfile.write("\n"+wrap(self.resolution, width, caption="Resolution: ")) + 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+" ") - myfile.write("\n"+wrap(myreferences, width, caption="References: ")) - myfile.write("\n") - myfile.close() + outstream.write("\n"+wrap(myreferences, width, caption="References: ")) + outstream.write("\n") def isVulnerable(self): """ |
