python2.7 friendly
This commit is contained in:
parent
06e89c264b
commit
b4a490901a
2 changed files with 4 additions and 2 deletions
|
@ -119,7 +119,7 @@ class Chop(object):
|
||||||
self.keyframes = make_keyframe_index(video)
|
self.keyframes = make_keyframe_index(video)
|
||||||
return self.keyframes
|
return self.keyframes
|
||||||
|
|
||||||
def get_gop_sections(self, start: float, end: float) -> dict:
|
def get_gop_sections(self, start, end):
|
||||||
keyframes = self.get_keyframes()
|
keyframes = self.get_keyframes()
|
||||||
start_pos = bisect_left(keyframes, start)
|
start_pos = bisect_left(keyframes, start)
|
||||||
end_pos = bisect_left(keyframes, end)
|
end_pos = bisect_left(keyframes, end)
|
||||||
|
|
|
@ -17,7 +17,7 @@ class JSONField(django.contrib.postgres.fields.JSONField):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if 'encoder' not in kwargs:
|
if 'encoder' not in kwargs:
|
||||||
kwargs['encoder'] = DjangoJSONEncoder
|
kwargs['encoder'] = DjangoJSONEncoder
|
||||||
super().__init__(*args, **kwargs)
|
super(JSONField, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
def to_json(python_object):
|
def to_json(python_object):
|
||||||
if isinstance(python_object, datetime.datetime):
|
if isinstance(python_object, datetime.datetime):
|
||||||
|
@ -74,6 +74,8 @@ class DictField(models.TextField):
|
||||||
except:
|
except:
|
||||||
raise Exception('failed to parse value: %s' % value)
|
raise Exception('failed to parse value: %s' % value)
|
||||||
if value is not None:
|
if value is not None:
|
||||||
|
if isinstance(value, string_types):
|
||||||
|
value = json.loads(value)
|
||||||
assert isinstance(value, self._type)
|
assert isinstance(value, self._type)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue