verified autopep8 on qcineoob, cineoob, suboob, booblyrics, cookboob

This commit is contained in:
Julien Veyssier 2013-03-16 01:57:54 +01:00
commit 62074615da
14 changed files with 146 additions and 138 deletions

View file

@ -27,7 +27,7 @@ from weboob.tools.application.repl import ReplApplication
from weboob.tools.application.formatters.iformatter import IFormatter, PrettyFormatter
__all__ = ['Booblyrics','LyricsGetFormatter','LyricsListFormatter']
__all__ = ['Booblyrics', 'LyricsGetFormatter', 'LyricsListFormatter']
class LyricsGetFormatter(IFormatter):
@ -39,7 +39,7 @@ class LyricsGetFormatter(IFormatter):
result += 'Title: %s\n' % obj.title
result += 'Artist: %s\n' % obj.artist
result += '\n%sContent%s\n' % (self.BOLD, self.NC)
result += '%s'%obj.content
result += '%s' % obj.content
return result
@ -65,11 +65,11 @@ class Booblyrics(ReplApplication):
CAPS = ICapLyrics
EXTRA_FORMATTERS = {'lyrics_list': LyricsListFormatter,
'lyrics_get': LyricsGetFormatter,
}
}
COMMANDS_FORMATTERS = {'search': 'lyrics_list',
'get': 'lyrics_get',
}
SEARCH_CRITERIAS = ['artist','song']
}
SEARCH_CRITERIAS = ['artist', 'song']
def complete_get(self, text, line, *ignored):
args = line.split(' ')

View file

