def docs():
    "create documentation"
    from epydoc import cli  # pylint: disable=no-name-in-module

    easy.path('build').exists() or easy.path('build').makedirs()

    # get storage path
    docs_dir = easy.options.docs.get('docs_dir', 'build/apidocs')

    # clean up previous docs
    (easy.path(docs_dir) /
     "epydoc.css").exists() and easy.path(docs_dir).rmtree()

    # set up includes
    try:
        include_names = easy.options.docs.includes
    except AttributeError:
        include_names = []
    else:
        include_names = include_names.replace(',', ' ').split()

    # set up excludes
    try:
        exclude_names = easy.options.docs.excludes
    except AttributeError:
        exclude_names = []
    else:
        exclude_names = exclude_names.replace(',', ' ').split()

    excludes = []
    for pkg in exclude_names:
        excludes.append("--exclude")
        excludes.append('^' + re.escape(pkg))

    # call epydoc in-process
    sys_argv = sys.argv
    try:
        sys.argv = [
            sys.argv[0] + "::epydoc",
            "-v",
            "--inheritance",
            "listed",
            "--output",
            os.path.abspath(docs_dir),
            "--name",
            "%s %s" % (easy.options.setup.name, easy.options.setup.version),
            "--url",
            easy.options.setup.url,
            "--graph",
            "umlclasstree",
        ] + excludes + support.toplevel_packages() + include_names
        sys.stderr.write("Running '%s'\n" % ("' '".join(sys.argv)))
        cli.cli()
    finally:
        sys.argv = sys_argv
Beispiel #2
0
def docs():
    "create documentation"
    from epydoc import cli # pylint: disable=W0404

    easy.path('build').exists() or easy.path('build').makedirs()

    # get storage path
    docs_dir = easy.options.docs.get('docs_dir', 'build/apidocs')

    # clean up previous docs
    (easy.path(docs_dir) / "epydoc.css").exists() and easy.path(docs_dir).rmtree()

    # set up includes
    try:
        include_names = easy.options.docs.includes
    except AttributeError:
        include_names = []
    else:
        include_names = include_names.replace(',', ' ').split()

    # set up excludes
    try:
        exclude_names = easy.options.docs.excludes
    except AttributeError:
        exclude_names = []
    else:
        exclude_names = exclude_names.replace(',', ' ').split()

    excludes = []
    for pkg in exclude_names:
        excludes.append("--exclude")
        excludes.append('^' + re.escape(pkg))

    # call epydoc in-process
    sys_argv = sys.argv
    try:
        sys.argv = [
            sys.argv[0] + "::epydoc",
            "-v",
            "--inheritance", "listed",
            "--output", os.path.abspath(docs_dir),
            "--name", "%s %s" % (easy.options.setup.name, easy.options.setup.version),
            "--url", easy.options.setup.url,
            "--graph", "umlclasstree",
        ] + excludes + support.toplevel_packages() + include_names
        sys.stderr.write("Running '%s'\n" % ("' '".join(sys.argv)))
        cli.cli()
    finally:
        sys.argv = sys_argv
Beispiel #3
0
def lint():
    "report pylint results"
    # report according to file extension
    report_formats = {
        ".html": "html",
        ".log": "parseable",
        ".txt": "text",
    }

    lint_build_dir = easy.path("build/lint")
    lint_build_dir.exists() or lint_build_dir.makedirs()  # pylint: disable=expression-not-assigned

    argv = []
    rcfile = easy.options.lint.get("rcfile")
    if not rcfile and easy.path("pylint.cfg").exists():
        rcfile = "pylint.cfg"
    if rcfile:
        argv += ["--rcfile", os.path.abspath(rcfile)]
    if easy.options.lint.get("msg_only", False):
        argv += ["-rn"]
    argv += [
        "--import-graph", (lint_build_dir / "imports.dot").abspath(),
    ]
    argv += support.toplevel_packages()

    sys.stderr.write("Running %s::pylint '%s'\n" % (sys.argv[0], "' '".join(argv)))
    outfile = easy.options.lint.get("output", None)
    if outfile:
        outfile = os.path.abspath(outfile)

    try:
        with easy.pushd("src" if easy.path("src").exists() else "."):
            if outfile:
                argv.extend(["-f", report_formats.get(easy.path(outfile).ext, "text")])
                sys.stderr.write("Writing output to %r\n" % (str(outfile),))
                outhandle = open(outfile, "w")
                try:
                    subprocess.check_call(["pylint"] + argv, stdout=outhandle)
                finally:
                    outhandle.close()
            else:
                subprocess.check_call(["pylint"] + argv, )
            sys.stderr.write("paver::lint - No problems found.\n")
    except subprocess.CalledProcessError as exc:
        if exc.returncode & 32:
            # usage error (internal error in this code)
            sys.stderr.write("paver::lint - Usage error, bad arguments %r?!\n" % (argv,))
            sys.exit(exc.returncode)
        else:
            bits = {
                1: "fatal",
                2: "error",
                4: "warning",
                8: "refactor",
                16: "convention",
            }
            sys.stderr.write("paver::lint - Some %s message(s) issued.\n" % (
                ", ".join([text for bit, text in bits.items() if exc.returncode & bit])
            ))
            if exc.returncode & 3:
                sys.stderr.write("paver::lint - Exiting due to fatal / error message.\n")
                sys.exit(exc.returncode)
Beispiel #4
0
def lint():
    "report pylint results"
    from pylint import lint as linter  # pylint: disable=W0404

    # report according to file extension
    report_formats = {
        ".html": "html",
        ".log": "parseable",
        ".txt": "text",
    }

    lint_build_dir = easy.path("build/lint")
    lint_build_dir.exists() or lint_build_dir.makedirs()

    argv = []
    rcfile = easy.options.lint.get("rcfile")
    if not rcfile and easy.path("pylint.cfg").exists():
        rcfile = "pylint.cfg"
    if rcfile:
        argv += ["--rcfile", os.path.abspath(rcfile)]
    if easy.options.lint.get("msg_only", False):
        argv += ["-rn"]
    argv += [
        "--import-graph",
        (lint_build_dir / "imports.dot").abspath(),
    ]
    argv += support.toplevel_packages()

    sys.stderr.write("Running %s::pylint '%s'\n" %
                     (sys.argv[0], "' '".join(argv)))
    outfile = easy.options.lint.get("output", None)
    if outfile:
        outfile = os.path.abspath(outfile)

    try:
        with easy.pushd("src" if easy.path("src").exists() else "."):
            if outfile:
                argv.extend(
                    ["-f",
                     report_formats.get(easy.path(outfile).ext, "text")])
                sys.stderr.write("Writing output to %r\n" % (str(outfile), ))
                outhandle = open(outfile, "w")
                try:
                    subprocess.check_call(["pylint"] + argv, stdout=outhandle)
                finally:
                    outhandle.close()
            else:
                subprocess.check_call(["pylint"] + argv, )
            sys.stderr.write("paver::lint - No problems found.\n")
    except subprocess.CalledProcessError, exc:
        if exc.returncode & 32:
            # usage error (internal error in this code)
            sys.stderr.write(
                "paver::lint - Usage error, bad arguments %r?!\n" % (argv, ))
            sys.exit(exc.returncode)
        else:
            bits = {
                1: "fatal",
                2: "error",
                4: "warning",
                8: "refactor",
                16: "convention",
            }
            sys.stderr.write(
                "paver::lint - Some %s message(s) issued.\n" % (", ".join([
                    text for bit, text in bits.items() if exc.returncode & bit
                ])))
            if exc.returncode & 3:
                sys.stderr.write(
                    "paver::lint - Exiting due to fatal / error message.\n")
                sys.exit(exc.returncode)