Make it work with Python 3.
Chris Pressey
4 years ago
|
0 |
Jinja2==2.10
|
|
1 |
PyYAML==3.12
|
|
2 |
tqdm==4.19.6
|
1 | 1 |
import os
|
2 | 2 |
import sys
|
3 | 3 |
|
4 | |
from kinoje.utils import Executor, load_config_file
|
|
4 |
from kinoje.utils import Executor, load_config_file, zrange
|
5 | 5 |
|
6 | 6 |
|
7 | 7 |
SUPPORTED_OUTPUT_FORMATS = ('.m4v', '.mp4', '.gif')
|
|
45 | 45 |
# TODO: show some warning if this is not an integer delay
|
46 | 46 |
delay = int(100.0 / self.config['fps'])
|
47 | 47 |
|
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)]
|
49 | 49 |
if self.config.get('shorten_final_frame'):
|
50 | 50 |
filespec = ' '.join(filenames[:-1] + ['-delay', str(delay / 2), filenames[-1]])
|
51 | 51 |
else:
|
5 | 5 |
|
6 | 6 |
from jinja2 import Template
|
7 | 7 |
|
8 | |
from kinoje.utils import Executor, fmod, tween, load_config_file
|
|
8 |
from kinoje.utils import Executor, fmod, tween, load_config_file, items, zrange
|
9 | 9 |
|
10 | 10 |
|
11 | 11 |
class Expander(object):
|
|
21 | 21 |
self.tqdm = tqdm
|
22 | 22 |
|
23 | 23 |
self.fun_context = {}
|
24 | |
for key, value in self.config.get('functions', {}).iteritems():
|
|
24 |
for key, value in items(self.config.get('functions', {})):
|
25 | 25 |
self.fun_context[key] = eval("lambda x: " + value)
|
26 | 26 |
|
27 | 27 |
def fillout_template(self, frame, t):
|
|
42 | 42 |
def expand_all(self):
|
43 | 43 |
t = self.config['start']
|
44 | 44 |
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'])):
|
46 | 46 |
self.fillout_template(frame, t)
|
47 | 47 |
t += t_step
|
48 | 48 |
|
0 | 0 |
import os
|
1 | 1 |
import sys
|
2 | 2 |
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)
|
3 | 17 |
|
4 | 18 |
|
5 | 19 |
def load_config_file(filename):
|