twisted / twistedchecker

twistedchecker is a tool to automatically verify code against the Twisted coding standard.
MIT License
9 stars 13 forks source link

Extend twistedchecker to run on arbitrary directories #45

Open ghost opened 10 years ago

ghost commented 10 years ago

Twistedchecker currently expects a python module or package directory as an argument.

It would useful if you could also pass it an arbitrary directory which it would search recursively for any python files.

This would be more consistent with the behaviour of Pyflakes.

{{{

!python

def iterSourceCode(paths): """ Iterate over all Python source files in C{paths}.

@param paths: A list of paths.  Directories will be recursed into and
    any .py files found will be yielded.  Any non-directories will be
    yielded as-is.
"""
for path in paths:
    if os.path.isdir(path):
        for dirpath, dirnames, filenames in os.walk(path):
            for filename in filenames:
                if filename.endswith('.py'):
                    yield os.path.join(dirpath, filename)
    else:
        yield path

}}}

This idea was raised by Tom in the comments in:

Which discusses the Twisted Better Examples plan:

It is a blocker for:


Imported from Launchpad using lp2gh.

adiroiban commented 9 years ago

It would be nice to also have twistedchecker run on a set of files.

In this way you can have a tools which look for files changes since trunk and run checks only on those files, as it should be much faster than running on the whole code.

For my project I have something like this for pyflakes and pep8 checks and is fast :)