Python zipfile 模块,read() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用zipfile.read()

项目:convenience    作者:Jean13    | 项目源码 | 文件源码
def decompress_bz2(filepath):

    download_photo(filepath)

    try:
        # Open the BZ2 file
        zipfile = bz2.BZ2File(filepath)
        # Get the decompressed data
        data = zipfile.read()
        # Assuming the filepath ends with .bz2
        newfilepath = filepath[:-4]
        # Write an uncompressed file
        open(newfilepath, 'wb').write(data)

        return newfilepath

    except IOError as e:
        print "[!] Please verifiy you entered the correct cookie value.\n"
        print e
项目:python-    作者:secondtonone1    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:my-first-blog    作者:AnkurBegining    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:swjtu-pyscraper    作者:Desgard    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:noc-orchestrator    作者:DirceuSilvaLabs    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:noc-orchestrator    作者:DirceuSilvaLabs    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:noc-orchestrator    作者:DirceuSilvaLabs    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:jira_worklog_scanner    作者:pgarneau    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:zanph    作者:zanph    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:wheel    作者:pypa    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:Sci-Finder    作者:snverse    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:Sci-Finder    作者:snverse    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:ascii-art-py    作者:blinglnav    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:ivaochdoc    作者:ivaoch    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:aws-cfn-plex    作者:lordmuffin    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:RPoint    作者:george17-meet    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:isni-reconcile    作者:cmh2166    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:AshsSDK    作者:thehappydinoa    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:habilitacion    作者:GabrielBD    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:flickr_downloader    作者:Denisolt    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:threatdetectionservice    作者:flyballlabs    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:oa_qian    作者:sunqb    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:RealtimePythonChat    作者:quangtqag    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:Indushell    作者:SecarmaLabs    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:SHAREOpenRefineWkshop    作者:cmh2166    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:binaryanalysis    作者:armijnhemel    | 项目源码 | 文件源码
def searchUnpackKnownAr(filename, tempdir=None, scanenv={}, debug=False):
    ## first check if the file actually could be a valid ar file
    arfile = open(filename, 'rb')
    arfile.seek(0)
    arheader = arfile.read(7)
    arfile.close()
    if arheader != fsmagic.fsmagic['ar']:
        return ([], [], [], {})

    ## then try unpacking it.
    res = searchUnpackAr(filename, tempdir, [], {'ar': [0]}, scanenv, debug)
    (diroffsets, blacklist, newtags, hints) = res

    failed = False
    ## there were results, so check if they were successful
    if diroffsets != []:
        if len(diroffsets) != 1:
            failed = True
        else:
            (dirpath, startoffset, endoffset) = diroffsets[0]
            if startoffset != 0 or endoffset != os.stat(filename).st_size:
                failed = True

        if failed:
            for i in diroffsets:
                (dirpath, startoffset, endoffset) = i
                try:
                    shutil.rmtree(dirpath)
                except:
                    pass
            return ([], [], [], {})
        else:
            return (diroffsets, blacklist, newtags, hints)
    return ([], [], [], {})
项目:binaryanalysis    作者:armijnhemel    | 项目源码 | 文件源码
def gzipcrc32(filename):
    datafile = open(filename, 'rb')
    datafile.seek(0)
    databuffer = datafile.read(10000000)
    crc32 = binascii.crc32('')
    while databuffer != '':
        crc32 = binascii.crc32(databuffer, crc32)
        databuffer = datafile.read(10000000)
    datafile.close()
    crc32 = crc32 & 0xffffffff
    return crc32
项目:binaryanalysis    作者:armijnhemel    | 项目源码 | 文件源码
def searchUnpackKnownGzip(filename, tempdir=None, scanenv={}, debug=False):
    ## first check if the file actually could be a valid gzip file
    gzipfile = open(filename, 'rb')
    gzipfile.seek(0)
    gzipheader = gzipfile.read(3)
    gzipfile.close()
    if gzipheader != fsmagic.fsmagic['gzip']:
        return ([], [], [], {})

    ## then try unpacking it.
    res = searchUnpackGzip(filename, tempdir, [], {'gzip': [0]}, scanenv, debug)
    (diroffsets, blacklist, newtags, hints) = res

    failed = False
    ## there were results, so check if they were successful
    if diroffsets != []:
        if len(diroffsets) != 1:
            failed = True
        else:
            (dirpath, startoffset, endoffset) = diroffsets[0]
            if startoffset != 0 or endoffset != os.stat(filename).st_size:
                failed = True

        if failed:
            for i in diroffsets:
                (dirpath, startoffset, endoffset) = i
                try:
                    shutil.rmtree(dirpath)
                except:
                    pass
            return ([], [], [], {})
        else:
            return (diroffsets, blacklist, newtags, hints)
    return ([], [], [], {})
