Example #1
0
 def report(self):
   '''
   run reporting modules
   '''
   import pweave
   
   os.chdir('source')
   try:
     pweave.pweave('genPnw.Pnw')
   except:
     sys.stderr.write('error creating data files in %s'%self.here + '/source')
     return
   import glob
   files = glob.glob('K*Pnw')
   for file in files:
     print file
     try:
       pweave.pweave(file)
     except:
       sys.stderr.write('error Pweaving data file %s in %s'%(file,self.here + '/source'))
   os.chdir(self.here)
   cmd = 'make clean html'
   try:
     os.system(cmd)
   except:
     sys.stderr.write('error making html')
   return
Example #2
0
    def report(self):
        '''
    run reporting modules
    '''
        import pweave

        os.chdir('source')
        try:
            pweave.pweave('genPnw.Pnw')
        except:
            sys.stderr.write('error creating data files in %s' % self.here +
                             '/source')
            return
        import glob
        files = glob.glob('K*Pnw')
        for file in files:
            print file
            try:
                pweave.pweave(file)
            except:
                sys.stderr.write('error Pweaving data file %s in %s' %
                                 (file, self.here + '/source'))
        os.chdir(self.here)
        cmd = 'make clean html'
        try:
            os.system(cmd)
        except:
            sys.stderr.write('error making html')
        return
Example #3
0
def weave():

    if len(sys.argv)==1:
        print "This is Pweave %s, enter Pweave -h for help" % pweave.__version__
        sys.exit()

# Command line options
    parser = OptionParser(usage="Pweave [options] sourcefile", version="Pweave " + pweave.__version__)
    parser.add_option("-f", "--format", dest="format", default='rst',
                      help="The output format. Available formats: " + pweave.PwebFormats.shortformats() + " Use Pweave -l to list descriptions or see http://mpastell.com/pweave/formats.html")
    parser.add_option("-i", "--input-format", dest="informat", default='noweb',
                      help="Input format: noweb, notebook or script")
    parser.add_option("-s", "--shell", dest="shell", default='python',
                      help="shell used to run code: python or ipython")
    parser.add_option("-l","--list-formats", dest="listformats", action = "store_true" ,default=False,
                      help="List output formats")
    parser.add_option("-m", "--matplotlib", dest="mplotlib", default='true',
                      help="Do you want to use matplotlib (or Sho with Ironpython) True (default) or False")
    parser.add_option("-d","--documentation-mode", dest="docmode",
                  action = "store_true" ,default=False,
                      help="Use documentation mode, chunk code and results will be loaded from cache and inline code will be hidden")
    parser.add_option("-c","--cache-results", dest="cache",
                  action = "store_true", default=False,
                      help="Cache results to disk for documentation mode")
    parser.add_option("--figure-directory", dest="figdir", default = 'figures',
                      help="Directory path for matplolib graphics: Default 'figures'")
    parser.add_option("--cache-directory", dest="cachedir", default = 'cache',
                      help="Directory path for cached results used in documentation mode: Default 'cache'")
    parser.add_option("-g","--figure-format", dest="figfmt",
                      help="Figure format for matplotlib graphics: Defaults to 'png' for rst and Sphinx html documents and 'pdf' for tex")

    (options, args) = parser.parse_args()
    
    try:
        infile = args[0]
    except:
        infile = ""
    
   

    mplotlib = (options.mplotlib.lower() == 'true')

    if options.figfmt is not None:
        figfmt = ('.%s' % options.figfmt)
    else:
        figfmt = None

    pweave.pweave(infile, doctype = options.format, informat=options.informat, shell=options.shell, plot = mplotlib,
           docmode = options.docmode, cache = options.cache, figdir = options.figdir,
           cachedir = options.cachedir, figformat = figfmt, listformats = options.listformats)
Example #4
0
def test_pweave():
    """Integration test pweave by comparing output to a known good
    reference.

    N.B. can't use anything in the .mdw that will give different
    outputs each time. For example, setting term=True and then
    calling figure() will output a matplotlib figure reference. This
    has a memory pointer that changes every time.
    """
    REF = 'tests/simple_REF.md'
    infile = 'tests/simple.mdw'
    outfile = 'tests/simple.md'
    pweave.pweave(file=infile, doctype="pandoc", figdir='tests/figures')

    # Compare the outfile and the ref
    out = open(outfile)
    ref = open(REF)
    assert(out.read() == ref.read())
