• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.getAllSourceFiles函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: go

def go( boost_root ):
    
    OUTPUT = "src/third_party/boost"
    if os.path.exists( OUTPUT ):
        shutil.rmtree( OUTPUT )

    cmd = [ "bcp" , "--scan" , "--boost=%s" % boost_root ]
    
    src = utils.getAllSourceFiles()
    
    cmd += src
    cmd.append( OUTPUT )

    if not os.path.exists( OUTPUT ):
        os.makedirs( OUTPUT )

    res = utils.execsys( cmd )
    
    out = open( OUTPUT + "/bcp-out.txt" , 'w' )
    out.write( res[0] )
    out.close()
    
    out = open( OUTPUT + "/notes.txt" , 'w' )
    out.write( "command: " + " ".join( cmd ) )
    out.close()

    print( res[1] )
开发者ID:10genReviews,项目名称:mongo,代码行数:27,代码来源:bcp.py


示例2: readErrorCodes

def readErrorCodes( callback, replaceZero = False ):
    
    quick = [ "assert" , "Exception" , "verify" ]

    ps = [ re.compile( "(([umsgf]asser(t|ted))) *\(( *)(\d+)" ) ,
           re.compile( "((User|Msg|MsgAssertion)Exceptio(n))\(( *)(\d+)" ) ,
           re.compile( "(((verify))) *\(( *)(\d+)" )
           ]
    
    for x in utils.getAllSourceFiles():
        
        needReplace = [False]
        lines = []
        lastCodes = [0]
        lineNum = 1
        
        for line in open( x ):

            found = False
            for zz in quick:
                if line.find( zz ) >= 0:
                    found = True
                    break

            if found:
                for p in ps:               

                    def repl( m ):
                        m = m.groups()

                        start = m[0]
                        spaces = m[3]
                        code = m[4]
                        if code == '0' and replaceZero :
                            code = getNextCode( lastCodes )
                            lastCodes.append( code )
                            code = str( code )
                            needReplace[0] = True

                            print( "Adding code " + code + " to line " + x + ":" + str( lineNum ) )

                        else :
                            codes.append( ( x , lineNum , line , code ) )
                            callback( x , lineNum , line , code )

                        return start + "(" + spaces + code

                    line = re.sub( p, repl, line )
                    # end if ps loop
            
            if replaceZero : lines.append( line )
            lineNum = lineNum + 1
        
        if replaceZero and needReplace[0] :
            print( "Replacing file " + x )
            of = open( x + ".tmp", 'w' )
            of.write( "".join( lines ) )
            of.close()
            os.remove(x)
            os.rename( x + ".tmp", x )
开发者ID:osheroff,项目名称:mongo,代码行数:60,代码来源:errorcodes.py


示例3: readErrorCodes

def readErrorCodes( callback ):
    ps = [ re.compile( "([umsg]asser(t|ted)) *\( *(\d+)" ) ,
           re.compile( "(User|Msg)Exceptio(n)\( *(\d+)" )
           ]
    for x in utils.getAllSourceFiles():
        lineNum = 1
        for line in open( x ):
            for p in ps:               
                for m in p.findall( line ):
                    codes.append( ( x , lineNum , line , m[2] ) )
                    callback( x , lineNum , line , m[2] )
            lineNum = lineNum + 1
开发者ID:LsRbls,项目名称:mongo,代码行数:12,代码来源:errorcodes.py


示例4: parseSourceFiles

def parseSourceFiles( callback ):
    """Walks MongoDB sourcefiles and invokes callback for each AssertLocation found."""

    quick = [ "assert" , "Exception"]

    patterns = [
        re.compile( r"[umsgf]asser(?:t|ted) *\( *(\d+)" ) ,
        re.compile( r"(?:User|Msg|MsgAssertion)Exception *\( *(\d+)" ),
        re.compile( r"fassertFailed(?:NoTrace|WithStatus)? *\( *(\d+)" )
    ]

    bad = [ re.compile( r"^\s*assert *\(" ) ]

    for sourceFile in utils.getAllSourceFiles():
        if not sourceFile.find( "src/mongo/" ) >= 0:
            # Skip generated sources
            continue

        with open(sourceFile) as f:
            line_iterator = enumerate(f, 1)
            for (lineNum, line) in line_iterator:

                # See if we can skip regexes
                if not any([zz in line for zz in quick]):
                    continue

                for b in bad:
                    if b.search(line):
                        print( "%s\n%d" % (sourceFile, line) )
                        msg = "Bare assert prohibited. Replace with [umwdf]assert"
                        raise Exception(msg)

                # no more than one pattern should ever match
                matches = [x for x in [p.search(line) for p in patterns]
                           if x]
                assert len(matches) <= 1, matches
                if matches:
                    match = matches[0]
                    code = match.group(1)
                    span = match.span()

                    # Advance to statement terminator iff not on this line
                    lines = [line.strip()]

                    if not isTerminated(lines):
                        for (_lineNum, line) in line_iterator:
                            lines.append(line.strip())
                            if isTerminated(lines):
                                break

                    thisLoc = AssertLocation(sourceFile, lineNum, lines, code)
                    callback( thisLoc )
