xfile.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:document-api-python 作者: tableau 项目源码 文件源码
def find_file_in_zip(zip_file):
    '''Returns the twb/tds file from a Tableau packaged file format. Packaged
    files can contain cache entries which are also valid XML, so only look for
    files with a .tds or .twb extension.
    '''

    candidate_files = filter(lambda x: x.split('.')[-1] in ('twb', 'tds'),
                             zip_file.namelist())

    for filename in candidate_files:
        with zip_file.open(filename) as xml_candidate:
            try:
                ET.parse(xml_candidate)
                return filename
            except ET.ParseError:
                # That's not an XML file by gosh
                pass
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号