python类read()的实例源码

xml_parse.py 文件源码 项目:convenience 作者: Jean13 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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
install.py 文件源码 项目:python- 作者: secondtonone1 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
install.py 文件源码 项目:my-first-blog 作者: AnkurBegining 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
install.py 文件源码 项目:swjtu-pyscraper 作者: Desgard 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
install.py 文件源码 项目:noc-orchestrator 作者: DirceuSilvaLabs 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
install.py 文件源码 项目:noc-orchestrator 作者: DirceuSilvaLabs 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
install.py 文件源码 项目:noc-orchestrator 作者: DirceuSilvaLabs 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
install.py 文件源码 项目:jira_worklog_scanner 作者: pgarneau 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
install.py 文件源码 项目:zanph 作者: zanph 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
install.py 文件源码 项目:wheel 作者: pypa 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
install.py 文件源码 项目:Sci-Finder 作者: snverse 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
install.py 文件源码 项目:Sci-Finder 作者: snverse 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
install.py 文件源码 项目:ascii-art-py 作者: blinglnav 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
install.py 文件源码 项目:ivaochdoc 作者: ivaoch 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
install.py 文件源码 项目:aws-cfn-plex 作者: lordmuffin 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
install.py 文件源码 项目:RPoint 作者: george17-meet 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
install.py 文件源码 项目:isni-reconcile 作者: cmh2166 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
install.py 文件源码 项目:AshsSDK 作者: thehappydinoa 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
install.py 文件源码 项目:habilitacion 作者: GabrielBD 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
install.py 文件源码 项目:flickr_downloader 作者: Denisolt 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
install.py 文件源码 项目:threatdetectionservice 作者: flyballlabs 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
install.py 文件源码 项目:oa_qian 作者: sunqb 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
install.py 文件源码 项目:RealtimePythonChat 作者: quangtqag 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
install.py 文件源码 项目:Indushell 作者: SecarmaLabs 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
install.py 文件源码 项目:SHAREOpenRefineWkshop 作者: cmh2166 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def parsed_wheel_info(self):
        """Parse wheel metadata (the .data/WHEEL file)"""
        return read_pkg_info_bytes(self.zipfile.read(self.wheelinfo_name))
fwunpack.py 文件源码 项目:binaryanalysis 作者: armijnhemel 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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 ([], [], [], {})
fwunpack.py 文件源码 项目:binaryanalysis 作者: armijnhemel 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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
fwunpack.py 文件源码 项目:binaryanalysis 作者: armijnhemel 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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 ([], [], [], {})
fwunpack.py 文件源码 项目:binaryanalysis 作者: armijnhemel 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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)
fwunpack.py 文件源码 项目:binaryanalysis 作者: armijnhemel 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
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)


问题


面经


文章

微信
公众号

扫码关注公众号