コード例 #1
0
def check(path, options):
    if not os.path.isdir(path):
        sys.stderr.write('%s is not a valid folder.\n' % path)
        return 1
    path = norm_folder(path)
    print('Checking for disabled unit tests in %s...\n' % path)
    visitor = TestCheckVisitor()
    checkedFiles, checkedFolders = metadata.visit(path, visitor)
    rootLen = len(path)
    if visitor.improperSummary:
        print(visitor.improperSummary)
    shouldNag = xmail.hasDest(options) or xmail.hasHostInfo(options)
    for dt in visitor.disabledTests:
        txt = '%s(%d): Warning: disabled unit test.\n' % (dt.path[rootLen:],
                                                          dt.lineNum)
        txt += '    ' + str(dt).replace('\n', '\n    ')
        print(txt + '\n')
        if visitor.improperSummary:
            txt += '\n\nIn addition, %d unit tests appear to be disabled but improperly documented.\n' % visitor.improperCount
            txt += 'Please consider fixing these as well:\n\n'
            txt += visitor.improperSummary
        if shouldNag:
            nag(dt, txt, options)
    print(
        'Checked %d files in %d folders.\n  Found %d correctly disabled tests.\n  Found %d tests that seem to be disabled but not documented.'
        % (checkedFiles, checkedFolders, len(
            visitor.disabledTests), visitor.improperCount))
コード例 #2
0
ファイル: check_copyright.py プロジェクト: dhh1128/sandman
def check(path, warn=True):
    if not os.path.isdir(path):
        sys.stderr.write('%s is not a valid folder.\n' % path)
        return 1
    path = norm_folder(path)
    print('Checking copyright correctness in %s...\n' % path)
    visitor = CopyrightCheckVisitor(warn)
    checkedFiles, checkedFolders = metadata.visit(path, visitor)
    print('Checked %d files in %d folders; found %d errors.' % (checkedFiles, checkedFolders, visitor.badCount))
    return visitor.badCount, visitor.categorizedFiles
コード例 #3
0
def check(folder, warn=True):
    if not os.path.isdir(folder):
        sys.stderr.write('%s is not a valid folder.\n' % folder)
        return 1
    fc = FolderChecker(warn)
    checkedFiles, checkedFolders = metadata.visit(folder, DoNothingVisitor(), fc)
    if(fc.rtn):
        return 0
    else:
        return 1
コード例 #4
0
def check(path, warn=True):
    if not os.path.isdir(path):
        sys.stderr.write('%s is not a valid folder.\n' % path)
        return 1
    path = norm_folder(path)
    print('Checking svn:keywords in %s...\n' % path)
    visitor = KeywordCheckVisitor(warn)
    checkedFiles, checkedFolders = metadata.visit(path, visitor)
    print('Checked %d files in %d folders; found %d errors.' % (checkedFiles, checkedFolders, len(visitor.badFiles)))
    return visitor.badFiles
コード例 #5
0
def check(path, warn=True):
    if not os.path.isdir(path):
        sys.stderr.write('%s is not a valid folder.\n' % path)
        return 1
    path = norm_folder(path)
    print('Checking pep8 compliance in %s...\n' % path)
    visitor = KeywordCheckVisitor(warn)
    checkedFiles, checkedFolders = metadata.visit(path, visitor)
    print('Checked %d files in %d folders; found %d errors.' % (
        checkedFiles, checkedFolders, len(visitor.badFiles)))
    return visitor.badFiles
コード例 #6
0
def check(folder, warn=True):
    if not os.path.isdir(folder):
        sys.stderr.write('%s is not a valid folder.\n' % folder)
        return 1
    fc = FolderChecker(warn)
    checkedFiles, checkedFolders = metadata.visit(folder, DoNothingVisitor(),
                                                  fc)
    if (fc.rtn):
        return 0
    else:
        return 1
コード例 #7
0
def analyze(path, prebuilt, options):
    if not os.path.isdir(path):
        sys.stderr.write('%s is not a valid folder.\n' % path)
        return 1
    path = norm_folder(path)
    stats = StatsHolder(path)
    print('\nCompiling stats for %s...' % metadata.get_friendly_name_for_path(path))
    visitor = StatsVisitor(stats)
    recurser = StatsRecurser(stats)
    visitedFiles, visitedFolders = metadata.visit(path, visitor, recurser, excludePrograms=True)#, debug=True)
    report = generateReport(stats)
    print(report)
    if xmail.hasDest(options):
        xmail.sendmail(report, subject='code stats for %s' % metadata.get_friendly_name_for_path(path),
            sender='Code Stat Scanner <*****@*****.**>', options=options)
コード例 #8
0
ファイル: locdata.py プロジェクト: perfectsearch/sandman
 def __init__(self, root, testing=False):
     self._svnInfo = None
     self.trans = {}
     self.src = {}
     self.byLocale = {}
     self.pathsByComponent = {}
     self.possibleMisses = {}
     self.formatErrors = {}
     root = ioutil.norm_folder(root)
     self.conf = metadata.Conf(root, report=False)
     if type(root) == _STR_TYPE:
         root = unicode(root, "utf-8")
     self.root = root
     if not testing:
         fileCount, folderCount = metadata.visit(self.root, visitor=self, recurser=self, report=False)
         self._connect()