@ -35,12 +35,13 @@ from weboob.core import CallErrors
__all__ = ['Cineoob']
ROLE_LIST = ['actor','director','writer','composer','producer']
COUNTRY_LIST = ['us','fr','de','jp']
ROLE_LIST = ['actor', 'director', 'writer', 'composer', 'producer']
COUNTRY_LIST = ['us', 'fr', 'de', 'jp']
class MovieInfoFormatter(IFormatter):
MANDATORY_FIELDS = ('id', 'original_title', 'release_date', 'other_titles', 'duration', 'pitch', 'note', 'roles', 'country')
MANDATORY_FIELDS = ('id', 'original_title', 'release_date',
'other_titles', 'duration', 'pitch', 'note', 'roles', 'country')
def format_obj(self, obj, alias):
result = u'%s%s%s\n' % (self.BOLD, obj.original_title, self.NC)
@ -53,7 +54,7 @@ class MovieInfoFormatter(IFormatter):
result += 'Note: %s\n' % obj.note
if not empty(obj.roles):
result += '\n%sRelated persons%s\n' % (self.BOLD, self.NC)
for role,lpersons in obj.roles.items():
for role, lpersons in obj.roles.items():
result += ' -- %s\n' % role
for name in lpersons:
result += ' * %s\n' % name
@ -63,7 +64,7 @@ class MovieInfoFormatter(IFormatter):
result += ' * %s\n' % t
if not empty(obj.pitch):
result += '\n%sStory%s\n' % (self.BOLD, self.NC)
result += '%s'%obj.pitch
result += '%s' % obj.pitch
return result
@ -84,10 +85,10 @@ class MovieReleasesFormatter(PrettyFormatter):
MANDATORY_FIELDS = ('id', 'original_title', 'all_release_dates')
def get_title(self, obj):
return u'Releases of %s'%obj.original_title
return u'Releases of %s' % obj.original_title
def get_description(self, obj):
return u'\n%s'%obj.all_release_dates
return u'\n%s' % obj.all_release_dates
def yearsago(years, from_date=None):
@ -125,8 +126,8 @@ class PersonInfoFormatter(IFormatter):
if not empty(obj.birth_date):
result += 'Birth date: %s\n' % obj.birth_date.strftime('%Y-%m-%d')
if not empty(obj.death_date):
age = num_years(obj.birth_date,obj.death_date)
result += 'Death date: %s at %s years old\n' % (obj.death_date.strftime('%Y-%m-%d'),age)
age = num_years(obj.birth_date, obj.death_date)
result += 'Death date: %s at %s years old\n' % (obj.death_date.strftime('%Y-%m-%d'), age)
else:
age = num_years(obj.birth_date)
result += 'Age: %s\n' % age
@ -136,13 +137,13 @@ class PersonInfoFormatter(IFormatter):
result += 'Nationality: %s\n' % obj.nationality
if not empty(obj.roles):
result += '\n%sRelated movies%s\n' % (self.BOLD, self.NC)
for role,lmovies in obj.roles.items():
for role, lmovies in obj.roles.items():
result += ' -- %s\n' % role
for movie in lmovies:
result += ' * %s\n' % movie
if not empty(obj.short_biography):
result += '\n%sBiography%s\n' % (self.BOLD, self.NC)
result += '%s'%obj.short_biography
result += '%s' % obj.short_biography
return result
@ -163,10 +164,10 @@ class PersonBiographyFormatter(PrettyFormatter):
MANDATORY_FIELDS = ('id', 'name', 'biography')
def get_title(self, obj):
return u'Biography of %s'%obj.name
return u'Biography of %s' % obj.name
def get_description(self, obj):
result = u'\n%s'%obj.biography
result = u'\n%s' % obj.biography
return result
@ -178,7 +179,7 @@ class Cineoob(ReplApplication):
", list persons related to a movie, list movies related to a person and list common movies " \
"of two persons."
SHORT_DESCRIPTION = "search movies and persons around cinema"
CAPS = (ICapCinema,ICapTorrent,ICapSubtitle)
CAPS = (ICapCinema, ICapTorrent, ICapSubtitle)
EXTRA_FORMATTERS = {'movie_list': MovieListFormatter,
'movie_info': MovieInfoFormatter,
'movie_releases': MovieReleasesFormatter,
@ -189,7 +190,7 @@ class Cineoob(ReplApplication):
'torrent_info': TorrentInfoFormatter,
'subtitle_list': SubtitleListFormatter,
'subtitle_info': SubtitleInfoFormatter
}
}
COMMANDS_FORMATTERS = {'search_movie': 'movie_list',
'info_movie': 'movie_info',
'search_person': 'person_list',
@ -198,15 +199,15 @@ class Cineoob(ReplApplication):
'filmography': 'movie_list',
'biography': 'person_bio',
'releases': 'movie_releases',
'movies_in_common':'movie_list',
'persons_in_common':'person_list',
'movies_in_common': 'movie_list',
'persons_in_common': 'person_list',
'search_torrent': 'torrent_list',
'search_movie_torrent': 'torrent_list',
'info_torrent': 'torrent_info',
'search_subtitle': 'subtitle_list',
'search_movie_subtitle': 'subtitle_list',
'info_subtitle': 'subtitle_info'
}
}
def complete_filmography(self, text, line, *ignored):
args = line.split(' ')
@ -214,7 +215,7 @@ class Cineoob(ReplApplication):
return ROLE_LIST
def complete_casting(self, text, line, *ignored):
return self.complete_filmography(text,line,ignored)
return self.complete_filmography(text, line, ignored)
def do_movies_in_common(self, line):
"""
@ -392,7 +393,7 @@ class Cineoob(ReplApplication):
Show the complete biography of a person.
"""
person = self.get_object(person_id,'get_person',('name','biography'))
person = self.get_object(person_id, 'get_person', ('name', 'biography'))
if not person:
print >>sys.stderr, 'Person not found: %s' % person_id
return 3
@ -415,7 +416,7 @@ class Cineoob(ReplApplication):
"""
id, country = self.parse_command_args(line, 2, 1)
movie = self.get_object(id,'get_movie',('original_title'))
movie = self.get_object(id, 'get_movie', ('original_title'))
if not movie:
print >>sys.stderr, 'Movie not found: %s' % id
return 3
@ -604,7 +605,7 @@ class Cineoob(ReplApplication):
print >>sys.stderr, 'Subtitle "%s" not found' % id
return 3
def do_search_subtitle(self,line):
def do_search_subtitle(self, line):
"""
search_subtitle language [PATTERN]
@ -620,7 +621,7 @@ class Cineoob(ReplApplication):
self.cached_format(subtitle)
self.flush()
def do_search_movie_subtitle(self,line):
def do_search_movie_subtitle(self, line):
"""
search_movie_subtitle language movie_ID

View file

@ -43,13 +43,13 @@ class RecipeInfoFormatter(IFormatter):
result += 'Amount of people: %s\n' % obj.nb_person
result += '\n%sIngredients%s\n' % (self.BOLD, self.NC)
for i in obj.ingredients:
result += ' * %s\n'%i
result += ' * %s\n' % i
result += '\n%sInstructions%s\n' % (self.BOLD, self.NC)
result += '%s\n'%obj.instructions
result += '%s\n' % obj.instructions
if not empty(obj.comments):
result += '\n%sComments%s\n' % (self.BOLD, self.NC)
for c in obj.comments:
result += ' * %s\n'%c
result += ' * %s\n' % c
return result
@ -62,9 +62,9 @@ class RecipeListFormatter(PrettyFormatter):
def get_description(self, obj):
result = u''
if not empty(obj.preparation_time):
result += 'prep time: %smin'%obj.preparation_time
result += 'prep time: %smin' % obj.preparation_time
if not empty(obj.short_description):
result += 'description: %s\n'%obj.short_description
result += 'description: %s\n' % obj.short_description
return result
@ -77,10 +77,10 @@ class Cookboob(ReplApplication):
CAPS = ICapRecipe
EXTRA_FORMATTERS = {'recipe_list': RecipeListFormatter,
'recipe_info': RecipeInfoFormatter
}
}
COMMANDS_FORMATTERS = {'search': 'recipe_list',
'info': 'recipe_info'
}
}
def complete_info(self, text, line, *ignored):
args = line.split(' ')

View file

@ -59,7 +59,7 @@ class MainWindow(QtMainWindow):
# action history is composed by the last action and the action list
# An action is a function, a list of arguments and a description string
self.action_history = {'last_action':None,'action_list':[]}
self.action_history = {'last_action': None, 'action_list': []}
self.connect(self.ui.backButton, SIGNAL("clicked()"), self.doBack)
self.ui.backButton.hide()
@ -83,7 +83,7 @@ class MainWindow(QtMainWindow):
self.ui.langLabel.hide()
def backendsConfig(self):
bckndcfg = BackendCfg(self.weboob, (ICapCinema,ICapTorrent,ICapSubtitle,), self)
bckndcfg = BackendCfg(self.weboob, (ICapCinema, ICapTorrent, ICapSubtitle,), self)
if bckndcfg.run():
self.loadBackendsList()
@ -107,7 +107,7 @@ class MainWindow(QtMainWindow):
result = []
history_path = os.path.join(self.weboob.workdir, 'qcineoob_history')
if os.path.exists(history_path):
f=codecs.open(history_path,'r','utf-8')
f = codecs.open(history_path, 'r', 'utf-8')
conf_hist = f.read()
f.close()
if conf_hist is not None and conf_hist.strip() != '':
@ -119,16 +119,16 @@ class MainWindow(QtMainWindow):
'''
if len(self.search_history) > 0:
history_path = os.path.join(self.weboob.workdir, 'qcineoob_history')
f=codecs.open(history_path,'w','utf-8')
f = codecs.open(history_path, 'w', 'utf-8')
f.write('\n'.join(self.search_history))
f.close()
def updateCompletion(self):
qc = QCompleter(QStringList(self.search_history),self)
qc = QCompleter(QStringList(self.search_history), self)
qc.setCaseSensitivity(Qt.CaseInsensitive)
self.ui.searchEdit.setCompleter(qc)
def typeComboChanged(self,value):
def typeComboChanged(self, value):
if unicode(value) == 'subtitle':
self.ui.langCombo.show()
self.ui.langLabel.show()
@ -145,7 +145,7 @@ class MainWindow(QtMainWindow):
self.action_history['action_list'].append(self.action_history['last_action'])
self.ui.backButton.setToolTip(self.action_history['last_action']['description'])
self.ui.backButton.show()
self.action_history['last_action'] = {'function':fun,'args':args,'description':description}
self.action_history['last_action'] = {'function': fun, 'args': args, 'description': description}
return fun(*args)
def doBack(self):
@ -171,7 +171,7 @@ class MainWindow(QtMainWindow):
self.minis = []
self.ui.searchEdit.setEnabled(False)
QApplication.setOverrideCursor( Qt.WaitCursor )
QApplication.setOverrideCursor(Qt.WaitCursor)
backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())
@ -187,7 +187,7 @@ class MainWindow(QtMainWindow):
self.minis = []
self.ui.searchEdit.setEnabled(False)
QApplication.setOverrideCursor( Qt.WaitCursor )
QApplication.setOverrideCursor(Qt.WaitCursor)
backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())
@ -217,9 +217,9 @@ class MainWindow(QtMainWindow):
pattern = unicode(self.ui.searchEdit.text())
if not pattern:
return
self.doAction(u'Search movie "%s"'%pattern,self.searchMovieAction,[pattern])
self.doAction(u'Search movie "%s"' % pattern, self.searchMovieAction, [pattern])
def searchMovieAction(self,pattern):
def searchMovieAction(self, pattern):
self.ui.stackedWidget.setCurrentWidget(self.ui.list_page)
for mini in self.minis:
self.ui.list_content.layout().removeWidget(mini)
@ -228,7 +228,7 @@ class MainWindow(QtMainWindow):
self.minis = []
self.ui.searchEdit.setEnabled(False)
QApplication.setOverrideCursor( Qt.WaitCursor )
QApplication.setOverrideCursor(Qt.WaitCursor)
backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())
@ -251,7 +251,7 @@ class MainWindow(QtMainWindow):
self.ui.info_content.layout().removeWidget(self.current_info_widget)
self.current_info_widget.hide()
self.current_info_widget.deleteLater()
wmovie = Movie(movie,backend,self)
wmovie = Movie(movie, backend, self)
self.ui.info_content.layout().addWidget(wmovie)
self.current_info_widget = wmovie
QApplication.restoreOverrideCursor()
@ -260,9 +260,9 @@ class MainWindow(QtMainWindow):
pattern = unicode(self.ui.searchEdit.text())
if not pattern:
return
self.doAction(u'Search person "%s"'%pattern,self.searchPersonAction,[pattern])
self.doAction(u'Search person "%s"' % pattern, self.searchPersonAction, [pattern])
def searchPersonAction(self,pattern):
def searchPersonAction(self, pattern):
self.ui.stackedWidget.setCurrentWidget(self.ui.list_page)
for mini in self.minis:
self.ui.list_content.layout().removeWidget(mini)
@ -271,7 +271,7 @@ class MainWindow(QtMainWindow):
self.minis = []
self.ui.searchEdit.setEnabled(False)
QApplication.setOverrideCursor( Qt.WaitCursor )
QApplication.setOverrideCursor(Qt.WaitCursor)
backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())
@ -294,7 +294,7 @@ class MainWindow(QtMainWindow):
self.ui.info_content.layout().removeWidget(self.current_info_widget)
self.current_info_widget.hide()
self.current_info_widget.deleteLater()
wperson = Person(person,backend,self)
wperson = Person(person, backend, self)
self.ui.info_content.layout().addWidget(wperson)
self.current_info_widget = wperson
QApplication.restoreOverrideCursor()
@ -303,9 +303,9 @@ class MainWindow(QtMainWindow):
pattern = unicode(self.ui.searchEdit.text())
if not pattern:
return
self.doAction(u'Search torrent "%s"'%pattern,self.searchTorrentAction,[pattern])
self.doAction(u'Search torrent "%s"' % pattern, self.searchTorrentAction, [pattern])
def searchTorrentAction(self,pattern):
def searchTorrentAction(self, pattern):
self.ui.stackedWidget.setCurrentWidget(self.ui.list_page)
for mini in self.minis:
self.ui.list_content.layout().removeWidget(mini)
@ -314,7 +314,7 @@ class MainWindow(QtMainWindow):
self.minis = []
self.ui.searchEdit.setEnabled(False)
QApplication.setOverrideCursor( Qt.WaitCursor )
QApplication.setOverrideCursor(Qt.WaitCursor)
backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())
@ -346,7 +346,7 @@ class MainWindow(QtMainWindow):
lang = unicode(self.ui.langCombo.currentText())
if not pattern:
return
self.doAction(u'Search subtitle "%s" (lang:%s)'%(pattern,lang),self.searchSubtitleAction,[lang,pattern])
self.doAction(u'Search subtitle "%s" (lang:%s)' % (pattern, lang), self.searchSubtitleAction, [lang, pattern])
def searchSubtitleAction(self, lang, pattern):
self.ui.stackedWidget.setCurrentWidget(self.ui.list_page)
@ -357,7 +357,7 @@ class MainWindow(QtMainWindow):
self.minis = []
self.ui.searchEdit.setEnabled(False)
QApplication.setOverrideCursor( Qt.WaitCursor )
QApplication.setOverrideCursor(Qt.WaitCursor)
backend_name = str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString())
@ -385,7 +385,8 @@ class MainWindow(QtMainWindow):
self.current_info_widget = wsubtitle
def closeEvent(self, ev):
self.config.set('settings', 'backend', str(self.ui.backendEdit.itemData(self.ui.backendEdit.currentIndex()).toString()))
self.config.set('settings', 'backend', str(self.ui.backendEdit.itemData(
self.ui.backendEdit.currentIndex()).toString()))
self.saveSearchHistory()
self.config.save()

View file

@ -41,7 +41,7 @@ class MiniMovie(QFrame):
self.ui.backendLabel.setText(backend.name)
def gotThumbnail(self):
self.backend.fill_movie(self.movie,('thumbnail_url'))
self.backend.fill_movie(self.movie, ('thumbnail_url'))
if not empty(self.movie.thumbnail_url):
data = urllib.urlopen(self.movie.thumbnail_url).read()
img = QImage.fromData(data)
@ -61,7 +61,8 @@ class MiniMovie(QFrame):
if event.button() == 2:
self.gotThumbnail()
else:
QApplication.setOverrideCursor( Qt.WaitCursor )
QApplication.setOverrideCursor(Qt.WaitCursor)
movie = self.backend.get_movie(self.movie.id)
if movie:
self.parent.doAction('Details of movie "%s"'%movie.original_title,self.parent.displayMovie,[movie,self.backend])
self.parent.doAction('Details of movie "%s"' %
movie.original_title, self.parent.displayMovie, [movie, self.backend])

View file

@ -36,18 +36,18 @@ class MiniPerson(QFrame):
self.weboob = weboob
self.backend = backend
self.person = person
self.ui.nameLabel.setText('%s'%person.name)
self.ui.nameLabel.setText('%s' % person.name)
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)
self.ui.shortDescLabel.setText('%s' % person.short_description)
else:
self.ui.shortDescTitleLabel.hide()
self.ui.shortDescLabel.hide()
self.ui.backendLabel.setText(backend.name)
def gotThumbnail(self):
self.backend.fill_person(self.person,('thumbnail_url'))
self.backend.fill_person(self.person, ('thumbnail_url'))
if not empty(self.person.thumbnail_url):
data = urllib.urlopen(self.person.thumbnail_url).read()
img = QImage.fromData(data)
@ -67,7 +67,8 @@ class MiniPerson(QFrame):
if event.button() == 2:
self.gotThumbnail()
else:
QApplication.setOverrideCursor( Qt.WaitCursor )
QApplication.setOverrideCursor(Qt.WaitCursor)
person = self.backend.get_person(self.person.id)
if person:
self.parent.doAction(u'Details of person "%s"'%person.name,self.parent.displayPerson,[person,self.backend])
self.parent.doAction(u'Details of person "%s"' %
person.name, self.parent.displayPerson, [person, self.backend])

View file

@ -35,7 +35,7 @@ class MiniSubtitle(QFrame):
self.subtitle = subtitle
self.ui.nameLabel.setText(subtitle.name)
if not empty(subtitle.nb_cd):
self.ui.nbcdLabel.setText(u'%s'%subtitle.nb_cd)
self.ui.nbcdLabel.setText(u'%s' % subtitle.nb_cd)
self.ui.backendLabel.setText(backend.name)
def enterEvent(self, event):
@ -51,4 +51,5 @@ class MiniSubtitle(QFrame):
subtitle = self.backend.get_subtitle(self.subtitle.id)
if subtitle:
self.parent.doAction('Details of subtitle "%s"'%subtitle.name,self.parent.displaySubtitle,[subtitle,self.backend])
self.parent.doAction('Details of subtitle "%s"' %
subtitle.name, self.parent.displaySubtitle, [subtitle, self.backend])

View file

@ -36,9 +36,9 @@ class MiniTorrent(QFrame):
self.torrent = torrent
self.ui.nameLabel.setText(torrent.name)
if not empty(torrent.seeders) and not empty(torrent.leechers):
self.ui.seedLeechLabel.setText('%s/%s'%(torrent.seeders,torrent.leechers))
self.ui.seedLeechLabel.setText('%s/%s' % (torrent.seeders, torrent.leechers))
if not empty(torrent.size):
self.ui.sizeLabel.setText(u'%s'%sizeof_fmt(torrent.size))
self.ui.sizeLabel.setText(u'%s' % sizeof_fmt(torrent.size))
self.ui.backendLabel.setText(backend.name)
def enterEvent(self, event):
@ -54,4 +54,5 @@ class MiniTorrent(QFrame):
torrent = self.backend.get_torrent(self.torrent.id)
if torrent:
self.parent.doAction('Details of torrent "%s"'%torrent.name,self.parent.displayTorrent,[torrent,self.backend])
self.parent.doAction('Details of torrent "%s"' %
torrent.name, self.parent.displayTorrent, [torrent, self.backend])

View file

@ -19,7 +19,7 @@
import urllib
from PyQt4.QtCore import Qt,SIGNAL
from PyQt4.QtCore import Qt, SIGNAL
from PyQt4.QtGui import QFrame, QImage, QPixmap
from weboob.applications.qcineoob.ui.movie_ui import Ui_Movie
@ -50,7 +50,7 @@ class Movie(QFrame):
self.gotThumbnail()
self.putReleases()
self.ui.idEdit.setText(u'%s@%s'%(movie.id,backend.name))
self.ui.idEdit.setText(u'%s@%s' % (movie.id, backend.name))
if not empty(movie.other_titles):
self.ui.otherTitlesPlain.setPlainText('\n'.join(movie.other_titles))
else:
@ -60,23 +60,23 @@ class Movie(QFrame):
else:
self.ui.releaseDateLabel.parent().hide()
if not empty(movie.duration):
self.ui.durationLabel.setText('%s min'%movie.duration)
self.ui.durationLabel.setText('%s min' % movie.duration)
else:
self.ui.durationLabel.parent().hide()
if not empty(movie.pitch):
self.ui.pitchPlain.setPlainText('%s'%movie.pitch)
self.ui.pitchPlain.setPlainText('%s' % movie.pitch)
else:
self.ui.pitchPlain.parent().hide()
if not empty(movie.country):
self.ui.countryLabel.setText('%s'%movie.country)
self.ui.countryLabel.setText('%s' % movie.country)
else:
self.ui.countryLabel.parent().hide()
if not empty(movie.note):
self.ui.noteLabel.setText('%s'%movie.note)
self.ui.noteLabel.setText('%s' % movie.note)
else:
self.ui.noteLabel.parent().hide()
for role in ROLE_LIST:
self.ui.castingCombo.addItem('%ss'%role)
self.ui.castingCombo.addItem('%ss' % role)
self.ui.verticalLayout.setAlignment(Qt.AlignTop)
self.ui.verticalLayout_2.setAlignment(Qt.AlignTop)
@ -97,15 +97,15 @@ class Movie(QFrame):
def searchSubtitle(self):
tosearch = unicode(self.movie.original_title)
lang = unicode(self.ui.langCombo.currentText())
desc = 'Search subtitles for "%s" (lang:%s)'%(tosearch,lang)
self.parent.doAction(desc, self.parent.searchSubtitleAction,[lang,tosearch])
desc = 'Search subtitles for "%s" (lang:%s)' % (tosearch, lang)
self.parent.doAction(desc, self.parent.searchSubtitleAction, [lang, tosearch])
def searchTorrent(self):
tosearch = self.movie.original_title
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])
tosearch += ' %s' % self.movie.release_date.year
desc = 'Search torrents for "%s"' % tosearch
self.parent.doAction(desc, self.parent.searchTorrentAction, [tosearch])
def casting(self):
role = None
@ -113,6 +113,6 @@ class Movie(QFrame):
role_desc = ''
if tosearch != 'all':
role = tosearch[:-1]
role_desc = ' as %s'%role
self.parent.doAction('Casting%s of movie "%s"'%(role_desc,self.movie.original_title),
self.parent.castingAction,[self.movie.id,role])
role_desc = ' as %s' % role
self.parent.doAction('Casting%s of movie "%s"' % (role_desc, self.movie.original_title),
self.parent.castingAction, [self.movie.id, role])

View file

@ -42,13 +42,13 @@ class Person(QFrame):
self.gotThumbnail()
self.ui.nameLabel.setText(person.name)
self.ui.idEdit.setText(u'%s@%s'%(person.id,backend.name))
self.ui.idEdit.setText(u'%s@%s' % (person.id, backend.name))
if not empty(person.real_name):
self.ui.realNameLabel.setText('%s'%person.real_name)
self.ui.realNameLabel.setText('%s' % person.real_name)
else:
self.ui.realNameLabel.parent().hide()
if not empty(person.birth_place):
self.ui.birthPlaceLabel.setText('%s'%person.birth_place)
self.ui.birthPlaceLabel.setText('%s' % person.birth_place)
else:
self.ui.birthPlaceLabel.parent().hide()
if not empty(person.birth_date):
@ -59,7 +59,7 @@ class Person(QFrame):
self.ui.deathDateLabel.setText(person.death_date.strftime('%Y-%m-%d'))
else:
self.ui.deathDateLabel.parent().hide()
self.ui.shortBioPlain.setPlainText('%s'%person.short_biography)
self.ui.shortBioPlain.setPlainText('%s' % person.short_biography)
for role in ROLE_LIST:
self.ui.filmographyCombo.addItem(role)
self.ui.verticalLayout_2.setAlignment(Qt.AlignTop)
@ -76,9 +76,9 @@ class Person(QFrame):
role_desc = ''
if tosearch != 'all':
role = tosearch
role_desc = ' as %s'%role
self.parent.doAction('Filmography of "%s"%s'%(self.person.name,role_desc),
self.parent.filmographyAction,[self.person.id,role])
role_desc = ' as %s' % role
self.parent.doAction('Filmography of "%s"%s' % (self.person.name, role_desc),
self.parent.filmographyAction, [self.person.id, role])
def biography(self):
QApplication.setOverrideCursor(Qt.WaitCursor)

View file

@ -32,13 +32,13 @@ class QCineoob(QtApplication):
COPYRIGHT = 'Copyright(C) 2013 Julien Veyssier'
DESCRIPTION = "Qt application allowing to search movies, people, torrent and subtitles."
SHORT_DESCRIPTION = "search movies, people, torrent and subtitles"
CAPS = ICapCinema,ICapTorrent,ICapSubtitle
CAPS = ICapCinema, ICapTorrent, ICapSubtitle
CONFIG = {'settings': {'backend': '',
}
}
}
}
def main(self, argv):
self.load_backends([ICapCinema,ICapTorrent,ICapSubtitle])
self.load_backends([ICapCinema, ICapTorrent, ICapSubtitle])
self.load_config()
self.main_window = MainWindow(self.config, self.weboob)

View file

@ -19,7 +19,7 @@
import sys
from PyQt4.QtCore import Qt,SIGNAL
from PyQt4.QtCore import Qt, SIGNAL
from PyQt4.QtGui import QFrame, QFileDialog
from weboob.applications.qcineoob.ui.subtitle_ui import Ui_Subtitle
@ -37,22 +37,22 @@ class Subtitle(QFrame):
self.connect(self.ui.downloadButton, SIGNAL("clicked()"), self.download)
self.subtitle = subtitle
self.ui.idEdit.setText(u'%s@%s'%(subtitle.id,backend.name))
self.ui.nameLabel.setText(u'%s'%subtitle.name)
self.ui.idEdit.setText(u'%s@%s' % (subtitle.id, backend.name))
self.ui.nameLabel.setText(u'%s' % subtitle.name)
if not empty(subtitle.nb_cd):
self.ui.nbcdLabel.setText(u'%s'%subtitle.nb_cd)
self.ui.nbcdLabel.setText(u'%s' % subtitle.nb_cd)
else:
self.ui.nbcdLabel.parent().hide()
if not empty(subtitle.language):
self.ui.langLabel.setText(u'%s'%subtitle.language)
self.ui.langLabel.setText(u'%s' % subtitle.language)
else:
self.ui.langLabel.parent().hide()
if not empty(subtitle.description):
self.ui.descriptionPlain.setPlainText(u'%s'%subtitle.description)
self.ui.descriptionPlain.setPlainText(u'%s' % subtitle.description)
else:
self.ui.descriptionPlain.parent().hide()
if not empty(subtitle.url):
self.ui.urlEdit.setText(u'%s'%subtitle.url)
self.ui.urlEdit.setText(u'%s' % subtitle.url)
else:
self.ui.downloadButton.setDisabled(True)
self.ui.downloadButton.setText('Impossible to download this subtitle')
@ -60,10 +60,11 @@ class Subtitle(QFrame):
self.ui.verticalLayout.setAlignment(Qt.AlignTop)
def download(self):
fileDial = QFileDialog(self,'Save "%s" subtitle file'%self.subtitle.name,'%s'%self.subtitle.name,'all files (*)')
fileDial = QFileDialog(self, 'Save "%s" subtitle file' %
self.subtitle.name, '%s' % self.subtitle.name, 'all files (*)')
fileDial.setAcceptMode(QFileDialog.AcceptSave)
fileDial.setLabelText(QFileDialog.Accept,'Save subtitle file')
fileDial.setLabelText(QFileDialog.FileName,'Subtitle file name')
fileDial.setLabelText(QFileDialog.Accept, 'Save subtitle file')
fileDial.setLabelText(QFileDialog.FileName, 'Subtitle file name')
ok = (fileDial.exec_() == 1)
if not ok:
return

View file

@ -19,7 +19,7 @@
import sys
from PyQt4.QtCore import Qt,SIGNAL
from PyQt4.QtCore import Qt, SIGNAL
from PyQt4.QtGui import QFrame, QFileDialog
from weboob.applications.qcineoob.ui.torrent_ui import Ui_Torrent
@ -38,10 +38,10 @@ class Torrent(QFrame):
self.connect(self.ui.downloadButton, SIGNAL("clicked()"), self.download)
self.torrent = torrent
self.ui.idEdit.setText(u'%s@%s'%(torrent.id,backend.name))
self.ui.nameLabel.setText(u'%s'%torrent.name)
self.ui.idEdit.setText(u'%s@%s' % (torrent.id, backend.name))
self.ui.nameLabel.setText(u'%s' % torrent.name)
if not empty(torrent.url):
self.ui.urlEdit.setText(u'%s'%torrent.url)
self.ui.urlEdit.setText(u'%s' % torrent.url)
else:
self.ui.urlFrame.hide()
self.ui.downloadButton.setDisabled(True)
@ -49,21 +49,22 @@ class Torrent(QFrame):
self.ui.downloadButton.setText(u'Download not available\nbut magnet link provided')
self.ui.downloadButton.setToolTip(u'Use the magnet link')
if not empty(torrent.magnet):
self.ui.magnetEdit.setText(u'%s'%torrent.magnet)
self.ui.magnetEdit.setText(u'%s' % torrent.magnet)
else:
self.ui.magnetFrame.hide()
if not empty(torrent.seeders) and not empty(torrent.leechers):
self.ui.seedLeechLabel.setText(u'%s/%s'%(torrent.seeders,torrent.leechers))
self.ui.seedLeechLabel.setText(u'%s/%s' % (torrent.seeders, torrent.leechers))
if not empty(torrent.size):
self.ui.sizeLabel.setText(u'%s'%sizeof_fmt(torrent.size))
self.ui.sizeLabel.setText(u'%s' % sizeof_fmt(torrent.size))
self.ui.verticalLayout.setAlignment(Qt.AlignTop)
def download(self):
fileDial = QFileDialog(self,'Save "%s" torrent file'%self.torrent.name,'%s.torrent'%self.torrent.name,'Torrent file (*.torrent);;all files (*)')
fileDial = QFileDialog(self, 'Save "%s" torrent file' % self.torrent.name, '%s.torrent' %
self.torrent.name, 'Torrent file (*.torrent);;all files (*)')
fileDial.setAcceptMode(QFileDialog.AcceptSave)
fileDial.setLabelText(QFileDialog.Accept,'Save torrent file')
fileDial.setLabelText(QFileDialog.FileName,'Torrent file name')
fileDial.setLabelText(QFileDialog.Accept, 'Save torrent file')
fileDial.setLabelText(QFileDialog.FileName, 'Torrent file name')
ok = (fileDial.exec_() == 1)
if not ok:
return

View file

@ -31,22 +31,22 @@ from weboob.core import CallErrors
__all__ = ['Suboob']
LANGUAGE_CONV = {
'ar':'ara', 'eo':'epo', 'ga':'', 'ru':'rus',
'af':'' , 'et':'est', 'it':'ita', 'sr':'scc',
'sq':'alb', 'tl':'' , 'ja':'jpn', 'sk':'slo',
'hy':'arm', 'fi':'fin', 'kn':'', 'sl':'slv',
'az':'' , 'fr':'fre', 'ko':'kor', 'es':'spa',
'eu':'baq', 'gl':'glg', 'la':'', 'sw':'swa',
'be':'' , 'ka':'geo', 'lv':'lav', 'sv':'swe',
'bn':'ben', 'de':'ger', 'lt':'lit', 'ta':'',
'bg':'bul', 'gr':'ell', 'mk':'mac', 'te':'tel',
'ca':'cat', 'gu':'' , 'ms':'may', 'th':'tha',
'zh':'chi', 'ht':'' , 'mt':'', 'tr':'tur',
'hr':'hrv', 'iw':'heb', 'no':'nor', 'uk':'ukr',
'cz':'cze', 'hi':'hin', 'fa':'per', 'ur':'urd',
'da':'dan', 'hu':'hun', 'pl':'pol', 'vi':'vie',
'nl':'dut', 'is':'ice', 'pt':'por', 'cy':'',
'en':'eng', 'id':'ind', 'ro':'rum', 'yi':''}
'ar': 'ara', 'eo': 'epo', 'ga': '', 'ru': 'rus',
'af': '', 'et': 'est', 'it': 'ita', 'sr': 'scc',
'sq': 'alb', 'tl': '', 'ja': 'jpn', 'sk': 'slo',
'hy': 'arm', 'fi': 'fin', 'kn': '', 'sl': 'slv',
'az': '', 'fr': 'fre', 'ko': 'kor', 'es': 'spa',
'eu': 'baq', 'gl': 'glg', 'la': '', 'sw': 'swa',
'be': '', 'ka': 'geo', 'lv': 'lav', 'sv': 'swe',
'bn': 'ben', 'de': 'ger', 'lt': 'lit', 'ta': '',
'bg': 'bul', 'gr': 'ell', 'mk': 'mac', 'te': 'tel',
'ca': 'cat', 'gu': '', 'ms': 'may', 'th': 'tha',
'zh': 'chi', 'ht': '', 'mt': '', 'tr': 'tur',
'hr': 'hrv', 'iw': 'heb', 'no': 'nor', 'uk': 'ukr',
'cz': 'cze', 'hi': 'hin', 'fa': 'per', 'ur': 'urd',
'da': 'dan', 'hu': 'hun', 'pl': 'pol', 'vi': 'vie',
'nl': 'dut', 'is': 'ice', 'pt': 'por', 'cy': '',
'en': 'eng', 'id': 'ind', 'ro': 'rum', 'yi': ''}
def sizeof_fmt(num):
@ -68,7 +68,7 @@ class SubtitleInfoFormatter(IFormatter):
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
result += '%s' % obj.description
return result
@ -79,7 +79,7 @@ class SubtitleListFormatter(PrettyFormatter):
return obj.name
def get_description(self, obj):
return 'lang : %s ; %s CD ; url : %s' % (obj.language,obj.nb_cd,obj.url)
return 'lang : %s ; %s CD ; url : %s' % (obj.language, obj.nb_cd, obj.url)
class Suboob(ReplApplication):
@ -92,10 +92,10 @@ class Suboob(ReplApplication):
CAPS = ICapSubtitle
EXTRA_FORMATTERS = {'subtitle_list': SubtitleListFormatter,
'subtitle_info': SubtitleInfoFormatter
}
}
COMMANDS_FORMATTERS = {'search': 'subtitle_list',
'info': 'subtitle_info'
}
}
def complete_info(self, text, line, *ignored):
args = line.split(' ')
@ -160,7 +160,7 @@ class Suboob(ReplApplication):
print >>sys.stderr, 'Subtitle "%s" not found' % id
return 3
def do_search(self,line):
def do_search(self, line):
"""
search language [PATTERN]