diff --git a/oxtimelines/timeline.py b/oxtimelines/timeline.py index dbba494..30cbf25 100644 --- a/oxtimelines/timeline.py +++ b/oxtimelines/timeline.py @@ -2,7 +2,7 @@ # vi:si:et:sw=4:sts=4:ts=4 # GPL 2008-2012 -from __future__ import division +from __future__ import division, with_statement from glob import glob import Image @@ -321,11 +321,12 @@ class Timelines(): #remove tiles that might exist from previous run if not self.points: for mode in self.modes: - tiles = glob('%s/timeline%s*%d*.jpg' % (self.tile_path, mode, self.large_tile_h)) + type = 'png' if mode == 'data' else 'jpg' + tiles = glob('%s/timeline%s*%d*.%s' % (self.tile_path, mode, self.large_tile_h, type)) for f in ox.sorted_strings(tiles)[self.large_tile_i+2:]: os.unlink(f) if self.render_small_tiles: - tiles = glob('%s/timeline%s*%d*.jpg' % (self.tile_path, mode, self.small_tile_h)) + tiles = glob('%s/timeline%s*%d*.%s' % (self.tile_path, mode, self.small_tile_h, type)) for f in ox.sorted_strings(tiles)[self.small_tile_i+2:]: os.unlink(f) @@ -526,7 +527,7 @@ class Timelines(): def _open_full_tile(self): if self.large_tile_n == 1: - self.full_tile_widhts = [self.large_tile_last_w] + self.full_tile_widths = [self.large_tile_last_w] else: full_tile_w = self.full_tile_w full_tile_n = self.large_tile_n @@ -629,11 +630,10 @@ class Timelines(): if self.cuts_path: # remove cuts at max_cut_len self.cuts = filter(lambda x: x not in self.no_cuts, self.cuts) - f = open(self.cuts_path + 'cuts.json', 'w') - # remove 0 and frame_n from cuts - # avoid float rounding artefacts - f.write('[' + ', '.join(map(lambda x: '%.2f' % (x / FPS), self.cuts[1:-1])) + ']') - f.close() + with open(self.cuts_path, 'w') as f: + # remove 0 and frame_n from cuts + # avoid float rounding artefacts + f.write('[' + ', '.join(map(lambda x: '%.2f' % (x / FPS), self.cuts[1:-1])) + ']') if self.render_audio: self._render_audio(self.volume) if self.log: