Python bz2.BZ2Compressor() Examples

The following are 30 code examples of bz2.BZ2Compressor(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module bz2 , or try the search function .
Example #1
Source File: tarfile.py    From learn_python3_spider with MIT License 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #2
Source File: tarfile.py    From meddle with MIT License 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = ""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #3
Source File: tarfile.py    From planespotter with MIT License 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #4
Source File: tarfile.py    From jbox with MIT License 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #5
Source File: tarfile.py    From recruit with Apache License 2.0 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #6
Source File: tarfile.py    From rules_pip with MIT License 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #7
Source File: paxtarfile.py    From quay with Apache License 2.0 5 votes vote down vote up
def init(self):
        import bz2

        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = ""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #8
Source File: tarfile.py    From Python24 with MIT License 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #9
Source File: tarfile.py    From kobo-predict with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #10
Source File: tarfile.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #11
Source File: tarfile.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = ""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #12
Source File: tarfile.py    From python with Apache License 2.0 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #13
Source File: tarfile.py    From Financial-Portfolio-Flask with MIT License 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #14
Source File: gmoca.py    From honeything with GNU General Public License v3.0 5 votes vote down vote up
def DebugOutput(self):
    compr = bz2.BZ2Compressor()
    cdata = cStringIO.StringIO()
    for cmd in self.MOCACMDS:
      cdata.write(compr.compress('X_GOOGLE-COM_GMOCA --------------------\n'))
      cdata.write(compr.compress(' '.join(cmd) + '\n'))
      try:
        mc = subprocess.Popen([MOCACTL] + cmd, stdout=subprocess.PIPE)
        out, _ = mc.communicate(None)
        cdata.write(compr.compress(out))
      except IOError:
        continue
    cdata.write(compr.flush())
    return base64.b64encode(cdata.getvalue()) 
Example #15
Source File: tarfile.py    From stopstalk-deployment with MIT License 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #16
Source File: tarfile.py    From Hands-On-Application-Development-with-PyCharm with MIT License 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #17
Source File: tarfile.py    From scylla with Apache License 2.0 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #18
Source File: tarfile.py    From Safejumper-for-Desktop with GNU General Public License v2.0 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #19
Source File: tarfile.py    From Building-Recommendation-Systems-with-Python with MIT License 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #20
Source File: tarfile.py    From pex with Apache License 2.0 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #21
Source File: tarfile.py    From deepWordBug with Apache License 2.0 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #22
Source File: tarfile.py    From Building-Recommendation-Systems-with-Python with MIT License 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #23
Source File: tarfile.py    From pipenv with MIT License 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #24
Source File: tarfile.py    From pipenv with MIT License 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #25
Source File: tarfile.py    From pySINDy with MIT License 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #26
Source File: tarfile.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #27
Source File: other.py    From pigaios with GNU General Public License v3.0 5 votes vote down vote up
def format(self, tokensource, outfile):
        try:
            outfile.write(b'')
        except TypeError:
            raise TypeError('The raw tokens formatter needs a binary '
                            'output file')
        if self.compress == 'gz':
            import gzip
            outfile = gzip.GzipFile('', 'wb', 9, outfile)
            def write(text):
                outfile.write(text.encode())
            flush = outfile.flush
        elif self.compress == 'bz2':
            import bz2
            compressor = bz2.BZ2Compressor(9)
            def write(text):
                outfile.write(compressor.compress(text.encode()))
            def flush():
                outfile.write(compressor.flush())
                outfile.flush()
        else:
            def write(text):
                outfile.write(text.encode())
            flush = outfile.flush

        if self.error_color:
            for ttype, value in tokensource:
                line = "%s\t%r\n" % (ttype, value)
                if ttype is Token.Error:
                    write(colorize(self.error_color, line))
                else:
                    write(line)
        else:
            for ttype, value in tokensource:
                write("%s\t%r\n" % (ttype, value))
        flush() 
Example #28
Source File: tarfile.py    From hacktoberfest2018 with GNU General Public License v3.0 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor() 
Example #29
Source File: other.py    From pySINDy with MIT License 5 votes vote down vote up
def format(self, tokensource, outfile):
        try:
            outfile.write(b'')
        except TypeError:
            raise TypeError('The raw tokens formatter needs a binary '
                            'output file')
        if self.compress == 'gz':
            import gzip
            outfile = gzip.GzipFile('', 'wb', 9, outfile)
            def write(text):
                outfile.write(text.encode())
            flush = outfile.flush
        elif self.compress == 'bz2':
            import bz2
            compressor = bz2.BZ2Compressor(9)
            def write(text):
                outfile.write(compressor.compress(text.encode()))
            def flush():
                outfile.write(compressor.flush())
                outfile.flush()
        else:
            def write(text):
                outfile.write(text.encode())
            flush = outfile.flush

        if self.error_color:
            for ttype, value in tokensource:
                line = "%s\t%r\n" % (ttype, value)
                if ttype is Token.Error:
                    write(colorize(self.error_color, line))
                else:
                    write(line)
        else:
            for ttype, value in tokensource:
                write("%s\t%r\n" % (ttype, value))
        flush() 
Example #30
Source File: tarfile.py    From hacktoberfest2018 with GNU General Public License v3.0 5 votes vote down vote up
def init(self):
        import bz2
        self.pos = 0
        if self.mode == "r":
            self.bz2obj = bz2.BZ2Decompressor()
            self.fileobj.seek(0)
            self.buf = b""
        else:
            self.bz2obj = bz2.BZ2Compressor()