add space and other flake8 cleanups
This commit is contained in:
parent
225259e521
commit
5e149a5cb8
1 changed files with 24 additions and 24 deletions
|
@ -71,7 +71,7 @@ class Edit(models.Model):
|
||||||
return ('/edits/%s' % quote(self.get_id())).replace('%3A', ':')
|
return ('/edits/%s' % quote(self.get_id())).replace('%3A', ':')
|
||||||
|
|
||||||
def add_clip(self, data, index=None):
|
def add_clip(self, data, index=None):
|
||||||
if index != None:
|
if index is not None:
|
||||||
ids = [i['id'] for i in self.clips.order_by('index').values('id')]
|
ids = [i['id'] for i in self.clips.order_by('index').values('id')]
|
||||||
c = Clip(edit=self)
|
c = Clip(edit=self)
|
||||||
if 'annotation' in data and data['annotation']:
|
if 'annotation' in data and data['annotation']:
|
||||||
|
@ -83,17 +83,17 @@ class Edit(models.Model):
|
||||||
c.end = data['out']
|
c.end = data['out']
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
if index != None:
|
if index is not None:
|
||||||
c.index = index
|
c.index = index
|
||||||
# dont add clip if in/out are invalid
|
# dont add clip if in/out are invalid
|
||||||
if not c.annotation:
|
if not c.annotation:
|
||||||
duration = c.item.sort.duration
|
duration = c.item.sort.duration
|
||||||
if c.start > c.end \
|
if c.start > c.end \
|
||||||
or round(c.start, 3) >= round(duration, 3) \
|
or round(c.start, 3) >= round(duration, 3) \
|
||||||
or round(c.end, 3) > round(duration, 3):
|
or round(c.end, 3) > round(duration, 3):
|
||||||
return False
|
return False
|
||||||
c.save()
|
c.save()
|
||||||
if index != None:
|
if index is not None:
|
||||||
ids.insert(index, c.id)
|
ids.insert(index, c.id)
|
||||||
self.sort_clips(ids)
|
self.sort_clips(ids)
|
||||||
return c
|
return c
|
||||||
|
@ -131,7 +131,7 @@ class Edit(models.Model):
|
||||||
return False
|
return False
|
||||||
if self.user == user or \
|
if self.user == user or \
|
||||||
user.is_staff or \
|
user.is_staff or \
|
||||||
user.profile.capability('canEditFeaturedEdits') == True:
|
user.profile.capability('canEditFeaturedEdits'):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ class Edit(models.Model):
|
||||||
elif value == 'featured':
|
elif value == 'featured':
|
||||||
if user.profile.capability('canEditFeaturedEdits'):
|
if user.profile.capability('canEditFeaturedEdits'):
|
||||||
pos, created = Position.objects.get_or_create(edit=self, user=user,
|
pos, created = Position.objects.get_or_create(edit=self, user=user,
|
||||||
section='featured')
|
section='featured')
|
||||||
if created:
|
if created:
|
||||||
qs = Position.objects.filter(user=user, section='featured')
|
qs = Position.objects.filter(user=user, section='featured')
|
||||||
pos.position = qs.aggregate(Max('position'))['position__max'] + 1
|
pos.position = qs.aggregate(Max('position'))['position__max'] + 1
|
||||||
|
@ -164,14 +164,14 @@ class Edit(models.Model):
|
||||||
elif self.status == 'featured' and value == 'public':
|
elif self.status == 'featured' and value == 'public':
|
||||||
Position.objects.filter(edit=self).delete()
|
Position.objects.filter(edit=self).delete()
|
||||||
pos, created = Position.objects.get_or_create(edit=self,
|
pos, created = Position.objects.get_or_create(edit=self,
|
||||||
user=self.user,section='personal')
|
user=self.user, section='personal')
|
||||||
qs = Position.objects.filter(user=self.user,
|
qs = Position.objects.filter(user=self.user,
|
||||||
section='personal')
|
section='personal')
|
||||||
pos.position = qs.aggregate(Max('position'))['position__max'] + 1
|
pos.position = qs.aggregate(Max('position'))['position__max'] + 1
|
||||||
pos.save()
|
pos.save()
|
||||||
for u in self.subscribed_users.all():
|
for u in self.subscribed_users.all():
|
||||||
pos, created = Position.objects.get_or_create(edit=self, user=u,
|
pos, created = Position.objects.get_or_create(edit=self, user=u,
|
||||||
section='public')
|
section='public')
|
||||||
qs = Position.objects.filter(user=u, section='public')
|
qs = Position.objects.filter(user=u, section='public')
|
||||||
pos.position = qs.aggregate(Max('position'))['position__max'] + 1
|
pos.position = qs.aggregate(Max('position'))['position__max'] + 1
|
||||||
pos.save()
|
pos.save()
|
||||||
|
@ -183,7 +183,7 @@ class Edit(models.Model):
|
||||||
data['name'] = "Untitled"
|
data['name'] = "Untitled"
|
||||||
name = data['name']
|
name = data['name']
|
||||||
num = 1
|
num = 1
|
||||||
while Edit.objects.filter(name=name, user=self.user).exclude(id=self.id).count()>0:
|
while Edit.objects.filter(name=name, user=self.user).exclude(id=self.id).count() > 0:
|
||||||
num += 1
|
num += 1
|
||||||
name = data['name'] + ' [%d]' % num
|
name = data['name'] + ' [%d]' % num
|
||||||
self.name = name
|
self.name = name
|
||||||
|
@ -210,7 +210,7 @@ class Edit(models.Model):
|
||||||
else:
|
else:
|
||||||
self.type = 'smart'
|
self.type = 'smart'
|
||||||
if self.query.get('static', False):
|
if self.query.get('static', False):
|
||||||
self.query = {'conditions': [], 'operator': '&'}
|
self.query = {'conditions': [], 'operator': '&'}
|
||||||
if 'posterFrames' in data:
|
if 'posterFrames' in data:
|
||||||
self.poster_frames = tuple(data['posterFrames'])
|
self.poster_frames = tuple(data['posterFrames'])
|
||||||
self.save()
|
self.save()
|
||||||
|
@ -265,8 +265,8 @@ class Edit(models.Model):
|
||||||
'conditions': get_conditions(condition['conditions'])
|
'conditions': get_conditions(condition['conditions'])
|
||||||
})
|
})
|
||||||
elif condition['key'] == 'annotations' or \
|
elif condition['key'] == 'annotations' or \
|
||||||
get_by_id(settings.CONFIG['layers'], condition['key']):
|
get_by_id(settings.CONFIG['layers'], condition['key']):
|
||||||
clip_conditions.append(condition)
|
clip_conditions.append(condition)
|
||||||
return clip_conditions
|
return clip_conditions
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -335,7 +335,7 @@ class Edit(models.Model):
|
||||||
|
|
||||||
def json(self, keys=None, user=None):
|
def json(self, keys=None, user=None):
|
||||||
if not keys:
|
if not keys:
|
||||||
keys=[
|
keys = [
|
||||||
'clips',
|
'clips',
|
||||||
'description',
|
'description',
|
||||||
'duration',
|
'duration',
|
||||||
|
@ -376,7 +376,7 @@ class Edit(models.Model):
|
||||||
response[key] = 0
|
response[key] = 0
|
||||||
elif self.type == 'static':
|
elif self.type == 'static':
|
||||||
response[key] = sum([(c['annotation__end'] or c['end']) - (c['annotation__start'] or c['start'])
|
response[key] = sum([(c['annotation__end'] or c['end']) - (c['annotation__start'] or c['start'])
|
||||||
for c in clips_qs.values('start', 'end', 'annotation__start', 'annotation__end')])
|
for c in clips_qs.values('start', 'end', 'annotation__start', 'annotation__end')])
|
||||||
else:
|
else:
|
||||||
response[key] = sum([c['end'] - c['start'] for c in clips_qs.values('start', 'end')])
|
response[key] = sum([c['end'] - c['start'] for c in clips_qs.values('start', 'end')])
|
||||||
elif key == 'editable':
|
elif key == 'editable':
|
||||||
|
@ -389,7 +389,7 @@ class Edit(models.Model):
|
||||||
if user and not user.is_anonymous():
|
if user and not user.is_anonymous():
|
||||||
response[key] = self.subscribed_users.filter(id=user.id).exists()
|
response[key] = self.subscribed_users.filter(id=user.id).exists()
|
||||||
elif hasattr(self, _map.get(key, key)):
|
elif hasattr(self, _map.get(key, key)):
|
||||||
response[key] = getattr(self, _map.get(key,key))
|
response[key] = getattr(self, _map.get(key, key))
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def render(self):
|
def render(self):
|
||||||
|
@ -403,7 +403,7 @@ class Edit(models.Model):
|
||||||
cmd = ['avconv', '-i', path,
|
cmd = ['avconv', '-i', path,
|
||||||
'-ss', data['in'], '-t', data['out'],
|
'-ss', data['in'], '-t', data['out'],
|
||||||
'-vcodec', 'copy', '-acodec', 'copy',
|
'-vcodec', 'copy', '-acodec', 'copy',
|
||||||
clips[-1]]
|
clips[-1]]
|
||||||
#p = subprocess.Popen(cmd, close_fds=True)
|
#p = subprocess.Popen(cmd, close_fds=True)
|
||||||
#p.wait()
|
#p.wait()
|
||||||
cmd = ['mkvmerge', clips[0]] \
|
cmd = ['mkvmerge', clips[0]] \
|
||||||
|
@ -426,8 +426,8 @@ class Clip(models.Model):
|
||||||
duration = models.FloatField(default=0)
|
duration = models.FloatField(default=0)
|
||||||
|
|
||||||
hue = models.FloatField(default=0)
|
hue = models.FloatField(default=0)
|
||||||
saturation= models.FloatField(default=0)
|
saturation = models.FloatField(default=0)
|
||||||
lightness= models.FloatField(default=0)
|
lightness = models.FloatField(default=0)
|
||||||
volume = models.FloatField(default=0)
|
volume = models.FloatField(default=0)
|
||||||
sortvalue = models.CharField(max_length=1000, null=True, db_index=True)
|
sortvalue = models.CharField(max_length=1000, null=True, db_index=True)
|
||||||
|
|
||||||
|
@ -447,9 +447,9 @@ class Clip(models.Model):
|
||||||
sortvalue = ''
|
sortvalue = ''
|
||||||
if self.id:
|
if self.id:
|
||||||
for l in settings.CONFIG.get('clipLayers', []):
|
for l in settings.CONFIG.get('clipLayers', []):
|
||||||
sortvalue += ''.join(filter(lambda s: s,
|
sortvalue += ''.join([a.sortvalue
|
||||||
[a.sortvalue
|
for a in self.get_annotations().filter(layer=l)
|
||||||
for a in self.get_annotations().filter(layer=l)]))
|
if a.sortvalue])
|
||||||
if sortvalue:
|
if sortvalue:
|
||||||
self.sortvalue = sortvalue[:900]
|
self.sortvalue = sortvalue[:900]
|
||||||
else:
|
else:
|
||||||
|
@ -462,7 +462,7 @@ class Clip(models.Model):
|
||||||
self.duration = end - start
|
self.duration = end - start
|
||||||
if int(end*25) - int(start*25) > 0:
|
if int(end*25) - int(start*25) > 0:
|
||||||
self.hue, self.saturation, self.lightness = extract.average_color(
|
self.hue, self.saturation, self.lightness = extract.average_color(
|
||||||
self.item.timeline_prefix, self.start, self.end)
|
self.item.timeline_prefix, self.start, self.end)
|
||||||
self.volume = extract.average_volume(self.item.timeline_prefix, self.start, self.end)
|
self.volume = extract.average_volume(self.item.timeline_prefix, self.start, self.end)
|
||||||
else:
|
else:
|
||||||
self.hue = self.saturation = self.lightness = 0
|
self.hue = self.saturation = self.lightness = 0
|
||||||
|
|
Loading…
Reference in a new issue