开发者ID:Benguang,项目名称:mongo,代码行数:52,代码来源:errorcodes.py


示例5: parseSourceFiles

def parseSourceFiles( callback ):
    """Walks MongoDB sourcefiles and invokes callback for each AssertLocation found."""

    quick = [ "assert" , "Exception"]

    patterns = [
        re.compile( r"(?:u|m(?:sg)?)asser(?:t|ted)(?:NoTrace)?\s*\(\s*(\d+)", re.MULTILINE ) ,
        re.compile( r"(?:User|Msg|MsgAssertion)Exception\s*\(\s*(\d+)", re.MULTILINE ),
        re.compile( r"fassert(?:Failed)?(?:WithStatus)?(?:NoTrace)?(?:StatusOK)?\s*\(\s*(\d+)",
                    re.MULTILINE ),
    ]

    bad = [ re.compile( r"^\s*assert *\(" ) ]

    for sourceFile in utils.getAllSourceFiles():
        if not sourceFile.find( "src/mongo/" ) >= 0:
            # Skip generated sources
            continue

        with open(sourceFile) as f:
            text = f.read()

            if not any([zz in text for zz in quick]):
                continue

            # TODO: move check for bad assert type to the linter.
            for b in bad:
                if b.search(text):
                    msg = "Bare assert prohibited. Replace with [umwdf]assert"
                    print( "%s: %s" % (sourceFile, msg) )
                    raise Exception(msg)

            splitlines = text.splitlines(True)

            line_offsets = [0]
            for line in splitlines:
                line_offsets.append(line_offsets[-1] + len(line))

            matchiters = [p.finditer(text) for p in patterns]
            for matchiter in matchiters:
                for match in matchiter:
                    code = match.group(1)
                    span = match.span()

                    thisLoc = AssertLocation(sourceFile,
                                             getLineForPosition(line_offsets, span[1]),
                                             text[span[0]:span[1]],
                                             code)

                    callback( thisLoc )
开发者ID:AlexOreshkevich,项目名称:mongo,代码行数:50,代码来源:errorcodes.py


示例6: assignErrorCodes

def assignErrorCodes():
    cur = 10000
    for root in assertNames:
        for x in utils.getAllSourceFiles():
            print( x )
            didAnything = False
            fixed = ""
            for line in open( x ):
                s = line.partition( root + "(" )
                if s[1] == "" or line.startswith( "#define " + root):
                    fixed += line
                    continue
                fixed += s[0] + root + "( " + str( cur ) + " , " + s[2]
                cur = cur + 1
                didAnything = True
            if didAnything:
                out = open( x , 'w' )
                out.write( fixed )
                out.close()
开发者ID:1009430358,项目名称:docs,代码行数:19,代码来源:errorcodes.py


示例7: parseSourceFiles

def parseSourceFiles( callback ):
    """Walks MongoDB sourcefiles and invokes callback for each AssertLocation found."""

    quick = [ "assert" , "Exception"]

    patterns = [
        re.compile( r"(?:u|m(?:sg)?)asser(?:t|ted)(?:NoTrace)?\s*\(\s*(\d+)", re.MULTILINE ) ,
        re.compile( r"(?:DB|Assertion)Exception\s*\(\s*(\d+)", re.MULTILINE ),
        re.compile( r"fassert(?:Failed)?(?:WithStatus)?(?:NoTrace)?(?:StatusOK)?\s*\(\s*(\d+)",
                    re.MULTILINE ),
    ]

    bad = [ re.compile( r"^\s*assert *\(" ) ]

    for sourceFile in utils.getAllSourceFiles(prefix='src/mongo/'):
        if list_files:
            print 'scanning file: ' + sourceFile

        with open(sourceFile) as f:
            text = f.read()

            if not any([zz in text for zz in quick]):
                continue

            # TODO: move check for bad assert type to the linter.
            for b in bad:
                if b.search(text):
                    msg = "Bare assert prohibited. Replace with [umwdf]assert"
                    print( "%s: %s" % (sourceFile, msg) )
                    raise Exception(msg)

            matchiters = [p.finditer(text) for p in patterns]
            for matchiter in matchiters:
                for match in matchiter:
                    code = match.group(1)
                    span = match.span()

                    thisLoc = AssertLocation(sourceFile,
                                             span[1],
                                             text[span[0]:span[1]],
                                             code)

                    callback( thisLoc )
