コード例 #1
0
ファイル: connection.py プロジェクト: pombredanne/spacewalk
 def __init__(self, stream):
     def noop():
         pass
     self._real_stream = stream
     # gzipstream tries to flush stuff; add a noop function
     self._real_stream.flush = noop
     self.stream = self._real_stream
     if not isinstance(self._real_stream, gzipstream.GzipStream):
         self.stream = gzipstream.GzipStream(stream=self._real_stream, mode="r")
コード例 #2
0
#
# Copyright (c) 2008 Red Hat, Inc.
#
# This software is licensed to you under the GNU General Public License,
# version 2 (GPLv2). There is NO WARRANTY for this software, express or
# implied, including the implied warranties of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
# along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
#
# Red Hat trademarks are not licensed under GPLv2. No permission is
# granted to use or replicate Red Hat trademarks that are incorporated
# in this software or its documentation.
#
import gzipstream

f = open("/tmp/output.gz")

s = gzipstream.GzipStream(stream=f, mode="r")
print s
print s.read()
コード例 #3
0
from rhn import rpclib
from xml.sax import saxutils, make_parser, _exceptions
from xml.sax.handler import feature_namespaces


class Foo(saxutils.DefaultHandler):
    def startElement(self, tag, attrs):
        print "startElement", tag

    def characters(self, data):
        pass

    def endElement(self, tag):
        print "endElement", tag


f = open(INPUT)

gz = gzipstream.GzipStream(f, "r")

cs = connection.CompressedStream(gz)

fi = rpclib.transports.File(cs)

h = Foo()

parser = make_parser(feature_namespaces)
parser.setContentHandler(h)
parser.setErrorHandler(h)
parser.parse(fi)