项目:binaryanalysis    作者:armijnhemel    | 项目源码 | 文件源码
def searchUnpackRZIP(filename, tempdir=None, blacklist=[], offsets={}, scanenv={}, debug=False):
    hints = {}
    if not 'rzip' in offsets:
        return ([], blacklist, [], hints)
    if offsets['rzip'] == []:
        return ([], blacklist, [], hints)
    if offsets['rzip'][0] != 0:
        return ([], blacklist, [], hints)
    if os.stat(filename).st_size < 10:
        return ([], blacklist, [], hints)
    diroffsets = []
    tags = []
    offset = 0

    rzipfile = open(filename, 'rb')
    rzipfile.seek(0)
    rzipdata = rzipfile.read(10)
    rzipfile.close()

    rzipsize = struct.unpack('>L', rzipdata[6:10])[0]

    blacklistoffset = extractor.inblacklist(offset, blacklist)
    if blacklistoffset != None:
        return (diroffsets, blacklist, tags, hints)

    tmpdir = dirsetup(tempdir, filename, "rzip", 1)
    res = unpackRZIP(filename, offset, rzipsize, tmpdir)
    if res != None:
        rzipdir = res
        diroffsets.append((rzipdir, offset, 0))
        #blacklist.append((offset, offset + unpackrzipsize))
        #if offset == 0:
        #   tags.append("compressed")
        #   tags.append("rzip")
    else:
        ## cleanup
        os.rmdir(tmpdir)

    return (diroffsets, blacklist, tags, hints)
项目:binaryanalysis    作者:armijnhemel    | 项目源码 | 文件源码
def searchUnpackAndroidSparse(filename, tempdir=None, blacklist=[], offsets={}, scanenv={}, debug=False):
    hints = {}
    if not 'android-sparse' in offsets:
        return ([], blacklist, [], hints)
    if offsets['android-sparse'] == []:
        return ([], blacklist, [], hints)

    diroffsets = []
    counter = 1
    tags = []
    for offset in offsets['android-sparse']:
        blacklistoffset = extractor.inblacklist(offset, blacklist)
        if blacklistoffset != None:
            continue
        ## first see if the major version is correct
        sparsefile = open(filename, 'rb')
        sparsefile.seek(offset+4)
        sparsedata = sparsefile.read(2)
        sparsefile.close()
        if len(sparsedata) != 2:
            break
        majorversion = struct.unpack('<H', sparsedata)[0]
        if not majorversion == 1:
            continue

        tmpdir = dirsetup(tempdir, filename, "android-sparse", counter)
        res = unpackAndroidSparse(filename, offset, tmpdir)
        if res != None:
            (sparsesize, sparsedir) = res
            diroffsets.append((sparsedir, offset, sparsesize))

            blacklist.append((offset, offset + sparsesize))
            counter = counter + 1
        else:
            ## cleanup
            os.rmdir(tmpdir)
    return (diroffsets, blacklist, tags, hints)
项目:binaryanalysis    作者:armijnhemel    | 项目源码 | 文件源码
def searchUnpackUbi(filename, tempdir=None, blacklist=[], offsets={}, scanenv={}, debug=False):
    hints = {}
    if not 'ubi' in offsets:
        return ([], blacklist, [], hints)
    if offsets['ubi'] == []:
        return ([], blacklist, [], hints)
    datafile = open(filename, 'rb')
    ## We can use the values of offset and ubisize where offset != -1
    ## to determine the ranges for the blacklist.
    diroffsets = []
    counter = 1
    ## TODO: big file fixes
    data = datafile.read()
    datafile.close()
    for offset in offsets['ubi']:
        blacklistoffset = extractor.inblacklist(offset, blacklist)
        if blacklistoffset != None:
            continue
        tmpdir = dirsetup(tempdir, filename, "ubi", counter)
        res = unpackUbi(data, offset, tmpdir)
        if res != None:
            (ubitmpdir, ubisize) = res
            diroffsets.append((ubitmpdir, offset, ubisize))
            blacklist.append((offset, offset+ubisize))
            ## TODO use ubisize to set the blacklist correctly
            counter = counter + 1
        else:
            ## cleanup
            os.rmdir(tmpdir)
    return (diroffsets, blacklist, [], hints)
项目:Liljimbo-Chatbot    作者:chrisjim316    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:news-for-good    作者:thecodinghub    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:CaScale    作者:Thatsillogical    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:where2live    作者:fbessez    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:pyetje    作者:rorlika    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:respeaker_virtualenv    作者:respeaker    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:Tencent_Cartoon_Download    作者:Fretice    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:Problematica-public    作者:TechMaz    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:bawk    作者:jttwnsnd    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:infinite-lorem-ipsum    作者:patjm1992    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:coolrelation    作者:mrtial    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:fieldsight-kobocat    作者:awemulya    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:chalktalk_docs    作者:loremIpsum1771    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:python-group-proj    作者:Sharcee    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:covar_me_app    作者:CovarMe    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:My-Web-Server-Framework-With-Python2.7    作者:syjsu    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:WebAct    作者:CreatCodeBuild    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:PornGuys    作者:followloda    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
项目:amazon-alexa-twilio-customer-service    作者:ameerbadri    | 项目源码 | 文件源码
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))