Source

djanjinja / pavement.py

# -*- coding: utf-8 -*-

from paver.easy import *


@task
def lint(options):
    """Run PyLint on the ``djanjinja`` and ``djanjinja_test`` directories."""
    
    import os
    
    os.environ['DJANGO_SETTINGS_MODULE'] = 'djanjinja_test.settings'
    rcfile = path(__file__).abspath().dirname() / 'pylintrc'
    
    run_pylint('djanjinja', rcfile=rcfile)
    run_pylint('djanjinja_test', rcfile=rcfile, disable_msg='C0111')


def run_pylint(directory, **options):
    """Run PyLint on a given directory, with some command-line options."""
    
    from pylint import lint
    
    rcfile = options.pop('rcfile', None)
    if not rcfile:
        if (path(__file__).abspath().dirname() / 'pylintrc').exists():
            rcfile = path(__file__).abspath().dirname() / 'pylintrc'
    if rcfile:
        options['rcfile'] = rcfile
    
    arguments = []
    for option, value in options.items():
        arguments.append('--%s=%s' % (option.replace('_', '-'), value))
    arguments.append(directory)
    
    message = 'pylint ' + ' '.join(
        argument.replace(' ', r'\ ') for argument in arguments)
    
    try:
        dry(message, lint.Run, arguments)
    except SystemExit, exc:
        if exc.args[0] != 0:
            raise BuildFailure('PyLint returned with a non-zero exit code.')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.