instruction
stringclasses
100 values
code
stringlengths
78
193k
response
stringlengths
259
170k
file
stringlengths
59
203
Add docstrings to clarify complex logic
""" To try it in action and to get a sense of how it can help you just run: python trace/NicerTrace.py """ import datetime import os import socket import sys import sysconfig import time import trace class NicerTrace(trace.Trace): # as the 2 paths overlap the longer with site-packages needs to be first py_...
--- +++ @@ -1,3 +1,4 @@+""" NicerTrace - an improved Trace package """ """ To try it in action and to get a sense of how it can help you just run: @@ -21,6 +22,18 @@ stdlib_dir = sysconfig.get_paths()["stdlib"] def __init__(self, *args, packages_to_include=None, log_pids=False, **kwargs): + """nor...
https://raw.githubusercontent.com/stas00/ml-engineering/HEAD/debug/NicerTrace.py
Generate descriptive docstrings automatically
#!/usr/bin/env python3 import re import sys from pathlib import Path # Import from sibling module sys.path.insert(0, str(Path(__file__).parent)) def file_to_prefix(filepath): # Convert path like 'network/benchmarks/README.html' to 'network-benchmarks-readme' path = Path(filepath) parts = list(path.paren...
--- +++ @@ -1,4 +1,9 @@ #!/usr/bin/env python3 +""" +Preprocess HTML files for EPUB generation. +Makes all anchor IDs globally unique by prefixing with chapter identifier, +then updates all internal links to use the prefixed anchors. +""" import re import sys @@ -9,6 +14,7 @@ def file_to_prefix(filepath): + ...
https://raw.githubusercontent.com/stas00/ml-engineering/HEAD/build/mdbook/preprocess-html-for-epub.py
Write docstrings that follow conventions
import re from pathlib import Path # matches ("Markdown text", Link) in [Markdown text](Link) re_md_link_2_parts = re.compile(r""" ^ \[ ([^]]+) \] \( ([^)]+) \) $ """, re.VERBOSE) # matches one or more '[Markdown text](Link)' patterns re_md_link_full = re.compile(r""" ( \[ [^]]+ \] \( [^)]+ \) ) """, re.VERBOSE|re.M...
--- +++ @@ -1,3 +1,6 @@+""" +The utils in this module replicate github logic, which means it may or may not work for other markdown +""" import re from pathlib import Path @@ -39,12 +42,26 @@ return True def md_process_local_links(para, callback, **kwargs): + """ + parse the paragraph to detect local m...
https://raw.githubusercontent.com/stas00/ml-engineering/HEAD/build/mdbook/utils/github_md_utils.py
Generate docstrings for each module
#!/usr/bin/env python from pathlib import Path import argparse import datetime import gc import os import signal import socket import sys import textwrap import time import torch import torch.distributed as dist has_hpu = False try: import habana_frameworks.torch as ht if torch.hpu.is_available(): ha...
--- +++ @@ -1,5 +1,107 @@ #!/usr/bin/env python +""" + +The latest version of this program can be found at https://github.com/stas00/ml-engineering + +This benchmark is very similar to https://github.com/NVIDIA/nccl-tests but it's much easier to set +up as it only requires PyTorch to be installed + +This version: +- ...
https://raw.githubusercontent.com/stas00/ml-engineering/HEAD/network/benchmarks/all_reduce_bench.py
Create documentation for each function signature
import os from contextlib import contextmanager from pathlib import Path import torch.distributed as dist def get_local_rank() -> int: return int(os.getenv("LOCAL_RANK", 0)) def get_global_rank() -> int: if dist.is_initialized(): return dist.get_rank() else: return 0 # delay the local f...
--- +++ @@ -1,3 +1,9 @@+""" +Tooling for dealing with efficient dataset loading in a multi-process, potentially multi-node environment with shared and local filesystems. + +For notes please see https://github.com/stas00/ml-engineering/blob/master/training/datasets.md#preprocessing-and-caching-datasets-on-the-main-proce...
https://raw.githubusercontent.com/stas00/ml-engineering/HEAD/training/tools/main_process_first.py
Generate docstrings for exported functions
# Copyright 2020 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
--- +++ @@ -17,6 +17,9 @@ from enum import Enum class ExplicitEnum(str, Enum): + """ + Enum with more explicit error message for missing values. + """ @classmethod def _missing_(cls, value): @@ -25,6 +28,122 @@ ) class DebugUnderflowOverflow: + """ + This debug class helps detec...
https://raw.githubusercontent.com/stas00/ml-engineering/HEAD/debug/underflow_overflow.py
Document functions with clear intent
from __future__ import annotations import collections.abc as cabc import enum import os import stat import sys import typing as t from datetime import datetime from gettext import gettext as _ from gettext import ngettext from ._compat import _get_argv_encoding from ._compat import open_stream from .exceptions import...
--- +++ @@ -28,6 +28,22 @@ class ParamType: + """Represents the type of a parameter. Validates and converts values + from the command line or Python into the correct type. + + To implement a custom type, subclass and implement at least the + following: + + - The :attr:`name` class attribute must be...
https://raw.githubusercontent.com/pallets/click/HEAD/src/click/types.py
Auto-generate documentation strings for this file
from __future__ import annotations import collections.abc as cabc import os import re import sys import typing as t from functools import update_wrapper from types import ModuleType from types import TracebackType from ._compat import _default_text_stderr from ._compat import _default_text_stdout from ._compat import...
--- +++ @@ -34,6 +34,7 @@ def safecall(func: t.Callable[P, R]) -> t.Callable[P, R | None]: + """Wraps a function so that it swallows exceptions.""" def wrapper(*args: P.args, **kwargs: P.kwargs) -> R | None: try: @@ -46,6 +47,7 @@ def make_str(value: t.Any) -> str: + """Converts a value in...
https://raw.githubusercontent.com/pallets/click/HEAD/src/click/utils.py
Add docstrings following best practices
from __future__ import annotations import collections.abc as cabc import inspect import io import itertools import sys import typing as t from contextlib import AbstractContextManager from gettext import gettext as _ from ._compat import isatty from ._compat import strip_ansi from .exceptions import Abort from .excep...
--- +++ @@ -92,6 +92,49 @@ err: bool = False, show_choices: bool = True, ) -> t.Any: + """Prompts a user for input. This is a convenience function that can + be used to prompt a user for input later. + + If the user aborts the input by sending an interrupt signal, this + function will catch it an...
https://raw.githubusercontent.com/pallets/click/HEAD/src/click/termui.py
Document classes and their methods
from __future__ import annotations import inspect import typing as t from functools import update_wrapper from gettext import gettext as _ from .core import Argument from .core import Command from .core import Context from .core import Group from .core import Option from .core import Parameter from .globals import ge...
--- +++ @@ -26,6 +26,9 @@ def pass_context(f: t.Callable[te.Concatenate[Context, P], R]) -> t.Callable[P, R]: + """Marks a callback as wanting to receive the current context + object as first argument. + """ def new_func(*args: P.args, **kwargs: P.kwargs) -> R: return f(get_current_context(...
https://raw.githubusercontent.com/pallets/click/HEAD/src/click/decorators.py
Write docstrings for this repository
from __future__ import annotations import collections.abc as cabc from contextlib import contextmanager from gettext import gettext as _ from ._compat import term_len from .parser import _split_opt # Can force a width. This is used by the test system FORCED_WIDTH: int | None = None def measure_table(rows: cabc.It...
--- +++ @@ -35,6 +35,24 @@ subsequent_indent: str = "", preserve_paragraphs: bool = False, ) -> str: + """A helper function that intelligently wraps text. By default, it + assumes that it operates on a single paragraph of text but if the + `preserve_paragraphs` parameter is provided it will intellig...
https://raw.githubusercontent.com/pallets/click/HEAD/src/click/formatting.py
Add verbose docstrings with examples
from __future__ import annotations import collections.abc as cabc import contextlib import math import os import shlex import sys import time import typing as t from gettext import gettext as _ from io import StringIO from pathlib import Path from types import TracebackType from ._compat import _default_text_stdout ...
--- +++ @@ -1,3 +1,8 @@+""" +This module contains implementations for the termui module. To keep the +import time of Click down, some infrequently used functionality is +placed in this module and only imported as needed. +""" from __future__ import annotations @@ -297,6 +302,21 @@ self.eta_known = self.len...
https://raw.githubusercontent.com/pallets/click/HEAD/src/click/_termui_impl.py
Generate missing documentation strings
from __future__ import annotations import collections.abc as cabc import enum import errno import inspect import os import sys import typing as t from collections import abc from collections import Counter from contextlib import AbstractContextManager from contextlib import contextmanager from contextlib import ExitSt...
--- +++ @@ -54,6 +54,12 @@ def _complete_visible_commands( ctx: Context, incomplete: str ) -> cabc.Iterator[tuple[str, Command]]: + """List all the subcommands of a group that start with the + incomplete value and aren't hidden. + + :param ctx: Invocation context for the group. + :param incomplete: Va...
https://raw.githubusercontent.com/pallets/click/HEAD/src/click/core.py
Insert docstrings into my code
from __future__ import annotations import collections.abc as cabc import typing as t from gettext import gettext as _ from gettext import ngettext from ._compat import get_text_stderr from .globals import resolve_color_default from .utils import echo from .utils import format_filename if t.TYPE_CHECKING: from .c...
--- +++ @@ -24,6 +24,7 @@ class ClickException(Exception): + """An exception that Click can handle and show to the user.""" #: The exit code for this exception. exit_code = 1 @@ -53,6 +54,13 @@ class UsageError(ClickException): + """An internal exception that signals a usage error. This typic...
https://raw.githubusercontent.com/pallets/click/HEAD/src/click/exceptions.py
Generate NumPy-style docstrings
from __future__ import annotations import collections.abc as cabc import os import re import typing as t from gettext import gettext as _ from .core import Argument from .core import Command from .core import Context from .core import Group from .core import Option from .core import Parameter from .core import Parame...
--- +++ @@ -23,6 +23,18 @@ complete_var: str, instruction: str, ) -> int: + """Perform shell completion for the given CLI program. + + :param cli: Command being called. + :param ctx_args: Extra arguments to pass to + ``cli.make_context``. + :param prog_name: Name of the executable in the sh...
https://raw.githubusercontent.com/pallets/click/HEAD/src/click/shell_completion.py
Turn comments into proper docstrings
# This code uses parts of optparse written by Gregory P. Ward and # maintained by the Python Software Foundation. # Copyright 2001-2006 Gregory P. Ward # Copyright 2002-2006 Python Software Foundation from __future__ import annotations import collections.abc as cabc import typing as t from collections import deque fr...
--- +++ @@ -1,3 +1,22 @@+""" +This module started out as largely a copy paste from the stdlib's +optparse module with the features removed that we do not need from +optparse because we implement them in Click on a higher level (for +instance type handling, help formatting and a lot more). + +The plan is to remove more ...
https://raw.githubusercontent.com/pallets/click/HEAD/src/click/parser.py
Create Google-style docstrings for my code
from __future__ import annotations import typing as t from threading import local if t.TYPE_CHECKING: from .core import Context _local = local() @t.overload def get_current_context(silent: t.Literal[False] = False) -> Context: ... @t.overload def get_current_context(silent: bool = ...) -> Context | None: ......
--- +++ @@ -18,6 +18,20 @@ def get_current_context(silent: bool = False) -> Context | None: + """Returns the current click context. This can be used as a way to + access the current context object from anywhere. This is a more implicit + alternative to the :func:`pass_context` decorator. This function i...
https://raw.githubusercontent.com/pallets/click/HEAD/src/click/globals.py
Write docstrings describing functionality
from __future__ import annotations import codecs import collections.abc as cabc import io import os import re import sys import typing as t from types import TracebackType from weakref import WeakKeyDictionary CYGWIN = sys.platform.startswith("cygwin") WIN = sys.platform.startswith("win") auto_wrap_for_ansi: t.Callab...
--- +++ @@ -38,6 +38,7 @@ def is_ascii_encoding(encoding: str) -> bool: + """Checks if a given encoding is ascii.""" try: return codecs.lookup(encoding).name == "ascii" except LookupError: @@ -45,6 +46,7 @@ def get_best_encoding(stream: t.IO[t.Any]) -> str: + """Returns the default stre...
https://raw.githubusercontent.com/pallets/click/HEAD/src/click/_compat.py
Write proper docstrings for these functions
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation...
--- +++ @@ -463,6 +463,8 @@ class _VisualWait: + """Small progress indication (as "wonderful visual") during waiting process + """ pos = 0 delta = 1 def __init__(self, maxpos=10): @@ -474,6 +476,8 @@ sys.stdout.write('\r'+(' '*(35+self.maxpos))+'\r') sys.stdout.flush() def heartbeat(self): + """Show...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/client/fail2banclient.py
Add detailed documentation for each class
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation...
--- +++ @@ -90,6 +90,8 @@ output(normVersion()) def dispUsage(self): + """ Prints Fail2Ban command line options and exits + """ caller = os.path.basename(self._argv[0]) output("Usage: "+caller+" [OPTIONS]" + (" <COMMAND>" if not caller.endswith('server') else "")) output("") @@ -129,6 +131,8 @@ outp...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/client/fail2bancmdline.py
Write docstrings for algorithm functions
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation;...
--- +++ @@ -39,6 +39,13 @@ "int": int, } def _OptionsTemplateGen(options): + """Iterator over the options template with default options. + + Each options entry is composed of an array or tuple with: + [[type, name, ?default?], ...] + Or it is a dict: + {name: [type, default], ...} + """ if isinstance(options, (...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/client/configreader.py
Create docstrings for API functions
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation;...
--- +++ @@ -33,6 +33,21 @@ class JailThread(Thread): + """Abstract class for threading elements in Fail2Ban. + + Attributes + ---------- + daemon + ident + name + status + active : bool + Control the state of the thread. + idle : bool + Control the idle state of the thread. + sleeptime : int + The time the threa...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/server/jailthread.py
Add docstrings to improve collaboration
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation;...
--- +++ @@ -38,11 +38,15 @@ # # def asip(ip): + """A little helper to guarantee ip being an IPAddr instance""" if isinstance(ip, IPAddr): return ip return IPAddr(ip) def getfqdn(name=''): + """Get fully-qualified hostname of given host, thereby resolve of an external + IPs and name will be preferred before ...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/server/ipdns.py
Write proper docstrings for these functions
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation;...
--- +++ @@ -31,6 +31,14 @@ # class MyTime: + """A wrapper around time module primarily for testing purposes + + This class is a wrapper around time.time() and time.gmtime(). When + performing unit test, it is very useful to get a fixed value from + these functions. Thus, time.time() and time.gmtime() should never ...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/server/mytime.py
Document classes and their methods
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation;...
--- +++ @@ -139,11 +139,15 @@ return (self.jail is not None and self.jail.name or "~jailless~") def clearAllParams(self): + """ Clear all lists/dicts parameters (used by reloading) + """ self.delFailRegex() self.delIgnoreRegex() self.delIgnoreIP() def reload(self, begin=True): + """ Begin or end o...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/server/filter.py
Provide docstrings following PEP 257
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation...
--- +++ @@ -16,6 +16,12 @@ # You should have received a copy of the GNU General Public License # along with Fail2Ban; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +""" +Fail2Ban reads log file that contains password failure report +and bans the ...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/client/fail2banregex.py
Write reusable docstrings
# -*- Mode: Python; tab-width: 4 -*- # Id: asynchat.py,v 2.26 2000/09/07 22:29:26 rushing Exp # Author: Sam Rushing <rushing@nightmare.com> # ====================================================================== # Copyright 1996 by Sam Rushing # # All Rights Reserved # # Permission...
--- +++ @@ -25,6 +25,26 @@ # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # ====================================================================== +r"""A class supporting chat-style (command/response) protocols. + +This class adds support for 'chat' style protocols - where one side +sends a 'command', an...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/compat/asynchat.py
Improve documentation using docstrings
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation;...
--- +++ @@ -46,6 +46,14 @@ # define a new logger function for notice # this is exactly like existing info, critical, debug...etc def _Logger_notice(self, msg, *args, **kwargs): + """ + Log 'msg % args' with severity 'NOTICE'. + + To pass exception information, use the keyword argument exc_info with + a true value, e....
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/__init__.py
Create simple docstrings for beginners
# emacs: -*- mode: python; coding: utf-8; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Softw...
--- +++ @@ -72,6 +72,10 @@ def _updateTimeRE(): def _getYearCentRE(cent=(0,3), distance=3, now=(MyTime.now(), MyTime.alternateNow)): + """ Build century regex for last year and the next years (distance). + + Thereby respect possible run in the test-cases (alternate date used there) + """ cent = lambda year...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/server/strptime.py
Include argument descriptions in docstrings
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation;...
--- +++ @@ -41,6 +41,12 @@ BANNED = 0x08 def __init__(self, ip=None, time=None, matches=None, data={}, ticket=None): + """Ticket constructor + + @param ip the IP address + @param time the ban time + @param matches (log) lines caused the ticket + """ self.setID(ip) self._flags = 0; @@ -230,6 +236,9 @...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/server/ticket.py
Add docstrings including usage examples
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation;...
--- +++ @@ -35,6 +35,13 @@ class JailsReader(ConfigReader): def __init__(self, force_enable=False, **kwargs): + """ + Parameters + ---------- + force_enable : bool, optional + Passed to JailReader to force enable the jails. + It is for internal use + """ ConfigReader.__init__(self, **kwargs) self._...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/client/jailsreader.py
Add docstrings to my Python code
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation;...
--- +++ @@ -72,6 +72,21 @@ class CallingMap(MutableMapping, object): + """A Mapping type which returns the result of callable values. + + `CallingMap` behaves similar to a standard python dictionary, + with the exception that any values which are callable, are called + and the result is returned as the value. + No ...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/server/action.py
Document helper functions with docstrings
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation;...
--- +++ @@ -32,12 +32,39 @@ class Jails(Mapping): + """Handles the jails. + + This class handles the jails. Creation, deletion or access to a jail + must be done through this class. This class is thread-safe which is + not the case of the jail itself, including filter and actions. This + class is based on Mapping t...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/server/jails.py
Help me document legacy Python code
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation;...
--- +++ @@ -36,6 +36,19 @@ # And interpolation of __name__ was simply removed, thus we need to # decorate default interpolator to handle it class BasicInterpolationWithName(BasicInterpolation): + """Decorator to bring __name__ interpolation back. + + Original handling of __name__ was removed because of + functional d...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/client/configparserinc.py
Help me comply with documentation standards
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation;...
--- +++ @@ -77,6 +77,10 @@ @staticmethod def _glob(path): + """Given a path for glob return list of files to be passed to server. + + Dangling symlinks are warned about and not returned + """ pathList = [] for p in glob.glob(path): if os.path.exists(p): @@ -237,6 +241,14 @@ return _merge_dicts(self....
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/client/jailreader.py
Generate docstrings for this script
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation;...
--- +++ @@ -87,12 +87,16 @@ class DateDetectorCache(object): + """Implements the caching of the default templates list. + """ def __init__(self): self.__lock = Lock() self.__templates = list() @property def templates(self): + """List of template instances managed by the detector. + """ if self.__...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/server/datedetector.py
Add structured docstrings to improve clarity
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation;...
--- +++ @@ -37,6 +37,31 @@ class Jail(object): + """Fail2Ban jail, which manages a filter and associated actions. + + The class handles the initialisation of a filter, and actions. It's + role is then to act as an interface between the filter and actions, + passing bans detected by the filter, for the actions to th...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/server/jail.py
Add inline docstrings for readability
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation;...
--- +++ @@ -40,6 +40,7 @@ def _json_default(x): + """Avoid errors on types unknown in json-adapters.""" if isinstance(x, set): x = list(x) return uni_string(x) @@ -81,6 +82,35 @@ class Fail2BanDb(object): + """Fail2Ban database for storing persistent data. + + This allows after Fail2Ban is restarted to r...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/server/database.py
Provide docstrings following PEP 257
# emacs: -*- mode: python; coding: utf-8; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Softw...
--- +++ @@ -55,6 +55,16 @@ class DateTemplate(object): + """A template which searches for and returns a date from a log line. + + This is an not functional abstract class which other templates should + inherit from. + + Attributes + ---------- + name + regex + """ LINE_BEGIN = 8 LINE_END = 4 @@ -74,6 +84,28...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/server/datetemplate.py
Write docstrings for backend logic
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation;...
--- +++ @@ -59,6 +59,7 @@ return threading.current_thread().__class__.__name__ def _make_file_path(name): + """Creates path of file (last level only) on demand""" name = os.path.dirname(name) # only if it is absolute (e. g. important for socket, so if unix path): if os.path.isabs(name): @@ -102,6 +103,7 @@ ...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/server/server.py
Write beginner-friendly docstrings
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation;...
--- +++ @@ -38,6 +38,24 @@ logSys = getLogger(__name__) class ObserverThread(JailThread): + """Handles observing a database, managing bad ips and ban increment. + + Parameters + ---------- + + Attributes + ---------- + daemon + ident + name + status + active : bool + Control the state of the thread. + idle : bool +...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/server/observer.py
Add docstrings to clarify complex logic
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation;...
--- +++ @@ -54,6 +54,8 @@ for name, num in signal.__dict__.items() if name.startswith("SIG")) class Utils(): + """Utilities provide diverse static methods like executes OS shell commands, etc. + """ DEFAULT_SLEEP_TIME = 2 DEFAULT_SLEEP_INTERVAL = 0.2 @@ -62,6 +64,8 @@ class Cache(object): + """A simple ...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/server/utils.py
Generate docstrings for exported functions
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation;...
--- +++ @@ -48,6 +48,32 @@ class Actions(JailThread, Mapping): + """Handles jail actions. + + This class handles the actions of the jail. Creation, deletion or to + actions must be done through this class. This class is based on the + Mapping type, and the `add` method must be used to add new actions. + This class ...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/server/actions.py
Generate descriptive docstrings automatically
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation;...
--- +++ @@ -91,6 +91,7 @@ def formatExceptionInfo(): + """ Consistently format exception information """ cla, exc = sys.exc_info()[:2] return (cla.__name__, uni_string(exc)) @@ -102,6 +103,10 @@ # to stay in line with the main Fail2Ban license # def mbasename(s): + """Custom function to include directory na...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/helpers.py
Add docstrings to improve code quality
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation;...
--- +++ @@ -71,10 +71,43 @@ class SMTPAction(ActionBase): + """Fail2Ban action which sends emails to inform on jail starting, + stopping and bans. + """ def __init__( self, jail, name, host="localhost", ssl=False, user=None, password=None, sendername="Fail2Ban", sender="fail2ban", dest="root", matches=Non...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/config/action.d/smtp.py
Include argument descriptions in docstrings
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: t -*- # vi: set ft=python sts=4 ts=4 sw=4 noet : # This file is part of Fail2Ban. # # Fail2Ban is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation;...
--- +++ @@ -40,6 +40,7 @@ _systemdPathCache = Utils.Cache() def _getSystemdPath(path): + """Get systemd path using systemd-path command (cached)""" p = _systemdPathCache.get(path) if p: return p p = Utils.executeCmd('systemd-path %s' % path, timeout=10, shell=True, output=True) @@ -52,9 +53,11 @@ return p ...
https://raw.githubusercontent.com/fail2ban/fail2ban/HEAD/fail2ban/server/filtersystemd.py
Write docstrings for backend logic
# -*- coding: utf-8 -*- # Copyright 2015-2025 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. import sys from ..text import re_compile modules = [ "2ch", "2c...
--- +++ @@ -274,6 +274,7 @@ def find(url): + """Find a suitable extractor for the given URL""" for cls in _list_classes(): if match := cls.pattern.match(url): return cls(match) @@ -281,6 +282,7 @@ def add(cls): + """Add 'cls' to the list of available extractors""" if isinst...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/__init__.py
Write beginner-friendly docstrings
# -*- coding: utf-8 -*- # Copyright 2024-2026 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. import os import logging from . import util, formatter log = logging.g...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Download Archives""" import os import logging @@ -88,10 +89,12 @@ f"(entry TEXT PRIMARY KEY)") def add(self, kwdict): + """Add item...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/archive.py
Fully document this Python code with docstrings
# -*- coding: utf-8 -*- # Copyright 2014-2026 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. import time import mimetypes from requests.exceptions import RequestExc...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Downloader module for http:// and https:// URLs""" import time import mimetypes @@ -381,6 +382,7 @@ return True def _release_conn_impl(self, response): + ...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/downloader/http.py
Document my Python code with docstrings
# -*- coding: utf-8 -*- # This is a slightly modified version of yt-dlp's aes module. # https://github.com/yt-dlp/yt-dlp/blob/master/yt_dlp/aes.py import struct import binascii from math import ceil try: from Cryptodome.Cipher import AES as Cryptodome_AES except ImportError: try: from Crypto.Cipher i...
--- +++ @@ -25,14 +25,17 @@ if Cryptodome_AES: def aes_cbc_decrypt_bytes(data, key, iv): + """Decrypt bytes with AES-CBC using pycryptodome""" return Cryptodome_AES.new( key, Cryptodome_AES.MODE_CBC, iv).decrypt(data) def aes_gcm_decrypt_and_verify_bytes(data, key, tag, nonce)...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/aes.py
Annotate my code with docstrings
# -*- coding: utf-8 -*- # Copyright 2021-2025 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .booru import BooruExtractor from .. import text import operator ...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://comicvine.gamespot.com/""" from .booru import BooruExtractor from .. import text @@ -13,6 +14,7 @@ class ComicvineTagExtractor(BooruExtractor): +...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/comicvine.py
Insert docstrings into my code
# -*- coding: utf-8 -*- # Copyright 2018-2026 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message from .. import text, util import...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://www.artstation.com/""" from .common import Extractor, Message from .. import text, util @@ -13,6 +14,7 @@ class ArtstationExtractor(Extractor): +...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/artstation.py
Write beginner-friendly docstrings
# -*- coding: utf-8 -*- # Copyright 2019-2026 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message from .. import util BASE_PATTER...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://500px.com/""" from .common import Extractor, Message from .. import util @@ -14,6 +15,7 @@ class _500pxExtractor(Extractor): + """Base class f...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/500px.py
Generate NumPy-style docstrings
# -*- coding: utf-8 -*- # Copyright 2018-2026 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import DownloaderBase from .. import ytdl, text, util from...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Downloader module for URLs requiring youtube-dl support""" from .common import DownloaderBase from .. import ytdl, text, util @@ -380,6 +381,7 @@ def compatible_formats...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/downloader/ytdl.py
Document this code for team use
# -*- coding: utf-8 -*- # Copyright 2024-2026 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message, Dispatch from .. import text, u...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://archiveofourown.org/""" from .common import Extractor, Message, Dispatch from .. import text, util @@ -15,6 +16,7 @@ class Ao3Extractor(Extractor...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/ao3.py
Auto-generate documentation strings for this file
# -*- coding: utf-8 -*- # Copyright 2014-2026 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. import os import sys import logging from . import version, config, optio...
--- +++ @@ -484,6 +484,35 @@ self.urls += urls def add_file(self, path, action=None): + """Process an input file. + + Lines starting with '#' and empty lines will be ignored. + Lines starting with '-' will be interpreted as a key-value pair + separated by an '='. where + ...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/__init__.py
Create structured documentation for my script
# -*- coding: utf-8 -*- # Copyright 2016-2026 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. import os import time import logging from . import config, util log = ...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Utilities for caching function results""" import os import time @@ -96,6 +97,7 @@ def clear(module): + """Delete database entries for 'module'""" if (db := data...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/cache.py
Write proper docstrings for these functions
# -*- coding: utf-8 -*- # Copyright 2025 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, GalleryExtractor, Message from .. import text...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://ahottie.top/""" from .common import Extractor, GalleryExtractor, Message from .. import text @@ -14,6 +15,7 @@ class AhottieExtractor(Extractor):...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/ahottie.py
Can you add docstrings to this Python file?
# -*- coding: utf-8 -*- # Copyright 2015-2025 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message from .. import text class _4ch...
--- +++ @@ -6,12 +6,14 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://www.4chan.org/""" from .common import Extractor, Message from .. import text class _4chanThreadExtractor(Extractor): + """Extractor for 4ch...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/4chan.py
Add docstrings to improve collaboration
# -*- coding: utf-8 -*- # Copyright 2025 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import GalleryExtractor from .. import text class Comedywildl...
--- +++ @@ -6,12 +6,14 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://www.comedywildlifephoto.com/""" from .common import GalleryExtractor from .. import text class ComedywildlifephotoGalleryExtractor(GalleryExtr...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/comedywildlifephoto.py
Add standardized docstrings across the file
# -*- coding: utf-8 -*- # Copyright 2014-2026 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message from .. import text, util import...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://e-hentai.org/ and https://exhentai.org/""" from .common import Extractor, Message from .. import text, util @@ -17,6 +18,7 @@ class ExhentaiExtra...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/exhentai.py
Generate NumPy-style docstrings
# -*- coding: utf-8 -*- # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message from .. import text, util BASE_PATTERN = r"(?:https?://)?(?:www\.)?ar...
--- +++ @@ -4,6 +4,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://arca.live/""" from .common import Extractor, Message from .. import text, util @@ -12,6 +13,7 @@ class ArcaliveExtractor(Extractor): + """Base...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/arcalive.py
Insert docstrings into my code
# -*- coding: utf-8 -*- # Copyright 2014-2025 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. import os from .. import config, util _config = config._config class ...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Common classes and constants used by downloader modules.""" import os from .. import config, util @@ -13,6 +14,7 @@ class DownloaderBase(): + """Base class for downl...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/downloader/common.py
Add verbose docstrings with examples
# -*- coding: utf-8 -*- # Copyright 2026 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message from .. import text BASE_PATTERN = r...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://foriio.com/""" from .common import Extractor, Message from .. import text @@ -14,6 +15,7 @@ class ForiioExtractor(Extractor): + """Base class ...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/foriio.py
Help me comply with documentation standards
# -*- coding: utf-8 -*- # Copyright 2015-2025 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import ChapterExtractor, MangaExtractor, Extractor, Messag...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://dynasty-scans.com/""" from .common import ChapterExtractor, MangaExtractor, Extractor, Message from .. import text, util @@ -14,6 +15,7 @@ class ...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/dynastyscans.py
Create docstrings for all classes and functions
# -*- coding: utf-8 -*- # Copyright 2025 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import ChapterExtractor, MangaExtractor from .. import text BA...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://dandadan.net/""" from .common import ChapterExtractor, MangaExtractor from .. import text @@ -14,11 +15,13 @@ class DandadanBase(): + """Base ...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/dandadan.py
Generate docstrings with examples
# -*- coding: utf-8 -*- # Copyright 2014-2025 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import BaseExtractor, Message from .. import text, util, d...
--- +++ @@ -6,12 +6,14 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://danbooru.donmai.us/ and other Danbooru instances""" from .common import BaseExtractor, Message from .. import text, util, dt class DanbooruExt...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/danbooru.py
Improve documentation using docstrings
# -*- coding: utf-8 -*- # Copyright 2017-2025 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message from .. import text class _2ch...
--- +++ @@ -6,12 +6,14 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://www.2chan.net/""" from .common import Extractor, Message from .. import text class _2chanThreadExtractor(Extractor): + """Extractor for 2ch...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/2chan.py
Create docstrings for each class method
# -*- coding: utf-8 -*- # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message from .. import text BASE_PATTERN = r"(?:https?://)?(?:www\.)?fapello...
--- +++ @@ -4,6 +4,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://fapello.com/""" from .common import Extractor, Message from .. import text @@ -13,6 +14,7 @@ class FapelloPostExtractor(Extractor): + """Extra...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/fapello.py
Annotate my code with docstrings
# -*- coding: utf-8 -*- # Copyright 2021-2025 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import GalleryExtractor, Extractor, Message from .. import...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://bbc.co.uk/""" from .common import GalleryExtractor, Extractor, Message from .. import text, util @@ -14,6 +15,7 @@ class BbcGalleryExtractor(Gall...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/bbc.py
Add docstrings that explain inputs and outputs
# -*- coding: utf-8 -*- # Copyright 2026 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, ChapterExtractor, MangaExtractor, Message fro...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://allporncomic.com/""" from .common import Extractor, ChapterExtractor, MangaExtractor, Message from .. import text @@ -14,6 +15,7 @@ class Allporn...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/allporncomic.py
Document classes and their methods
# -*- coding: utf-8 -*- # Copyright 2025-2026 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import ChapterExtractor, MangaExtractor from .. import tex...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://danke.moe/""" from .common import ChapterExtractor, MangaExtractor from .. import text, util @@ -15,6 +16,7 @@ class DankefuerslesenBase(): + ...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/dankefuerslesen.py
Add docstrings including usage examples
# -*- coding: utf-8 -*- # Copyright 2026 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message from .. import text import random BA...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://filester.me/""" from .common import Extractor, Message from .. import text @@ -15,6 +16,7 @@ class FilesterExtractor(Extractor): + """Base cla...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/filester.py
Add docstrings to my Python code
# -*- coding: utf-8 -*- # Copyright 2019-2025 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message from .. import text class _35p...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://35photo.pro/""" from .common import Extractor, Message from .. import text @@ -32,9 +33,11 @@ yield Message.Url, url, text.nameext_fr...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/35photo.py
Add docstrings explaining edge cases
# -*- coding: utf-8 -*- # Copyright 2024-2026 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message, Dispatch from .. import text, u...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://www.civitai.com/""" from .common import Extractor, Message, Dispatch from .. import text, util @@ -17,6 +18,7 @@ class CivitaiExtractor(Extractor...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/civitai.py
Write docstrings for this repository
# -*- coding: utf-8 -*- # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message from .. import text BASE_PATTERN = ( r"(?:hatenablog:https?://([...
--- +++ @@ -4,6 +4,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://hatenablog.com""" from .common import Extractor, Message from .. import text @@ -18,6 +19,7 @@ class HatenablogExtractor(Extractor): + """Base...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/hatenablog.py
Generate helpful docstrings for debugging
# -*- coding: utf-8 -*- # Copyright 2020-2025 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message, Dispatch from .. import text, u...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://www.furaffinity.net/""" from .common import Extractor, Message, Dispatch from .. import text, util @@ -14,6 +15,7 @@ class FuraffinityExtractor(E...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/furaffinity.py
Insert docstrings into my code
# -*- coding: utf-8 -*- # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from . import lolisafe from .common import Message from .. import text BASE_PATTERN = r"(?:https?://)?(?:www...
--- +++ @@ -4,6 +4,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://cyberdrop.cr/""" from . import lolisafe from .common import Message @@ -13,6 +14,7 @@ class CyberdropAlbumExtractor(lolisafe.LolisafeAlbumExtract...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/cyberdrop.py
Include argument descriptions in docstrings
# -*- coding: utf-8 -*- # Copyright 2018-2026 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message from .. import text, util clas...
--- +++ @@ -6,12 +6,14 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://www.behance.net/""" from .common import Extractor, Message from .. import text, util class BehanceExtractor(Extractor): + """Base class for...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/behance.py
Provide clean and structured docstrings
# -*- coding: utf-8 -*- # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import GalleryExtractor from .. import text class EpornerGalleryExtractor(GalleryExtractor): ...
--- +++ @@ -4,12 +4,14 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://www.eporner.com/""" from .common import GalleryExtractor from .. import text class EpornerGalleryExtractor(GalleryExtractor): + """Extracto...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/eporner.py
Provide docstrings following PEP 257
# -*- coding: utf-8 -*- # Copyright 2020-2026 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message from .. import text, util, dt fr...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://aryion.com/""" from .common import Extractor, Message from .. import text, util, dt @@ -15,6 +16,7 @@ class AryionExtractor(Extractor): + """B...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/aryion.py
Provide clean and structured docstrings
# -*- coding: utf-8 -*- # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import GalleryExtractor, Extractor, Message from .. import text BASE_PATTERN = r"(?:https?://)?...
--- +++ @@ -4,6 +4,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://fitnakedgirls.com/""" from .common import GalleryExtractor, Extractor, Message from .. import text @@ -12,6 +13,7 @@ class FitnakedgirlsExtractor...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/fitnakedgirls.py
Write docstrings that follow conventions
# -*- coding: utf-8 -*- # Copyright 2014-2026 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message from . import danbooru from .. i...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://e621.net/ and other e621 instances""" from .common import Extractor, Message from . import danbooru @@ -13,6 +14,7 @@ class E621Extractor(danboor...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/e621.py
Add structured docstrings to improve clarity
# -*- coding: utf-8 -*- # Copyright 2019-2025 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import BaseExtractor, Message from .. import text, util ...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for Blogger blogs""" from .common import BaseExtractor, Message from .. import text, util @@ -18,6 +19,7 @@ class BloggerExtractor(BaseExtractor): + """Ba...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/blogger.py
Generate missing documentation strings
# -*- coding: utf-8 -*- # Copyright 2015-2026 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message, Dispatch from .. import text, u...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://www.deviantart.com/""" from .common import Extractor, Message, Dispatch from .. import text, util, dt @@ -23,6 +24,7 @@ class DeviantartExtractor...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/deviantart.py
Write beginner-friendly docstrings
# -*- coding: utf-8 -*- # Copyright 2016-2025 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import BaseExtractor, Message from .. import text, util ...
--- +++ @@ -6,12 +6,14 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for FoOlSlide based sites""" from .common import BaseExtractor, Message from .. import text, util class FoolslideExtractor(BaseExtractor): + """Base cl...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/foolslide.py
Document all endpoints with docstrings
# -*- coding: utf-8 -*- # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message from .. import text, util class FantiaExtractor(Extractor): cate...
--- +++ @@ -4,12 +4,14 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://fantia.jp/""" from .common import Extractor, Message from .. import text, util class FantiaExtractor(Extractor): + """Base class for Fantia...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/fantia.py
Document all public functions with docstrings
# -*- coding: utf-8 -*- # Copyright 2021-2025 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import GalleryExtractor, Extractor, Message from .. import...
--- +++ @@ -6,12 +6,14 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://architizer.com/""" from .common import GalleryExtractor, Extractor, Message from .. import text class ArchitizerProjectExtractor(GalleryExtrac...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/architizer.py
Write Python docstrings for this snippet
# -*- coding: utf-8 -*- # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message from .. import config, text import os.path class GenericExtractor(Ex...
--- +++ @@ -4,6 +4,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Generic information extractor""" from .common import Extractor, Message from .. import config, text @@ -11,6 +12,7 @@ class GenericExtractor(Extractor): + """Extract...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/generic.py
Write reusable docstrings
# -*- coding: utf-8 -*- # Copyright 2023-2025 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message from .. import text class _4ch...
--- +++ @@ -6,12 +6,14 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://4chanarchives.com/""" from .common import Extractor, Message from .. import text class _4chanarchivesThreadExtractor(Extractor): + """Extra...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/4chanarchives.py
Add docstrings to make code maintainable
# -*- coding: utf-8 -*- # Copyright 2016-2025 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import ChapterExtractor, MangaExtractor from .. import tex...
--- +++ @@ -6,17 +6,20 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://hentai2read.com/""" from .common import ChapterExtractor, MangaExtractor from .. import text, util class Hentai2readBase(): + """Base class...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/hentai2read.py
Write docstrings describing functionality
# -*- coding: utf-8 -*- # Copyright 2015-2026 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. import sys import os.path import logging from . import util log = logg...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Global configuration module""" import sys import os.path @@ -214,6 +215,7 @@ def load(files=None, strict=False, loads=None, conf=_config): + """Load configuration fi...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/config.py
Help me write clear docstrings
# -*- coding: utf-8 -*- # Copyright 2024-2026 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message, Dispatch from .. import text, u...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://bsky.app/""" from .common import Extractor, Message, Dispatch from .. import text, util @@ -16,6 +17,7 @@ class BlueskyExtractor(Extractor): + ...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/bluesky.py
Add clean documentation to messy code
# -*- coding: utf-8 -*- # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message from .. import text import itertools BASE_PATTERN = r"(?:https?://)?(...
--- +++ @@ -4,6 +4,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://girlsreleased.com/""" from .common import Extractor, Message from .. import text @@ -13,6 +14,7 @@ class GirlsreleasedExtractor(Extractor): + ...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/girlsreleased.py
Add docstrings to make code maintainable
# -*- coding: utf-8 -*- # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message from .. import text, util class BilibiliExtractor(Extractor): ca...
--- +++ @@ -4,12 +4,14 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://www.bilibili.com/""" from .common import Extractor, Message from .. import text, util class BilibiliExtractor(Extractor): + """Base class f...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/bilibili.py
Document this script properly
# -*- coding: utf-8 -*- # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message from .. import text, dt BASE_PATTERN = r"(?:https?://)?discord\.com" ...
--- +++ @@ -4,6 +4,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://discord.com/""" from .common import Extractor, Message from .. import text, dt @@ -12,6 +13,7 @@ class DiscordExtractor(Extractor): + """Base ...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/discord.py
Generate docstrings for exported functions
# -*- coding: utf-8 -*- # Copyright 2015-2026 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. class GalleryDLException(Exception): default = None msgfmt = N...
--- +++ @@ -6,9 +6,37 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Exception classes used by gallery-dl + +Class Hierarchy: + +Exception + └── GalleryDLException + ├── ExtractionError + │ ├── HttpError + │ │ └── Challe...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/exception.py
Turn comments into proper docstrings
# -*- coding: utf-8 -*- # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor, Message from .. import text BASE_PATTERN = r"(?:https?://)?(?:www\.)?cfake\.c...
--- +++ @@ -4,6 +4,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://cfake.com/""" from .common import Extractor, Message from .. import text @@ -12,6 +13,7 @@ class CfakeExtractor(Extractor): + """Base class fo...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/cfake.py
Generate NumPy-style docstrings
# -*- coding: utf-8 -*- # Copyright 2022-2026 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. from .common import Extractor from .lolisafe import LolisafeAlbumExtrac...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Extractors for https://bunkr.si/""" from .common import Extractor from .lolisafe import LolisafeAlbumExtractor @@ -56,6 +57,7 @@ class BunkrAlbumExtractor(LolisafeAlbum...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/extractor/bunkr.py
Add docstrings that explain inputs and outputs
# -*- coding: utf-8 -*- # Copyright 2025 Mike Fährmann # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. import sys import time from datetime import datetime, date, timedelta, timez...
--- +++ @@ -6,6 +6,7 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +"""Date/Time utilities""" import sys import time @@ -40,6 +41,7 @@ def convert(value): + """Convert 'value' to a naive UTC datetime object""" if not value: ...
https://raw.githubusercontent.com/mikf/gallery-dl/HEAD/gallery_dl/dt.py