Example #5
0
def test_pweave():
    """Integration test pweave by comparing output to a known good
    reference.

    N.B. can't use anything in the .mdw that will give different
    outputs each time. For example, setting term=True and then
    calling figure() will output a matplotlib figure reference. This
    has a memory pointer that changes every time.
    """
    REF = 'tests/simple_REF.md'
    infile = 'tests/simple.mdw'
    outfile = 'tests/simple.md'
    pweave.pweave(file=infile, doctype="pandoc", figdir='tests/figures')

    # Compare the outfile and the ref
    out = open(outfile)
    ref = open(REF)
    assert (out.read() == ref.read())
Example #6
0
import pweave as pw
import os as os
import pweave as pw
from parameters import *

os.system("cp $ROUTINESPATH/Photoz-Analysis/pz_report.Plw ./" + code + "_" + cat_file[:-4] + "_report.Plw")
pw.pweave(code + "_" + cat_file[:-4] + "_report.Plw", doctype = 'tex')
os.system("rm " + code + "_" + cat_file[:-4] + "_report.Plw")
def weave():

    if len(sys.argv) == 1:
        print "This is Pweave %s, enter Pweave -h for help" % pweave.__version__
        sys.exit()


# Command line options
    parser = OptionParser(usage="Pweave [options] sourcefile",
                          version="Pweave " + pweave.__version__)
    parser.add_option(
        "-f",
        "--format",
        dest="format",
        default='rst',
        help="The output format. Available formats: " +
        pweave.PwebFormats.shortformats() +
        " Use Pweave -l to list descriptions or see http://mpastell.com/pweave/formats.html"
    )
    parser.add_option("-i",
                      "--input-format",
                      dest="informat",
                      default='noweb',
                      help="Input format: noweb, notebook or script")
    parser.add_option("-s",
                      "--shell",
                      dest="shell",
                      default='python',
                      help="shell used to run code: python or ipython")
    parser.add_option("-l",
                      "--list-formats",
                      dest="listformats",
                      action="store_true",
                      default=False,
                      help="List output formats")
    parser.add_option(
        "-m",
        "--matplotlib",
        dest="mplotlib",
        default='true',
        help=
        "Do you want to use matplotlib (or Sho with Ironpython) True (default) or False"
    )
    parser.add_option(
        "-d",
        "--documentation-mode",
        dest="docmode",
        action="store_true",
        default=False,
        help=
        "Use documentation mode, chunk code and results will be loaded from cache and inline code will be hidden"
    )
    parser.add_option("-c",
                      "--cache-results",
                      dest="cache",
                      action="store_true",
                      default=False,
                      help="Cache results to disk for documentation mode")
    parser.add_option(
        "--figure-directory",
        dest="figdir",
        default='figures',
        help="Directory path for matplolib graphics: Default 'figures'")
    parser.add_option(
        "--cache-directory",
        dest="cachedir",
        default='cache',
        help=
        "Directory path for cached results used in documentation mode: Default 'cache'"
    )
    parser.add_option(
        "-g",
        "--figure-format",
        dest="figfmt",
        help=
        "Figure format for matplotlib graphics: Defaults to 'png' for rst and Sphinx html documents and 'pdf' for tex"
    )

    (options, args) = parser.parse_args()

    try:
        infile = args[0]
    except:
        infile = ""

    mplotlib = (options.mplotlib.lower() == 'true')

    if options.figfmt is not None:
        figfmt = ('.%s' % options.figfmt)
    else:
        figfmt = None

    pweave.pweave(infile,
                  doctype=options.format,
                  informat=options.informat,
                  shell=options.shell,
                  plot=mplotlib,
                  docmode=options.docmode,
                  cache=options.cache,
                  figdir=options.figdir,
                  cachedir=options.cachedir,
                  figformat=figfmt,
                  listformats=options.listformats)