开发者ID:DINKIN,项目名称:mongo,代码行数:43,代码来源:errorcodes.py


示例8: parseSourceFiles

def parseSourceFiles( callback ):
    """Walks MongoDB sourcefiles and invokes callback for each AssertLocation found."""

    quick = ["assert", "Exception", "ErrorCodes::Error"]

    patterns = [
        re.compile( r"(?:u|m(?:sg)?)asser(?:t|ted)(?:NoTrace)?\s*\(\s*(\d+)", re.MULTILINE ) ,
        re.compile( r"(?:DB|Assertion)Exception\s*[({]\s*(\d+)", re.MULTILINE ),
        re.compile( r"fassert(?:Failed)?(?:WithStatus)?(?:NoTrace)?(?:StatusOK)?\s*\(\s*(\d+)",
                    re.MULTILINE ),
        re.compile( r"ErrorCodes::Error\s*[({]\s*(\d+)", re.MULTILINE )
    ]

    for sourceFile in utils.getAllSourceFiles(prefix='src/mongo/'):
        if list_files:
            print 'scanning file: ' + sourceFile

        with open(sourceFile) as f:
            text = f.read()

            if not any([zz in text for zz in quick]):
                continue

            matchiters = [p.finditer(text) for p in patterns]
            for matchiter in matchiters:
                for match in matchiter:
                    code = match.group(1)
                    codeOffset = match.start(1)

                    # Note that this will include the text of the full match but will report the
                    # position of the beginning of the code portion rather than the beginning of the
                    # match. This is to position editors on the spot that needs to change.
                    thisLoc = AssertLocation(sourceFile,
                                             codeOffset,
                                             text[match.start():match.end()],
                                             code)

                    callback( thisLoc )
开发者ID:i80and,项目名称:mongo,代码行数:38,代码来源:errorcodes.py


示例9: readErrorCodes

def readErrorCodes():   
    """Open each source file in sourceroot and scan for potential error messages."""
    sys.stderr.write("Analyzing source tree: {}\n".format(sourceroot))
    quick = [ "assert" , "Exception"]

    ps = [ re.compile( "(([wum]asser(t|ted))) *\(( *)(\d+) *,\s*(\"\S[^\"]+\S\")\s*,?.*" ) ,
           re.compile( "(([wum]asser(t|ted))) *\(( *)(\d+) *,\s*([\S\s+<\(\)\"]+) *,?.*" ) ,
           re.compile( '((msgasser(t|ted))) *\(( *)(\d+) *, *(\"\S[^,^\"]+\S\") *,?' ) ,
           re.compile( '((msgasser(t|ted)NoTrace)) *\(( *)(\d+) *, *(\"\S[^,^\"]+\S\") *,?' ) ,
           re.compile( "((fasser(t|ted))) *\(( *)(\d+)()" ) ,  
           re.compile( "((DB|User|Msg|MsgAssertion)Exceptio(n))\(( *)(\d+) *,? *(\S+.+\S) *,?" ),
           re.compile( "((fassertFailed)()) *\(( *)(\d+)()" ),
           re.compile( "(([wum]asser(t|ted)))\s*\(([^\d]*)(\d+)\s*,?()"),
           re.compile( "((msgasser(t|ted)))\s*\(([^\d]*)(\d+)\s*,?()"),
           re.compile( "((msgasser(t|ted)NoTrace))\s*\(([^\d]*)(\d+)\s*,?()"),
           
           ]

    bad = [ re.compile( "\sassert *\(" ) ]
    arr=[]
    for x in utils.getAllSourceFiles(arr,product_source):
    	if (debug == True):
			sys.stderr.write("Analyzing: {}\n".format(x))
        needReplace = [False]
        lines = []
        lastCodes = [0]
        lineNum = 1
        
        stripChars = " " + "\n"
        sourcerootOffset = len(sourceroot)

        
        for line in open( x ):

            found = False
            for zz in quick:
                if line.find( zz ) >= 0:
                    found = True
                    break

            if found:
                
                for p in ps:               

                    def repl( m ):
                        m = m.groups()
                        severity = m[0]
                        start = m[0]
                        spaces = m[3]
                        code = m[4]
                        message = m[5]
                        codes.append( ( x , lineNum , line , code, message, severity ) )
                        if x.startswith(sourceroot):
							fn = x[sourcerootOffset+1:].rpartition("/2")[2]

                        msgDICT = {
							'id': code, 
							'parsed':message, 
							'message':message,
							'assert':severity,
							'severity': returnSeverityText(severity),
							'uresp':'',
							'sysresp':'', 
							'linenum':lineNum, 
							'file':fn,
							'src': line.strip(stripChars),
							'altered': 0
							}
                        messages[int(code)] = msgDICT

                        return start + "(" + spaces + code

                    line = re.sub( p, repl, line )
            
            lineNum = lineNum + 1
