Skip to content

Commit 4c9cd8f

Browse files
authored
Merge pull request gpodder#1674 from tpikonen/docstrings
Fix docstring formatting
2 parents d400bcb + 0ea0727 commit 4c9cd8f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+567
-650
lines changed

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ known_first_party=gpodder,soco
1010

1111
[flake8]
1212
max-line-length = 142
13-
ignore = BLK100, CCR001, CNL100, D1, E126, E128, E402, I, W503, Q000
13+
ignore = BLK100, CCR001, CNL100, D1, E126, E128, E402, I, W503, Q000, SC

share/gpodder/examples/hello_world.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ def on_unload(self):
4040
logger.info('Extension is being unloaded.')
4141

4242
def on_ui_object_available(self, name, ui_object):
43-
"""
44-
Called by gPodder when ui is ready.
45-
"""
43+
"""Called by gPodder when ui is ready.""" # noqa: D401
4644
if name == 'gpodder-gtk':
4745
self.gpodder = ui_object
4846

share/gpodder/extensions/enqueue_in_mediaplayer.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,8 @@ def open_files(self, filenames):
8181

8282

8383
class MPRISResumer(FreeDesktopPlayer):
84-
"""
85-
resume episod playback at saved time
86-
"""
84+
"""Resume episode playback at saved time."""
85+
8786
OBJECT_PLAYER = '/org/mpris/MediaPlayer2'
8887
OBJECT_DBUS = '/org/freedesktop/DBus'
8988
INTERFACE_PLAYER = 'org.mpris.MediaPlayer2.Player'

share/gpodder/extensions/filter.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@
2424

2525

2626
class BlockExceptFrame:
27-
"""
28-
Utility class to manage a Block or Except frame, with sub-widgets:
27+
"""Utility class to manage a Block or Except frame.
28+
29+
With sub-widgets:
2930
- Creation as well as internal UI change is handled;
3031
- Changes to the other widget and to the model have to be handled outside.
3132
It's less optimized than mapping each widget to a different signal handler,
3233
but makes shorter code.
3334
"""
35+
3436
def __init__(self, value, enable_re, enable_ic, on_change_cb):
3537
self.on_change_cb = on_change_cb
3638
self.frame = Gtk.Frame()

share/gpodder/extensions/mpris-listener.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ def subsecond_difference(usec1, usec2):
5151

5252

5353
class CurrentTrackTracker(object):
54-
"""An instance of this class is responsible for tracking the state of the
55-
currently playing track -- it's playback status, playing position, etc.
54+
"""This class tracks the state of the currently playing track.
55+
56+
Playback status, playing position, etc.
5657
"""
58+
5759
def __init__(self, notifier):
5860
self.uri = None
5961
self.length = None

share/gpodder/extensions/notification-win32.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
#
1919

20-
# Notification implementation for Windows
2120
# Sean Munkel; 2012-12-29
22-
"""
21+
"""Notification implementation for Windows.
22+
2323
Current state (2018/07/29 ELL):
2424
- I can't get pywin32 to work in msys2 (the platform used for this python3/gtk3 installer)
2525
so existing code using COM doesn't work.

share/gpodder/extensions/podverse.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ def on_search(self, query):
6161

6262

6363
class gPodderExtension:
64-
""" (un)register a podverse search provider """
64+
"""Register and unregister a podverse search provider."""
65+
6566
def __init__(self, container):
6667
pass
6768

share/gpodder/extensions/rockbox_convert2mp4.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ def _calc_resolution(self, video_width, video_height, device_width, device_heigh
100100
return (int(round(dest_width)), round(int(dest_height)))
101101

102102
def _convert_mp4(self, episode, from_file):
103-
"""Convert MP4 file to rockbox mpg file"""
104-
103+
"""Convert MP4 file to rockbox mpg file."""
105104
# generate new filename and check if the file already exists
106105
to_file = self._get_rockbox_filename(from_file)
107106
if to_file is None:

share/gpodder/extensions/sonos.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ def __init__(self, container):
5050
self.speakers[uid] = speaker
5151

5252
def _stream_to_speaker(self, speaker_uid, episodes):
53-
""" Play or enqueue selected episodes """
54-
53+
"""Play or enqueue selected episodes."""
5554
urls = [episode.url for episode in episodes if SONOS_CAN_PLAY(episode)]
5655
logger.info('Streaming to Sonos %s: %s' % (self.speakers[speaker_uid].ip_address, ', '.join(urls)))
5756

@@ -65,8 +64,7 @@ def _stream_to_speaker(self, speaker_uid, episodes):
6564
controller.play()
6665

6766
def on_episodes_context_menu(self, episodes):
68-
""" Adds a context menu for each Sonos speaker group """
69-
67+
"""Add a context menu for each Sonos speaker group."""
7068
# Only show context menu if we can play at least one file
7169
if not any(SONOS_CAN_PLAY(e) for e in episodes):
7270
return []

share/gpodder/extensions/tagging.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@ def write_basic_tags(self, remove_before_modify, modify_tags, set_artist_to_albu
125125
audio.save()
126126

127127
def insert_coverart(self):
128-
""" implement the cover art logic in the subclass
129-
"""
128+
"""Implement the cover art logic in the subclass."""
130129
None
131130

132131
def get_cover_picture(self, cover):
133-
""" Returns mutagen Picture class for the cover image
132+
"""Return mutagen Picture class for the cover image.
133+
134134
Useful for OGG and FLAC format
135135
136136
Picture type = cover image

share/gpodder/extensions/taskbar_progress.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class ITaskbarList3(ITaskbarList2):
151151

152152

153153
def consume_events():
154-
""" consume pending events """
154+
"""Consume pending events."""
155155
while Gtk.events_pending():
156156
Gtk.main_iteration()
157157

share/gpodder/extensions/ted_subtitles.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@
2222

2323

2424
class gPodderExtension(object):
25+
"""TED Subtitle Download Extension.
26+
27+
Downloads ted subtitles.
2528
"""
26-
TED Subtitle Download Extension
27-
Downloads ted subtitles
28-
"""
29+
2930
def __init__(self, container):
3031
self.container = container
3132

3233
def milli_to_srt(self, time):
33-
"""Converts milliseconds to srt time format"""
34+
"""Convert milliseconds to srt time format."""
3435
srt_time = timedelta(milliseconds=time)
3536
srt_time = str(srt_time)
3637
if '.' in srt_time:
@@ -42,7 +43,7 @@ def milli_to_srt(self, time):
4243
return srt_time
4344

4445
def ted_to_srt(self, jsonstring, introduration):
45-
"""Converts the json object to srt format"""
46+
"""Convert the json object to srt format."""
4647
jsonobject = json.loads(jsonstring)
4748

4849
srtContent = ''

share/gpodder/extensions/youtube-dl.py

+23-23
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161

6262
def youtube_parsedate(s):
63-
"""Parse a string into a unix timestamp
63+
"""Parse a string into a unix timestamp.
6464
6565
Only strings provided by youtube-dl API are
6666
parsed with this function (20170920).
@@ -71,18 +71,16 @@ def youtube_parsedate(s):
7171

7272

7373
def video_guid(video_id):
74-
"""
75-
generate same guid as youtube
76-
"""
74+
"""Generate same guid as youtube."""
7775
return 'yt:video:{}'.format(video_id)
7876

7977

8078
class YoutubeCustomDownload(download.CustomDownload):
81-
"""
82-
Represents the download of a single episode using youtube-dl.
79+
"""Represents the download of a single episode using youtube-dl.
8380
8481
Actual youtube-dl interaction via gPodderYoutubeDL.
8582
"""
83+
8684
def __init__(self, ytdl, url, episode):
8785
self._ytdl = ytdl
8886
self._url = url
@@ -100,9 +98,7 @@ def partial_filename(self, val):
10098
self._partial_filename = val
10199

102100
def retrieve_resume(self, tempname, reporthook=None):
103-
"""
104-
called by download.DownloadTask to perform the download.
105-
"""
101+
"""Called by download.DownloadTask to perform the download.""" # noqa: D401
106102
self._reporthook = reporthook
107103
# outtmpl: use given tempname by DownloadTask
108104
# (escape % because outtmpl used as a string template by youtube-dl)
@@ -177,9 +173,8 @@ def _my_hook(self, d):
177173

178174

179175
class YoutubeFeed(model.Feed):
180-
"""
181-
Represents the youtube feed for model.PodcastChannel
182-
"""
176+
"""Represents the youtube feed for model.PodcastChannel."""
177+
183178
def __init__(self, url, cover_url, description, max_episodes, ie_result, downloader):
184179
self._url = url
185180
self._cover_url = cover_url
@@ -222,12 +217,18 @@ def get_cover_url(self):
222217
return self._cover_url
223218

224219
def get_http_etag(self):
225-
""" :return str: optional -- last HTTP etag header, for conditional request next time """
220+
"""Return the last HTTP etag header, for conditional request next time.
221+
222+
:return str: optional.
223+
"""
226224
# youtube-dl doesn't provide it!
227225
return None
228226

229227
def get_http_last_modified(self):
230-
""" :return str: optional -- last HTTP Last-Modified header, for conditional request next time """
228+
"""Return the last HTTP Last-Modified header, for conditional request next time.
229+
230+
:return str: optional
231+
"""
231232
# youtube-dl doesn't provide it!
232233
return None
233234

@@ -274,8 +275,8 @@ def get_new_episodes(self, channel, existing_guids):
274275
return episodes, all_seen_guids
275276

276277
def get_next_page(self, channel, max_episodes):
277-
"""
278-
Paginated feed support (RFC 5005).
278+
"""Paginated feed support (RFC 5005).
279+
279280
If the feed is paged, return the next feed page.
280281
Returned page will in turn be asked for the next page, until None is returned.
281282
:return feedcore.Result: the next feed's page,
@@ -322,7 +323,7 @@ def __init__(self, gpodder_config, my_config, force=False):
322323
self._ydl_opts['logger'] = logger
323324

324325
def add_format(self, gpodder_config, opts, fallback=None):
325-
""" construct youtube-dl -f argument from configured format. """
326+
"""Construct youtube-dl -f argument from configured format."""
326327
# You can set a custom format or custom formats by editing the config for key
327328
# `youtube.preferred_fmt_ids`
328329
#
@@ -447,9 +448,10 @@ def extract_type(ie_result):
447448
YoutubeFeed(url, cover_url, description, max_episodes, ie_result, self))
448449

449450
def fetch_channel(self, channel, max_episodes=0):
450-
"""
451-
called by model.gPodderFetcher to get a custom feed.
452-
:returns feedcore.Result: a YoutubeFeed or None if channel is not a youtube channel or playlist
451+
"""Return a custom feed. Called by model.gPodderFetcher.
452+
453+
:returns feedcore.Result: A YoutubeFeed or None if channel is not
454+
a youtube channel or playlist
453455
"""
454456
if not self.my_config.manage_channel:
455457
return None
@@ -493,9 +495,7 @@ def is_supported_url(self, url):
493495
return False
494496

495497
def custom_downloader(self, unused_config, episode):
496-
"""
497-
called from registry.custom_downloader.resolve
498-
"""
498+
"""Called from registry.custom_downloader.resolve.""" # noqa: D401
499499
if not self.force and not self.my_config.manage_downloads:
500500
return None
501501

src/gpodder/__init__.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,12 @@ def fixup_home(old_home):
233233

234234

235235
def load_plugins():
236-
"""Load (non-essential) plugin modules
236+
"""Load (non-essential) plugin modules.
237237
238238
This loads a default set of plugins, but you can use
239239
the environment variable "GPODDER_PLUGINS" to modify
240-
the list of plugins."""
240+
the list of plugins.
241+
"""
241242
PLUGINS = os.environ.get('GPODDER_PLUGINS', None)
242243
if PLUGINS is None:
243244
PLUGINS = DEFAULT_PLUGINS

src/gpodder/build_info.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# the Free Software Foundation; either version 3 of the License, or
77
# (at your option) any later version.
88

9-
"""This file gets edited at build time to add build specific data"""
9+
"""This file gets edited at build time to add build specific data."""
1010

1111
BUILD_TYPE = u"default"
1212
"""Either 'windows', 'windows-portable', 'osx' or 'default'"""

src/gpodder/common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333

3434
def clean_up_downloads(delete_partial=False):
35-
"""Clean up temporary files left behind by old gPodder versions
35+
"""Clean up temporary files left behind by old gPodder versions.
3636
3737
delete_partial - If True, also delete in-progress downloads
3838
"""
@@ -48,7 +48,7 @@ def clean_up_downloads(delete_partial=False):
4848

4949

5050
def find_partial_downloads(channels, start_progress_callback, progress_callback, final_progress_callback, finish_progress_callback):
51-
"""Find partial downloads and match them with episodes
51+
"""Find partial downloads and match them with episodes.
5252
5353
channels - A list of all model.PodcastChannel objects
5454
start_progress_callback - A callback(count) when partial files are searched

src/gpodder/config.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,7 @@ def __init__(self, filename='gpodder.json'):
332332
logger.info('Appending alternate PATH: %s' % self.path.alternate)
333333

334334
def register_defaults(self, defaults):
335-
"""
336-
Register default configuration options (e.g. for extensions)
335+
"""Register default configuration options (e.g. for extensions).
337336
338337
This function takes a dictionary that will be merged into the
339338
current configuration if the keys don't yet exist. This can
@@ -342,9 +341,9 @@ def register_defaults(self, defaults):
342341
self.__json_config._merge_keys(defaults)
343342

344343
def add_observer(self, callback):
345-
"""
346-
Add a callback function as observer. This callback
347-
will be called when a setting changes. It should
344+
"""Add a callback function as observer.
345+
346+
This callback will be called when a setting changes. It should
348347
have this signature:
349348
350349
observer(name, old_value, new_value)
@@ -358,9 +357,7 @@ def add_observer(self, callback):
358357
logger.warning('Observer already added: %s', repr(callback))
359358

360359
def remove_observer(self, callback):
361-
"""
362-
Remove an observer previously added to this object.
363-
"""
360+
"""Remove an observer previously added to this object."""
364361
if callback in self.__observers:
365362
self.__observers.remove(callback)
366363
else:
@@ -425,7 +422,7 @@ def toggle_flag(self, name):
425422
setattr(self, name, not getattr(self, name))
426423

427424
def update_field(self, name, new_value):
428-
"""Update a config field, converting strings to the right types"""
425+
"""Update a config field, converting strings to the right types."""
429426
old_value = self._lookup(name)
430427
new_value = string_to_config_value(new_value, old_value)
431428
setattr(self, name, new_value)
@@ -455,7 +452,7 @@ def __setattr__(self, name, value):
455452
setattr(self.__json_config, name, value)
456453

457454
def migrate_defaults(self):
458-
""" change default values in config """
455+
"""Change default values in config."""
459456
if self.device_sync.max_filename_length == 999:
460457
logger.debug("setting config.device_sync.max_filename_length=120"
461458
" (999 is bad for NTFS and ext{2-4})")

0 commit comments

Comments
 (0)