Exemplo n.º 1
0
def checkFile(filePath, config = defaultConfig):
    '''通过路径检查css文件'''
    fileContent = open(filePath).read()
    console.log('[ckstyle] checking %s' % filePath)
    checker = doCheck(fileContent, filePath, config)
    path = os.path.realpath(filePath + config.extension)
    if checker.hasError():
        reporter = ReporterUtil.getReporter('json' if config.exportJson else 'text', checker)
        reporter.doReport()
        if config.printFlag:
            if os.path.exists(path):
                os.remove(path)
            console.show(reporter.export() + '\n')
        else:
            open(path, 'w').write(reporter.export())
            console.show('[ckstyle] @see %s\n' % path)
        return False
    else:
        if config.exportJson:
            console.show('{"status":"ok","result":"%s is ok"}' % filePath)
        else:
            console.show('[ckstyle] %s is ok\n' % filePath)
        if os.path.exists(path):
            os.remove(path)
        return True
Exemplo n.º 2
0
def checkFile(filePath, config = defaultConfig):
    '''通过路径检查css文件'''
    fileContent = open(filePath).read()
    console.show('[ckstyle] checking %s' % filePath)
    checker = doCheck(fileContent, filePath, config)
    path = os.path.realpath(filePath + config.extension)
    if checker.hasError():
        reporter = ReporterUtil.getReporter('text', checker)
        reporter.doReport()
        if config.printFlag:
            if os.path.exists(path):
                os.remove(path)
            console.show(reporter.export() + '\n')
        else:
            open(path, 'w').write(reporter.export())
            console.show('[ckstyle] @see %s\n' % path)
        return False
    else:
        console.show('[ckstyle] %s is ok\n' % filePath)
        if os.path.exists(path):
            os.remove(path)
        return True
Exemplo n.º 3
0
def checkFile(filePath, config = defaultConfig):
    '''通过路径检查css文件'''
    fileContent = open(filePath).read()
    print '[ckstyle] checking %s' % filePath
    checker = doCheck(fileContent, filePath, config)
    path = os.path.realpath(filePath + config.extension)
    if checker.hasError():
        reporter = ReporterUtil.getReporter('text', checker)
        reporter.doReport()
        if config.printFlag:
            if os.path.exists(path):
                os.remove(path)
            print reporter.export(), '\n'
        else:
            open(path, 'w').write(reporter.export())
            print '[ckstyle] @see %s\n' % path
        return False
    else:
        print '[ckstyle] %s is ok\n' % filePath
        if os.path.exists(path):
            os.remove(path)
        return True
Exemplo n.º 4
0
def checkCssText(text):
    checker = doCheck(text)
    reporter = ReporterUtil.getReporter('text', checker)
    reporter.doReport()
    console.show(reporter.export())
Exemplo n.º 5
0
def checkCssText(text):
    checker = doCheck(text)
    reporter = ReporterUtil.getReporter('text', checker)
    reporter.doReport()
    print reporter.export()