def get_modules(paths, toplevel=True):
    """Take files from the command line even if they don't end with .py."""
    modules = []
    for path in paths:
        path = os.path.abspath(path)
        if toplevel and path.endswith('.pyc'):
            sys.exit('.pyc files are not supported: {0}'.format(path))
        if os.path.isfile(path) and (path.endswith('.py') or toplevel):
            modules.append(path)
        elif os.path.isdir(path):
            subpaths = [
                os.path.join(path, filename)
                for filename in sorted(os.listdir(path))]
            modules.extend(get_modules(subpaths, toplevel=False))
        elif toplevel:
            sys.exit('Error: {0} could not be found.'.format(path))
    return modules
def get_modules ( paths , toplevel = True ) : modules = [ ] for path in paths : path = os . path . abspath ( path ) if toplevel and path . endswith ( '.pyc' ) : sys . exit ( '.pyc files are not supported: {0}' . format ( path ) ) if os . path . isfile ( path ) and ( path . endswith ( '.py' ) or toplevel ) : modules . append ( path ) elif os . path . isdir ( path ) : subpaths = [ os . path . join ( path , filename ) for filename in sorted ( os . listdir ( path ) ) ] modules . extend ( get_modules ( subpaths , toplevel = False ) ) elif toplevel : sys . exit ( 'Error: {0} could not be found.' . format ( path ) ) return modules
Take files from the command line even if they don't end with .py.