git @ Cat's Eye Technologies kinoje / d0495b8
Make it work with Python 3. Chris Pressey 4 years ago
4 changed file(s) with 22 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
0 Jinja2==2.10
1 PyYAML==3.12
2 tqdm==4.19.6
11 import os
22 import sys
33
4 from kinoje.utils import Executor, load_config_file
4 from kinoje.utils import Executor, load_config_file, zrange
55
66
77 SUPPORTED_OUTPUT_FORMATS = ('.m4v', '.mp4', '.gif')
4545 # TODO: show some warning if this is not an integer delay
4646 delay = int(100.0 / self.config['fps'])
4747
48 filenames = [os.path.join(self.dirname, self.frame_fmt % f) for f in xrange(0, num_frames)]
48 filenames = [os.path.join(self.dirname, self.frame_fmt % f) for f in zrange(0, num_frames)]
4949 if self.config.get('shorten_final_frame'):
5050 filespec = ' '.join(filenames[:-1] + ['-delay', str(delay / 2), filenames[-1]])
5151 else:
55
66 from jinja2 import Template
77
8 from kinoje.utils import Executor, fmod, tween, load_config_file
8 from kinoje.utils import Executor, fmod, tween, load_config_file, items, zrange
99
1010
1111 class Expander(object):
2121 self.tqdm = tqdm
2222
2323 self.fun_context = {}
24 for key, value in self.config.get('functions', {}).iteritems():
24 for key, value in items(self.config.get('functions', {})):
2525 self.fun_context[key] = eval("lambda x: " + value)
2626
2727 def fillout_template(self, frame, t):
4242 def expand_all(self):
4343 t = self.config['start']
4444 t_step = self.config['t_step']
45 for frame in self.tqdm(xrange(self.config['num_frames'])):
45 for frame in self.tqdm(zrange(self.config['num_frames'])):
4646 self.fillout_template(frame, t)
4747 t += t_step
4848
00 import os
11 import sys
22 from subprocess import check_call
3
4
5 def items(d):
6 try:
7 return d.iteritems()
8 except AttributeError:
9 return d.items()
10
11
12 def zrange(*args):
13 try:
14 return xrange(*args)
15 except NameError:
16 return range(*args)
317
418
519 def load_config_file(filename):