aboutsummaryrefslogtreecommitdiffstats
path: root/lvc/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'lvc/utils.py')
-rw-r--r--lvc/utils.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/lvc/utils.py b/lvc/utils.py
index e0a64f3..3b79433 100644
--- a/lvc/utils.py
+++ b/lvc/utils.py
@@ -4,6 +4,7 @@ import logging
import os
import sys
+
def hms_to_seconds(hours, minutes, seconds):
return (hours * 3600 +
minutes * 60 +
@@ -25,8 +26,7 @@ def round_even(num):
def rescale_video((source_width, source_height),
- (target_width, target_height),
- dont_upsize=True):
+ (target_width, target_height), dont_upsize=True):
"""
Rescale a video given a (width, height) target. This returns the largest
(width, height) which maintains the original aspect ratio while fitting
@@ -42,7 +42,7 @@ def rescale_video((source_width, source_height),
return (round_even(source_width), round_even(source_height))
if (dont_upsize and
- (source_width <= target_width or source_height <= target_height)):
+ (source_width <= target_width or source_height <= target_height)):
return (round_even(source_width), round_even(source_height))
width_ratio = float(source_width) / float(target_width)
@@ -50,6 +50,7 @@ def rescale_video((source_width, source_height),
ratio = max(width_ratio, height_ratio)
return round_even(source_width / ratio), round_even(source_height / ratio)
+
def line_reader(handle):
"""Builds a line reading generator for the given handle. This
generator breaks on empty strings, \\r and \\n.
@@ -92,7 +93,7 @@ class Matrix(object):
def __init__(self, columns, rows, initial_value=None):
self.columns = columns
self.rows = rows
- self.data = [ initial_value ] * (columns * rows)
+ self.data = [initial_value] * (columns * rows)
def __getitem__(self, key):
return self.data[(key[0] * self.rows) + key[1]]
@@ -138,7 +139,7 @@ class Cache(object):
if key in self.dict:
existing_invalidator = self.invalidators[key]
if (existing_invalidator is None or
- not existing_invalidator(key)):
+ not existing_invalidator(key)):
self.access_times[key] = self.counter.next()
return self.dict[key]
@@ -204,6 +205,7 @@ def size_string(nbytes):
else:
return "%(size)s B" % {"size": nbytes}
+
def convert_path_for_subprocess(path):
"""Convert a path to a form suitable for passing to a subprocess.