git @ Cat's Eye Technologies kinoje / 9348ba1
Support for loading multiple config files as successive overlays. Chris Pressey 3 years ago
5 changed file(s) with 33 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
11 import os
22 import sys
33
4 from kinoje.utils import BaseProcessor, load_config_file, zrange
4 from kinoje.utils import BaseProcessor, load_config_files, zrange
55
66
77 SUPPORTED_OUTPUT_FORMATS = ('.m4v', '.mp4', '.gif')
7676 def main():
7777 argparser = ArgumentParser()
7878
79 argparser.add_argument('configfile', metavar='FILENAME', type=str,
80 help='Configuration file containing the template and parameters'
79 argparser.add_argument('configfile', metavar='FILENAME(S)', type=str,
80 help='Configuration file containing the template and parameters. '
81 'May be a comma-separated list of YAML files, where successive '
82 'files are applied as overlays.'
8183 )
8284 argparser.add_argument('framesdir', metavar='DIRNAME', type=str,
8385 help='Directory that will be populated with image of each single frame'
104106 if outext not in SUPPORTED_OUTPUT_FORMATS:
105107 raise ValueError("%s not a supported output format (%r)" % (outext, SUPPORTED_OUTPUT_FORMATS))
106108
107 config = load_config_file(options.configfile)
109 config = load_config_files(options.configfile)
108110 config['shorten_final_frame'] = options.shorten_final_frame
109111
110112 compiler = Compiler.get_class_for(options.output)(config, options.framesdir, options.output)
55
66 from jinja2 import Template
77
8 from kinoje.utils import BaseProcessor, fmod, tween, load_config_file, items, zrange
8 from kinoje.utils import BaseProcessor, fmod, tween, load_config_files, items, zrange
99
1010
1111 class Expander(BaseProcessor):
4646 argparser = ArgumentParser()
4747
4848 argparser.add_argument('configfile', metavar='FILENAME', type=str,
49 help='Configuration file containing the template and parameters'
49 help='Configuration file containing the template and parameters. '
50 'May be a comma-separated list of YAML files, where successive '
51 'files are applied as overlays.'
5052 )
5153 argparser.add_argument('instantsdir', metavar='DIRNAME', type=str,
5254 help='Directory that will be populated with instants (text files describing frames)'
5557
5658 options = argparser.parse_args(sys.argv[1:])
5759
58 config = load_config_file(options.configfile)
60 config = load_config_files(options.configfile)
5961
6062 expander = Expander(config, options.instantsdir)
6163 expander.expand_all()
1111 from kinoje.renderer import Renderer
1212 from kinoje.compiler import Compiler, SUPPORTED_OUTPUT_FORMATS
1313
14 from kinoje.utils import LoggingExecutor, load_config_file
14 from kinoje.utils import LoggingExecutor, load_config_files
1515
1616
1717 def main():
1818 argparser = ArgumentParser()
1919
20 argparser.add_argument('configfile', metavar='FILENAME', type=str,
20 argparser.add_argument('configfile', metavar='FILENAME(S)', type=str,
2121 help='A YAML file containing the template to render for each frame, '
22 'as well as configuration for rendering the template.'
22 'as well as configuration for rendering the template. '
23 'May be a comma-separated list of YAML files, where successive '
24 'files are applied as overlays.'
2325 )
2426 argparser.add_argument('-o', '--output', metavar='FILENAME', type=str, default=None,
2527 help='The movie file to create. The extension of this filename '
3941
4042 CompilerClass = Compiler.get_class_for(output_filename)
4143
42 config = load_config_file(options.configfile)
44 config = load_config_files(options.configfile)
4345
4446 fd, log_filename = mkstemp()
4547 exe = LoggingExecutor(log_filename)
22 import os
33 import sys
44
5 from kinoje.utils import BaseProcessor, load_config_file
5 from kinoje.utils import BaseProcessor, load_config_files
66
77
88 class Renderer(BaseProcessor):
4040 def main():
4141 argparser = ArgumentParser()
4242
43 argparser.add_argument('configfile', metavar='FILENAME', type=str,
44 help='Configuration file containing the template and parameters'
43 argparser.add_argument('configfile', metavar='FILENAME(S)', type=str,
44 help='Configuration file containing the template and parameters. '
45 'May be a comma-separated list of YAML files, where successive '
46 'files are applied as overlays.'
4547 )
4648 argparser.add_argument('instantsdir', metavar='DIRNAME', type=str,
4749 help='Directory containing instants (text file descriptions of each single frame) to render'
5355
5456 options = argparser.parse_args(sys.argv[1:])
5557
56 config = load_config_file(options.configfile)
58 config = load_config_files(options.configfile)
5759
5860 renderer = Renderer(config, options.instantsdir, options.framesdir)
5961 renderer.render_all()
2323 return xrange(*args)
2424 except NameError:
2525 return range(*args)
26
27
28 def load_config_files(filenames):
29 if ',' in filenames:
30 config = {}
31 for filename in filenames.split(','):
32 config.update(load_config_file(filename))
33 return config
34 else:
35 return load_config_file(filenames)
2636
2737
2838 def load_config_file(filename):