开发者ID:1009430358,项目名称:docs,代码行数:75,代码来源:errorcodes.py


示例10: run_lint

def run_lint(paths, nudgeOn=False):
    # errors are as of 10/14
    # idea is not to let it any new type of error
    # as we knock one out, we should remove line
    # note: not all of these are things we want, so please check first

    nudge = []  # things we'd like to turn on sson, so don't make worse
    later = []  # things that are unlikely anytime soon, so meh
    never = []  # things we totally disagree with

    nudge.append("-build/c++11")  # errors found: 6
    never.append("-build/header_guard")  # errors found: 345
    nudge.append("-build/include")  # errors found: 924
    nudge.append("-build/include_order")  # errors found: 511
    nudge.append("-build/include_what_you_use")  # errors found: 986
    nudge.append("-build/namespaces")  # errors found: 131
    never.append("-readability/braces")  # errors found: 880
    later.append("-readability/casting")  # errors found: 748
    nudge.append("-readability/check")  # errors found: 7
    nudge.append("-readability/function")  # errors found: 49
    nudge.append("-readability/inheritance")  # errors found: 7
    later.append("-readability/namespace")  # errors found: 876
    later.append("-readability/streams")  # errors found: 72
    later.append("-readability/todo")  # errors found: 309
    nudge.append("-runtime/arrays")  # errors found: 5
    later.append("-runtime/explicit")  # errors found: 322
    never.append("-runtime/indentation_namespace")  # errors found: 4601
    later.append("-runtime/int")  # errors found: 1420
    later.append("-runtime/printf")  # errors found: 29
    nudge.append("-runtime/references")  # errors found: 1338
    nudge.append("-runtime/string")  # errors found: 6
    nudge.append("-runtime/threadsafe_fn")  # errors found: 46
    never.append("-whitespace/blank_line")  # errors found: 2080
    never.append("-whitespace/braces")  # errors found: 962
    later.append("-whitespace/comma")  # errors found: 621
    later.append("-whitespace/comments")  # errors found: 2189
    nudge.append("-whitespace/empty_loop_body")  # errors found: 19
    later.append("-whitespace/end_of_line")  # errors found: 4340
    later.append("-whitespace/line_length")  # errors found: 14500
    never.append("-whitespace/indent")  # errors found: 4108
    later.append("-whitespace/newline")  # errors found: 1520
    nudge.append("-whitespace/operators")  # errors found: 2297
    never.append("-whitespace/parens")  # errors found: 49058
    nudge.append("-whitespace/semicolon")  # errors found: 121
    nudge.append("-whitespace/tab")  # errors found: 233

    filters = later + never
    if not nudgeOn:
        filters = filters + nudge

    sourceFiles = []
    for x in paths:
        utils.getAllSourceFiles(sourceFiles, x)

    args = ["--linelength=100", "--filter=" + ",".join(filters), "--counting=detailed"] + sourceFiles
    filenames = cpplint.ParseArguments(args)

    def _ourIsTestFilename(fn):
        if fn.find("dbtests") >= 0:
            return True
        if fn.endswith("_test.cpp"):
            return True
        return False

    cpplint._IsTestFilename = _ourIsTestFilename

    # Change stderr to write with replacement characters so we don't die
    # if we try to print something containing non-ASCII characters.
    sys.stderr = codecs.StreamReaderWriter(sys.stderr, codecs.getreader("utf8"), codecs.getwriter("utf8"), "replace")
    cpplint._cpplint_state.ResetErrorCounts()
    for filename in filenames:
        config_h_check_obj = CheckForConfigH()
        cpplint.ProcessFile(filename, cpplint._cpplint_state.verbose_level, extra_check_functions=[config_h_check_obj])
    cpplint._cpplint_state.PrintErrorCounts()

    return cpplint._cpplint_state.error_count == 0
开发者ID:RedBeard0531,项目名称:mongo,代码行数:76,代码来源:lint.py


示例11: run_lint

def run_lint( paths, nudgeOn=False ):
    # errors are as of 10/14
    # idea is not to let it any new type of error
    # as we knock one out, we should remove line
    # note: not all of these are things we want, so please check first

    nudge = [] # things we'd like to turn on sson, so don't make worse
    later = [] # things that are unlikely anytime soon, so meh
    never = [] # things we totally disagree with

    nudge.append( '-build/class' ) # errors found: 1
    never.append( '-build/header_guard' ) # errors found: 345
    nudge.append( '-build/include' ) # errors found: 924
    nudge.append( '-build/include_order' ) # errors found: 511
    nudge.append( '-build/include_what_you_use' ) # errors found: 986
    nudge.append( '-build/namespaces' ) # errors found: 131
    never.append( '-readability/braces' ) # errors found: 880
    later.append( '-readability/casting' ) # errors found: 748
    nudge.append( '-readability/function' ) # errors found: 49
    later.append( '-readability/streams' ) # errors found: 72
    later.append( '-readability/todo' ) # errors found: 309
    nudge.append( '-runtime/arrays' ) # errors found: 5
    nudge.append( '-runtime/casting' ) # errors found: 2
    later.append( '-runtime/explicit' ) # errors found: 322
    later.append( '-runtime/int' ) # errors found: 1420
    later.append( '-runtime/printf' ) # errors found: 29
    nudge.append( '-runtime/references' ) # errors found: 1338
    nudge.append( '-runtime/rtti' ) # errors found: 36
    nudge.append( '-runtime/sizeof' ) # errors found: 57
    nudge.append( '-runtime/string' ) # errors found: 6
    nudge.append( '-runtime/threadsafe_fn' ) # errors found: 46
    never.append( '-whitespace/blank_line' ) # errors found: 2080
    never.append( '-whitespace/braces' ) # errors found: 962
    later.append( '-whitespace/comma' ) # errors found: 621
    later.append( '-whitespace/comments' ) # errors found: 2189
    later.append( '-whitespace/end_of_line' ) # errors found: 4340
    later.append( '-whitespace/labels' ) # errors found: 58
    later.append( '-whitespace/line_length' ) # errors found: 14500
    later.append( '-whitespace/newline' ) # errors found: 1520
    nudge.append( '-whitespace/operators' ) # errors found: 2297
    never.append( '-whitespace/parens' ) # errors found: 49058
    nudge.append( '-whitespace/semicolon' ) # errors found: 121
    nudge.append( '-whitespace/tab' ) # errors found: 233

    filters = later + never
    if not nudgeOn:
        filters = filters + nudge

        
    sourceFiles = []
    for x in paths:
        utils.getAllSourceFiles( sourceFiles, x )


    args = [ "--filter=" + ",".join( filters ) , "--counting=detailed" ] + sourceFiles
    filenames = cpplint.ParseArguments( args  )

    def _ourIsTestFilename(fn):
        if fn.find( "dbtests" ) >= 0:
            return True
        if fn.endswith( "_test.cpp" ):
            return True
        return False
    
    cpplint._IsTestFilename = _ourIsTestFilename

    # Change stderr to write with replacement characters so we don't die
    # if we try to print something containing non-ASCII characters.
    sys.stderr = codecs.StreamReaderWriter(sys.stderr,
                                           codecs.getreader('utf8'),
                                           codecs.getwriter('utf8'),
                                           'replace')
    
    cpplint._cpplint_state.ResetErrorCounts()
    for filename in filenames:
        cpplint.ProcessFile(filename, cpplint._cpplint_state.verbose_level)
    cpplint._cpplint_state.PrintErrorCounts()
    
    return cpplint._cpplint_state.error_count == 0
开发者ID:MaheshOruganti,项目名称:mongo-cxx-driver-legacy-1.1.0,代码行数:79,代码来源:lint.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.getHtml函数代码示例发布时间:2022-05-26
下一篇:
Python utils.get函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap