py3 fixes

This commit is contained in:
j 2016-08-31 00:31:38 +02:00
parent 9b3547f9bc
commit 6aabe8d9df
4 changed files with 8 additions and 8 deletions

View file

@ -17,7 +17,7 @@ def save_chunk(obj, file, chunk, offset, name, done_cb=None):
if not file: if not file:
file.name = name file.name = name
ox.makedirs(os.path.dirname(file.path)) ox.makedirs(os.path.dirname(file.path))
with open(file.path, 'w') as f: with open(file.path, 'wb') as f:
f.write(chunk.read()) f.write(chunk.read())
obj.save() obj.save()
else: else:
@ -27,7 +27,7 @@ def save_chunk(obj, file, chunk, offset, name, done_cb=None):
offset = size offset = size
elif offset > size: elif offset > size:
return False, size return False, size
with open(path, 'r+') as f: with open(path, 'rb+') as f:
f.seek(offset) f.seek(offset)
f.write(chunk.read()) f.write(chunk.read())
return done_cb() if done_cb else True, file.size return done_cb() if done_cb else True, file.size

View file

@ -31,7 +31,7 @@ class AspectRatio(fractions.Fraction):
def __new__(cls, numerator, denominator=None): def __new__(cls, numerator, denominator=None):
if not denominator: if not denominator:
ratio = map(int, numerator.split(':')) ratio = list(map(int, numerator.split(':')))
if len(ratio) == 1: if len(ratio) == 1:
ratio.append(1) ratio.append(1)
numerator = ratio[0] numerator = ratio[0]
@ -560,7 +560,7 @@ def timeline_strip(item, cuts, info, prefix):
if cuts[0] != 0: if cuts[0] != 0:
cuts.insert(0, 0) cuts.insert(0, 0)
cuts = map(lambda x: int(round(x * fps)), cuts) cuts = list(map(lambda x: int(round(x * fps)), cuts))
for frame in range(frames): for frame in range(frames):
i = int(frame / timeline_width) i = int(frame / timeline_width)

View file

@ -215,7 +215,7 @@ class File(models.Model):
add_file(f) add_file(f)
versions = ox.movie.parse_item_files(files) versions = ox.movie.parse_item_files(files)
for version in versions: for version in versions:
p = filter(lambda f: f['oshash'] == self.oshash, version['files']) p = list(filter(lambda f: f['oshash'] == self.oshash, version['files']))
if p: if p:
return p[0]['normalizedPath'] return p[0]['normalizedPath']
@ -774,7 +774,7 @@ class Stream(models.Model):
self.duration = self.info.get('duration', 0) self.duration = self.info.get('duration', 0)
if 'video' in self.info and self.info['video']: if 'video' in self.info and self.info['video']:
if 'display_aspect_ratio' in self.info['video'][0]: if 'display_aspect_ratio' in self.info['video'][0]:
dar = map(int, self.info['video'][0]['display_aspect_ratio'].split(':')) dar = list(map(int, self.info['video'][0]['display_aspect_ratio'].split(':')))
self.aspect_ratio = dar[0] / dar[1] self.aspect_ratio = dar[0] / dar[1]
else: else:
self.aspect_ratio = self.info['video'][0]['width'] / self.info['video'][0]['height'] self.aspect_ratio = self.info['video'][0]['width'] / self.info['video'][0]['height']

View file

@ -29,14 +29,14 @@ def trim(docstring):
# and split into a list of lines: # and split into a list of lines:
lines = docstring.expandtabs().splitlines() lines = docstring.expandtabs().splitlines()
# Determine minimum indentation (first line doesn't count): # Determine minimum indentation (first line doesn't count):
indent = sys.maxint indent = sys.maxsize
for line in lines[1:]: for line in lines[1:]:
stripped = line.lstrip() stripped = line.lstrip()
if stripped: if stripped:
indent = min(indent, len(line) - len(stripped)) indent = min(indent, len(line) - len(stripped))
# Remove indentation (first line is special): # Remove indentation (first line is special):
trimmed = [lines[0].strip()] trimmed = [lines[0].strip()]
if indent < sys.maxint: if indent < sys.maxsize:
for line in lines[1:]: for line in lines[1:]:
trimmed.append(line[indent:].rstrip()) trimmed.append(line[indent:].rstrip())
# Strip off trailing and leading blank lines: # Strip off trailing and leading blank lines: