def find_packages(manifest):
    """ Determine packages and subpackages """
    packages = {}
    collect = manifest.get('packages.collect', '').split()
    lib = manifest.get('packages.lib', '.')
    try:
        sep = _os.path.sep
    except AttributeError:
        sep = _os.path.join('1', '2')[1:-1]
    for root in collect:
        for dirpath, _, filenames in _shell.walk(_os.path.join(lib, root)):
            if dirpath.find('.svn') >= 0 or dirpath.find('.git') >= 0:
                continue
            if '__init__.py' in filenames:
                packages[_os.path.normpath(dirpath).replace(sep, '.')] = None
    packages = packages.keys()
    packages.sort()
    return packages
Exemplo n.º 2
0
def find_packages(manifest):
    """ Determine packages and subpackages """
    packages = {}
    collect = manifest.get('packages.collect', '').split()
    lib = manifest.get('packages.lib', '.')
    try:
        sep = _os.path.sep
    except AttributeError:
        sep = _os.path.join('1', '2')[1:-1]
    for root in collect:
        for dirpath, _, filenames in _shell.walk(_os.path.join(lib, root)):
            if dirpath.find('.svn') >= 0 or dirpath.find('.git') >= 0:
                continue
            if '__init__.py' in filenames:
                packages[_os.path.normpath(dirpath).replace(sep, '.')] = None
    packages = list(packages.keys())
    packages.sort()
    return packages
Exemplo n.º 3
0
Arquivo: make.py Projeto: ndparker/tdi
    def run(self):
        from _setup.util import SafeConfigParser as parser

        parser = parser()
        parser.read("package.cfg", **cfgread)
        strversion = parser.get("package", "version.number")
        shortversion = tuple(map(int, strversion.split(".")[:2]))

        shell.rm_rf(self.dirs["_website"])
        shell.cp_r(self.dirs["userdoc_source"], _os.path.join(self.dirs["_website"], "src"))
        for filename in shell.files(_os.path.join(self.dirs["_website"], "src"), "*.txt"):
            fp = textopen(filename, "r")
            try:
                content = fp.read().replace("../examples/", "examples/")
            finally:
                fp.close()
            fp = textopen(filename, "w")
            try:
                fp.write(content)
            finally:
                fp.close()

        shell.cp_r(self.dirs["examples"], _os.path.join(self.dirs["_website"], "src", "examples"))
        shell.rm_rf(_os.path.join(self.dirs["_website"], "build"))
        shell.rm_rf(self.dirs["website"])
        _os.makedirs(self.dirs["website"])
        filename = _os.path.join(self.dirs["_website"], "src", "website_download.txt")
        fp = textopen(filename)
        try:
            download = fp.read()
        finally:
            fp.close()
        filename = _os.path.join(self.dirs["_website"], "src", "index.txt")
        fp = textopen(filename)
        try:
            indexlines = fp.readlines()
        finally:
            fp.close()

        fp = textopen(filename, "w")
        try:
            for line in indexlines:
                if line.startswith(".. placeholder: Download"):
                    line = download
                fp.write(line)
        finally:
            fp.close()

        shell.cp_r(self.dirs["examples"], _os.path.join(self.dirs["website"], "examples"))
        for top, dirs, _ in shell.walk(_os.path.join(self.dirs["website"], "examples")):
            if ".svn" in dirs:
                dirs.remove(".svn")
                shell.rm_rf(_os.path.join(top, ".svn"))
            if ".git" in dirs:
                dirs.remove(".git")
                shell.rm_rf(_os.path.join(top, ".git"))

        shell.cp_r(self.dirs["apidoc"], _os.path.join(self.dirs["website"], "doc-%d.%d" % shortversion))
        shell.cp_r(self.dirs["apidoc"], _os.path.join(self.dirs["_website"], "src", "doc-%d.%d" % shortversion))
        fp = textopen(_os.path.join(self.dirs["_website"], "src", "conf.py"), "a")
        try:
            fp.write(
                "\nepydoc = dict(tdi=%r)\n"
                % (_os.path.join(shell.native(self.dirs["_website"]), "src", "doc-%d.%d" % shortversion),)
            )
            fp.write("\nexclude_trees.append(%r)\n" % "doc-%d.%d" % shortversion)
            fp.write("\nexclude_trees.append('examples')\n")
        finally:
            fp.close()
        from _setup.dev import userdoc

        userdoc.sphinx(
            build=shell.native(_os.path.join(self.dirs["_website"], "build")),
            source=shell.native(_os.path.join(self.dirs["_website"], "src")),
            target=shell.native(self.dirs["website"]),
        )
        shell.rm(_os.path.join(self.dirs["website"], ".buildinfo"))
        fp = open(_os.path.join(self.dirs["website"], "examples", ".htaccess"), "wb")
        try:
            fp.write("Options -Indexes\n")
            fp.write("<Files *.py>\n")
            fp.write("ForceType text/plain\n")
            fp.write("</Files>\n")
            fp.write("<Files *.out>\n")
            fp.write("ForceType text/plain\n")
            fp.write("</Files>\n")
        finally:
            fp.close()
Exemplo n.º 4
0
                if genout == output:
                    out += "%(GREEN)sOK%(NORMAL)s   "
                else:
                    out += "%(RED)sfail%(NORMAL)s "
                    erred = 1
        out += "- %(script)s\n"
        term.write(out, script=_os.path.basename(script))
        return erred

    # end
    # begin main test code

    erred = 0
    basedir = shell.native(basedir)
    strip = len(basedir) - len(_os.path.basename(basedir))
    for dirname, dirs, files in shell.walk(basedir):
        dirs[:] = [item for item in dirs
            if item not in ('.svn', '.git', 'out')
        ]
        dirs.sort()
        files = [item for item in files if item.endswith('.py')]
        if not files:
            continue
        if not _os.path.isdir(_os.path.join(basedir, dirname, 'out')):
            continue
        term.yellow("---> %s" % (dirname[strip:],))
        files.sort()
        for filename in files:
            if run_test(
                _os.path.join(dirname, filename),
                _os.path.join(dirname, 'out', filename[:-3] + '.out'),
Exemplo n.º 5
0
def run_tests(basedir, libdir):
    """ Run output based tests """
    import rcssmin as _rcssmin

    py_cssmin = _rcssmin._make_cssmin(python_only=True)
    c_cssmin = _rcssmin._make_cssmin(python_only=False)

    def run_test(example, output_file):
        """ Run it """
        try:
            fp = open(example, "r")
        except IOError:
            return
        else:
            try:
                input = fp.read()
            finally:
                fp.close()

        def load_output(filename):
            try:
                fp = open(filename, "r")
            except IOError:
                return None
            else:
                try:
                    output = fp.read()
                finally:
                    fp.close()
            output = output.strip()
            if _re.search(r"(?<!\\)(?:\\\\)*\\[0-9a-zA-Z]{1,6}$", output):
                output += " "
            return output

        output = load_output(output_file)
        output_b = load_output(output_file + ".b")

        def do_test(cssmin, output, **options):
            try:
                genout = cssmin(input, **options)
            except (KeyboardInterrupt, SystemExit):
                raise
            except:
                return 1, "%(RED)s exc%(NORMAL)s "
            else:
                if output is None:
                    return 1, "%(RED)smiss%(NORMAL)s "
                elif genout == output or genout == output.rstrip():
                    return 0, "%(GREEN)sOK%(NORMAL)s   "
                else:
                    return 1, "%(RED)sfail%(NORMAL)s "

        erred, out = do_test(py_cssmin, output)
        erred, c_out = do_test(c_cssmin, output)
        erred, out_b = do_test(py_cssmin, output_b, keep_bang_comments=True)
        erred, c_out_b = do_test(c_cssmin, output_b, keep_bang_comments=True)

        term.write(
            "%(out)s %(out_b)s  |  %(c_out)s %(c_out_b)s - %%(example)s\n" % locals(),
            example=_os.path.basename(example),
        )
        return erred

    # end
    # begin main test code

    erred = 0
    basedir = shell.native(basedir)
    strip = len(basedir) - len(_os.path.basename(basedir))
    for dirname, dirs, files in shell.walk(basedir):
        dirs[:] = [item for item in dirs if item not in (".svn", ".git", "out")]
        dirs.sort()
        files = [item for item in files if item.endswith(".css")]
        if not files:
            continue
        if not _os.path.isdir(_os.path.join(basedir, dirname, "out")):
            continue
        term.yellow("---> %s" % (dirname[strip:],))
        files.sort()
        for filename in files:
            if run_test(_os.path.join(dirname, filename), _os.path.join(dirname, "out", filename[:-4] + ".out")):
                erred = 1
        term.yellow("<--- %s" % (dirname[strip:],))
    return erred
Exemplo n.º 6
0
def run_tests(basedir, libdir):
    """ Run output based tests """
    import rcssmin as _rcssmin
    py_cssmin = _rcssmin._make_cssmin(python_only=True)
    c_cssmin = _rcssmin._make_cssmin(python_only=False)

    def run_test(example, output_file):
        """ Run it """
        try:
            fp = open(example, 'r')
        except IOError:
            return
        else:
            try:
                input = fp.read()
            finally:
                fp.close()

        def load_output(filename):
            try:
                fp = open(filename, 'r')
            except IOError:
                return None
            else:
                try:
                    output = fp.read()
                finally:
                    fp.close()
            output = output.strip()
            if _re.search(r'(?<!\\)(?:\\\\)*\\[0-9a-zA-Z]{1,6}$', output):
                output += ' '
            return output

        output = load_output(output_file)
        output_b = load_output(output_file + '.b')

        def do_test(cssmin, output, **options):
            try:
                genout = cssmin(input, **options)
            except (KeyboardInterrupt, SystemExit):
                raise
            except:
                return 1, "%(RED)s exc%(NORMAL)s "
            else:
                if output is None:
                    return 1, "%(RED)smiss%(NORMAL)s "
                elif genout == output or genout == output.rstrip():
                    return 0, "%(GREEN)sOK%(NORMAL)s   "
                else:
                    return 1, "%(RED)sfail%(NORMAL)s "

        erred, out = do_test(py_cssmin, output)
        erred, c_out = do_test(c_cssmin, output)
        erred, out_b = do_test(py_cssmin, output_b, keep_bang_comments=True)
        erred, c_out_b = do_test(c_cssmin, output_b, keep_bang_comments=True)

        term.write(
            "%(out)s %(out_b)s  |  %(c_out)s %(c_out_b)s - %%(example)s\n"
                % locals(),
            example=_os.path.basename(example),
        )
        return erred

    # end
    # begin main test code

    erred = 0
    basedir = shell.native(basedir)
    strip = len(basedir) - len(_os.path.basename(basedir))
    for dirname, dirs, files in shell.walk(basedir):
        dirs[:] = [
            item for item in dirs if item not in ('.svn', '.git', 'out')
        ]
        dirs.sort()
        files = [item for item in files if item.endswith('.css')]
        if not files:
            continue
        if not _os.path.isdir(_os.path.join(basedir, dirname, 'out')):
            continue
        term.yellow("---> %s" % (dirname[strip:],))
        files.sort()
        for filename in files:
            if run_test(
                _os.path.join(dirname, filename),
                _os.path.join(dirname, 'out', filename[:-4] + '.out'),
            ): erred = 1
        term.yellow("<--- %s" % (dirname[strip:],))
    return erred