本文整理汇总了Python中Errors.open_listing_file方法的典型用法代码示例。如果您正苦于以下问题:Python Errors.open_listing_file方法的具体用法?Python Errors.open_listing_file怎么用?Python Errors.open_listing_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Errors
的用法示例。
在下文中一共展示了Errors.open_listing_file方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_errors
# 需要导入模块: import Errors [as 别名]
# 或者: from Errors import open_listing_file [as 别名]
def setup_errors(self, options, result):
if options.use_listing_file:
result.listing_file = Utils.replace_suffix(source, ".lis")
path = result.listing_file
else:
path = None
Errors.open_listing_file(path=path, echo_to_stderr=options.errors_to_stderr)
示例2: setup_errors
# 需要导入模块: import Errors [as 别名]
# 或者: from Errors import open_listing_file [as 别名]
def setup_errors(self, options):
if options.use_listing_file:
result.listing_file = Utils.replace_suffix(source, ".lis")
Errors.open_listing_file(result.listing_file,
echo_to_stderr = options.errors_to_stderr)
else:
Errors.open_listing_file(None)
示例3: compile
# 需要导入模块: import Errors [as 别名]
# 或者: from Errors import open_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
示例4: compile
# 需要导入模块: import Errors [as 别名]
# 或者: from Errors import open_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
示例5: compile
# 需要导入模块: import Errors [as 别名]
# 或者: from Errors import open_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