예제 #1
0
 def setUp(self):
     """
         Create test fixture. Load code and expected results from files.
     """
     with open('tests/data/code.txt') as f:
         self.sf = StreamerFlowchart('Test', f.read())
     with open('tests/data/code_figure.tex') as f:
         self.expectedFigure = f.read()[:-1]  # don't want empty line
     with open('tests/data/code_document.tex') as f:
         self.expectedDocument = f.read()
     self.figure = latex.make_figure(self.sf)
     self.document = latex.make_document([self.figure])
예제 #2
0
def main():
    """
        Run a command line interface that exposes the functionality in a simple
        way.
    """
    parser = argparse.ArgumentParser(
        formatter_class=argparse.RawDescriptionHelpFormatter,
        description=DESC,
        epilog=EPILOG
    )
    parser.add_argument('name', help='the streamer\'s name')
    parser.add_argument('-c', '--config', metavar='configfile',
        help='Path of a JSON file containing a valid config.')
    args = parser.parse_args()
    if args.config is None:  # process single file read from stdin
        streamers = [{'name': args.name, 'code': sys.stdin.read()}]
    else:  # process one or more files from config
        with open(args.config) as cf:
            streamers = json.load(cf)

    flowcharts = (StreamerFlowchart(**s) for s in streamers)
    figures = (latex.make_figure(f) for f in flowcharts)
    document = latex.make_document(figures)
    print(document)