From 00c8db1a1999a8a7522bb9ec90843c1a1303bff1 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 22 Jan 2011 15:44:30 +0530 Subject: [PATCH] import cleanup --- pandora/annotaion/models.py | 1 - pandora/api/models.py | 2 -- pandora/archive/models.py | 32 +++++++++++++++++++------------- pandora/item/models.py | 9 +++++---- pandora/itemlist/models.py | 11 ++++++++--- pandora/user/models.py | 3 --- pandora/user/views.py | 1 - static/js/pandora.js | 2 +- 8 files changed, 33 insertions(+), 28 deletions(-) diff --git a/pandora/annotaion/models.py b/pandora/annotaion/models.py index 3754473ff..a337dfc0d 100644 --- a/pandora/annotaion/models.py +++ b/pandora/annotaion/models.py @@ -7,7 +7,6 @@ from django.contrib.auth.models import User import utils - class Layer(models.Model): class Meta: diff --git a/pandora/api/models.py b/pandora/api/models.py index dc3eab498..04d0a3cef 100644 --- a/pandora/api/models.py +++ b/pandora/api/models.py @@ -1,5 +1,3 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 -from item.models import * - diff --git a/pandora/archive/models.py b/pandora/archive/models.py index 7393f0777..5a3be5c28 100644 --- a/pandora/archive/models.py +++ b/pandora/archive/models.py @@ -78,24 +78,28 @@ class File(models.Model): setattr(self, key, self.info.get(key, 0)) if 'video' in self.info and self.info['video']: - self.video_codec = self.info['video'][0]['codec'] - self.width = self.info['video'][0]['width'] - self.height = self.info['video'][0]['height'] - self.framerate = self.info['video'][0]['framerate'] - if 'display_aspect_ratio' in self.info['video'][0]: - self.display_aspect_ratio = self.info['video'][0]['display_aspect_ratio'] + video = self.info['video'][0] + self.video_codec = video['codec'] + self.width = video['width'] + self.height = video['height'] + self.framerate = video['framerate'] + if 'display_aspect_ratio' in video: + self.display_aspect_ratio = video['display_aspect_ratio'] else: self.display_aspect_ratio = "%s:%s" % (self.width, self.height) self.is_video = True self.is_audio = False - if self.name.endswith('.jpg') or self.name.endswith('.png') or self.duration == 0.04: + if self.name.endswith('.jpg') or \ + self.name.endswith('.png') or \ + self.duration == 0.04: self.is_video = False else: self.is_video = False if 'audio' in self.info and self.info['audio']: - self.audio_codec = self.info['audio'][0]['codec'] - self.samplerate = self.info['audio'][0].get('samplerate', 0) - self.channels = self.info['audio'][0].get('channels', 0) + audio = self.info['audio'][0] + self.audio_codec = audio['codec'] + self.samplerate = audio.get('samplerate', 0) + self.channels = audio.get('channels', 0) if not self.is_video: self.is_audio = True @@ -118,8 +122,10 @@ class File(models.Model): super(File, self).save(*args, **kwargs) #upload and data handling - video = models.FileField(null=True, blank=True, upload_to=lambda f, x: f.path('%s.webm'%settings.VIDEO_PROFILE)) - data = models.FileField(null=True, blank=True, upload_to=lambda f, x: f.path('data.bin')) + video = models.FileField(null=True, blank=True, + upload_to=lambda f, x: f.path('%s.webm'%settings.VIDEO_PROFILE)) + data = models.FileField(null=True, blank=True, + upload_to=lambda f, x: f.path('data.bin')) def path(self, name): h = self.oshash @@ -297,4 +303,4 @@ class Frame(models.Model): ''' def __unicode__(self): - return u'%s at %s' % (self.file, self.position) + return u'%s/%s' % (self.file, self.position) diff --git a/pandora/item/models.py b/pandora/item/models.py index 6d3860f3a..84ea9d3e6 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -6,7 +6,6 @@ from datetime import datetime import os.path import subprocess from glob import glob -import unicodedata from django.db import models from django.core.files.base import ContentFile @@ -24,7 +23,7 @@ import utils import tasks from archive import extract -from annotaion.models import Annotation, Layer +from annotaion.models import Annotation from person.models import get_name_sort from app.models import site_config @@ -103,13 +102,15 @@ class Item(models.Model): external_data = fields.DictField(default={}, editable=False) data = fields.DictField(default={}, editable=False) json = fields.DictField(default={}, editable=False) - poster = models.ImageField(default=None, blank=True, upload_to=lambda i, x: i.path("poster.jpg")) + poster = models.ImageField(default=None, blank=True, + upload_to=lambda i, x: i.path("poster.jpg")) poster_url = models.TextField(blank=True) poster_height = models.IntegerField(default=0) poster_width = models.IntegerField(default=0) poster_frame = models.FloatField(default=-1) - icon = models.ImageField(default=None, blank=True, upload_to=lambda i, x: i.path("icon.jpg")) + icon = models.ImageField(default=None, blank=True, + upload_to=lambda i, x: i.path("icon.jpg")) #stream related fields stream_aspect = models.FloatField(default=4/3) diff --git a/pandora/itemlist/models.py b/pandora/itemlist/models.py index 885d3b55d..d55c936f0 100644 --- a/pandora/itemlist/models.py +++ b/pandora/itemlist/models.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 from __future__ import division, with_statement +import os +import subprocess from django.db import models from django.contrib.auth.models import User @@ -26,7 +28,8 @@ class List(models.Model): type= models.CharField(max_length=255, default='static') description = models.TextField(default='') - icon = models.ImageField(default=None, blank=True, upload_to=lambda i, x: i.path("icon.jpg")) + icon = models.ImageField(default=None, blank=True, + upload_to=lambda i, x: i.path("icon.jpg")) #is through table still required? items = models.ManyToManyField('item.Item', related_name='lists', @@ -73,7 +76,9 @@ class List(models.Model): return True return False - def json(self, keys=['id', 'name', 'user', 'type', 'query', 'status', 'subscribed'], user=None): + def json(self, keys=None, user=None): + if not keys: + keys=['id', 'name', 'user', 'type', 'query', 'status', 'subscribed'] response = {} for key in keys: if key == 'items': @@ -98,7 +103,7 @@ class List(models.Model): def make_icon(self): frames = [] - iself.icon.name = self.path('icon.png') + self.icon.name = self.path('icon.png') icon = self.icon.path if frames: cmd = [ diff --git a/pandora/user/models.py b/pandora/user/models.py index e2fa1d25f..6f1fd24ce 100644 --- a/pandora/user/models.py +++ b/pandora/user/models.py @@ -1,14 +1,11 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 -import os from datetime import datetime from django.contrib.auth.models import User from django.db import models from django.db.models import Max -from django.conf import settings -from ox.utils import json from ox.django.fields import DictField from app.models import site_config diff --git a/pandora/user/views.py b/pandora/user/views.py index 86fa8896f..bc9bf3c03 100644 --- a/pandora/user/views.py +++ b/pandora/user/views.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 -import os import random random.seed() diff --git a/static/js/pandora.js b/static/js/pandora.js index 375d84765..0d6edff28 100755 --- a/static/js/pandora.js +++ b/static/js/pandora.js @@ -3649,4 +3649,4 @@ var pandora = new Ox.App({ load(); -}); \ No newline at end of file +//});