Did I find the right examples for you? yes no Crawl my project Python Jobs
All Samples(4) | Call(2) | Derive(0) | Import(2)
Makes the conversion between bits and bytes. @param bitsStream: String representing a chain of bits @return: A tuple (status,statusContent), where statusContent is the string containing the resulting bytes in case status = 0 or an error in case status = -1
def getBytesFromBits(bitsStream): ''' Makes the conversion between bits and bytes. @param bitsStream: String representing a chain of bits @return: A tuple (status,statusContent), where statusContent is the string containing the resulting bytes in case status = 0 or an error in case status = -1 ''' if not isinstance(bitsStream,str): return (-1,'The bitsStream must be a string') bytes = '' if re.match('[01]*$',bitsStream): try: for i in range(0,len(bitsStream),8): bits = bitsStream[i:i+8] byte = chr(int(bits,2)) bytes += byte except: return (-1,'Error in conversion from bits to bytes') return (0,bytes) else: return (-1,'The format of the bit stream is not correct')
import sys, zlib, lzw, struct from PDFUtils import getNumsFromBytes, getBytesFromBits, getBitsFromNum from ccitt import CCITTFax
return (ret,outputBits) outputBitsStream += outputBits output = getBytesFromBits(outputBitsStream) return output # PNG prediction
src/c/l/classyPDF-HEAD/peepdf_classy/PDFFilters.py classyPDF(Download)
import sys, zlib, lzw, struct from PDFUtils import getNumsFromBytes, getBytesFromBits, getBitsFromNum def decodeStream(stream, filter, parameters = {}):
return (ret,outputBits) outputBitsStream += outputBits output = getBytesFromBits(outputBitsStream) return output # PNG prediction