Exemple #1
0
def parseTrans(path, relpath, locale):
    txt = _read(path)
    nextInactiveBlock = codescan.pickInactiveBlockFinder(path)
    # Remove all the inactive blocks from our analysis.
    txt = codescan.getActiveBlocksOnly(txt, nextInactiveBlock)
    matches = cvtMatches([m for m in TRANS_PAT.finditer(txt)], txt, relpath, 2, 4, locale)
    if matches:
        pass  # print(relpath)
    return matches
Exemple #2
0
def parseTrans(path, relpath, locale):
    txt = _read(path)
    nextInactiveBlock = codescan.pickInactiveBlockFinder(path)
    # Remove all the inactive blocks from our analysis.
    txt = codescan.getActiveBlocksOnly(txt, nextInactiveBlock)
    matches = cvtMatches([m for m in TRANS_PAT.finditer(txt)], txt, relpath, 2,
                         4, locale)
    if matches:
        pass  #print(relpath)
    return matches
Exemple #3
0
def parseSrc(path, relpath, component):
    txt = _read(path)
    nextInactiveBlock = codescan.pickInactiveBlockFinder(path)
    # Remove all the inactive blocks from our analysis.
    txt = codescan.getActiveBlocksOnly(txt, nextInactiveBlock)
    matches = cvtMatches([m for m in GETTEXT_PAT.finditer(txt)], txt, relpath,
                         3, 3, 'en')
    found = cvtMatches(findMisses(txt), txt, relpath, 2, 2, 'en')
    formatSpecErr = cvtMatches(
        [m for m in FORMAT_SPECIFIERS_PAT.finditer(txt)], txt, relpath, 0, 0,
        'en')
    comments = cvtMatches([m for m in COMMENT_PAT.finditer(txt)], txt, relpath,
                          0, 0, 'en')
    if found:
        cr = path[0:path.find(relpath)]
        doNotExtract = file(
            os.path.join(cr, 'buildscripts/.do-not-extract.txt').replace(
                '\\', '/')).read().split('\n')
        doNotExtract += file(
            os.path.join(cr, component, '.do-not-extract.txt').replace(
                '\\', '/')).read().split('\n')
        i = 0
        while i < len(found):
            deleted = False
            if found[i].id in doNotExtract:
                del found[i]
                continue
            for m in matches:
                if deleted:
                    break
                if m.id == found[i].id:
                    if m.fileLocs[0].line == found[i].fileLocs[0].line:
                        del found[i]
                        deleted = True
            for err in formatSpecErr:
                if deleted:
                    break
                if err.fileLocs[0].line == found[i].fileLocs[0].line:
                    del found[i]
                    deleted = True
            for c in comments:
                if deleted:
                    break
                if c.fileLocs[0].line == found[i].fileLocs[0].line:
                    del found[i]
                    deleted = True
            if deleted:
                continue
            i += 1
    if matches:
        pass  #print(relpath)
    return matches, found, formatSpecErr
Exemple #4
0
def parseSrc(path, relpath, component):
    txt = _read(path)
    nextInactiveBlock = codescan.pickInactiveBlockFinder(path)
    # Remove all the inactive blocks from our analysis.
    txt = codescan.getActiveBlocksOnly(txt, nextInactiveBlock)
    matches = cvtMatches([m for m in GETTEXT_PAT.finditer(txt)], txt, relpath, 3, 3, "en")
    found = cvtMatches(findMisses(txt), txt, relpath, 2, 2, "en")
    formatSpecErr = cvtMatches([m for m in FORMAT_SPECIFIERS_PAT.finditer(txt)], txt, relpath, 0, 0, "en")
    comments = cvtMatches([m for m in COMMENT_PAT.finditer(txt)], txt, relpath, 0, 0, "en")
    if found:
        cr = path[0 : path.find(relpath)]
        doNotExtract = file(os.path.join(cr, "buildscripts/.do-not-extract.txt").replace("\\", "/")).read().split("\n")
        doNotExtract += file(os.path.join(cr, component, ".do-not-extract.txt").replace("\\", "/")).read().split("\n")
        i = 0
        while i < len(found):
            deleted = False
            if found[i].id in doNotExtract:
                del found[i]
                continue
            for m in matches:
                if deleted:
                    break
                if m.id == found[i].id:
                    if m.fileLocs[0].line == found[i].fileLocs[0].line:
                        del found[i]
                        deleted = True
            for err in formatSpecErr:
                if deleted:
                    break
                if err.fileLocs[0].line == found[i].fileLocs[0].line:
                    del found[i]
                    deleted = True
            for c in comments:
                if deleted:
                    break
                if c.fileLocs[0].line == found[i].fileLocs[0].line:
                    del found[i]
                    deleted = True
            if deleted:
                continue
            i += 1
    if matches:
        pass  # print(relpath)
    return matches, found, formatSpecErr
Exemple #5
0
 def visit(self, folder, item, relativePath):
     if JAVASCRIPT_PAT.match(item):
         path = os.path.join(folder, item)
         txt = _read(path)
         nextInactiveBlock = codescan.pickInactiveBlockFinder(path)
         #Remove all the inactive blocks from our analysis
         txt = codescan.getActiveBlocksOnly(txt, nextInactiveBlock)
         matches = [m for m in CONSOLE_PAT.finditer(txt)]
         comments = [c for c in COMMENT_PAT.finditer(txt)]
         lines = []
         for m in matches:
             offset = m.start()
             linenum = codescan.getLineNumForOffset(txt, offset)
             comment = False
             for c in comments:
                 if (linenum == codescan.getLineNumForOffset(txt, c.start())) and (offset > c.start()):
                     comment = True
             if not comment:
                 lines.append(linenum)
         if lines:
             self.badCount += 1
             self.categorizedFiles[os.path.join(relativePath, item)] = lines