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


Python Errors类代码示例

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


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

示例1: run_pipeline

def run_pipeline(pipeline, source, printtree=True):
    from Cython.Compiler.Visitor import PrintTree

    error = None
    data = source
    try:
        try:
            for phase in pipeline:
                if phase is not None:
                    if DebugFlags.debug_verbose_pipeline:
                        t = time()
                        print "Entering pipeline phase %r" % phase
                    if not printtree and isinstance(phase, PrintTree):
                        continue
                    data = phase(data)
                    if DebugFlags.debug_verbose_pipeline:
                        print "    %.3f seconds" % (time() - t)
        except CompileError, err:
            # err is set
            Errors.report_error(err)
            error = err
    except InternalError, err:
        # Only raise if there was not an earlier error
        if Errors.num_errors == 0:
            raise
        error = err
开发者ID:blackvladimir,项目名称:cython,代码行数:26,代码来源:Pipeline.py

示例2: setup_errors

 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)
开发者ID:enyst,项目名称:plexnet,代码行数:7,代码来源:Main.py

示例3: setup_errors

 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)
开发者ID:bhy,项目名称:cython-haoyu,代码行数:7,代码来源:Main.py

示例4: run_pipeline

 def run_pipeline(self, pipeline, source):
     err = None
     data = source
     try:
         for phase in pipeline:
             if phase is not None:
                 data = phase(data)
     except CompileError, err:
         # err is set
         Errors.report_error(err)
开发者ID:enyst,项目名称:plexnet,代码行数:10,代码来源:Main.py

示例5: run_pipeline

 def run_pipeline(self, pipeline, source):
     error = None
     data = source
     try:
         for phase in pipeline:
             if phase is not None:
                 if DebugFlags.debug_verbose_pipeline:
                     print "Entering pipeline phase %r" % phase
                 data = phase(data)
     except CompileError, err:
         # err is set
         Errors.report_error(err)
         error = err
开发者ID:bigmlcom,项目名称:pylibs,代码行数:13,代码来源:Main.py

示例6: teardown_errors

 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,代码行数:14,代码来源:Main.py

示例7: compile

 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,代码行数:35,代码来源:Main.py

示例8: run_pipeline

def run_pipeline(pipeline, source):
    error = None
    data = source
    try:
        try:
            for phase in pipeline:
                if phase is not None:
                    if DebugFlags.debug_verbose_pipeline:
                        t = time()
                        print "Entering pipeline phase %r" % phase
                    data = phase(data)
                    if DebugFlags.debug_verbose_pipeline:
                        print "    %.3f seconds" % (time() - t)
        except CompileError, err:
            # err is set
            Errors.report_error(err)
            error = err
    except InternalError, err:
        # Only raise if there was not an earlier error
        if Errors.num_errors == 0:
            raise
        error = err
开发者ID:agasheesh,项目名称:cython,代码行数:22,代码来源:Pipeline.py

示例9: teardown_errors

 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,代码行数:23,代码来源:Main.py

示例10: compile

 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,代码行数:52,代码来源:Main.py

示例11: pragmaIncbin

def pragmaIncbin(ppt, line, result):
    "Includes a binary file"
    filename = line.expect("STRING").value
    offset = IR.ConstantExpr(0)
    size = None
    if str(line.lookahead(0)) == ",":
        line.pop()
        offset = FE.parse_expr(line)
        if str(line.lookahead(0)) == ",":
            line.pop()
            size = FE.parse_expr(line)
    line.expect("EOL")
    if type(filename) == str:
        try:
            f = file(os.path.join(FE.context_directory, filename), "rb")
            if offset.hardcoded and (size is None or size.hardcoded):
                # We know how big it will be, we can just use the values.
                # First check to make sure they're sane
                if offset.value() < 0:
                    Err.log("Offset may not be negative")
                    f.close()
                    return
                f.seek(0, 2)  # Seek to end of file
                if offset.value() > f.tell():
                    Err.log("Offset runs past end of file")
                    f.close()
                    return
                if size is not None:
                    if size.value() < 0:
                        Err.log("Length may not be negative")
                        f.close()
                        return
                    if offset.value() + size.value() > f.tell():
                        Err.log(".incbin length too long")
                        f.close()
                        return
                if size is None:
                    size = IR.ConstantExpr(-1)
                f.seek(offset.value())
                bytes = f.read(size.value())
                bytes = [IR.ConstantExpr(ord(x)) for x in bytes]
                result.append(IR.Node(ppt, "Byte", *bytes))
            else:
                # offset or length could change based on label placement.
                # This seems like an unbelievably bad idea, but since we
                # don't have constant prop it will happen for any symbolic
                # alias. Don't use symbolic aliases when extracting tiny
                # pieces out of humongous files, I guess.
                bytes = f.read()
                bytes = [IR.ConstantExpr(ord(x)) for x in bytes]
                if size is None:
                    size = IR.SequenceExpr([IR.ConstantExpr(len(bytes)),
                                            "-",
                                            offset])
                result.append(IR.Node(ppt, "ByteRange", offset, size, *bytes))
            f.close()
        except IOError:
            Err.log("Could not read " + filename)
            return
开发者ID:0day1day,项目名称:Egg-Shell,代码行数:59,代码来源:CorePragmas.py

示例12: endMacro

def endMacro():
    global currentname
    global currentbody
    global macros
    if currentname is None:
        Err.log("Internal error!  Ended a non-existent macro!")
    else:
        macros[currentname] = currentbody
        currentname = None
        currentbody = None
开发者ID:kitnic,项目名称:Egg-Shell,代码行数:10,代码来源:Macro.py

示例13: add_token

 def add_token(token):
     "Converts a substring into a single lexeme"
     if token == "":
         return
     if token == "0":
         result.append(Lexeme("NUM", 0))
         return
     firstchar = token[0]
     rest = token[1:]
     if firstchar == '"':
         result.append(Lexeme("STRING", rest))
         return
     elif firstchar in bases:
         try:
             result.append(Lexeme("NUM", long(rest, bases[firstchar][1])))
             return
         except ValueError:
             Err.log('Invalid ' + bases[firstchar][0] + ' constant: ' +
                     rest)
             result.append(Lexeme("NUM", 0))
             return
     elif firstchar.isdigit():
         try:
             result.append(Lexeme("NUM", long(token)))
         except ValueError:
             Err.log('Identifiers may not begin with a number')
             result.append(Lexeme("LABEL", "ERROR"))
         return
     elif firstchar == "'":
         if len(rest) == 1:
             result.append(Lexeme("NUM", ord(rest)))
         else:
             Err.log("Invalid character constant '" + rest + "'")
             result.append(Lexeme("NUM", 0))
         return
     elif firstchar in punctuation:
         if rest != "":
             Err.log("Internal lexer error!  '" + token + "' can't happen!")
         result.append(Lexeme(firstchar))
         return
     else:   # Label, opcode, or index register
         id = token.lower()
         if is_opcode(id):
             result.append(Lexeme("OPCODE", id))
         elif id == "x":
             result.append(Lexeme("X"))
         elif id == "y":
             result.append(Lexeme("Y"))
         else:
             result.append(Lexeme("LABEL", id))
         return
     # should never reach here
     Err.log("Internal lexer error: add_token fall-through")
开发者ID:0day1day,项目名称:Egg-Shell,代码行数:53,代码来源:Frontend.py

示例14: newMacro

def newMacro(name):
    "Start creating a new macro with the specified name."
    global currentname
    global currentbody
    global macros
    if currentname is not None:
        Err.log("Internal error!  Nested macro attempt!")
    else:
        if name in macros:
            Err.log("Duplicate macro definition '%s'" % name)
        currentname = name
        currentbody = []
开发者ID:kitnic,项目名称:Egg-Shell,代码行数:12,代码来源:Macro.py

示例15: expect

 def expect(self, *tokens):
     """Reads a token from the ParseLine line and returns it if it's of a
 type in the sequence tokens.  Otherwise, it logs an error."""
     token = self.pop()
     if token.type in tokens:
         return token
     if 'LABEL' in tokens:
         if token.type in ['X', 'Y']:
             token.value = token.type.lower()
             token.type = 'LABEL'
             return token
         elif token.type == 'OPCODE':
             token.type = 'LABEL'
             return token
     Err.log('Expected: "' + '", "'.join(tokens) + '"')
     return token
开发者ID:0day1day,项目名称:Egg-Shell,代码行数:16,代码来源:Frontend.py


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