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


Python Errors.close_listing_file方法代码示例

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


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

示例1: compile

# 需要导入模块: import Errors [as 别名]
# 或者: from Errors import close_listing_file [as 别名]
 def compile(self, source, options = None):
     # Compile a Pyrex implementation file in this context
     # and return a CompilationResult.
     if not options:
         options = default_options
     result = CompilationResult()
     cwd = os.getcwd()
     source = os.path.join(cwd, source)
     if options.use_listing_file:
         result.listing_file = replace_suffix(source, ".lis")
         Errors.open_listing_file(result.listing_file,
             echo_to_stderr = options.errors_to_stderr)
     else:
         Errors.open_listing_file(None)
     if options.output_file:
         result.c_file = os.path.join(cwd, options.output_file)
     else:
         result.c_file = replace_suffix(source, ".c")
     module_name = self.extract_module_name(source)
     initial_pos = (source, 1, 0)
     scope = self.find_module(module_name, pos = initial_pos, need_pxd = 0)
     try:
         tree = self.parse(source, scope.type_names, pxd = 0)
         tree.process_implementation(scope, result)
     except CompileError:
         result.c_file = None
     Errors.close_listing_file()
     result.num_errors = Errors.num_errors
     if result.num_errors > 0:
         result.c_file = None
     if result.c_file and not options.c_only and c_compile:
         result.object_file = c_compile(result.c_file)
         if not options.obj_only and c_link:
             result.extension_file = c_link(result.object_file)
     return result
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:37,代码来源:Main.py

示例2: compile

# 需要导入模块: import Errors [as 别名]
# 或者: from Errors import close_listing_file [as 别名]
 def compile(self, source, options = None):
     # Compile a Pyrex implementation file in this context
     # and return a CompilationResult.
     if not options:
         options = default_options
     result = CompilationResult()
     cwd = os.getcwd()
     source = os.path.join(cwd, source)
     if options.use_listing_file:
         result.listing_file = replace_suffix(source, ".lis")
         Errors.open_listing_file(result.listing_file,
             echo_to_stderr = options.errors_to_stderr)
     else:
         Errors.open_listing_file(None)
     if options.output_file:
         result.c_file = os.path.join(cwd, options.output_file)
     else:
         if options.cplus:
             result.c_file = replace_suffix(source, cplus_suffix)
         else:
             result.c_file = map_suffix(source, pyx_to_c_suffix, ".c")
     module_name = self.extract_module_name(source)
     initial_pos = (source, 1, 0)
     def_scope = self.find_module(module_name, pos = initial_pos, need_pxd = 0)
     imp_scope = ImplementationScope(def_scope)
     errors_occurred = False
     try:
         tree = self.parse(source, imp_scope, pxd = 0)
         tree.process_implementation(imp_scope, options, result)
     except CompileError:
         errors_occurred = True
     Errors.close_listing_file()
     result.num_errors = Errors.num_errors
     if result.num_errors > 0:
         errors_occurred = True
     if errors_occurred and result.c_file:
         try:
             st = os.stat(source)
             castrate_file(result.c_file, st)
         except EnvironmentError:
             pass
         result.c_file = None
     if result.c_file and not options.c_only and c_compile:
         result.object_file = c_compile(result.c_file,
             verbose_flag = options.show_version,
             cplus = options.cplus)
         if not options.obj_only and c_link:
             result.extension_file = c_link(result.object_file,
                 extra_objects = options.objects,
                 verbose_flag = options.show_version,
                 cplus = options.cplus)
     return result
开发者ID:Distrotech,项目名称:Pyrex,代码行数:54,代码来源:Main.py

示例3: teardown_errors

# 需要导入模块: import Errors [as 别名]
# 或者: from Errors import close_listing_file [as 别名]
 def teardown_errors(self, err, options, result):
     source_desc = result.compilation_source.source_desc
     if not isinstance(source_desc, FileSourceDescriptor):
         raise RuntimeError("Only file sources for code supported")
     Errors.close_listing_file()
     result.num_errors = Errors.num_errors
     if result.num_errors > 0:
         err = True
     if err and result.c_file:
         try:
             Utils.castrate_file(result.c_file, os.stat(source_desc.filename))
         except EnvironmentError:
             pass
         result.c_file = None
