Fix 'W504 line break after binary operator' flake8 warnings
Fixed by running autopep8 -i -r --select=W504 . and some hand tuning.
This commit is contained in:
parent
6bd0bb0530
commit
d87ac85506
4
bin/gpo
4
bin/gpo
|
@ -1176,8 +1176,8 @@ class gPodderCli(object):
|
||||||
defaults = defaults or ()
|
defaults = defaults or ()
|
||||||
minarg, maxarg = len(args) - len(defaults), len(args)
|
minarg, maxarg = len(args) - len(defaults), len(args)
|
||||||
|
|
||||||
if (len(command_line) < minarg or
|
if (len(command_line) < minarg
|
||||||
(len(command_line) > maxarg and varargs is None)):
|
or (len(command_line) > maxarg and varargs is None)):
|
||||||
self._error('Wrong argument count for %s.' % func.__name__)
|
self._error('Wrong argument count for %s.' % func.__name__)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -139,9 +139,9 @@ def main():
|
||||||
from gpodder import log
|
from gpodder import log
|
||||||
log.setup(options.verbose, options.quiet)
|
log.setup(options.verbose, options.quiet)
|
||||||
|
|
||||||
if (not (gpodder.ui.win32 or gpodder.ui.osx) and
|
if (not (gpodder.ui.win32 or gpodder.ui.osx)
|
||||||
os.environ.get('DISPLAY', '') == '' and
|
and os.environ.get('DISPLAY', '') == ''
|
||||||
os.environ.get('WAYLAND_DISPLAY', '') == ''):
|
and os.environ.get('WAYLAND_DISPLAY', '') == ''):
|
||||||
logger.error('Cannot start gPodder: $DISPLAY or $WAYLAND_DISPLAY is not set.')
|
logger.error('Cannot start gPodder: $DISPLAY or $WAYLAND_DISPLAY is not set.')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
|
@ -121,18 +121,18 @@ class CurrentTrackTracker(object):
|
||||||
# If the position is being updated, and the current status was Playing
|
# If the position is being updated, and the current status was Playing
|
||||||
# If the status *is* playing, and *was* playing, but the position
|
# If the status *is* playing, and *was* playing, but the position
|
||||||
# has changed discontinuously, notify a stop for the old position
|
# has changed discontinuously, notify a stop for the old position
|
||||||
if (cur['status'] == 'Playing' and
|
if (cur['status'] == 'Playing'
|
||||||
('status' not in kwargs or kwargs['status'] == 'Playing') and not
|
and ('status' not in kwargs or kwargs['status'] == 'Playing') and not
|
||||||
subsecond_difference(cur['pos'], kwargs['pos'])):
|
subsecond_difference(cur['pos'], kwargs['pos'])):
|
||||||
logger.debug('notify Stopped: playback discontinuity:' +
|
logger.debug('notify Stopped: playback discontinuity:'
|
||||||
'calc: %r observed: %r', cur['pos'], kwargs['pos'])
|
+ 'calc: %r observed: %r', cur['pos'], kwargs['pos'])
|
||||||
self.notify_stop()
|
self.notify_stop()
|
||||||
|
|
||||||
if ((kwargs['pos']) <= 0 and
|
if ((kwargs['pos']) <= 0
|
||||||
self.pos is not None and
|
and self.pos is not None
|
||||||
self.length is not None and
|
and self.length is not None
|
||||||
(self.length - USECS_IN_SEC) < self.pos and
|
and (self.length - USECS_IN_SEC) < self.pos
|
||||||
self.pos < (self.length + 2 * USECS_IN_SEC)):
|
and self.pos < (self.length + 2 * USECS_IN_SEC)):
|
||||||
logger.debug('pos=0 end of stream (calculated pos: %f/%f [%f])',
|
logger.debug('pos=0 end of stream (calculated pos: %f/%f [%f])',
|
||||||
self.pos / USECS_IN_SEC, self.length / USECS_IN_SEC,
|
self.pos / USECS_IN_SEC, self.length / USECS_IN_SEC,
|
||||||
(self.pos / USECS_IN_SEC) - (self.length / USECS_IN_SEC))
|
(self.pos / USECS_IN_SEC) - (self.length / USECS_IN_SEC))
|
||||||
|
@ -174,11 +174,11 @@ class CurrentTrackTracker(object):
|
||||||
self.notify('Playing')
|
self.notify('Playing')
|
||||||
|
|
||||||
def notify(self, status):
|
def notify(self, status):
|
||||||
if (self.uri is None or
|
if (self.uri is None
|
||||||
self.pos is None or
|
or self.pos is None
|
||||||
self.status is None or
|
or self.status is None
|
||||||
self.length is None or
|
or self.length is None
|
||||||
self.length <= 0):
|
or self.length <= 0):
|
||||||
return
|
return
|
||||||
pos = self.pos // USECS_IN_SEC
|
pos = self.pos // USECS_IN_SEC
|
||||||
parsed_url = urllib.parse.urlparse(self.uri)
|
parsed_url = urllib.parse.urlparse(self.uri)
|
||||||
|
|
|
@ -48,8 +48,8 @@ class gPodderExtension(object):
|
||||||
srtContent = ''
|
srtContent = ''
|
||||||
for captionIndex, caption in enumerate(jsonobject['captions'], 1):
|
for captionIndex, caption in enumerate(jsonobject['captions'], 1):
|
||||||
startTime = self.milli_to_srt(introduration + caption['startTime'])
|
startTime = self.milli_to_srt(introduration + caption['startTime'])
|
||||||
endTime = self.milli_to_srt(introduration + caption['startTime'] +
|
endTime = self.milli_to_srt(introduration + caption['startTime']
|
||||||
caption['duration'])
|
+ caption['duration'])
|
||||||
srtContent += ''.join([str(captionIndex), os.linesep, startTime,
|
srtContent += ''.join([str(captionIndex), os.linesep, startTime,
|
||||||
' --> ', endTime, os.linesep,
|
' --> ', endTime, os.linesep,
|
||||||
caption['content'], os.linesep * 2])
|
caption['content'], os.linesep * 2])
|
||||||
|
|
|
@ -104,8 +104,8 @@ def get_expired_episodes(channels, config):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Download strategy "Only keep latest"
|
# Download strategy "Only keep latest"
|
||||||
if (channel.download_strategy == channel.STRATEGY_LATEST and
|
if (channel.download_strategy == channel.STRATEGY_LATEST
|
||||||
index > 0):
|
and index > 0):
|
||||||
logger.info('Removing episode (only keep latest strategy): %s',
|
logger.info('Removing episode (only keep latest strategy): %s',
|
||||||
episode.title)
|
episode.title)
|
||||||
yield episode
|
yield episode
|
||||||
|
|
|
@ -333,11 +333,11 @@ class ExtensionManager(object):
|
||||||
logger.debug('Found extension "%s" in %s', name, filename)
|
logger.debug('Found extension "%s" in %s', name, filename)
|
||||||
config = getattr(core.config.extensions, name)
|
config = getattr(core.config.extensions, name)
|
||||||
container = ExtensionContainer(self, name, config, filename)
|
container = ExtensionContainer(self, name, config, filename)
|
||||||
if (name in enabled_extensions or
|
if (name in enabled_extensions
|
||||||
container.metadata.mandatory_in_current_ui):
|
or container.metadata.mandatory_in_current_ui):
|
||||||
container.set_enabled(True)
|
container.set_enabled(True)
|
||||||
if (name in enabled_extensions and
|
if (name in enabled_extensions
|
||||||
container.metadata.disable_in_current_ui):
|
and container.metadata.disable_in_current_ui):
|
||||||
container.set_enabled(False)
|
container.set_enabled(False)
|
||||||
self.containers.append(container)
|
self.containers.append(container)
|
||||||
|
|
||||||
|
@ -390,9 +390,9 @@ class ExtensionManager(object):
|
||||||
def get_extensions(self):
|
def get_extensions(self):
|
||||||
"""Get a list of all loaded extensions and their enabled flag"""
|
"""Get a list of all loaded extensions and their enabled flag"""
|
||||||
return [c for c in self.containers
|
return [c for c in self.containers
|
||||||
if c.metadata.available_for_current_ui and
|
if c.metadata.available_for_current_ui
|
||||||
not c.metadata.mandatory_in_current_ui and
|
and not c.metadata.mandatory_in_current_ui
|
||||||
not c.metadata.disable_in_current_ui]
|
and not c.metadata.disable_in_current_ui]
|
||||||
|
|
||||||
# Define all known handler functions here, decorate them with the
|
# Define all known handler functions here, decorate them with the
|
||||||
# "call_extension" decorator to forward all calls to extension scripts that have
|
# "call_extension" decorator to forward all calls to extension scripts that have
|
||||||
|
|
|
@ -92,11 +92,11 @@ class OnSyncActionList(Gtk.ListStore):
|
||||||
|
|
||||||
def get_index(self):
|
def get_index(self):
|
||||||
for index, row in enumerate(self):
|
for index, row in enumerate(self):
|
||||||
if (self._config.device_sync.after_sync.delete_episodes and
|
if (self._config.device_sync.after_sync.delete_episodes
|
||||||
row[self.C_ON_SYNC_DELETE]):
|
and row[self.C_ON_SYNC_DELETE]):
|
||||||
return index
|
return index
|
||||||
if (self._config.device_sync.after_sync.mark_episodes_played and
|
if (self._config.device_sync.after_sync.mark_episodes_played
|
||||||
row[self.C_ON_SYNC_MARK_PLAYED] and not
|
and row[self.C_ON_SYNC_MARK_PLAYED] and not
|
||||||
self._config.device_sync.after_sync.delete_episodes):
|
self._config.device_sync.after_sync.delete_episodes):
|
||||||
return index
|
return index
|
||||||
return 0 # Some sane default
|
return 0 # Some sane default
|
||||||
|
|
|
@ -74,8 +74,8 @@ class gPodderConfigEditor(BuilderWidget):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
# either the variable name or its value
|
# either the variable name or its value
|
||||||
return (text in model.get_value(iter, 0).lower() or
|
return (text in model.get_value(iter, 0).lower()
|
||||||
text in model.get_value(iter, 2).lower())
|
or text in model.get_value(iter, 2).lower())
|
||||||
|
|
||||||
def value_edited(self, renderer, path, new_text):
|
def value_edited(self, renderer, path, new_text):
|
||||||
model = self.configeditor.get_model()
|
model = self.configeditor.get_model()
|
||||||
|
|
|
@ -496,8 +496,8 @@ class gPodder(BuilderWidget, dbus.service.Object):
|
||||||
# Assume the episode's total time for the action
|
# Assume the episode's total time for the action
|
||||||
total = episode.total_time
|
total = episode.total_time
|
||||||
|
|
||||||
assert (episode.current_position_updated is None or
|
assert (episode.current_position_updated is None
|
||||||
now >= episode.current_position_updated)
|
or now >= episode.current_position_updated)
|
||||||
|
|
||||||
episode.current_position = end
|
episode.current_position = end
|
||||||
episode.current_position_updated = now
|
episode.current_position_updated = now
|
||||||
|
@ -649,8 +649,8 @@ class gPodder(BuilderWidget, dbus.service.Object):
|
||||||
path, column, x, y = result
|
path, column, x, y = result
|
||||||
# The user clicked the icon if she clicked in the first column
|
# The user clicked the icon if she clicked in the first column
|
||||||
# and the x position is in the area where the icon resides
|
# and the x position is in the area where the icon resides
|
||||||
if (x < self.EPISODE_LIST_ICON_WIDTH and
|
if (x < self.EPISODE_LIST_ICON_WIDTH
|
||||||
column == treeview.get_columns()[0]):
|
and column == treeview.get_columns()[0]):
|
||||||
model = treeview.get_model()
|
model = treeview.get_model()
|
||||||
cursor_episode = model.get_value(model.get_iter(path),
|
cursor_episode = model.get_value(model.get_iter(path),
|
||||||
EpisodeListModel.C_EPISODE)
|
EpisodeListModel.C_EPISODE)
|
||||||
|
@ -841,8 +841,8 @@ class gPodder(BuilderWidget, dbus.service.Object):
|
||||||
# Initialize progress icons
|
# Initialize progress icons
|
||||||
cake_size = cake_size_from_widget(self.treeAvailable)
|
cake_size = cake_size_from_widget(self.treeAvailable)
|
||||||
for i in range(EpisodeListModel.PROGRESS_STEPS + 1):
|
for i in range(EpisodeListModel.PROGRESS_STEPS + 1):
|
||||||
pixbuf = draw_cake_pixbuf(i /
|
pixbuf = draw_cake_pixbuf(
|
||||||
EpisodeListModel.PROGRESS_STEPS, size=cake_size)
|
i / EpisodeListModel.PROGRESS_STEPS, size=cake_size)
|
||||||
icon_name = 'gpodder-progress-%d' % i
|
icon_name = 'gpodder-progress-%d' % i
|
||||||
Gtk.IconTheme.add_builtin_icon(icon_name, cake_size, pixbuf)
|
Gtk.IconTheme.add_builtin_icon(icon_name, cake_size, pixbuf)
|
||||||
|
|
||||||
|
@ -1443,14 +1443,14 @@ class gPodder(BuilderWidget, dbus.service.Object):
|
||||||
selection = treeview.get_selection()
|
selection = treeview.get_selection()
|
||||||
model, paths = selection.get_selected_rows()
|
model, paths = selection.get_selected_rows()
|
||||||
|
|
||||||
if path is None or (path not in paths and
|
if path is None or (path not in paths
|
||||||
event.button == 3):
|
and event.button == 3):
|
||||||
# We have right-clicked, but not into the selection,
|
# We have right-clicked, but not into the selection,
|
||||||
# assume we don't want to operate on the selection
|
# assume we don't want to operate on the selection
|
||||||
paths = []
|
paths = []
|
||||||
|
|
||||||
if (path is not None and not paths and
|
if (path is not None and not paths
|
||||||
event.button == 3):
|
and event.button == 3):
|
||||||
# No selection or clicked outside selection;
|
# No selection or clicked outside selection;
|
||||||
# select the single item where we clicked
|
# select the single item where we clicked
|
||||||
treeview.grab_focus()
|
treeview.grab_focus()
|
||||||
|
@ -2440,8 +2440,8 @@ class gPodder(BuilderWidget, dbus.service.Object):
|
||||||
else:
|
else:
|
||||||
list_model_length = len(self.podcast_list_model)
|
list_model_length = len(self.podcast_list_model)
|
||||||
|
|
||||||
force_update = (sections_active != self.config.podcast_list_sections or
|
force_update = (sections_active != self.config.podcast_list_sections
|
||||||
sections_changed)
|
or sections_changed)
|
||||||
|
|
||||||
# Filter items in the list model that are not podcasts, so we get the
|
# Filter items in the list model that are not podcasts, so we get the
|
||||||
# correct podcast list count (ignore section headers and separators)
|
# correct podcast list count (ignore section headers and separators)
|
||||||
|
@ -2914,8 +2914,8 @@ class gPodder(BuilderWidget, dbus.service.Object):
|
||||||
count) % {'count': count}
|
count) % {'count': count}
|
||||||
self.show_message(title, _('New episodes available'))
|
self.show_message(title, _('New episodes available'))
|
||||||
else:
|
else:
|
||||||
if (show_new_episodes_dialog and
|
if (show_new_episodes_dialog
|
||||||
self.config.auto_download == 'show'):
|
and self.config.auto_download == 'show'):
|
||||||
self.new_episodes_show(episodes, notification=True)
|
self.new_episodes_show(episodes, notification=True)
|
||||||
else: # !show_new_episodes_dialog or auto_download == 'ignore'
|
else: # !show_new_episodes_dialog or auto_download == 'ignore'
|
||||||
message = N_('%(count)d new episode available',
|
message = N_('%(count)d new episode available',
|
||||||
|
@ -3771,8 +3771,8 @@ class gPodder(BuilderWidget, dbus.service.Object):
|
||||||
GLib.source_remove(self._auto_update_timer_source_id)
|
GLib.source_remove(self._auto_update_timer_source_id)
|
||||||
self._auto_update_timer_source_id = None
|
self._auto_update_timer_source_id = None
|
||||||
|
|
||||||
if (self.config.auto_update_feeds and
|
if (self.config.auto_update_feeds
|
||||||
self.config.auto_update_frequency):
|
and self.config.auto_update_frequency):
|
||||||
interval = 60 * 1000 * self.config.auto_update_frequency
|
interval = 60 * 1000 * self.config.auto_update_frequency
|
||||||
logger.debug('Setting up auto update timer with interval %d.',
|
logger.debug('Setting up auto update timer with interval %d.',
|
||||||
self.config.auto_update_frequency)
|
self.config.auto_update_frequency)
|
||||||
|
@ -3922,8 +3922,8 @@ class gPodder(BuilderWidget, dbus.service.Object):
|
||||||
try:
|
try:
|
||||||
file.mount_enclosing_volume_finish(res)
|
file.mount_enclosing_volume_finish(res)
|
||||||
except GLib.Error as err:
|
except GLib.Error as err:
|
||||||
if (not err.matches(Gio.io_error_quark(), Gio.IOErrorEnum.NOT_SUPPORTED) and
|
if (not err.matches(Gio.io_error_quark(), Gio.IOErrorEnum.NOT_SUPPORTED)
|
||||||
not err.matches(Gio.io_error_quark(), Gio.IOErrorEnum.ALREADY_MOUNTED)):
|
and not err.matches(Gio.io_error_quark(), Gio.IOErrorEnum.ALREADY_MOUNTED)):
|
||||||
logger.error('mounting volume %s failed: %s' % (file.get_uri(), err.message))
|
logger.error('mounting volume %s failed: %s' % (file.get_uri(), err.message))
|
||||||
result = False
|
result = False
|
||||||
finally:
|
finally:
|
||||||
|
|
|
@ -64,8 +64,8 @@ class GEpisode(model.PodcastEpisode):
|
||||||
length_str = '%s; ' % util.format_filesize(self.file_size)
|
length_str = '%s; ' % util.format_filesize(self.file_size)
|
||||||
else:
|
else:
|
||||||
length_str = ''
|
length_str = ''
|
||||||
return ('<b>%s</b>\n<small>%s' + _('released %s') +
|
return ('<b>%s</b>\n<small>%s' + _('released %s')
|
||||||
'; ' + _('from %s') + '</small>') % (
|
+ '; ' + _('from %s') + '</small>') % (
|
||||||
html.escape(re.sub(r'\s+', ' ', self.title)),
|
html.escape(re.sub(r'\s+', ' ', self.title)),
|
||||||
html.escape(length_str),
|
html.escape(length_str),
|
||||||
html.escape(self.pubdate_prop),
|
html.escape(self.pubdate_prop),
|
||||||
|
@ -82,8 +82,8 @@ class GEpisode(model.PodcastEpisode):
|
||||||
downloaded_string = self.get_age_string()
|
downloaded_string = self.get_age_string()
|
||||||
if not downloaded_string:
|
if not downloaded_string:
|
||||||
downloaded_string = _('today')
|
downloaded_string = _('today')
|
||||||
return ('<b>%s</b>\n<small>%s; %s; ' + _('downloaded %s') +
|
return ('<b>%s</b>\n<small>%s; %s; ' + _('downloaded %s')
|
||||||
'; ' + _('from %s') + '</small>') % (
|
+ '; ' + _('from %s') + '</small>') % (
|
||||||
html.escape(self.title),
|
html.escape(self.title),
|
||||||
html.escape(util.format_filesize(self.file_size)),
|
html.escape(util.format_filesize(self.file_size)),
|
||||||
html.escape(played_string),
|
html.escape(played_string),
|
||||||
|
@ -459,8 +459,8 @@ class EpisodeListModel(Gtk.ListStore):
|
||||||
tooltip.append(_('deletion prevented'))
|
tooltip.append(_('deletion prevented'))
|
||||||
|
|
||||||
if episode.total_time > 0 and episode.current_position:
|
if episode.total_time > 0 and episode.current_position:
|
||||||
tooltip.append('%d%%' % (100. * float(episode.current_position) /
|
tooltip.append('%d%%' % (
|
||||||
float(episode.total_time),))
|
100. * float(episode.current_position) / float(episode.total_time)))
|
||||||
elif episode._download_error is not None:
|
elif episode._download_error is not None:
|
||||||
tooltip.append(_('ERROR: %s') % episode._download_error)
|
tooltip.append(_('ERROR: %s') % episode._download_error)
|
||||||
status_icon = self.ICON_ERROR
|
status_icon = self.ICON_ERROR
|
||||||
|
|
|
@ -282,8 +282,8 @@ class PodcastEpisode(PodcastModelObject):
|
||||||
is_locked = property(fget=_deprecated, fset=_deprecated)
|
is_locked = property(fget=_deprecated, fset=_deprecated)
|
||||||
|
|
||||||
def has_website_link(self):
|
def has_website_link(self):
|
||||||
return bool(self.link) and (self.link != self.url or
|
return bool(self.link) and (self.link != self.url
|
||||||
youtube.is_video_link(self.link))
|
or youtube.is_video_link(self.link))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_podcastparser_entry(cls, entry, channel):
|
def from_podcastparser_entry(cls, entry, channel):
|
||||||
|
@ -417,8 +417,8 @@ class PodcastEpisode(PodcastModelObject):
|
||||||
# "Podcast Name - Title" and "Podcast Name: Title" -> "Title"
|
# "Podcast Name - Title" and "Podcast Name: Title" -> "Title"
|
||||||
for postfix in (' - ', ': '):
|
for postfix in (' - ', ': '):
|
||||||
prefix = self.parent.title + postfix
|
prefix = self.parent.title + postfix
|
||||||
if (self.title.startswith(prefix) and
|
if (self.title.startswith(prefix)
|
||||||
len(self.title) - len(prefix) > LEFTOVER_MIN):
|
and len(self.title) - len(prefix) > LEFTOVER_MIN):
|
||||||
return self.title[len(prefix):]
|
return self.title[len(prefix):]
|
||||||
|
|
||||||
regex_patterns = [
|
regex_patterns = [
|
||||||
|
@ -437,14 +437,14 @@ class PodcastEpisode(PodcastModelObject):
|
||||||
|
|
||||||
# "#001: Title" -> "001: Title"
|
# "#001: Title" -> "001: Title"
|
||||||
if (
|
if (
|
||||||
not self.parent._common_prefix and
|
not self.parent._common_prefix
|
||||||
re.match(r'^#\d+: ', self.title) and
|
and re.match(r'^#\d+: ', self.title)
|
||||||
len(self.title) - 1 > LEFTOVER_MIN):
|
and len(self.title) - 1 > LEFTOVER_MIN):
|
||||||
return self.title[1:]
|
return self.title[1:]
|
||||||
|
|
||||||
if (self.parent._common_prefix is not None and
|
if (self.parent._common_prefix is not None
|
||||||
self.title.startswith(self.parent._common_prefix) and
|
and self.title.startswith(self.parent._common_prefix)
|
||||||
len(self.title) - len(self.parent._common_prefix) > LEFTOVER_MIN):
|
and len(self.title) - len(self.parent._common_prefix) > LEFTOVER_MIN):
|
||||||
return self.title[len(self.parent._common_prefix):]
|
return self.title[len(self.parent._common_prefix):]
|
||||||
|
|
||||||
return self.title
|
return self.title
|
||||||
|
@ -535,8 +535,8 @@ class PodcastEpisode(PodcastModelObject):
|
||||||
return self.state != gpodder.STATE_DELETED or self.archive
|
return self.state != gpodder.STATE_DELETED or self.archive
|
||||||
|
|
||||||
def check_is_new(self):
|
def check_is_new(self):
|
||||||
return (self.state == gpodder.STATE_NORMAL and self.is_new and
|
return (self.state == gpodder.STATE_NORMAL and self.is_new
|
||||||
not self.downloading)
|
and not self.downloading)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
gpodder.user_extensions.on_episode_save(self)
|
gpodder.user_extensions.on_episode_save(self)
|
||||||
|
@ -642,8 +642,8 @@ class PodcastEpisode(PodcastModelObject):
|
||||||
filename = filename.strip('.' + string.whitespace) + extension
|
filename = filename.strip('.' + string.whitespace) + extension
|
||||||
|
|
||||||
for name in util.generate_names(filename):
|
for name in util.generate_names(filename):
|
||||||
if (not self.db.episode_filename_exists(self.podcast_id, name) or
|
if (not self.db.episode_filename_exists(self.podcast_id, name)
|
||||||
self.download_filename == name):
|
or self.download_filename == name):
|
||||||
return name
|
return name
|
||||||
|
|
||||||
def local_filename(self, create, force_update=False, check_only=False,
|
def local_filename(self, create, force_update=False, check_only=False,
|
||||||
|
@ -706,9 +706,9 @@ class PodcastEpisode(PodcastModelObject):
|
||||||
episode_filename, _ = util.filename_from_url(url)
|
episode_filename, _ = util.filename_from_url(url)
|
||||||
|
|
||||||
# Use title for YouTube, Vimeo and Soundcloud downloads
|
# Use title for YouTube, Vimeo and Soundcloud downloads
|
||||||
if (youtube.is_video_link(self.url) or
|
if (youtube.is_video_link(self.url)
|
||||||
vimeo.is_video_link(self.url) or
|
or vimeo.is_video_link(self.url)
|
||||||
episode_filename == 'stream'):
|
or episode_filename == 'stream'):
|
||||||
episode_filename = self.title
|
episode_filename = self.title
|
||||||
|
|
||||||
# If the basename is empty, use the md5 hexdigest of the URL
|
# If the basename is empty, use the md5 hexdigest of the URL
|
||||||
|
@ -865,9 +865,10 @@ class PodcastEpisode(PodcastModelObject):
|
||||||
current position is greater than 99 percent of the
|
current position is greater than 99 percent of the
|
||||||
total time or inside the last 10 seconds of a track.
|
total time or inside the last 10 seconds of a track.
|
||||||
"""
|
"""
|
||||||
return (self.current_position > 0 and self.total_time > 0 and
|
return (self.current_position > 0
|
||||||
(self.current_position + 10 >= self.total_time or
|
and self.total_time > 0
|
||||||
self.current_position >= self.total_time * .99))
|
and (self.current_position + 10 >= self.total_time
|
||||||
|
or self.current_position >= self.total_time * .99))
|
||||||
|
|
||||||
def get_play_info_string(self, duration_only=False):
|
def get_play_info_string(self, duration_only=False):
|
||||||
duration = util.format_time(self.total_time)
|
duration = util.format_time(self.total_time)
|
||||||
|
@ -1016,8 +1017,8 @@ class PodcastChannel(PodcastModelObject):
|
||||||
ignore_files = ['folder' + ext for ext in
|
ignore_files = ['folder' + ext for ext in
|
||||||
coverart.CoverDownloader.EXTENSIONS]
|
coverart.CoverDownloader.EXTENSIONS]
|
||||||
|
|
||||||
external_files = existing_files.difference(list(known_files) +
|
external_files = existing_files.difference(list(known_files)
|
||||||
[os.path.join(self.save_dir, ignore_file)
|
+ [os.path.join(self.save_dir, ignore_file)
|
||||||
for ignore_file in ignore_files])
|
for ignore_file in ignore_files])
|
||||||
if not external_files:
|
if not external_files:
|
||||||
return
|
return
|
||||||
|
@ -1228,8 +1229,8 @@ class PodcastChannel(PodcastModelObject):
|
||||||
real_new_episode_count += 1
|
real_new_episode_count += 1
|
||||||
|
|
||||||
# Only allow a certain number of new episodes per update
|
# Only allow a certain number of new episodes per update
|
||||||
if (self.download_strategy == PodcastChannel.STRATEGY_LATEST and
|
if (self.download_strategy == PodcastChannel.STRATEGY_LATEST
|
||||||
real_new_episode_count > 1):
|
and real_new_episode_count > 1):
|
||||||
episode.is_new = False
|
episode.is_new = False
|
||||||
episode.save()
|
episode.save()
|
||||||
|
|
||||||
|
@ -1243,8 +1244,8 @@ class PodcastChannel(PodcastModelObject):
|
||||||
# Keep episodes that are currently being downloaded, though (bug 1534)
|
# Keep episodes that are currently being downloaded, though (bug 1534)
|
||||||
if self.id is not None:
|
if self.id is not None:
|
||||||
episodes_to_purge = [e for e in existing if
|
episodes_to_purge = [e for e in existing if
|
||||||
e.state != gpodder.STATE_DOWNLOADED and
|
e.state != gpodder.STATE_DOWNLOADED
|
||||||
e.guid not in seen_guids and not e.downloading]
|
and e.guid not in seen_guids and not e.downloading]
|
||||||
|
|
||||||
for episode in episodes_to_purge:
|
for episode in episodes_to_purge:
|
||||||
logger.debug('Episode removed from feed: %s (%s)',
|
logger.debug('Episode removed from feed: %s (%s)',
|
||||||
|
@ -1415,8 +1416,8 @@ class PodcastChannel(PodcastModelObject):
|
||||||
download_folder = download_folder.strip('.' + string.whitespace)
|
download_folder = download_folder.strip('.' + string.whitespace)
|
||||||
|
|
||||||
for folder_name in util.generate_names(download_folder):
|
for folder_name in util.generate_names(download_folder):
|
||||||
if (not self.db.podcast_download_folder_exists(folder_name) or
|
if (not self.db.podcast_download_folder_exists(folder_name)
|
||||||
self.download_folder == folder_name):
|
or self.download_folder == folder_name):
|
||||||
return folder_name
|
return folder_name
|
||||||
|
|
||||||
def get_save_dir(self, force_new=False):
|
def get_save_dir(self, force_new=False):
|
||||||
|
|
|
@ -254,8 +254,8 @@ class MygPoClient(object):
|
||||||
logger.debug('Play action for %s', episode.url)
|
logger.debug('Play action for %s', episode.url)
|
||||||
episode.mark(is_played=True)
|
episode.mark(is_played=True)
|
||||||
|
|
||||||
if (action.timestamp > episode.current_position_updated and
|
if (action.timestamp > episode.current_position_updated
|
||||||
action.position is not None):
|
and action.position is not None):
|
||||||
logger.debug('Updating position for %s', episode.url)
|
logger.debug('Updating position for %s', episode.url)
|
||||||
episode.current_position = action.position
|
episode.current_position = action.position
|
||||||
episode.current_position_updated = action.timestamp
|
episode.current_position_updated = action.timestamp
|
||||||
|
|
|
@ -221,8 +221,8 @@ class Device(services.ObservableService):
|
||||||
for track in list(tracklist):
|
for track in list(tracklist):
|
||||||
# Filter tracks that are not meant to be synchronized
|
# Filter tracks that are not meant to be synchronized
|
||||||
does_not_exist = not track.was_downloaded(and_exists=True)
|
does_not_exist = not track.was_downloaded(and_exists=True)
|
||||||
exclude_played = (not track.is_new and
|
exclude_played = (not track.is_new
|
||||||
self._config.device_sync.skip_played_episodes)
|
and self._config.device_sync.skip_played_episodes)
|
||||||
wrong_type = track.file_type() not in self.allowed_types
|
wrong_type = track.file_type() not in self.allowed_types
|
||||||
|
|
||||||
if does_not_exist:
|
if does_not_exist:
|
||||||
|
@ -347,8 +347,8 @@ class iPodDevice(Device):
|
||||||
|
|
||||||
def episode_on_device(self, episode):
|
def episode_on_device(self, episode):
|
||||||
return next((track for track in self.tracks_list
|
return next((track for track in self.tracks_list
|
||||||
if track.ipod_track.podcast_rss == episode.channel.url and
|
if track.ipod_track.podcast_rss == episode.channel.url
|
||||||
track.ipod_track.podcast_url == episode.url), None)
|
and track.ipod_track.podcast_url == episode.url), None)
|
||||||
|
|
||||||
def remove_track(self, track):
|
def remove_track(self, track):
|
||||||
self.notify('status', _('Removing %s') % track.title)
|
self.notify('status', _('Removing %s') % track.title)
|
||||||
|
@ -444,8 +444,8 @@ class MP3PlayerDevice(Device):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
info = self.destination.query_info(
|
info = self.destination.query_info(
|
||||||
Gio.FILE_ATTRIBUTE_ACCESS_CAN_WRITE + "," +
|
Gio.FILE_ATTRIBUTE_ACCESS_CAN_WRITE + ","
|
||||||
Gio.FILE_ATTRIBUTE_STANDARD_TYPE,
|
+ Gio.FILE_ATTRIBUTE_STANDARD_TYPE,
|
||||||
Gio.FileQueryInfoFlags.NONE,
|
Gio.FileQueryInfoFlags.NONE,
|
||||||
None)
|
None)
|
||||||
except GLib.Error as err:
|
except GLib.Error as err:
|
||||||
|
@ -460,8 +460,8 @@ class MP3PlayerDevice(Device):
|
||||||
# open is ok if the target is a directory, and it can be written to
|
# open is ok if the target is a directory, and it can be written to
|
||||||
# for smb, query_info doesn't return FILE_ATTRIBUTE_ACCESS_CAN_WRITE,
|
# for smb, query_info doesn't return FILE_ATTRIBUTE_ACCESS_CAN_WRITE,
|
||||||
# -- if that's the case, just assume that it's writable
|
# -- if that's the case, just assume that it's writable
|
||||||
if (not info.has_attribute(Gio.FILE_ATTRIBUTE_ACCESS_CAN_WRITE) or
|
if (not info.has_attribute(Gio.FILE_ATTRIBUTE_ACCESS_CAN_WRITE)
|
||||||
info.get_attribute_boolean(Gio.FILE_ATTRIBUTE_ACCESS_CAN_WRITE)):
|
or info.get_attribute_boolean(Gio.FILE_ATTRIBUTE_ACCESS_CAN_WRITE)):
|
||||||
self.notify('status', _('MP3 player opened'))
|
self.notify('status', _('MP3 player opened'))
|
||||||
self.tracks_list = self.get_all_tracks()
|
self.tracks_list = self.get_all_tracks()
|
||||||
return True
|
return True
|
||||||
|
@ -558,10 +558,10 @@ class MP3PlayerDevice(Device):
|
||||||
tracks = []
|
tracks = []
|
||||||
|
|
||||||
attributes = (
|
attributes = (
|
||||||
Gio.FILE_ATTRIBUTE_STANDARD_NAME + "," +
|
Gio.FILE_ATTRIBUTE_STANDARD_NAME + ","
|
||||||
Gio.FILE_ATTRIBUTE_STANDARD_TYPE + "," +
|
+ Gio.FILE_ATTRIBUTE_STANDARD_TYPE + ","
|
||||||
Gio.FILE_ATTRIBUTE_STANDARD_SIZE + "," +
|
+ Gio.FILE_ATTRIBUTE_STANDARD_SIZE + ","
|
||||||
Gio.FILE_ATTRIBUTE_TIME_MODIFIED)
|
+ Gio.FILE_ATTRIBUTE_TIME_MODIFIED)
|
||||||
|
|
||||||
root_path = self.destination
|
root_path = self.destination
|
||||||
for path_info in root_path.enumerate_children(attributes, Gio.FileQueryInfoFlags.NONE, None):
|
for path_info in root_path.enumerate_children(attributes, Gio.FileQueryInfoFlags.NONE, None):
|
||||||
|
|
|
@ -79,8 +79,8 @@ class gPodderSyncUI(object):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for episode in channel.get_all_episodes():
|
for episode in channel.get_all_episodes():
|
||||||
if (episode.was_downloaded(and_exists=True) or
|
if (episode.was_downloaded(and_exists=True)
|
||||||
not only_downloaded):
|
or not only_downloaded):
|
||||||
episodes.append(episode)
|
episodes.append(episode)
|
||||||
return episodes
|
return episodes
|
||||||
|
|
||||||
|
@ -133,8 +133,8 @@ class gPodderSyncUI(object):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Might not be synced if it's played already
|
# Might not be synced if it's played already
|
||||||
if (not force_played and
|
if (not force_played
|
||||||
self._config.device_sync.skip_played_episodes):
|
and self._config.device_sync.skip_played_episodes):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# In all other cases, we expect the episode to be
|
# In all other cases, we expect the episode to be
|
||||||
|
@ -316,9 +316,9 @@ class gPodderSyncUI(object):
|
||||||
def cleanup_episodes():
|
def cleanup_episodes():
|
||||||
# 'skip_played_episodes' must be used or else all the
|
# 'skip_played_episodes' must be used or else all the
|
||||||
# played tracks will be copied then immediately deleted
|
# played tracks will be copied then immediately deleted
|
||||||
if (self._config.device_sync.delete_deleted_episodes or
|
if (self._config.device_sync.delete_deleted_episodes
|
||||||
(self._config.device_sync.delete_played_episodes and
|
or (self._config.device_sync.delete_played_episodes
|
||||||
self._config.device_sync.skip_played_episodes)):
|
and self._config.device_sync.skip_played_episodes)):
|
||||||
all_episodes = self._filter_sync_episodes(
|
all_episodes = self._filter_sync_episodes(
|
||||||
channels, only_downloaded=False)
|
channels, only_downloaded=False)
|
||||||
for local_episode in all_episodes:
|
for local_episode in all_episodes:
|
||||||
|
|
|
@ -2350,8 +2350,8 @@ def mount_volume_for_file(file, op=None):
|
||||||
file.mount_enclosing_volume_finish(res)
|
file.mount_enclosing_volume_finish(res)
|
||||||
result = True
|
result = True
|
||||||
except GLib.Error as err:
|
except GLib.Error as err:
|
||||||
if (not err.matches(Gio.io_error_quark(), Gio.IOErrorEnum.NOT_SUPPORTED) and
|
if (not err.matches(Gio.io_error_quark(), Gio.IOErrorEnum.NOT_SUPPORTED)
|
||||||
not err.matches(Gio.io_error_quark(), Gio.IOErrorEnum.ALREADY_MOUNTED)):
|
and not err.matches(Gio.io_error_quark(), Gio.IOErrorEnum.ALREADY_MOUNTED)):
|
||||||
message = err.message
|
message = err.message
|
||||||
result = False
|
result = False
|
||||||
finally:
|
finally:
|
||||||
|
|
|
@ -32,9 +32,9 @@ class MakeCertPem:
|
||||||
"""
|
"""
|
||||||
cmd = ["security", "find-certificate", "-a", "-p",
|
cmd = ["security", "find-certificate", "-a", "-p",
|
||||||
"/System/Library/Keychains/SystemRootCertificates.keychain"]
|
"/System/Library/Keychains/SystemRootCertificates.keychain"]
|
||||||
cert_re = re.compile(b"^-----BEGIN CERTIFICATE-----$" +
|
cert_re = re.compile(b"^-----BEGIN CERTIFICATE-----$"
|
||||||
b".+?" +
|
+ b".+?"
|
||||||
b"^-----END CERTIFICATE-----$", re.M | re.S)
|
+ b"^-----END CERTIFICATE-----$", re.M | re.S)
|
||||||
try:
|
try:
|
||||||
certs_str = subprocess.check_output(cmd)
|
certs_str = subprocess.check_output(cmd)
|
||||||
all_certs = cert_re.findall(certs_str)
|
all_certs = cert_re.findall(certs_str)
|
||||||
|
|
|
@ -32,9 +32,9 @@ def get_certs(openssl):
|
||||||
|
|
||||||
cmd = ["security", "find-certificate", "-a", "-p",
|
cmd = ["security", "find-certificate", "-a", "-p",
|
||||||
"/System/Library/Keychains/SystemRootCertificates.keychain"]
|
"/System/Library/Keychains/SystemRootCertificates.keychain"]
|
||||||
cert_re = re.compile(b"^-----BEGIN CERTIFICATE-----$" +
|
cert_re = re.compile(b"^-----BEGIN CERTIFICATE-----$"
|
||||||
b".+?" +
|
+ b".+?"
|
||||||
b"^-----END CERTIFICATE-----$", re.M | re.S)
|
+ b"^-----END CERTIFICATE-----$", re.M | re.S)
|
||||||
try:
|
try:
|
||||||
certs_str = subprocess.check_output(cmd)
|
certs_str = subprocess.check_output(cmd)
|
||||||
all_certs = cert_re.findall(certs_str)
|
all_certs = cert_re.findall(certs_str)
|
||||||
|
|
Loading…
Reference in New Issue