Changeset 20


Ignore:
Timestamp:
May 6, 2014 1:19:25 PM (10 years ago)
Author:
JohnLightfoot
Message:

bug fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/renderer.py

    r17 r20  
    66import shutil
    77
     8from extern import mako
    89from mako.template import Template
    910from mako.lookup import TemplateLookup
     11
     12import templates
     13import templates.resources as resources
     14
    1015
    1116class Renderer(object):
     
    1621        self.result = result
    1722
     23    def copy_resources(self, dirname):
     24        outdir = os.path.join(dirname, 'resources')
     25
     26        # shutil.copytree complains if the output directory exists
     27        if os.path.exists(outdir):
     28            shutil.rmtree(outdir)
     29
     30        # copy all uncompressed non-python resources to output directory
     31        src = os.path.dirname(resources.__file__)
     32        dst = outdir
     33        ignore_fn = shutil.ignore_patterns('*.zip','*.py','*.pyc','CVS*')
     34        shutil.copytree(src,
     35                        dst,
     36                        symlinks=False,
     37                        ignore=ignore_fn)
     38
     39#        # unzip fancybox to output directory
     40#        infile = os.path.join(src, 'fancybox.zip')
     41#        z = zipfile.ZipFile(infile, 'r')
     42#        z.extractall(outdir)
     43
    1844    def run(self):
    1945        # make a directory to contain this result
     
    2349
    2450        # make a resources directory and copy the Bootstrap stuff there
    25         shutil.copytree('dist', os.path.join(dirname, 'resources'))
    26 
    27         # copy the css file there too
    28         shutil.copy('bootstrap-3.0.3/examples/navbar-fixed-top/navbar-fixed-top.css', dirname)
     51        self.copy_resources(dirname)
    2952
    3053        # where to find the template files
    31         mylookup = TemplateLookup(directories=['templates'])
     54        templates_dir = os.path.dirname(templates.__file__)
     55        mylookup = TemplateLookup(directories=[templates_dir])
    3256
    3357        # render the simulation steps first
Note: See TracChangeset for help on using the changeset viewer.