Пример #1
0
                filepath = os.path.join(dirpath, file)
                fileParser.parseFile(filepath)

                for object in fileParser.parsedObjects:
                    print object
                    raw_input("Press any key...")

                processed += 1
                break

    return processed


def remove_hidden_directories(dirnames):
    for dir in dirnames:
        if dir[0] == ".":
            dirnames.remove(dir)


if __name__ == "__main__":
    srcDir = "./src/"
    logPath = "./_logs"

    fs.removetree(logPath)
    log = Log(logPath, file="_log")
    log.section("Code style check")
    checkCodeStyle(srcDir)

    status, report = log.report()
    open(os.path.join(logPath, "_report.txt"), "w").write(report)
Пример #2
0
  log.write('Success!')
  return 0

def test(log):
  parser = codeParser.RawCodeParser(None, cCodeSyntax)
  # parser = codeParser.RawCodeParser(log, cCodeSyntax)
  testFailed = 0

  for i in range(len(cCodeParserTest)):
    testVector = cCodeParserTest[i]
    log.write('Test #%d. %s' % (i, testVector['label']))
    parser.clearStateMachine()
    result = parser.parseText(testVector['data'])
    testFailed += checkParseResult(testVector['expectedResult'], result, log)

  if not testFailed:
    log.write('\nAll tests passed!')
  else:
    log.write('\n%d tests failed.' % testFailed)

if __name__ == '__main__':
  logPath = './_logs'

  fs.removetree(logPath)
  log = Log(logPath, file = 'testFileParser')
  log.section('File parser testing')
  test(log)

  status, report = log.report()
  open(os.path.join(logPath, '_report.txt'), 'w').write(report)