From 6aabe8d9dfc37fd70b784499d9f029aabf3a8bf1 Mon Sep 17 00:00:00 2001 From: j Date: Wed, 31 Aug 2016 00:31:38 +0200 Subject: [PATCH] py3 fixes --- pandora/archive/chunk.py | 4 ++-- pandora/archive/extract.py | 4 ++-- pandora/archive/models.py | 4 ++-- pandora/oxdjango/api/actions.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pandora/archive/chunk.py b/pandora/archive/chunk.py index 045d007f8..56afe8088 100644 --- a/pandora/archive/chunk.py +++ b/pandora/archive/chunk.py @@ -17,7 +17,7 @@ def save_chunk(obj, file, chunk, offset, name, done_cb=None): if not file: file.name = name 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()) obj.save() else: @@ -27,7 +27,7 @@ def save_chunk(obj, file, chunk, offset, name, done_cb=None): offset = size elif offset > size: return False, size - with open(path, 'r+') as f: + with open(path, 'rb+') as f: f.seek(offset) f.write(chunk.read()) return done_cb() if done_cb else True, file.size diff --git a/pandora/archive/extract.py b/pandora/archive/extract.py index 98d804677..641a08645 100644 --- a/pandora/archive/extract.py +++ b/pandora/archive/extract.py @@ -31,7 +31,7 @@ class AspectRatio(fractions.Fraction): def __new__(cls, numerator, denominator=None): if not denominator: - ratio = map(int, numerator.split(':')) + ratio = list(map(int, numerator.split(':'))) if len(ratio) == 1: ratio.append(1) numerator = ratio[0] @@ -560,7 +560,7 @@ def timeline_strip(item, cuts, info, prefix): if cuts[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): i = int(frame / timeline_width) diff --git a/pandora/archive/models.py b/pandora/archive/models.py index a5d42d289..f45e5082d 100644 --- a/pandora/archive/models.py +++ b/pandora/archive/models.py @@ -215,7 +215,7 @@ class File(models.Model): add_file(f) versions = ox.movie.parse_item_files(files) 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: return p[0]['normalizedPath'] @@ -774,7 +774,7 @@ class Stream(models.Model): self.duration = self.info.get('duration', 0) if 'video' in self.info and self.info['video']: 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] else: self.aspect_ratio = self.info['video'][0]['width'] / self.info['video'][0]['height'] diff --git a/pandora/oxdjango/api/actions.py b/pandora/oxdjango/api/actions.py index 87bed6253..970145974 100644 --- a/pandora/oxdjango/api/actions.py +++ b/pandora/oxdjango/api/actions.py @@ -29,14 +29,14 @@ def trim(docstring): # and split into a list of lines: lines = docstring.expandtabs().splitlines() # Determine minimum indentation (first line doesn't count): - indent = sys.maxint + indent = sys.maxsize for line in lines[1:]: stripped = line.lstrip() if stripped: indent = min(indent, len(line) - len(stripped)) # Remove indentation (first line is special): trimmed = [lines[0].strip()] - if indent < sys.maxint: + if indent < sys.maxsize: for line in lines[1:]: trimmed.append(line[indent:].rstrip()) # Strip off trailing and leading blank lines: