Example #1
0
    def mkoutdir(self, clobber = True):
        """
        Create outdir as outpudir/module.class.method (destructively
        if clobber is True).
        """

        funcname = '.'.join(self.id().split('.')[-3:])
        outdir = path.join(self.outputdir, funcname)
        mkdir(outdir, clobber)
        return outdir
Example #2
0
def action(args):

    timestamp = timestamp_now()
    title = args.title or os.getcwd()
    outdir = args.outdir
    mkdir(outdir)

    # make a local copies of css and js files
    bootstrap_css = make_local_copy(outdir, 'css', 'bootstrap.css')
    jquery_js = make_local_copy(outdir, 'js', 'jquery-1.11.2.min.js')
    bootstrap_js = make_local_copy(outdir, 'js', 'bootstrap.js')
    js_files = [jquery_js, bootstrap_js]

    versions = get_versions()
    text = args.text.read()
    table = csv.reader(args.table)
    # has the side effect of copying files into place
    images = [include_file(path.join(outdir, 'img'), img)
              for img in args.img] * args.reps if args.img else None

    env = Environment(loader=PackageLoader('static_html_demo', 'templates'))
    # env.globals = globals()

    with open(path.join(outdir, 'index.html'), 'w') as f:
        f.write(env.get_template('index.html').render(
            title=title,
            bootstrap_css=bootstrap_css,
            js_files=js_files,
            footers=versions,
            timestamp=timestamp,
            text=text,
            table=table,
            images=images,
            ncol=args.ncol,
            navigation=[('index.html', 'home')],
        ))
Example #3
0
    2: logging.DEBUG,
}.get(verbosity, logging.DEBUG)

if verbosity > 1:
    logformat = '%(levelname)s %(module)s %(lineno)s %(message)s'
else:
    logformat = '%(message)s'

logging.basicConfig(file=sys.stdout, format=logformat, level=loglevel)
log = logging.getLogger(__name__)

# module data
datadir = 'testfiles'
outputdir = 'test_output'

mkdir(outputdir)

def get_testfile(fn):
    pth = path.join(datadir, fn)
    if not path.exists(pth):
        raise ValueError('no such file "{}"'.format(pth))
    return pth

class TestBase(unittest.TestCase):
    """
    Base class for unit tests with methods for defining output
    directories based on method name.
    """

    outputdir = outputdir