more PEP8 stuff
Esse commit está contido em:
+24
-22
@@ -24,9 +24,9 @@ the base model for the plugin to work on top of.
|
||||
|
||||
from datetime import datetime, date
|
||||
import os
|
||||
import cgi
|
||||
import tempfile
|
||||
import gc
|
||||
import html
|
||||
|
||||
from gi.repository import RB
|
||||
from gi.repository import GObject
|
||||
@@ -289,6 +289,7 @@ class Album(GObject.Object):
|
||||
self._year = None
|
||||
self._rating = None
|
||||
self._duration = None
|
||||
self._cover_resized_id = None
|
||||
|
||||
self._signals_id = {}
|
||||
|
||||
@@ -714,10 +715,10 @@ class AlbumsModel(GObject.Object):
|
||||
__gsignals__ = {
|
||||
'generate-tooltip': (GObject.SIGNAL_RUN_LAST, str, (object,)),
|
||||
'generate-markup': (GObject.SIGNAL_RUN_LAST, str, (object,)),
|
||||
'album-updated': ((GObject.SIGNAL_RUN_LAST, None, (object, object))),
|
||||
'visual-updated': ((GObject.SIGNAL_RUN_LAST, None, (object, object))),
|
||||
'filter-changed': ((GObject.SIGNAL_RUN_FIRST, None, ())),
|
||||
'album-added': ((GObject.SIGNAL_RUN_LAST, None, (object,)))
|
||||
'album-updated': (GObject.SIGNAL_RUN_LAST, None, (object, object)),
|
||||
'visual-updated': (GObject.SIGNAL_RUN_LAST, None, (object, object)),
|
||||
'filter-changed': (GObject.SIGNAL_RUN_FIRST, None, ()),
|
||||
'album-added': (GObject.SIGNAL_RUN_LAST, None, (object,))
|
||||
}
|
||||
|
||||
# list of columns names and positions on the TreeModel
|
||||
@@ -1088,7 +1089,7 @@ class AlbumsModel(GObject.Object):
|
||||
pos = 0
|
||||
for show_result in list(map(self._album_filter, self._albums)):
|
||||
self.show(self._albums[pos], show_result)
|
||||
pos = pos + 1
|
||||
pos += 1
|
||||
|
||||
def _album_filter(self, album):
|
||||
for f in list(self._filters.values()):
|
||||
@@ -1401,13 +1402,6 @@ class CoverRequester(GObject.Object):
|
||||
|
||||
|
||||
class CoverManager(GObject.Object):
|
||||
"""
|
||||
Manager that takes care of cover loading and updating.
|
||||
|
||||
:param plugin: `Peas.PluginInfo` instance used to have access to the
|
||||
predefined unknown cover.
|
||||
:param album_manager: `AlbumManager` responsible for this manager.
|
||||
"""
|
||||
|
||||
# signals
|
||||
__gsignals__ = {
|
||||
@@ -1423,6 +1417,14 @@ class CoverManager(GObject.Object):
|
||||
shadow_image = GObject.property(type=str, default="above")
|
||||
|
||||
def __init__(self, plugin, manager):
|
||||
"""
|
||||
Manager that takes care of cover loading and updating.
|
||||
|
||||
:param plugin: `Peas.PluginInfo` instance used to have access to the
|
||||
predefined unknown cover.
|
||||
:param manager: `AlbumManager` responsible for this manager.
|
||||
"""
|
||||
|
||||
super(CoverManager, self).__init__()
|
||||
# self.cover_db = None to be defined by inherited class
|
||||
self._manager = manager
|
||||
@@ -1779,14 +1781,14 @@ class BaseTextManager(GObject.Object):
|
||||
|
||||
|
||||
class AlbumTextManager(BaseTextManager):
|
||||
"""
|
||||
Manager that keeps control of the text options for the model's markup text.
|
||||
It takes care of creating the text for the model when requested to do it.
|
||||
|
||||
:param album_manager: `AlbumManager` responsible for this manager.
|
||||
"""
|
||||
|
||||
def __init__(self, manager):
|
||||
"""
|
||||
Manager that keeps control of the text options for the model's markup text.
|
||||
It takes care of creating the text for the model when requested to do it.
|
||||
|
||||
:param manager: `AlbumManager` responsible for this manager.
|
||||
"""
|
||||
|
||||
super(AlbumTextManager, self).__init__(manager)
|
||||
|
||||
def generate_tooltip(self, model, album):
|
||||
@@ -1794,8 +1796,8 @@ class AlbumTextManager(BaseTextManager):
|
||||
Utility function that creates the tooltip for this album to set into
|
||||
the model.
|
||||
"""
|
||||
return cgi.escape(rb3compat.unicodeencode(_('%s by %s'), 'utf-8') % (album.name,
|
||||
album.artists))
|
||||
return html.escape(rb3compat.unicodeencode(_('%s by %s'), 'utf-8') % (album.name,
|
||||
album.artists))
|
||||
|
||||
def generate_markup_text(self, model, album):
|
||||
"""
|
||||
|
||||
@@ -132,7 +132,7 @@ class CoverArtBrowserSource(RB.Source):
|
||||
|
||||
self.task_progress.props.task_outcome = RB.TaskOutcome.COMPLETE
|
||||
|
||||
return (self.status, progress_text, progress)
|
||||
return self.status, progress_text, progress
|
||||
|
||||
def do_selected(self):
|
||||
"""
|
||||
@@ -302,7 +302,7 @@ class CoverArtBrowserSource(RB.Source):
|
||||
|
||||
# theme override option
|
||||
activations = setting[self.gs.PluginKey.ACTIVATIONS]
|
||||
activations = activations + 1
|
||||
activations += 1
|
||||
setting[self.gs.PluginKey.ACTIVATIONS] = activations
|
||||
|
||||
if activations > 4:
|
||||
@@ -310,12 +310,12 @@ class CoverArtBrowserSource(RB.Source):
|
||||
else:
|
||||
override = 'ui/gtkthemeoverride_max.css'
|
||||
|
||||
cssProvider = Gtk.CssProvider()
|
||||
cssprovider = Gtk.CssProvider()
|
||||
css = rb.find_plugin_file(self.plugin, override)
|
||||
cssProvider.load_from_path(css)
|
||||
cssprovider.load_from_path(css)
|
||||
screen = Gdk.Screen.get_default()
|
||||
styleContext = Gtk.StyleContext()
|
||||
styleContext.add_provider_for_screen(screen, cssProvider,
|
||||
stylecontext = Gtk.StyleContext()
|
||||
stylecontext.add_provider_for_screen(screen, cssprovider,
|
||||
Gtk.STYLE_PROVIDER_PRIORITY_USER)
|
||||
|
||||
print("CoverArtBrowser DEBUG - end _create_ui")
|
||||
@@ -520,10 +520,10 @@ class CoverArtBrowserSource(RB.Source):
|
||||
|
||||
print("Child Width2 %d" % child_width)
|
||||
|
||||
paned_positions.append(self.viewmgr.view_name + \
|
||||
":" + \
|
||||
str(child_width) + \
|
||||
":" + \
|
||||
paned_positions.append(self.viewmgr.view_name +
|
||||
":" +
|
||||
str(child_width) +
|
||||
":" +
|
||||
open_type)
|
||||
|
||||
print("after paned positions %s" % paned_positions)
|
||||
@@ -707,7 +707,7 @@ class CoverArtBrowserSource(RB.Source):
|
||||
"""
|
||||
print("CoverArtBrowser DEBUG - queue_selected_album")
|
||||
|
||||
if source == None:
|
||||
if source is None:
|
||||
source = self.source_query_model
|
||||
|
||||
selected_albums = self.viewmgr.current_view.get_selected_objects()
|
||||
@@ -717,20 +717,20 @@ class CoverArtBrowserSource(RB.Source):
|
||||
for album in selected_albums:
|
||||
# Retrieve and sort the entries of the album
|
||||
tracks = album.get_tracks(threshold)
|
||||
total = total + len(tracks)
|
||||
total += len(tracks)
|
||||
# Add the songs to the play queue
|
||||
for track in tracks:
|
||||
source.add_entry(track.entry, index)
|
||||
if index != -1:
|
||||
index = index + 1
|
||||
index += 1
|
||||
|
||||
if total == 0 and threshold:
|
||||
msg = _("No tracks have been added because no tracks meet the favourite rating threshold")
|
||||
dialog = Gtk.MessageDialog(None,
|
||||
Gtk.DialogFlags.MODAL,
|
||||
Gtk.MessageType.INFO,
|
||||
Gtk.ButtonsType.OK,
|
||||
_(
|
||||
"No tracks have been added because no tracks meet the favourite rating threshold"))
|
||||
msg)
|
||||
|
||||
dialog.run()
|
||||
dialog.destroy()
|
||||
@@ -767,7 +767,7 @@ class CoverArtBrowserSource(RB.Source):
|
||||
# so lets reverse through the model calculating the position
|
||||
|
||||
while entry is not None:
|
||||
index = index + 1
|
||||
index += 1
|
||||
entry = source.get_previous_from_entry(entry)
|
||||
|
||||
entry = self.shell.props.shell_player.get_playing_entry()
|
||||
@@ -777,7 +777,7 @@ class CoverArtBrowserSource(RB.Source):
|
||||
current_album = self.album_manager.model.get_from_dbentry(entry)
|
||||
while entry is not None:
|
||||
entry = source.get_next_from_entry(entry)
|
||||
index = index + 1
|
||||
index += 1
|
||||
if entry:
|
||||
album = self.album_manager.model.get_from_dbentry(entry)
|
||||
print(entry.get_string(RB.RhythmDBPropType.TITLE))
|
||||
@@ -829,12 +829,11 @@ class CoverArtBrowserSource(RB.Source):
|
||||
for playlist in playlists_entries:
|
||||
if playlist.props.is_local and \
|
||||
isinstance(playlist, RB.StaticPlaylistSource):
|
||||
args = (playlist, favourite)
|
||||
|
||||
# take the name of the playlist, strip out non-english characters and reduce the string
|
||||
# to just a-to-z characters i.e. this will make the action_name valid in RB3
|
||||
|
||||
ascii_name = unicodedata.normalize('NFKD', \
|
||||
ascii_name = unicodedata.normalize('NFKD',
|
||||
rb3compat.unicodestr(playlist.props.name, 'utf-8')).encode(
|
||||
'ascii', 'ignore')
|
||||
ascii_name = ascii_name.decode(encoding='UTF-8')
|
||||
@@ -1010,7 +1009,7 @@ class CoverArtBrowserSource(RB.Source):
|
||||
album = params
|
||||
force = PanedCollapsible.Paned.DEFAULT
|
||||
|
||||
if (album and self.click_count == 1 \
|
||||
if (album and self.click_count == 1
|
||||
and self.last_selected_album is album) or force != PanedCollapsible.Paned.DEFAULT:
|
||||
# check if it's a second or third click on the album and expand
|
||||
# or collapse the entry view accordingly
|
||||
@@ -1151,6 +1150,7 @@ class Statusbar(GObject.Object):
|
||||
# 'interesting stuff' about the album
|
||||
if len(albums) == 1:
|
||||
# . TRANSLATORS - for example "abba's greatest hits by ABBA"
|
||||
album = albums[0]
|
||||
self.status = rb3compat.unicodedecode(_('%s by %s') %
|
||||
(album.name, album.artist), 'UTF-8')
|
||||
else:
|
||||
@@ -1306,14 +1306,12 @@ class ViewManager(GObject.Object):
|
||||
self.window = window
|
||||
|
||||
# initialize views
|
||||
self._views = {}
|
||||
ui = Gtk.Builder()
|
||||
self._views[CoverIconView.name] = CoverIconView()
|
||||
self._views[CoverFlowView.name] = CoverFlowView()
|
||||
self._views[ListView.name] = ListView()
|
||||
self._views[QueueView.name] = QueueView()
|
||||
self._views[PlaySourceView.name] = PlaySourceView()
|
||||
self._views[ArtistView.name] = ArtistView()
|
||||
self._views = {CoverIconView.name: CoverIconView(),
|
||||
CoverFlowView.name: CoverFlowView(),
|
||||
ListView.name: ListView(),
|
||||
QueueView.name: QueueView(),
|
||||
PlaySourceView.name: PlaySourceView(),
|
||||
ArtistView.name: ArtistView()}
|
||||
self._lastview = None
|
||||
|
||||
self.controller = ViewController(source.shell, self)
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário