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


Python Report.write方法代码示例

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


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

示例1: generate_projection_report

# 需要导入模块: from report import Report [as 别名]
# 或者: from report.Report import write [as 别名]
def generate_projection_report(folder):
    '''
    Generate a projection report for the NARCCAP data.
    
    :param folder: Path to the folder containing the NARCCAP example data.
    :type folder: str
    :returns: Path to the report file.
    :rtype: str
    '''
    report = Report()
    files = os.listdir(folder)
    files = filter(lambda x: x.endswith('.nc'),files)
    files = map(lambda x: os.path.join(folder,x),files)
    for f in files:
        report.add('Filename: {0}'.format(os.path.split(f)[1]),add_break=False)
        rootgrp = nc.Dataset(f,'r')
        try:
            projection = get_projection(rootgrp)
            report.add('OpenClimateGIS Projection Class: {0}'.format(projection.__class__))
            report.add('OpenClimateGIS Computed PROJ4 String: {0}'.format(projection.proj4_str))
            try:
                ref_var = rootgrp.variables[projection.variable_name]
                report.add('NetCDF Variable/Attribute Dump:')
                report.add(projection.variable_name,indent=1)
                for attr in ref_var.ncattrs():
                    report.add('{0}: {1}'.format(attr,ref_var.getncattr(attr)),indent=2)
            except KeyError:
                ## likely WGS84
                if isinstance(projection,WGS84):
                    continue
                else: raise
            finally:
                report.add_break()
                report.add('-'*89)
                report.add_break()
        finally:
            rootgrp.close()
    report.write('/tmp/foo.txt')
    import webbrowser;webbrowser.open('/tmp/foo.txt')
开发者ID:HydroLogic,项目名称:ocgis,代码行数:41,代码来源:work.py


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