当前位置: 首页>>代码示例>>Python>>正文


Python PyZipFile.open方法代码示例

本文整理汇总了Python中zipfile.PyZipFile.open方法的典型用法代码示例。如果您正苦于以下问题:Python PyZipFile.open方法的具体用法?Python PyZipFile.open怎么用?Python PyZipFile.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在zipfile.PyZipFile的用法示例。


在下文中一共展示了PyZipFile.open方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GenerateMission

# 需要导入模块: from zipfile import PyZipFile [as 别名]
# 或者: from zipfile.PyZipFile import open [as 别名]
def GenerateMission(filename):

    # Create XML parser
    parser = make_parser()
    generator = MissionGenerator()
    parser.setContentHandler(generator)

    # Parse KMZ file
    kmz = PyZipFile(filename, 'r')
    kml = kmz.open('doc.kml', 'r')
    parser.parse(kml)

    kmz.close()

    # Arrange the XML items into useful variables
    items = {}
    items['base_location'] = ParseCoordinates(generator.mapping, 'Base')
    items['landing_site'] = ParseCoordinates(generator.mapping, 'Fake reported location')
    items['path'] = ParseCoordinates(generator.mapping, 'Sample Nominal Path')
    items['return_path']= items['path'].reverse()

    items['base_geofence'] = GenerateGeofences(ParseCoordinates(generator.mapping, 'Base geofence'))
    items['landing_site_geofence'] = GenerateGeofences(ParseCoordinates(generator.mapping, 'Sample remote landing site'))
    items['mission_geofence'] = GenerateGeofences(ParseCoordinates(generator.mapping, 'Sample full geofence'))
    
    return items
开发者ID:MDB22,项目名称:MedExpress,代码行数:28,代码来源:mission_reader.py

示例2: get_module_meta_path

# 需要导入模块: from zipfile import PyZipFile [as 别名]
# 或者: from zipfile.PyZipFile import open [as 别名]
def get_module_meta_path(module_description):
    """Returns the finder to be appended to sys.meta_path
    module_description is a tuple of 2 elements:
        format: either 'zip', 'tar', 'tar:gz', 'tar:bz' or a string to be used as module name
        content: a base64 encoded string of a zip archive, a tar(gz/bz2) archive or a plain python module
    """
    raw_format = module_description[0].split(':')
    if raw_format[0] in ('zip', 'tar'):
        f = BytesIO()
        f.write(decodestring(module_description[1]))
        f.seek(0)
        if raw_format[0] == 'zip':
            zipf = PyZipFile(f)
            module_dict = dict((splitext(z.filename)[0].replace('/', '.'), zipf.open(z.filename).read()) for z in zipf.infolist() if splitext(z.filename)[1] == ".py")
        elif raw_format[0] == 'tar':
            compression = raw_format[1] if len(raw_format) > 1 else ''
            tarf = taropen(fileobj=f, mode="r:" + compression)
            module_dict = dict((splitext(t.name)[0].replace('/', '.'), tarf.extractfile(t.name).read()) for t in tarf.getmembers() if splitext(t.name)[1] == ".py")
    else:
        module_dict = {module_description[0]: decodestring(module_description[1])}
    return Finder(module_dict)
开发者ID:casell,项目名称:python_memory_module_import,代码行数:23,代码来源:memory_module_loader.py


注:本文中的zipfile.PyZipFile.open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。