Ejemplo n.º 1
0
def test_is_newer():
    file_b = _named_temporary_file().name
    touch(file_b)
    sleep(2)
    file_a = _named_temporary_file().name
    touch(file_a)
    assert is_newer(file_a, file_b)
    assert not is_newer(file_b, file_a)
Ejemplo n.º 2
0
        def _create_class_diagrams(path):
            """
            Create class UML diagram

            :param path: path to the module file.
            :type path: str
            """
            info("_create_class_diagrams")
            if not executables_available(["pynsource"]):
                return
            files = [
                os.path.join(dir_path, f)
                for dir_path, dir_names, files in os.walk(path)
                for f in fnmatch.filter(files, "*.py")
            ]
            debug("files: {files}".format(files=repr(files)))
            for src_file in files:
                debug(src_file)
                name = src_file.replace(Project.herringfile_dir + "/", "").replace(".py", ".png").replace("/", ".")
                output = "classes_{name}".format(name=name)
                debug(output)
                if not os.path.isfile(output) or (os.path.isfile(output) and is_newer(output, src_file)):
                    run_python(
                        "pynsource -y {output} {source}".format(output=output, source=src_file),
                        verbose=False,
                        ignore_errors=True,
                    )
Ejemplo n.º 3
0
    def _create_class_diagrams(path):
        """
        Create class UML diagram

        :param path: path to the module file.
        :type path: str
        """
        info("_create_class_diagrams")
        if not executables_available(['pynsource']):
            warning('pynsource not available')
            return

        files = [os.path.join(dir_path, f)
                 for dir_path, dir_names, files in os.walk(path)
                 for f in fnmatch.filter(files, '*.py')]
        debug("files: {files}".format(files=repr(files)))
        with open(os.path.join(Project.docs_dir, "pynsource.log"), "w") as outputter:
            for src_file in files:
                debug(src_file)
                name = src_file.replace(Project.herringfile_dir + '/', '').replace('.py', '.png').replace('/', '.')
                output = "classes_{name}".format(name=name)
                debug(output)
                if not os.path.isfile(output) or (os.path.isfile(output) and is_newer(output, src_file)):
                    output = run_python("pynsource -y {output} {source}".format(output=output, source=src_file),
                                        verbose=False, ignore_errors=True)
                    outputter.write(output)