开发者ID:jpe,项目名称:cython,代码行数:16,代码来源:Main.py

示例4: teardown_errors

# 需要导入模块: import Errors [as 别名]
# 或者: from Errors import close_listing_file [as 别名]
 def teardown_errors(self, err, options, result):
     source_desc = result.compilation_source.source_desc
     if not isinstance(source_desc, FileSourceDescriptor):
         raise RuntimeError("Only file sources for code supported")
     Errors.close_listing_file()
     result.num_errors = Errors.num_errors
     if result.num_errors > 0:
         err = True
     if err and result.c_file:
         try:
             Utils.castrate_file(result.c_file, os.stat(source_desc.filename))
         except EnvironmentError:
             pass
         result.c_file = None
     if result.c_file and not options.c_only and c_compile:
         result.object_file = c_compile(result.c_file,
             verbose_flag = options.show_version,
             cplus = options.cplus)
         if not options.obj_only and c_link:
             result.extension_file = c_link(result.object_file,
                 extra_objects = options.objects,
                 verbose_flag = options.show_version,
                 cplus = options.cplus)
开发者ID:enyst,项目名称:plexnet,代码行数:25,代码来源:Main.py

示例5: compile

# 需要导入模块: import Errors [as 别名]
# 或者: from Errors import close_listing_file [as 别名]
    def compile(self, source, options = None, full_module_name = None):
        # Compile a Pyrex implementation file in this context
        # and return a CompilationResult.
        if not options:
            options = default_options
        result = CompilationResult()
        cwd = os.getcwd()

        if full_module_name is None:
            full_module_name, _ = os.path.splitext(source)
            full_module_name = re.sub(r'[\\/]', '.', full_module_name)
            full_module_name = re.sub(r'[^\w.]', '_', full_module_name)

        source = os.path.join(cwd, source)
        
        if options.use_listing_file:
            result.listing_file = replace_suffix(source, ".lis")
            Errors.open_listing_file(result.listing_file,
                echo_to_stderr = options.errors_to_stderr)
        else:
            Errors.open_listing_file(None)
        if options.output_file:
            result.c_file = os.path.join(cwd, options.output_file)
        else:
            if options.cplus:
                c_suffix = ".cpp"
            else:
                c_suffix = ".c"
            result.c_file = replace_suffix(source, c_suffix)
        c_stat = None
        if result.c_file:
            try:
                c_stat = os.stat(result.c_file)
            except EnvironmentError:
                pass
        module_name = full_module_name # self.extract_module_name(source, options)
        initial_pos = (source, 1, 0)
        scope = self.find_module(module_name, pos = initial_pos, need_pxd = 0)
        errors_occurred = False
        try:
            tree = self.parse(source, scope.type_names, pxd = 0, full_module_name = full_module_name)
            tree.process_implementation(scope, options, result)
        except CompileError:
            errors_occurred = True
        Errors.close_listing_file()
        result.num_errors = Errors.num_errors
        if result.num_errors > 0:
            errors_occurred = True
        if errors_occurred and result.c_file:
            try:
                #os.unlink(result.c_file)
                Utils.castrate_file(result.c_file, c_stat)
            except EnvironmentError:
                pass
            result.c_file = None
        if result.c_file and not options.c_only and c_compile:
            result.object_file = c_compile(result.c_file,
                verbose_flag = options.show_version,
                cplus = options.cplus)
            if not options.obj_only and c_link:
                result.extension_file = c_link(result.object_file,
                    extra_objects = options.objects,
                    verbose_flag = options.show_version,
                    cplus = options.cplus)
        return result
开发者ID:VuisterLab,项目名称:cing,代码行数:67,代码来源:Main.py


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