instruction stringclasses 100
values | code stringlengths 78 193k | response stringlengths 259 170k | file stringlengths 59 203 |
|---|---|---|---|
Add docstrings to existing functions | # Author: Fred L. Drake, Jr.
# fdrake@...
#
# This is a simple little module I wrote to make life easier. I didn't
# see anything quite like it in the library, though I may have overlooked
# something. I wrote this when I was trying to read some heavily nested
# tuples with fairly non-descript... | --- +++ @@ -8,6 +8,31 @@ # after Lisp/Scheme - style pretty-printing of lists. If you find it
# useful, thank small children who sleep at night.
+"""Support to pretty-print lists, tuples, & dictionaries recursively.
+
+Very simple, but useful, especially in debugging data structures.
+
+Classes
+-------
+
+Pretty... | https://raw.githubusercontent.com/binux/pyspider/HEAD/pyspider/libs/pprint.py |
Fully document this Python code with docstrings | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8:
# Author: Binux<i@binux.me>
# http://binux.me
# Created on 2012-11-06 11:50:13
import math
import logging
import hashlib
import datetime
import socket
import base64
import warnings
import threading
import six
from... | --- +++ @@ -21,12 +21,14 @@
class ReadOnlyDict(dict):
+ """A Read Only Dict"""
def __setitem__(self, key, value):
raise Exception("dict is read-only")
def getitem(obj, key=0, default=None):
+ """Get first element of list or return default"""
try:
return obj[key]
except:... | https://raw.githubusercontent.com/binux/pyspider/HEAD/pyspider/libs/utils.py |
Can you add docstrings to this Python file? | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8:
# Author: Binux<i@binux.me>
# http://binux.me
# Created on 2014-10-19 15:37:46
import time
import json
import logging
from six.moves import queue as Queue
logger = logging.getLogger("result")
class ResultWorker(o... | --- +++ @@ -14,6 +14,10 @@
class ResultWorker(object):
+ """
+ do with result
+ override this if needed.
+ """
def __init__(self, resultdb, inqueue):
self.resultdb = resultdb
@@ -21,6 +25,7 @@ self._quit = False
def on_result(self, task, result):
+ '''Called every r... | https://raw.githubusercontent.com/binux/pyspider/HEAD/pyspider/result/result_worker.py |
Add documentation for all methods | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8:
# Author: Binux<roy@binux.me>
# http://binux.me
# Created on 2015-05-22 20:54:01
import time
import umsgpack
from kombu import Connection, enable_insecure_serializers
from kombu.serialization import register
from k... | --- +++ @@ -18,12 +18,24 @@
class KombuQueue(object):
+ """
+ kombu is a high-level interface for multiple message queue backends.
+
+ KombuQueue is built on top of kombu API.
+ """
Empty = BaseQueue.Empty
Full = BaseQueue.Full
max_timeout = 0.3
def __init__(self, name, url="amqp... | https://raw.githubusercontent.com/binux/pyspider/HEAD/pyspider/message_queue/kombu_queue.py |
Generate NumPy-style docstrings | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8:
# Author: Binux<roy@binux.me>
# http://binux.me
# Created on 2015-04-27 22:48:04
import time
import redis
import umsgpack
from six.moves import queue as BaseQueue
class RedisQueue(object):
Empty = BaseQueue.... | --- +++ @@ -12,6 +12,9 @@
class RedisQueue(object):
+ """
+ A Queue like message built over redis
+ """
Empty = BaseQueue.Empty
Full = BaseQueue.Full
@@ -19,6 +22,14 @@
def __init__(self, name, host='localhost', port=6379, db=0,
maxsize=0, lazy_limit=True, password=None,... | https://raw.githubusercontent.com/binux/pyspider/HEAD/pyspider/message_queue/redis_queue.py |
Generate docstrings for exported functions | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8:
# Author: Binux<17175297.hk@gmail.com>
# http://binux.me
# Created on 2012-11-15 17:27:54
import time
import socket
import select
import logging
import umsgpack
import threading
import amqp
from six.moves.urllib.p... | --- +++ @@ -22,6 +22,7 @@
def catch_error(func):
+ """Catch errors of rabbitmq then reconnect"""
import amqp
try:
import pika.exceptions
@@ -49,6 +50,9 @@
class PikaQueue(object):
+ """
+ A Queue like rabbitmq connector
+ """
Empty = BaseQueue.Empty
Full = BaseQueue.Fu... | https://raw.githubusercontent.com/binux/pyspider/HEAD/pyspider/message_queue/rabbitmq.py |
Add inline docstrings for readability | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8:
# Author: Binux<i@binux.me>
# http://binux.me
# Created on 2014-02-16 22:59:56
import sys
import six
import time
import logging
import traceback
logger = logging.getLogger("processor")
from six.moves import queue ... | --- +++ @@ -21,6 +21,7 @@
class ProcessorResult(object):
+ """The result and logs producted by a callback"""
def __init__(self, result=None, follows=(), messages=(),
logs=(), exception=None, extinfo=None, save=None):
@@ -35,11 +36,13 @@ self.save = save
def rethrow(self):
... | https://raw.githubusercontent.com/binux/pyspider/HEAD/pyspider/processor/processor.py |
Document helper functions with docstrings | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8:
# Author: Binux<i@binux.me>
# http://binux.me
# Created on 2014-02-16 22:24:20
import os
import six
import sys
import imp
import time
import weakref
import logging
import inspect
import traceback
import linecache
f... | --- +++ @@ -21,12 +21,16 @@
class ProjectManager(object):
+ """
+ load projects from projectdb, update project
+ """
CHECK_PROJECTS_INTERVAL = 5 * 60
RELOAD_PROJECT_INTERVAL = 60 * 60
@staticmethod
def build_module(project, env=None):
+ '''Build project script as module'''
... | https://raw.githubusercontent.com/binux/pyspider/HEAD/pyspider/processor/project_module.py |
Document all endpoints with docstrings | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8:
# Author: Binux<i@binux.me>
# http://binux.me
# Created on 2014-03-05 00:11:49
import os
import sys
import six
import copy
import time
import shutil
import logging
import logging.config
import click
import pyspid... | --- +++ @@ -89,6 +89,9 @@ @click.version_option(version=pyspider.__version__, prog_name=pyspider.__name__)
@click.pass_context
def cli(ctx, **kwargs):
+ """
+ A powerful spider system in python.
+ """
if kwargs['add_sys_path']:
sys.path.append(os.getcwd())
@@ -195,6 +198,9 @@ def scheduler(ct... | https://raw.githubusercontent.com/binux/pyspider/HEAD/pyspider/run.py |
Fully document this Python code with docstrings | import six
import platform
import multiprocessing
from multiprocessing.queues import Queue as BaseQueue
# The SharedCounter and Queue classes come from:
# https://github.com/vterron/lemon/commit/9ca6b4b
class SharedCounter(object):
def __init__(self, n=0):
self.count = multiprocessing.Value('i', n)
... | --- +++ @@ -8,20 +8,42 @@ # https://github.com/vterron/lemon/commit/9ca6b4b
class SharedCounter(object):
+ """ A synchronized shared counter.
+ The locking done by multiprocessing.Value ensures that only a single
+ process or thread may read or write the in-memory ctypes object. However,
+ in order to do... | https://raw.githubusercontent.com/binux/pyspider/HEAD/pyspider/libs/multiprocessing_queue.py |
Write reusable docstrings | # Copyright (c) 2006-2007 Open Source Applications Foundation
#
# 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 require... | --- +++ @@ -22,8 +22,10 @@
class WSGIXMLRPCApplication(object):
+ """Application to handle requests to the XMLRPC service"""
def __init__(self, instance=None, methods=None):
+ """Create windmill xmlrpc dispatcher"""
if methods is None:
methods = []
try:
@@ -44,6 +46,7... | https://raw.githubusercontent.com/binux/pyspider/HEAD/pyspider/libs/wsgi_xmlrpc.py |
Write Python docstrings for this snippet | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8:
# Author: Binux<i@binux.me>
# http://binux.me
# Created on 2012-11-14 17:09:50
from __future__ import unicode_literals, division, absolute_import
import time
import logging
from collections import deque
try:
f... | --- +++ @@ -26,24 +26,30 @@ pass
def event(self, value=1):
+ """Fire a event."""
raise NotImplementedError
def value(self, value):
+ """Set counter value."""
raise NotImplementedError
@property
def avg(self):
+ """Get average value"""
rai... | https://raw.githubusercontent.com/binux/pyspider/HEAD/pyspider/libs/counter.py |
Write docstrings for utility functions | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8:
# Author: Binux<i@binux.me>
# http://binux.me
# Created on 2012-10-24 16:08:17
import logging
try:
import curses
except ImportError:
curses = None
from tornado.log import LogFormatter as _LogFormatter
c... | --- +++ @@ -16,6 +16,7 @@
class LogFormatter(_LogFormatter, object):
+ """Init tornado.log.LogFormatter from logging.config.fileConfig"""
def __init__(self, fmt=None, datefmt=None, color=True, *args, **kwargs):
if fmt is None:
fmt = _LogFormatter.DEFAULT_FORMAT
@@ -23,6 +24,7 @@
cl... | https://raw.githubusercontent.com/binux/pyspider/HEAD/pyspider/libs/log.py |
Document this code for team use | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8:
# Author: Binux<i@binux.me>
# http://binux.me
# Created on 2014-02-07 17:05:11
import itertools
import json
import logging
import os
import time
from collections import deque
from six import iteritems, itervalues... | --- +++ @@ -24,7 +24,12 @@
class Project(object):
+ '''
+ project for scheduler
+ '''
def __init__(self, scheduler, project_info):
+ '''
+ '''
self.scheduler = scheduler
self.active_tasks = deque(maxlen=scheduler.ACTIVE_TASKS)
@@ -199,6 +204,7 @@ self._last_du... | https://raw.githubusercontent.com/binux/pyspider/HEAD/pyspider/scheduler/scheduler.py |
Replace inline comments with docstrings | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8:
# Author: Binux<i@binux.me>
# http://binux.me
# Created on 2014-02-07 13:12:10
import heapq
import logging
import threading
import time
try:
from UserDict import DictMixin
except ImportError:
from collecti... | --- +++ @@ -67,6 +67,11 @@
class PriorityTaskQueue(Queue.Queue):
+ '''
+ TaskQueue
+
+ Same taskid items will been merged
+ '''
def _init(self, maxsize):
self.queue = []
@@ -124,6 +129,9 @@
class TaskQueue(object):
+ '''
+ task queue for scheduler, have a priority queue and a t... | https://raw.githubusercontent.com/binux/pyspider/HEAD/pyspider/scheduler/task_queue.py |
Add docstrings including usage examples | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8:
# Author: Binux<i@binux.me>
# http://binux.me
# Created on 2014-02-16 23:12:48
import sys
import inspect
import functools
import fractions
import six
from six import add_metaclass, iteritems
from pyspider.libs.ur... | --- +++ @@ -24,11 +24,20 @@
def catch_status_code_error(func):
+ """
+ Non-200 response will been regarded as fetch failed and will not pass to callback.
+ Use this decorator to override this feature.
+ """
func._catch_status_code_error = True
return func
def not_send_status(func):
+ "... | https://raw.githubusercontent.com/binux/pyspider/HEAD/pyspider/libs/base_handler.py |
Add detailed documentation for each class | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8:
# Author: Binux<i@binux.me>
# http://binux.me
# Created on 2014-02-07 16:53:08
import time
try:
import threading as _threading
except ImportError:
import dummy_threading as _threading
class Bucket(object)... | --- +++ @@ -14,6 +14,9 @@
class Bucket(object):
+ '''
+ traffic flow control with token bucket
+ '''
update_interval = 30
@@ -28,6 +31,7 @@ self.last_update = time.time()
def get(self):
+ '''Get the number of tokens in bucket'''
now = time.time()
if self.buc... | https://raw.githubusercontent.com/binux/pyspider/HEAD/pyspider/scheduler/token_bucket.py |
Add docstrings with type hints explained | # -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# Name: sfp_abstractapi
# Purpose: Search AbstractAPI for domain, phone and IP address information.
#
# Author: Krishnasis Mandal <krishnasis@hotmail.com>
#
# Created: 29/07/2021
# Copyright: ... | --- +++ @@ -117,6 +117,14 @@ return None
def queryCompanyEnrichment(self, qry):
+ """Enrich domain with company information.
+
+ Args:
+ qry (str): domain name
+
+ Returns:
+ dict: company information
+ """
api_key = self.opts['companyenrichmen... | https://raw.githubusercontent.com/smicallef/spiderfoot/HEAD/modules/sfp_abstractapi.py |
Write beginner-friendly docstrings | # -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# Name: sfp_abuseipdb
# Purpose: Check if an IP address is malicious according to AbuseIPDB.com.
#
# Author: steve@binarypool.com
#
# Created: 06/09/2018
# Copyright: (c) Steve Micallef, 2018
... | --- +++ @@ -145,6 +145,14 @@ return self.parseBlacklist(res['content'])
def parseBlacklist(self, blacklist):
+ """Parse plaintext blacklist
+
+ Args:
+ blacklist (str): plaintext blacklist from AbuseIPDB
+
+ Returns:
+ list: list of blacklisted IP addresses
+ ... | https://raw.githubusercontent.com/smicallef/spiderfoot/HEAD/modules/sfp_abuseipdb.py |
Add detailed documentation for each class | # -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# Name: sfp_abusech
# Purpose: Check if a host/domain, IP address or netblock is malicious according
# to Abuse.ch.
#
# Author: steve@binarypool.com
#
# Created: 14/12/2013
# Copyr... | --- +++ @@ -157,6 +157,14 @@ return self.parseFeodoTrackerBlacklist(res['content'])
def parseFeodoTrackerBlacklist(self, blacklist):
+ """Parse plaintext blacklist
+
+ Args:
+ blacklist (str): plaintext blacklist from Abuse.ch Feodo Tracker
+
+ Returns:
+ list: ... | https://raw.githubusercontent.com/smicallef/spiderfoot/HEAD/modules/sfp_abusech.py |
Create docstrings for API functions | # -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# Name: sfp_hybrid_analysis
# Purpose: Search Hybrid Analysis for domains and URLs related to the target.
#
# Authors: <bcoles@gmail.com>
#
# Created: 2020-08-09
# Copyright: (c) bcoles 2020
# ... | --- +++ @@ -77,6 +77,14 @@ return ["RAW_RIR_DATA", "INTERNET_NAME", "DOMAIN_NAME", "LINKED_URL_INTERNAL"]
def queryDomain(self, qry):
+ """Query a domain
+
+ Args:
+ qry (str): domain
+
+ Returns:
+ str: API response as JSON
+ """
params = {
... | https://raw.githubusercontent.com/smicallef/spiderfoot/HEAD/modules/sfp_hybrid_analysis.py |
Add concise docstrings to each method | # -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# Name: sfp_hackertarget
# Purpose: SpiderFoot plug-in to search HackerTarget.com for hosts sharing
# the same IP. Optionally, also perform a basic TCP/UDP port scan
# for c... | --- +++ @@ -101,6 +101,14 @@ ]
def httpHeaders(self, ip):
+ """Retrieve HTTP headers for IP address
+
+ Args:
+ ip (str): IPv4 address
+
+ Returns:
+ dict: HTTP headers
+ """
params = urllib.parse.urlencode({
'q': ip
})
@@ -... | https://raw.githubusercontent.com/smicallef/spiderfoot/HEAD/modules/sfp_hackertarget.py |
Add minimal docstrings for each function | # -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# Name: sfp_countryname
# Purpose: SpiderFoot plug-in for scanning retrieved content by other
# modules (such as sfp_iban, sfp_phone, sfp_whois) and identifying country names
#
# Author: ... | --- +++ @@ -56,6 +56,14 @@ self.opts[opt] = userOpts[opt]
def detectCountryFromPhone(self, srcPhoneNumber: str) -> str:
+ """Lookup name of country from phone number region code.
+
+ Args:
+ srcPhoneNumber (str): phone number
+
+ Returns:
+ str: country name... | https://raw.githubusercontent.com/smicallef/spiderfoot/HEAD/modules/sfp_countryname.py |
Add clean documentation to messy code | # -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# Name: sfp_gleif
# Purpose: Search the Global LEI Index for company information using
# Global Legal Entity Identifier Foundation (GLEIF) search API.
#
# Author: <bcoles@gmail.com>
#
#... | --- +++ @@ -61,6 +61,14 @@ return ["COMPANY_NAME", "LEI", "PHYSICAL_ADDRESS", "RAW_RIR_DATA"]
def searchLegalName(self, qry):
+ """Fuzzy search for legal entity by name
+
+ Args:
+ qry (str): legal entity name
+
+ Returns:
+ dict: search results
+ """
... | https://raw.githubusercontent.com/smicallef/spiderfoot/HEAD/modules/sfp_gleif.py |
Add professional docstrings to my codebase | # -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# Name: sfp_spider
# Purpose: SpiderFoot plug-in for spidering sites and returning meta data
# for other plug-ins to consume.
#
# Author: Steve Micallef <steve@binarypool.com>
#
# Cr... | --- +++ @@ -99,6 +99,14 @@ ]
def processUrl(self, url: str) -> dict:
+ """Fetch data from a URL and obtain all links that should be followed.
+
+ Args:
+ url (str): URL to fetch
+
+ Returns:
+ dict: links identified in URL content
+ """
site = se... | https://raw.githubusercontent.com/smicallef/spiderfoot/HEAD/modules/sfp_spider.py |
Add standardized docstrings across the file | # -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# Name: sfp_uceprotect
# Purpose: SpiderFoot plug-in for looking up whether IPs/Netblocks/Domains
# appear in the UCEPROTECT blacklist, indicating potential open-relays,
# o... | --- +++ @@ -89,6 +89,14 @@ return '.'.join(reversed(ipaddr.split('.')))
def queryDnsblLevel1(self, qaddr):
+ """Query UCEPROTECT DNS Level 1 for an IPv4 address.
+
+ Args:
+ qaddr (str): IPv4 address.
+
+ Returns:
+ list: UCEPROTECT DNS entries
+ """
... | https://raw.githubusercontent.com/smicallef/spiderfoot/HEAD/modules/sfp_uceprotect.py |
Add concise docstrings to each method | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# Name: sfcli
# Purpose: Command Line Interface for SpiderFoot.
#
# Author: Steve Micallef <steve@binarypool.com>
#
# Created: 03/05/2017
# Copyright: (c) Steve Micallef... | --- +++ @@ -158,6 +158,8 @@
# Shortcut commands
def do_debug(self, line):
+ """debug
+ Short-cut command for set cli.debug = 1"""
if self.ownopts['cli.debug']:
val = "0"
else:
@@ -165,6 +167,8 @@ return self.do_set("cli.debug = " + val)
def do_spool... | https://raw.githubusercontent.com/smicallef/spiderfoot/HEAD/sfcli.py |
Add docstrings for internal functions | import hashlib
import random
import time
class SpiderFootEvent():
_generated = None
_eventType = None
_confidence = None
_visibility = None
_risk = None
_module = None
_data = None
_sourceEvent = None
_sourceEventHash = None
_moduleDataSource = None
_actualSource = None
... | --- +++ @@ -4,6 +4,23 @@
class SpiderFootEvent():
+ """SpiderFootEvent object representing identified data and associated meta data.
+
+ Attributes:
+ generated (float): Timestamp of event creation time
+ eventType (str): Event type, e.g. URL_FORM, RAW_DATA, etc.
+ confidence (int): How s... | https://raw.githubusercontent.com/smicallef/spiderfoot/HEAD/spiderfoot/event.py |
Write proper docstrings for these functions | # -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# Name: sflib
# Purpose: Common functions used by SpiderFoot modules.
#
# Author: Steve Micallef <steve@binarypool.com>
#
# Created: 26/03/2012
# Copyright: (c) Steve Micallef 2012
# Licenc... | --- +++ @@ -42,12 +42,28 @@
class SpiderFoot:
+ """SpiderFoot
+
+ Attributes:
+ dbh (SpiderFootDb): database handle
+ scanId (str): scan ID this instance of SpiderFoot is being used in
+ socksProxy (str): SOCKS proxy
+ opts (dict): configuration options
+ """
_dbh = None
... | https://raw.githubusercontent.com/smicallef/spiderfoot/HEAD/sflib.py |
Add missing documentation to my Python functions | # -*- coding: utf-8 -*-
# -----------------------------------------------------------------
# Name: sfscan
# Purpose: Scanning control functionality
#
# Author: Steve Micallef <steve@binarypool.com>
#
# Created: 11/03/2013
# Copyright: (c) Steve Micallef 2013
# License: MIT
# -----------... | --- +++ @@ -29,6 +29,12 @@
class SpiderFootScanner():
+ """SpiderFootScanner object.
+
+ Attributes:
+ scanId (str): unique ID of the scan
+ status (str): status of the scan
+ """
__scanId = None
__status = None
@@ -44,6 +50,24 @@ __scanName = None
def __init__(self, sc... | https://raw.githubusercontent.com/smicallef/spiderfoot/HEAD/sfscan.py |
Add minimal docstrings for each function | import logging
from copy import deepcopy
import re
import netaddr
import yaml
from spiderfoot import SpiderFootDb
class SpiderFootCorrelator:
log = logging.getLogger("spiderfoot.correlator")
dbh = None
scanId = None
types = None
rules = list()
type_entity_map = dict()
# For syntax checki... | --- +++ @@ -7,6 +7,11 @@
class SpiderFootCorrelator:
+ """SpiderFoot correlation capabilities.
+
+ Todo:
+ Make the rule checking per analysis method
+ """
log = logging.getLogger("spiderfoot.correlator")
dbh = None
@@ -42,6 +47,17 @@ }
def __init__(self, dbh: SpiderFootDb, ru... | https://raw.githubusercontent.com/smicallef/spiderfoot/HEAD/spiderfoot/correlation.py |
Write docstrings describing functionality | import atexit
import logging
import sys
import time
from contextlib import suppress
from logging.handlers import QueueHandler, QueueListener
from spiderfoot import SpiderFootDb, SpiderFootHelpers
class SpiderFootSqliteLogHandler(logging.Handler):
def __init__(self, opts: dict) -> None:
self.opts = opts
... | --- +++ @@ -9,8 +9,18 @@
class SpiderFootSqliteLogHandler(logging.Handler):
+ """Handler for logging to SQLite database.
+
+ This ensure all sqlite logging is done from a single
+ process and a single database handle.
+ """
def __init__(self, opts: dict) -> None:
+ """TBD.
+
+ Args:... | https://raw.githubusercontent.com/smicallef/spiderfoot/HEAD/spiderfoot/logger.py |
Add docstrings to my Python code | # -*- coding: utf-8 -*-
import html
import json
import os
import os.path
import random
import re
import ssl
import sys
import typing
import urllib.parse
import uuid
from pathlib import Path
from importlib import resources
import networkx as nx
from bs4 import BeautifulSoup, SoupStrainer
from networkx.readwrite.gexf i... | --- +++ @@ -66,9 +66,22 @@
class SpiderFootHelpers():
+ """SpiderFoot helper functions.
+
+ This class is used to store static helper functions which are
+ designed to function independent of scan config or global config.
+
+ Todo:
+ Eventually split this class into separate files.
+ """
... | https://raw.githubusercontent.com/smicallef/spiderfoot/HEAD/spiderfoot/helpers.py |
Add docstrings to meet PEP guidelines | # -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# Name: sfdb
# Purpose: Common functions for working with the database back-end.
#
# Author: Steve Micallef <steve@binarypool.com>
#
# Created: 15/05/2012
# Copyright: (c) Steve Micallef 201... | --- +++ @@ -20,6 +20,13 @@
class SpiderFootDb:
+ """SpiderFoot database
+
+ Attributes:
+ conn: SQLite connect() connection
+ dbh: SQLite cursor() database handle
+ dbhLock (_thread.RLock): thread lock on database handle
+ """
dbh = None
conn = None
@@ -277,6 +284,20 @@ ... | https://raw.githubusercontent.com/smicallef/spiderfoot/HEAD/spiderfoot/db.py |
Add minimal docstrings for each function | from contextlib import suppress
import io
import logging
import os
import queue
import sys
import threading
from time import sleep
import traceback
from .threadpool import SpiderFootThreadPool
# begin logging overrides
# these are copied from the python logging module
# https://github.com/python/cpython/blob/main/Lib... | --- +++ @@ -24,8 +24,23 @@
class SpiderFootPluginLogger(logging.Logger):
+ """Used only in SpiderFootPlugin to prevent modules
+ from having to initialize their own loggers.
+
+ Preserves filename, module, line numbers, etc. from the caller.
+ """
def findCaller(self, stack_info: bool = False, st... | https://raw.githubusercontent.com/smicallef/spiderfoot/HEAD/spiderfoot/plugin.py |
Add docstrings for better understanding | import queue
import logging
import threading
from time import sleep
from contextlib import suppress
class SpiderFootThreadPool:
def __init__(self, threads: int = 100, qsize: int = 10, name: str = '') -> None:
self.log = logging.getLogger(f"spiderfoot.{__name__}")
self.threads = int(threads)
... | --- +++ @@ -6,8 +6,39 @@
class SpiderFootThreadPool:
+ """
+ Each thread in the pool is spawned only once, and reused for best performance.
+
+ Example 1: using map()
+ with SpiderFootThreadPool(self.opts["_maxthreads"]) as pool:
+ # callback("a", "arg1"), callback("b", "arg1"), ...
+ ... | https://raw.githubusercontent.com/smicallef/spiderfoot/HEAD/spiderfoot/threadpool.py |
Generate descriptive docstrings automatically | import sys
import typing
import netaddr
if sys.version_info >= (3, 8): # PEP 589 support (TypedDict)
TargetAlias = typing.TypedDict("TargetAlias", {"type": str, "value": str})
else:
TargetAlias = typing.Dict[str, str]
class SpiderFootTarget():
_validTypes = ["IP_ADDRESS", 'IPV6_ADDRESS', "NETBLOCK_OW... | --- +++ @@ -11,6 +11,14 @@
class SpiderFootTarget():
+ """SpiderFoot target.
+
+ Attributes:
+ validTypes (typing.List[str]): valid event types accepted as a target
+ targetType (str): target type
+ targetValue (str): target value
+ targetAliases (typing.List[TargetAlias]): target ... | https://raw.githubusercontent.com/smicallef/spiderfoot/HEAD/spiderfoot/target.py |
Provide docstrings following PEP 257 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# Name: sf
# Purpose: Main wrapper for calling all SpiderFoot modules
#
# Author: Steve Micallef <steve@binarypool.com>
#
# Created: 03/04/2012
# Copyright: (c) Steve ... | --- +++ @@ -233,6 +233,14 @@
def start_scan(sfConfig: dict, sfModules: dict, args, loggingQueue) -> None:
+ """Start scan
+
+ Args:
+ sfConfig (dict): SpiderFoot config options
+ sfModules (dict): modules
+ args (argparse.Namespace): command line args
+ loggingQueue (Queue): main S... | https://raw.githubusercontent.com/smicallef/spiderfoot/HEAD/sf.py |
Write docstrings for utility functions | # -*- coding: utf-8 -*-
# -----------------------------------------------------------------
# Name: sfwebui
# Purpose: User interface class for use with a web browser
#
# Author: Steve Micallef <steve@binarypool.com>
#
# Created: 30/09/2012
# Copyright: (c) Steve Micallef 2012
# License: ... | --- +++ @@ -44,6 +44,7 @@
class SpiderFootWebUi:
+ """SpiderFoot web interface."""
lookup = TemplateLookup(directories=[''])
defaultConfig = dict()
@@ -52,6 +53,17 @@ docroot = ''
def __init__(self: 'SpiderFootWebUi', web_config: dict, config: dict, loggingQueue: 'logging.handlers.QueueLis... | https://raw.githubusercontent.com/smicallef/spiderfoot/HEAD/sfwebui.py |
Expand my code with proper documentation strings | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -712,6 +712,7 @@
@classmethod
def process_response(cls):
+ """Extract status and webhook."""
raise NotImplementedError
def process_webhook(self, event_type, webhook):
@@ -788,6 +789,12 @@
@classmethod
def complete_gold_purchase(cls, webhook):
+ """After rec... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/controllers/ipn.py |
Add missing documentation to my Python functions | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -94,6 +94,8 @@ @validate(article=VLink('article'),
comment=VCommentID('comment'))
def GET_oldinfo(self, article, type, dest, rest=None, comment=''):
+ """Legacy: supporting permalink pages from '06,
+ and non-search-engine-friendly links"""
if not (dest in ('... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/controllers/front.py |
Add well-formatted docstrings | #!/usr/bin/env python3
import argparse
import logging
import os
import re
import shlex
from collections import defaultdict
from collections.abc import Collection
from dataclasses import dataclass
from pathlib import Path
from subprocess import PIPE, STDOUT
from subprocess import run as _run
from time import sleep
from... | --- +++ @@ -1,4 +1,17 @@ #!/usr/bin/env python3
+"""
+Script that generates a changelog for the repository and its submodules, and outputs it in the current directory.
+
+NOTE: This script can be downloaded as-is and run from your repository.
+
+Repos using this script:
+ - ActivityWatch/activitywatch
+ - ErikBjare/gpt... | https://raw.githubusercontent.com/ActivityWatch/activitywatch/HEAD/scripts/build_changelog.py |
Write docstrings that follow conventions | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -31,6 +31,18 @@
def is_enabled(name, user=None, subreddit=None):
+ """Test and return whether a given feature is enabled for this request.
+
+ If `feature` is not found, returns False.
+
+ The optional arguments allow overriding that you generally don't want, but
+ is useful outside of reques... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/config/feature/feature.py |
Create documentation strings for testing functions | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -29,6 +29,10 @@
class FeatureState(object):
+ """A FeatureState is the state of a feature and its condition in the world.
+
+ It determines if this feature is enabled given the world provided.
+ """
# Special values for globally enabled properties - no need to interrogate
# the world... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/config/feature/state.py |
Add docstrings to incomplete code | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -52,6 +52,16 @@
def validate_mailgun_webhook(timestamp, token, signature):
+ """Check whether this is a valid webhook sent by Mailgun.
+
+ See https://documentation.mailgun.com/user_manual.html#securing-webhooks
+
+ NOTE:
+ A single Mailgun account is used for both outbound email (Mailgun HTT... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/controllers/mailgun.py |
Create docstrings for reusable components | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -108,6 +108,7 @@ )
@api_doc(api_section.multis, uri="/api/multi/user/{username}")
def GET_list_multis(self, user, expand_srs):
+ """Fetch a list of public multis belonging to `username`"""
multis = LabeledMulti.by_owner(user)
return self._format_multi_list(multis, c.use... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/controllers/multi.py |
Add well-formatted docstrings | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -54,6 +54,10 @@ """
def _oembed_for(thing, **embed_options):
+ """Given a Thing, return a dict of oEmbed data for that thing.
+
+ Raises NotImplementedError if this Thing type does not yet support oEmbeds.
+ """
if isinstance(thing, Comment):
return _oembed_comment(thing, **embed_... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/controllers/oembed.py |
Add docstrings for internal functions | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -672,6 +672,7 @@ return queries.get_all_promoted_links()
def listing(self):
+ """For sponsors, update wrapped links to include their campaigns."""
pane = super(self.__class__, self).listing()
if c.user_is_sponsor:
@@ -1161,6 +1162,10 @@
def _lowest_max_cpm_... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/controllers/promotecontroller.py |
Add docstrings that explain logic | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -112,6 +112,7 @@ self._abort_oauth_error(errors.OAUTH2_NO_REFRESH_TOKENS_ALLOWED)
def _error_response(self, state, redirect_uri, as_fragment=False):
+ """Return an error redirect."""
resp = {"state": state}
if (errors.OAUTH2_ACCESS_DENIED, "authorize") in c.error... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/controllers/oauth2.py |
Add docstrings for utility scripts | # -*- coding: utf-8 -*-
# The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public... | --- +++ @@ -67,6 +67,7 @@ from functools import partial
class ListingController(RedditController):
+ """Generalized controller for pages with lists of links."""
# toggle skipping of links based on the users' save/hide/vote preferences
@@ -109,14 +110,20 @@
@property
def menus(self):
+ "... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/controllers/listingcontroller.py |
Write docstrings describing each step | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -277,6 +277,7 @@
def set_obey_over18():
+ "querystring parameter for API to obey over18 filtering rules"
c.obey_over18 = request.GET.get("obey_over18") == "true"
valid_ascii_domain = re.compile(r'\A(\w[-\w]*\.)+[\w]+\Z')
@@ -645,6 +646,7 @@ return any(is_subdomain(origin.hostname, domain) ... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/controllers/reddit_base.py |
Add return value explanations in docstrings | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -65,6 +65,12 @@ return path
def force_html():
+ """Because we can take URIs like /s/http://.../foo.png, and we can
+ guarantee that the toolbar will never be used with a non-HTML
+ render style, we don't want to interpret the extension from the
+ target URL. So here we rewrite Mid... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/controllers/toolbar.py |
Add docstrings to incomplete code | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -124,6 +124,12 @@ page_name=VWikiPageName('page',
error_on_name_normalized=True))
def GET_wiki_page(self, pv, page_name):
+ """Return the content of a wiki page
+
+ If `v` is given, show the wiki page as it was at that version
+ I... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/controllers/wiki.py |
Create structured documentation for my script | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -95,6 +95,7 @@ prefix="rate_weblog_", seconds=10)
def OPTIONS_report_cache_poisoning(self):
+ """Send CORS headers for cache poisoning reports."""
if "Origin" not in request.headers:
return
origin = request.headers["Origin"]
@@ -143,6 ... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/controllers/web.py |
Add docstrings that explain logic | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -20,6 +20,15 @@ # Inc. All Rights Reserved.
###############################################################################
+"""
+For talking to authorize.net credit card payments via their XML api.
+
+This file consists mostly of wrapper classes for dealing with their
+API, while the actual useful functi... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/authorize/api.py |
Add docstrings for internal functions | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -50,6 +50,7 @@
def abort(code_or_exception=None, detail="", headers=None, comment=None,
**kwargs):
+ """Raise an HTTPException and save it in environ for use by error pages."""
# Pylons 0.9.6 makes it really hard to get your raised HTTPException,
# so this helper implements it manua... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/base.py |
Add documentation for all methods | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -19,6 +19,15 @@ # All portions of the code written by reddit are Copyright (c) 2006-2015 reddit
# Inc. All Rights Reserved.
###############################################################################
+"""Transitional integration with Baseplate.
+
+This module provides basic transitional integration wit... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/baseplate_integration.py |
Write docstrings for algorithm functions | import hashlib
import hmac
from pylons import app_globals as g
# A map of cache policies to their respective cache headers
# loggedout omitted because loggedout responses are intentionally cacheable
CACHE_POLICY_DIRECTIVES = {
"loggedin_www": {
"cache-control": {"private", "no-cache"},
"pragma": {"... | --- +++ @@ -33,6 +33,9 @@ # order of query params and suchlike.
route_name,
):
+ """
+ Make a MAC to send with cache poisoning reports for this page
+ """
mac_key = g.secrets["cache_poisoning"]
mac_data = (
poisoner_canary,
@@ -46,6 +49,7 @@
def cache_headers_valid(poli... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/cache_poisoning.py |
Include argument descriptions in docstrings | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -41,6 +41,7 @@
def add_comments(comments):
+ """Add comments to the CommentTree and update scores."""
from r2.models.builder import write_comment_orders
link_ids = [comment.link_id for comment in tup(comments)]
@@ -86,6 +87,7 @@
def _calculate_qa_comment_scores(link, cid_tree, comments... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/comment_tree.py |
Create docstrings for API functions | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -20,6 +20,7 @@ # Inc. All Rights Reserved.
###############################################################################
+"""Pylons middleware initialization"""
import importlib
import re
import urllib
@@ -117,6 +118,9 @@
# from pylons < 1.0
def ErrorDocuments(app, global_conf, mapper, **kw):
+ ... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/config/middleware.py |
Add minimal docstrings for each function | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -19,6 +19,18 @@ # All portions of the code written by reddit are Copyright (c) 2006-2015 reddit
# Inc. All Rights Reserved.
###############################################################################
+"""Parse and validate a safe subset of CSS.
+
+The goal of this validation is not to ensure functional... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/cssfilter.py |
Generate documentation strings for clarity | #!/usr/bin/env python
# -*- coding: ascii -*-
#
# Copyright 2011, 2012
# Andr\xe9 Malo or his licensors, as applicable
#
# 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.apach... | --- +++ @@ -15,6 +15,58 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+r"""
+==============
+ CSS Minifier
+==============
+
+CSS Minifier.
+
+The minifier is based on the semantics o... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/contrib/rcssmin.py |
Add professional docstrings to my codebase | #!/usr/bin/python3
#
# Copyright 2007 Google Inc.
# Licensed to PSF under a Contributor Agreement.
#
# 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/LIC... | --- +++ @@ -15,6 +15,12 @@ # implied. See the License for the specific language governing
# permissions and limitations under the License.
+"""A fast, lightweight IPv4/IPv6 manipulation library in Python.
+
+This library is used to create/poke/manipulate IPv4 and IPv6 addresses
+and networks.
+
+"""
__version__ =... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/contrib/ipaddress.py |
Add docstrings with type hints explained | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -26,9 +26,26 @@
class World(object):
+ """A World is the proxy to the app/request state for Features.
+
+ Proxying through World allows for easy testing and caching if needed.
+ """
@staticmethod
def stacked_proxy_safe_get(stacked_proxy, key, default=None):
+ """Get a field fr... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/config/feature/world.py |
Add detailed docstrings explaining each function | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -32,10 +32,12 @@
def get_built_statics_path():
+ """Return the path for built (compiled/compressed) statics."""
r2_path = get_r2_path()
return os.path.join(r2_path, 'build', 'public')
def get_raw_statics_path():
+ """Return the path for the raw (under version control) statics"""
... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/config/paths.py |
Help me write clear docstrings | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -28,6 +28,7 @@
class UserRelManager(object):
+ """Manages access to a relation between a type of thing and users."""
def __init__(self, name, relation, permission_class):
self.name = name
@@ -106,6 +107,7 @@
class MemoizedUserRelManager(UserRelManager):
+ """Memoized manager for... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/db/userrel.py |
Add docstrings for utility scripts | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -195,6 +195,12 @@
def add_error_codes(new_codes):
+ """Add error codes to the error enumeration.
+
+ It is assumed that the incoming messages are marked for translation but not
+ yet translated, so they can be declared before pylons.i18n is ready.
+
+ """
for code, message in new_codes.i... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/errors.py |
Create docstrings for each class method | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -27,6 +27,7 @@
class Queues(dict):
+ """A container for queue declarations."""
def __init__(self, queues):
dict.__init__(self)
self.__dict__ = self
@@ -48,6 +49,11 @@
class MessageQueue(object):
+ """A representation of an AMQP message queue.
+
+ This class is solely i... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/config/queues.py |
Add docstrings to clarify complex logic | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -83,6 +83,11 @@ api_section = Storage((k, k) for k in section_info)
def api_doc(section, uses_site=False, **kwargs):
+ """
+ Add documentation annotations to the decorated function.
+
+ See ApidocsController.docs_from_controller for a list of annotation fields.
+ """
def add_metadata(api_... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/controllers/api_docs.py |
Generate docstrings for this script | # ========================================================================
# simple-flake - https://github.com/SawdustSoftware/simple-flake
# ========================================================================
# Copyright (c) 2013 CustomMade Ventures
# Permission is hereby granted, free of charge, to any person ... | --- +++ @@ -48,6 +48,7 @@
def binary(num, padding=True):
+ """Show binary digits of a number, pads to 64 bits unless specified."""
binary_digits = "{0:b}".format(int(num))
if not padding:
return binary_digits
@@ -55,6 +56,7 @@
def extract_bits(data, shift, length):
+ """Extract a portio... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/contrib/simpleflake.py |
Create simple docstrings for beginners | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -41,6 +41,19 @@
class GzipMiddleware(object):
+ """A middleware that transparently compresses content with gzip.
+
+ Note: this middleware deliberately violates PEP-333 in three ways:
+
+ - it disables the use of the "write()" callable.
+ - it does content encoding which is a "hop-by-... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/gzipper.py |
Please document this code using docstrings | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -34,6 +34,11 @@
class MenuHandler(StringHandler):
+ """Bastard child of StringHandler and plurals. Menus are
+ typically a single word (and in some cases, a single plural word
+ like 'moderators' or 'contributors' so this class first checks its
+ own dictionary of string translations before ... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/menus.py |
Create docstrings for reusable components | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -47,6 +47,11 @@
class System(object):
+ """Take a set of campaigns and a set of targets and allocate the
+ inventory of each target to the campaigns in such a way to maximize
+ the free inventory in the priority target or targets.
+
+ """
def __init__(self, campaigns, targets, priority... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/inventory_optimization.py |
Document helper functions with docstrings | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -101,6 +101,10 @@ @squelch_exceptions
@sampled("events_collector_vote_sample_rate")
def vote_event(self, vote):
+ """Create a 'vote' event for event-collector
+
+ vote: An r2.models.vote Vote object
+ """
# For mapping vote directions to readable names used by da... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/eventcollector.py |
Generate docstrings for each module | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -21,12 +21,37 @@ ###############################################################################
class CdnProvider(object):
+ """Provider for handling Content Delivery Network (CDN) interactions.
+
+ """
def get_client_ip(self, environ):
+ """Verify and return the CDN-provided remote I... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/providers/cdn/__init__.py |
Create docstrings for all classes and functions | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -19,26 +19,68 @@ # All portions of the code written by reddit are Copyright (c) 2006-2015 reddit
# Inc. All Rights Reserved.
###############################################################################
+"""A very simple system for event hooks for plugins etc.
+
+In general, you will probably want to use... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/hooks.py |
Improve documentation using docstrings | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -39,6 +39,20 @@
def get_reply_to_address(message):
+ """Construct a reply-to address that encodes the message id.
+
+ The address is of the form:
+ zendeskreply+{message_id36}-{email_mac}
+
+ where the mac is generated from {message_id36} using the
+ `modmail_email_secret`
+
+ The r... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/message_to_email.py |
Document all public functions with docstrings | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -60,6 +60,7 @@ )
@api_doc(api_section.account)
def GET_me(self):
+ "Returns the identity of the user currently authenticated via OAuth."
resp = IdentityJsonTemplate().data(c.oauth_user)
return self.api_wrapper(resp)
@@ -74,6 +75,7 @@ )
@api_doc(api_section.ac... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/controllers/apiv1/user.py |
Add docstrings to make code maintainable | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -124,6 +124,7 @@
def mako_websafe(text=''):
+ """Wrapper for conditional_websafe so cached templates don't explode"""
return conditional_websafe(text)
@@ -153,6 +154,7 @@
def jssafe(text=u''):
+ """Prevents text from breaking outside of string literals in JS"""
if text.__class__ !... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/filters.py |
Generate helpful docstrings for debugging | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -105,6 +105,13 @@
@classmethod
def add_http_context(cls, client):
+ """Add request details to the 'request' context
+
+ These fields will be filtered by SanitizePasswordsProcessor
+ as long as they are one of 'data', 'cookies', 'headers', 'env', and
+ 'query_string'.
+
... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/log.py |
Create docstrings for each class method | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -60,6 +60,7 @@
def update_prediction_data():
+ """Fetch prediction data and write it to cassandra."""
min_daily_by_sr = _min_daily_pageviews_by_sr(NDAYS_TO_QUERY)
# combine front page values (sometimes frontpage gets '' for its name)
@@ -74,6 +75,7 @@
def _min_daily_pageviews_by_sr(nda... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/inventory.py |
Write docstrings for backend logic | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -20,6 +20,10 @@ # Inc. All Rights Reserved.
###############################################################################
+"""
+Try to regenerate the permacache items devoted to listings after a
+storage failure in Cassandra
+"""
"""
cat > mr_permacache <<HERE
@@ -210,6 +214,9 @@ ... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/migrate/mr_permacache.py |
Write reusable docstrings | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -26,11 +26,14 @@
def csrf_exempt(fn):
+ """Mark an endpoint as exempt from CSRF prevention checks"""
fn.handles_csrf = True
return fn
def check_controller_csrf_prevention(controller):
+ """Check that the a controller and its handlers are properly protected
+ from CSRF attacks""... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/csrf.py |
Improve documentation using docstrings | from datetime import datetime, timedelta
from dateutil.parser import parse as date_parse
import pytz
import string
from urllib import quote, unquote
from pylons import app_globals as g
from . import hooks
from .utils import randstr, to_epoch_milliseconds
LOID_COOKIE = "loid"
LOID_CREATED_COOKIE = "loidcreated"
# how... | --- +++ @@ -28,6 +28,17 @@
def ensure_unquoted(cookie_str):
+ """Keep unquoting. Never surrender.
+
+ Some of the cookies issued in the first version of this patch ended up
+ doubly quote()d. As a preventative measure, unquote several times.
+ [This could be a while loop, because every iteration will ... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/loid.py |
Create documentation for each function signature | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -94,6 +94,14 @@ class ThingTemplate(object):
@classmethod
def render(cls, thing):
+ """
+ Return a JSON representation of a Wrapped Thing object.
+
+ The Thing object should be Wrapped and been run through add_props just
+ like is required for regular HTML rendering. The... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/jsontemplates.py |
Write docstrings that follow conventions | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -35,6 +35,11 @@
class JsonResponse(object):
+ """
+ Simple Api response handler, returning a list of errors generated
+ in the api func's validators, as well as blobs of data set by the
+ api func.
+ """
content_type = 'application/json'
@@ -89,6 +94,9 @@ return res
... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/jsonresponse.py |
Generate docstrings for each module | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -20,6 +20,7 @@ # Inc. All Rights Reserved.
###############################################################################
+"""An implementation of the RFC-6238 Time-Based One Time Password algorithm."""
import time
import hmac
@@ -32,6 +33,7 @@
def make_hotp(secret, counter):
+ """Generate an ... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/totp.py |
Write documentation strings for class attributes | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -61,6 +61,20 @@ to_omit=None,
match_set=True,
over18=False):
+ """Return subreddits recommended if you like the given subreddits.
+
+ Args:
+ - srs is one Subreddit object or a list of Subreddits
+ - count is total number o... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/recommender.py |
Add docstrings including usage examples | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -29,6 +29,7 @@
class FastlyCdnProvider(CdnProvider):
+ """A provider for reddit's configuration of Fastly."""
def get_client_ip(self, environ):
try:
@@ -49,6 +50,11 @@ return environ.get("HTTP_CF_IPCOUNTRY", None)
def purge_content(self, url):
+ """Purge the conte... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/providers/cdn/fastly.py |
Create docstrings for all classes and functions | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -38,6 +38,14 @@
def _pad_message(text):
+ """Return `text` padded out to a multiple of block_size bytes.
+
+ This uses the PKCS7 padding algorithm. The pad-bytes have a value of N
+ where N is the number of bytes of padding added. If the input string is
+ already a multiple of the block size,... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/tracking.py |
Document this module using docstrings | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -19,6 +19,7 @@ # All portions of the code written by reddit are Copyright (c) 2006-2015 reddit
# Inc. All Rights Reserved.
###############################################################################
+"""View models for the traffic statistic pages on reddit."""
import collections
import datetime
@@ ... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/pages/trafficpages.py |
Create docstrings for each class method | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -21,11 +21,45 @@ ###############################################################################
class ImageResizingProvider(object):
+ """Provider for generating resizable image urls.
+
+ """
def resize_image(self, image, width=None, censor_nsfw=False, max_ratio=None):
+ """Turn a url o... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/providers/image_resizing/__init__.py |
Insert docstrings into my code | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -33,6 +33,7 @@ from r2.lib.utils import UrlParser, query_string
class ImgixImageResizingProvider(ImageResizingProvider):
+ """A provider that uses imgix to create on-the-fly resizings."""
config = {
ConfigValue.str: [
'imgix_domain',
@@ -72,6 +73,20 @@ return url.unpa... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/providers/image_resizing/imgix.py |
Auto-generate documentation strings for this file | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -21,15 +21,43 @@ ###############################################################################
class TicketProvider(object):
+ """Provider for handling support tickets interactions.
+
+ """
def build_ticket_url_from_id(self, ticket_id):
+ """
+ Creates a URL to access a ti... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/providers/support/__init__.py |
Add docstrings for internal functions | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -30,6 +30,7 @@ from r2.lib.providers.support import TicketProvider
class ZenDeskProvider(TicketProvider):
+ """A provider that interfaces with ZenDesk for managing tickets."""
def build_ticket_url_from_id(self, ticket_id):
return '%sagent/tickets/%s' % (
@@ -45,6 +46,17 @@ ... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/providers/support/zendesk.py |
Add docstrings to improve collaboration | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -36,6 +36,23 @@
class S3MediaProvider(MediaProvider):
+ """A media provider using Amazon S3.
+
+ Credentials for uploading objects can be provided via `S3KEY_ID` and
+ `S3SECRET_KEY`. If not provided, boto will search for credentials in
+ alternate venues including environment variables and E... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/providers/media/s3.py |
Annotate my code with docstrings | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -21,11 +21,40 @@ ###############################################################################
class MediaProvider(object):
+ """Provider for storing media objects.
+
+ Media objects are thumbnails, subreddit images/stylesheets, and app icons.
+ A media provider must allow new objects to be add... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/providers/media/__init__.py |
Add docstrings to existing functions | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -22,9 +22,33 @@
class AuthenticationProvider(object):
+ """Provider for authenticating web requests.
+
+ Authentication providers should look at the request environment and
+ determine if a particular user is logged in to the site. This may take the
+ form of cookies like on reddit.com or pe... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/providers/auth/__init__.py |
Generate helpful docstrings for debugging | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -19,6 +19,19 @@ # All portions of the code written by reddit are Copyright (c) 2006-2016 reddit
# Inc. All Rights Reserved.
###############################################################################
+"""A rate limit implementation with state in a key-value cache with item expiry.
+
+The standalone fun... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/ratelimit.py |
Write beginner-friendly docstrings | # The contents of this file are subject to the Common Public Attribution
# License Version 1.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://code.reddit.com/LICENSE. The License is based on the Mozilla Public
# License Version 1.1, ... | --- +++ @@ -21,9 +21,35 @@ ###############################################################################
class EmailProvider(object):
+ """Provider for sending emails.
+
+ """
def send_email(self, to_address, from_address, subject, text, reply_to,
parent_email_id=None, other_emai... | https://raw.githubusercontent.com/reddit-archive/reddit/HEAD/r2/r2/lib/providers/email/__init__.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.