コード例 #9
0
    def test_visit(self):
        class Visitor:
            def __init__(self):
                self.visited = []

            def visit(self, folder, item, relativePath):
                #print('visited %s' % item)
                self.visited.append(item)
        visitor = Visitor()
        path = os.path.join(MY_DATA_DIR, 'visit_test')
        visitedFiles, visitedFolders = metadata.visit(path, visitor, report=False)
        self.assertEqual(6, visitedFiles)
        self.assertEqual(3, visitedFolders)
        self.assertTrue('x.txt' in visitor.visited)
        self.assertTrue('c.txt' in visitor.visited)
        self.assertFalse('d.txt' in visitor.visited)
コード例 #10
0
ファイル: check_jsdebug.py プロジェクト: dhh1128/sandman
def check(path, warn=True):
    if not os.path.isdir(path):
        sys.stderr.write('%s is not a valid folder.\n' % path)
        return 1
    path = norm_seps(os.path.abspath(path), trailing=True)
    print('Checking for active console code in %s...\n' % path)
    visitor = JsDebugCheckVisitor(warn)
    checkedFiles, checkedFolders = metadata.visit(path, visitor)
    if visitor.badCount > 0:
        for key in visitor.categorizedFiles.keys():
            badFile = os.path.join(path, key)
            f = file(badFile).readlines()
            print badFile
            for line in visitor.categorizedFiles[key]:
                print ('%s - %s' % (line, f[line-1]))
    print('Checked %d files in %d folders; found %d errors.' % (checkedFiles, checkedFolders, visitor.badCount))
    return visitor.badCount, visitor.categorizedFiles
コード例 #11
0
 def __init__(self, root, testing=False):
     self._svnInfo = None
     self.trans = {}
     self.src = {}
     self.byLocale = {}
     self.pathsByComponent = {}
     self.possibleMisses = {}
     self.formatErrors = {}
     root = ioutil.norm_folder(root)
     self.conf = metadata.Conf(root, report=False)
     if type(root) == _STR_TYPE:
         root = unicode(root, 'utf-8')
     self.root = root
     if not testing:
         fileCount, folderCount = metadata.visit(self.root,
                                                 visitor=self,
                                                 recurser=self,
                                                 report=False)
         self._connect()
コード例 #12
0
ファイル: metadata_test.py プロジェクト: dhh1128/sandman
    def test_visit(self):
        class Visitor:
            def __init__(self):
                self.visited = []

            def visit(self, folder, item, relativePath):
                #print('visited %s' % item)
                self.visited.append(item)

        visitor = Visitor()
        path = os.path.join(MY_DATA_DIR, 'visit_test')
        visitedFiles, visitedFolders = metadata.visit(path,
                                                      visitor,
                                                      report=False)
        self.assertEqual(6, visitedFiles)
        self.assertEqual(3, visitedFolders)
        self.assertTrue('x.txt' in visitor.visited)
        self.assertTrue('c.txt' in visitor.visited)
        self.assertFalse('d.txt' in visitor.visited)
コード例 #13
0
def analyze(path, prebuilt, options):
    if not os.path.isdir(path):
        sys.stderr.write('%s is not a valid folder.\n' % path)
        return 1
    path = norm_folder(path)
    stats = StatsHolder(path)
    print('\nCompiling stats for %s...' %
          metadata.get_friendly_name_for_path(path))
    visitor = StatsVisitor(stats)
    recurser = StatsRecurser(stats)
    visitedFiles, visitedFolders = metadata.visit(
        path, visitor, recurser, excludePrograms=True)  #, debug=True)
    report = generateReport(stats)
    print(report)
    if xmail.hasDest(options):
        xmail.sendmail(report,
                       subject='code stats for %s' %
                       metadata.get_friendly_name_for_path(path),
                       sender='Code Stat Scanner <*****@*****.**>',
                       options=options)
コード例 #14
0
def check(path, options):
    if not os.path.isdir(path):
        sys.stderr.write('%s is not a valid folder.\n' % path)
        return 1
    path = norm_folder(path)
    print('Checking for disabled unit tests in %s...\n' % path)
    visitor = TestCheckVisitor()
    checkedFiles, checkedFolders = metadata.visit(path, visitor)
    rootLen = len(path)
    if visitor.improperSummary:
        print(visitor.improperSummary)
    shouldNag = xmail.hasDest(options) or xmail.hasHostInfo(options)
    for dt in visitor.disabledTests:
        txt = '%s(%d): Warning: disabled unit test.\n' % (dt.path[rootLen:], dt.lineNum)
        txt += '    ' + str(dt).replace('\n', '\n    ')
        print(txt + '\n')
        if visitor.improperSummary:
            txt += '\n\nIn addition, %d unit tests appear to be disabled but improperly documented.\n' % visitor.improperCount
            txt += 'Please consider fixing these as well:\n\n'
            txt += visitor.improperSummary
        if shouldNag:
            nag(dt, txt, options)
    print('Checked %d files in %d folders.\n  Found %d correctly disabled tests.\n  Found %d tests that seem to be disabled but not documented.' % (checkedFiles, checkedFolders, len(visitor.disabledTests), visitor.improperCount))