many emptyfications
This commit is contained in:
parent
400cb1424e
commit
f6e2f0a657
13 changed files with 51 additions and 46 deletions
|
|
@ -65,7 +65,7 @@ class SubtitlesPage(BasePage):
|
|||
subtitle.url = url
|
||||
subtitle.language = unicode('fr')
|
||||
subtitle.nb_cd = nb_cd
|
||||
subtitle.description = NotAvailable.__unicode__()
|
||||
subtitle.description = NotAvailable
|
||||
return subtitle
|
||||
|
||||
def iter_subtitles(self,language, pattern):
|
||||
|
|
@ -108,5 +108,5 @@ class SubtitlesPage(BasePage):
|
|||
subtitle.url = url
|
||||
subtitle.language = unicode('fr')
|
||||
subtitle.nb_cd = nb_cd
|
||||
subtitle.description = NotAvailable.__unicode__()
|
||||
subtitle.description = NotAvailable
|
||||
yield subtitle
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ from __future__ import with_statement
|
|||
import sys
|
||||
|
||||
from weboob.capabilities.lyrics import ICapLyrics
|
||||
from weboob.capabilities.base import empty
|
||||
from weboob.tools.application.repl import ReplApplication
|
||||
from weboob.capabilities.base import NotAvailable,NotLoaded
|
||||
from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter
|
||||
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ class LyricsListFormatter(PrettyFormatter):
|
|||
|
||||
def get_description(self, obj):
|
||||
artist = u''
|
||||
if obj.artist != NotAvailable and obj.artist != NotLoaded:
|
||||
if not empty(obj.artist):
|
||||
artist = obj.artist
|
||||
return '%s' % artist
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ from weboob.applications.suboob.suboob import SubtitleInfoFormatter, SubtitleLis
|
|||
from weboob.capabilities.torrent import ICapTorrent, MagnetOnly
|
||||
from weboob.capabilities.cinema import ICapCinema
|
||||
from weboob.capabilities.subtitle import ICapSubtitle
|
||||
from weboob.capabilities.base import NotAvailable,NotLoaded,empty
|
||||
from weboob.capabilities.base import empty
|
||||
from weboob.tools.application.repl import ReplApplication
|
||||
from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter
|
||||
from weboob.core import CallErrors
|
||||
|
|
@ -419,7 +419,7 @@ class Cineoob(ReplApplication):
|
|||
|
||||
# i would like to clarify with fillobj but how could i fill the movie AND choose the country ?
|
||||
for backend, release in self.do('get_movie_releases', movie.id, country, caps=ICapCinema):
|
||||
if release != NotAvailable:
|
||||
if not empty(release):
|
||||
movie.all_release_dates = u'%s' % (release)
|
||||
else:
|
||||
print >>sys.stderr, 'Movie releases not found: %s' % id
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ from __future__ import with_statement
|
|||
import sys
|
||||
|
||||
from weboob.capabilities.recipe import ICapRecipe
|
||||
from weboob.capabilities.base import NotAvailable, NotLoaded, empty
|
||||
from weboob.capabilities.base import empty
|
||||
from weboob.tools.application.repl import ReplApplication
|
||||
from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ from PyQt4.QtGui import QFrame, QImage, QPixmap, QApplication
|
|||
from PyQt4.QtCore import Qt
|
||||
|
||||
from weboob.applications.qcineoob.ui.minimovie_ui import Ui_MiniMovie
|
||||
from weboob.capabilities.base import NotAvailable
|
||||
from weboob.capabilities.base import empty
|
||||
|
||||
class MiniMovie(QFrame):
|
||||
def __init__(self, weboob, backend, movie, parent=None):
|
||||
|
|
@ -41,7 +41,7 @@ class MiniMovie(QFrame):
|
|||
|
||||
def gotThumbnail(self):
|
||||
self.backend.fill_movie(self.movie,('thumbnail_url'))
|
||||
if self.movie.thumbnail_url != NotAvailable:
|
||||
if not empty(self.movie.thumbnail_url):
|
||||
data = urllib.urlopen(self.movie.thumbnail_url).read()
|
||||
img = QImage.fromData(data)
|
||||
self.ui.imageLabel.setPixmap(QPixmap.fromImage(img))
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ from PyQt4.QtGui import QFrame, QImage, QPixmap, QApplication
|
|||
from PyQt4.QtCore import Qt
|
||||
|
||||
from weboob.applications.qcineoob.ui.miniperson_ui import Ui_MiniPerson
|
||||
from weboob.capabilities.base import NotAvailable
|
||||
from weboob.capabilities.base import empty
|
||||
|
||||
class MiniPerson(QFrame):
|
||||
def __init__(self, weboob, backend, person, parent=None):
|
||||
|
|
@ -36,7 +36,7 @@ class MiniPerson(QFrame):
|
|||
self.backend = backend
|
||||
self.person = person
|
||||
self.ui.nameLabel.setText('%s'%person.name)
|
||||
if person.short_description != NotAvailable:
|
||||
if not empty(person.short_description):
|
||||
if unicode(self.parent.ui.currentActionLabel.text()).startswith('Casting'):
|
||||
self.ui.shortDescTitleLabel.setText(u'Role')
|
||||
self.ui.shortDescLabel.setText('%s'%person.short_description)
|
||||
|
|
@ -47,7 +47,7 @@ class MiniPerson(QFrame):
|
|||
|
||||
def gotThumbnail(self):
|
||||
self.backend.fill_person(self.person,('thumbnail_url'))
|
||||
if self.person.thumbnail_url != NotAvailable:
|
||||
if not empty(self.person.thumbnail_url):
|
||||
data = urllib.urlopen(self.person.thumbnail_url).read()
|
||||
img = QImage.fromData(data)
|
||||
self.ui.imageLabel.setPixmap(QPixmap.fromImage(img))
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
from PyQt4.QtGui import QFrame
|
||||
|
||||
from weboob.applications.qcineoob.ui.minisubtitle_ui import Ui_MiniSubtitle
|
||||
from weboob.capabilities.base import NotAvailable
|
||||
from weboob.capabilities.base import empty
|
||||
|
||||
class MiniSubtitle(QFrame):
|
||||
def __init__(self, weboob, backend, subtitle, parent=None):
|
||||
|
|
@ -33,7 +33,7 @@ class MiniSubtitle(QFrame):
|
|||
self.backend = backend
|
||||
self.subtitle = subtitle
|
||||
self.ui.nameLabel.setText(subtitle.name)
|
||||
if subtitle.nb_cd != NotAvailable:
|
||||
if not empty(subtitle.nb_cd):
|
||||
self.ui.nbcdLabel.setText(u'%s'%subtitle.nb_cd)
|
||||
self.ui.backendLabel.setText(backend.name)
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ from PyQt4.QtGui import QFrame
|
|||
|
||||
from weboob.applications.qcineoob.ui.minitorrent_ui import Ui_MiniTorrent
|
||||
from weboob.applications.weboorrents.weboorrents import sizeof_fmt
|
||||
from weboob.capabilities.base import NotAvailable
|
||||
from weboob.capabilities.base import empty
|
||||
|
||||
class MiniTorrent(QFrame):
|
||||
def __init__(self, weboob, backend, torrent, parent=None):
|
||||
|
|
@ -34,9 +34,9 @@ class MiniTorrent(QFrame):
|
|||
self.backend = backend
|
||||
self.torrent = torrent
|
||||
self.ui.nameLabel.setText(torrent.name)
|
||||
if torrent.seeders != NotAvailable and torrent.leechers != NotAvailable:
|
||||
if not empty(torrent.seeders) and not empty(torrent.leechers):
|
||||
self.ui.seedLeechLabel.setText('%s/%s'%(torrent.seeders,torrent.leechers))
|
||||
if torrent.size != NotAvailable:
|
||||
if not empty(torrent.size):
|
||||
self.ui.sizeLabel.setText(u'%s'%sizeof_fmt(torrent.size))
|
||||
self.ui.backendLabel.setText(backend.name)
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ from PyQt4.QtCore import Qt,SIGNAL
|
|||
from PyQt4.QtGui import QFrame, QImage, QPixmap
|
||||
|
||||
from weboob.applications.qcineoob.ui.movie_ui import Ui_Movie
|
||||
from weboob.capabilities.base import NotAvailable
|
||||
from weboob.capabilities.base import empty
|
||||
from weboob.applications.suboob.suboob import LANGUAGE_CONV
|
||||
from weboob.applications.cineoob.cineoob import ROLE_LIST
|
||||
|
||||
|
|
@ -50,27 +50,27 @@ class Movie(QFrame):
|
|||
self.putReleases()
|
||||
|
||||
self.ui.idEdit.setText(u'%s@%s'%(movie.id,backend.name))
|
||||
if movie.other_titles != NotAvailable:
|
||||
if not empty(movie.other_titles):
|
||||
self.ui.otherTitlesPlain.setPlainText('\n'.join(movie.other_titles))
|
||||
else:
|
||||
self.ui.otherTitlesPlain.parent().hide()
|
||||
if movie.release_date != NotAvailable:
|
||||
if not empty(movie.release_date):
|
||||
self.ui.releaseDateLabel.setText(movie.release_date.strftime('%Y-%m-%d'))
|
||||
else:
|
||||
self.ui.releaseDateLabel.parent().hide()
|
||||
if movie.duration != NotAvailable:
|
||||
if not empty(movie.duration):
|
||||
self.ui.durationLabel.setText('%s min'%movie.duration)
|
||||
else:
|
||||
self.ui.durationLabel.parent().hide()
|
||||
if movie.pitch != NotAvailable:
|
||||
if not empty(movie.pitch):
|
||||
self.ui.pitchPlain.setPlainText('%s'%movie.pitch)
|
||||
else:
|
||||
self.ui.pitchPlain.parent().hide()
|
||||
if movie.country != NotAvailable:
|
||||
if not empty(movie.country):
|
||||
self.ui.countryLabel.setText('%s'%movie.country)
|
||||
else:
|
||||
self.ui.countryLabel.parent().hide()
|
||||
if movie.note != NotAvailable:
|
||||
if not empty(movie.note):
|
||||
self.ui.noteLabel.setText('%s'%movie.note)
|
||||
else:
|
||||
self.ui.noteLabel.parent().hide()
|
||||
|
|
@ -82,13 +82,13 @@ class Movie(QFrame):
|
|||
|
||||
def putReleases(self):
|
||||
rel = self.backend.get_movie_releases(self.movie.id)
|
||||
if rel != NotAvailable:
|
||||
if not empty(rel):
|
||||
self.ui.allReleasesPlain.setPlainText(rel)
|
||||
else:
|
||||
self.ui.allReleasesPlain.parent().hide()
|
||||
|
||||
def gotThumbnail(self):
|
||||
if self.movie.thumbnail_url != NotAvailable:
|
||||
if not empty(self.movie.thumbnail_url):
|
||||
data = urllib.urlopen(self.movie.thumbnail_url).read()
|
||||
img = QImage.fromData(data)
|
||||
self.ui.imageLabel.setPixmap(QPixmap.fromImage(img))
|
||||
|
|
@ -101,7 +101,7 @@ class Movie(QFrame):
|
|||
|
||||
def searchTorrent(self):
|
||||
tosearch = self.movie.original_title
|
||||
if self.movie.release_date != NotAvailable:
|
||||
if not empty(self.movie.release_date):
|
||||
tosearch += ' %s'%self.movie.release_date.year
|
||||
desc = 'Search torrents for "%s"'%tosearch
|
||||
self.parent.doAction(desc, self.parent.searchTorrentAction,[tosearch])
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ from PyQt4.QtCore import SIGNAL, Qt
|
|||
from PyQt4.QtGui import QFrame, QImage, QPixmap, QApplication
|
||||
|
||||
from weboob.applications.qcineoob.ui.person_ui import Ui_Person
|
||||
from weboob.capabilities.base import NotAvailable
|
||||
from weboob.capabilities.base import empty
|
||||
from weboob.applications.cineoob.cineoob import ROLE_LIST
|
||||
|
||||
class Person(QFrame):
|
||||
|
|
@ -42,19 +42,19 @@ class Person(QFrame):
|
|||
self.ui.nameLabel.setText(person.name)
|
||||
|
||||
self.ui.idEdit.setText(u'%s@%s'%(person.id,backend.name))
|
||||
if person.real_name != NotAvailable:
|
||||
if not empty(person.real_name):
|
||||
self.ui.realNameLabel.setText('%s'%person.real_name)
|
||||
else:
|
||||
self.ui.realNameLabel.parent().hide()
|
||||
if person.birth_place != NotAvailable:
|
||||
if not empty(person.birth_place):
|
||||
self.ui.birthPlaceLabel.setText('%s'%person.birth_place)
|
||||
else:
|
||||
self.ui.birthPlaceLabel.parent().hide()
|
||||
if person.birth_date != NotAvailable:
|
||||
if not empty(person.birth_date):
|
||||
self.ui.birthDateLabel.setText(person.birth_date.strftime('%Y-%m-%d'))
|
||||
else:
|
||||
self.ui.birthDateLabel.parent().hide()
|
||||
if person.death_date != NotAvailable:
|
||||
if not empty(person.death_date):
|
||||
self.ui.deathDateLabel.setText(person.death_date.strftime('%Y-%m-%d'))
|
||||
else:
|
||||
self.ui.deathDateLabel.parent().hide()
|
||||
|
|
@ -64,7 +64,7 @@ class Person(QFrame):
|
|||
self.ui.verticalLayout_2.setAlignment(Qt.AlignTop)
|
||||
|
||||
def gotThumbnail(self):
|
||||
if self.person.thumbnail_url != NotAvailable:
|
||||
if not empty(self.person.thumbnail_url):
|
||||
data = urllib.urlopen(self.person.thumbnail_url).read()
|
||||
img = QImage.fromData(data)
|
||||
self.ui.imageLabel.setPixmap(QPixmap.fromImage(img))
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ from PyQt4.QtCore import Qt,SIGNAL
|
|||
from PyQt4.QtGui import QFrame, QFileDialog
|
||||
|
||||
from weboob.applications.qcineoob.ui.subtitle_ui import Ui_Subtitle
|
||||
from weboob.capabilities.base import NotAvailable
|
||||
from weboob.capabilities.base import empty
|
||||
|
||||
class Subtitle(QFrame):
|
||||
def __init__(self, subtitle, backend, parent=None):
|
||||
|
|
@ -38,19 +38,21 @@ class Subtitle(QFrame):
|
|||
self.subtitle = subtitle
|
||||
self.ui.idEdit.setText(u'%s@%s'%(subtitle.id,backend.name))
|
||||
self.ui.nameLabel.setText(u'%s'%subtitle.name)
|
||||
if subtitle.nb_cd != NotAvailable:
|
||||
if not empty(subtitle.nb_cd):
|
||||
self.ui.nbcdLabel.setText(u'%s'%subtitle.nb_cd)
|
||||
else:
|
||||
self.ui.nbcdLabel.parent().hide()
|
||||
if subtitle.language != NotAvailable:
|
||||
if not empty(subtitle.language):
|
||||
self.ui.langLabel.setText(u'%s'%subtitle.language)
|
||||
else:
|
||||
self.ui.langLabel.parent().hide()
|
||||
if subtitle.description != NotAvailable:
|
||||
if not empty(subtitle.description):
|
||||
print 'plop'
|
||||
self.ui.descriptionPlain.setPlainText(u'%s'%subtitle.description)
|
||||
else:
|
||||
print 'ploppppp'
|
||||
self.ui.descriptionPlain.parent().hide()
|
||||
if subtitle.url != NotAvailable:
|
||||
if not empty(subtitle.url):
|
||||
self.ui.urlEdit.setText(u'%s'%subtitle.url)
|
||||
else:
|
||||
self.ui.downloadButton.setDisabled(True)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ from PyQt4.QtGui import QFrame, QFileDialog
|
|||
|
||||
from weboob.applications.qcineoob.ui.torrent_ui import Ui_Torrent
|
||||
from weboob.applications.weboorrents.weboorrents import sizeof_fmt
|
||||
from weboob.capabilities.base import NotAvailable, NotLoaded
|
||||
from weboob.capabilities.base import empty
|
||||
|
||||
class Torrent(QFrame):
|
||||
def __init__(self, torrent, backend, parent=None):
|
||||
|
|
@ -39,21 +39,21 @@ class Torrent(QFrame):
|
|||
self.torrent = torrent
|
||||
self.ui.idEdit.setText(u'%s@%s'%(torrent.id,backend.name))
|
||||
self.ui.nameLabel.setText(u'%s'%torrent.name)
|
||||
if torrent.url != NotAvailable:
|
||||
if not empty(torrent.url):
|
||||
self.ui.urlEdit.setText(u'%s'%torrent.url)
|
||||
else:
|
||||
self.ui.urlFrame.hide()
|
||||
self.ui.downloadButton.setDisabled(True)
|
||||
if torrent.magnet != NotAvailable and torrent.magnet != NotLoaded:
|
||||
if not empty(torrent.magnet):
|
||||
self.ui.downloadButton.setText(u'Download not available\nbut magnet link provided')
|
||||
self.ui.downloadButton.setToolTip(u'Use the magnet link')
|
||||
if torrent.magnet != NotAvailable and torrent.magnet != NotLoaded:
|
||||
if not empty(torrent.magnet):
|
||||
self.ui.magnetEdit.setText(u'%s'%torrent.magnet)
|
||||
else:
|
||||
self.ui.magnetFrame.hide()
|
||||
if torrent.seeders != NotAvailable and torrent.leechers != NotAvailable:
|
||||
if not empty(torrent.seeders) and not empty(torrent.leechers):
|
||||
self.ui.seedLeechLabel.setText(u'%s/%s'%(torrent.seeders,torrent.leechers))
|
||||
if torrent.size != NotAvailable:
|
||||
if not empty(torrent.size):
|
||||
self.ui.sizeLabel.setText(u'%s'%sizeof_fmt(torrent.size))
|
||||
|
||||
self.ui.verticalLayout.setAlignment(Qt.AlignTop)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ from __future__ import with_statement
|
|||
import sys
|
||||
|
||||
from weboob.capabilities.subtitle import ICapSubtitle
|
||||
from weboob.capabilities.base import empty
|
||||
from weboob.tools.application.repl import ReplApplication
|
||||
from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter
|
||||
from weboob.core import CallErrors
|
||||
|
|
@ -62,8 +63,10 @@ class SubtitleInfoFormatter(IFormatter):
|
|||
result = u'%s%s%s\n' % (self.BOLD, obj.name, self.NC)
|
||||
result += 'ID: %s\n' % obj.fullid
|
||||
result += 'URL: %s\n' % obj.url
|
||||
result += 'LANG: %s\n' % obj.language
|
||||
result += 'NB CD: %s\n' % obj.nb_cd
|
||||
if not empty(obj.language):
|
||||
result += 'LANG: %s\n' % obj.language
|
||||
if not empty(obj.nb_cd):
|
||||
result += 'NB CD: %s\n' % obj.nb_cd
|
||||
result += '\n%sDescription%s\n' % (self.BOLD, self.NC)
|
||||
result += '%s'%obj.description
|
||||
return result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue