Esempio n. 1
0
    def on_change(source):
        docs = absfilename("docs", name, here=here)
        sources = absfilename("sources", name, here=here)

        print("Source", sources)
        print("Docs  ", docs)

        call(["sphinx-build", "-b", "html", "docs", docs], cwd=sources)
Esempio n. 2
0
    def test_files_have_correct_header(self):
        filenames = list()

        for root, dirnames, basenames in walk(absfilename('.')):
            if 'src' not in root or 'tests' not in root:
                continue

            for basename in basenames:
                if basename.endswith('.py'):
                    filenames.append(path.join(root, basename))

        filenames.sort()

        allowed_normal = [
            '# -*- coding: utf-8 -*-',
            'from __future__ import absolute_import, division, print_function',
            ''
        ]
        allowed_executable = [
            '#!/usr/bin/env python',
            '# -*- coding: utf-8 -*-',
            'from __future__ import absolute_import, division, print_function',
            ''
        ]

        for filename in filenames:
            with open(filename) as stream:
                lines = [l.rstrip() for l in stream.read().split('\n')][:4]

            if S_IXUSR & stat(filename).st_mode:
                headers = allowed_executable
            else:
                headers = allowed_normal

            msg = '.{:s} does not have the correct header lines.'.format(
                filename[len(absfilename('.')):])
            msg += '\nFOUND:\n'
            msg += '\n'.join(lines)
            msg += '\nEXPECTED:\n'
            msg += '\n'.join(headers)

            assert len(lines) >= len(headers), msg
            for lx, line in enumerate(headers):
                assert line == lines[lx], msg
Esempio n. 3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function

from pandora import Monitor
from subprocess import call
from pandora import absfilename

monitor = Monitor()
here = absfilename(".")


@monitor.listen(["monitor.py"])
def on_monitor_change():
    monitor.restart_process()


def listen(name):
    @monitor.listen(["sources/%s/src/*.py" % name, "sources/%s/*.rst" % name], on_startup=True)
    def on_change(source):
        docs = absfilename("docs", name, here=here)
        sources = absfilename("sources", name, here=here)

        print("Source", sources)
        print("Docs  ", docs)

        call(["sphinx-build", "-b", "html", "docs", docs], cwd=sources)


for package in ["Assemble", "Avenue", "Disinfect", "Pandora", "Poort"]:
    listen(package)