instruction stringclasses 100
values | code stringlengths 78 193k | response stringlengths 259 170k | file stringlengths 59 203 |
|---|---|---|---|
Generate docstrings for each module | #
# This file is part of pyasn1 software.
#
# Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com>
# License: http://snmplabs.com/pyasn1/license.html
#
import sys
from pyasn1 import error
from pyasn1.compat import calling
from pyasn1.type import constraint
from pyasn1.type import tag
from pyasn1.type import tagma... | --- +++ @@ -27,6 +27,16 @@
class Asn1Type(Asn1Item):
+ """Base class for all classes representing ASN.1 types.
+
+ In the user code, |ASN.1| class is normally used only for telling
+ ASN.1 objects from others.
+
+ Note
+ ----
+ For as long as ASN.1 is concerned, a way to compare ASN.1 types
+ i... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pyasn1/type/base.py |
Add docstrings that explain purpose and usage | #
# This file is part of pyasn1 software.
#
# Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com>
# License: http://snmplabs.com/pyasn1/license.html
#
import datetime
from pyasn1 import error
from pyasn1.compat import dateandtime
from pyasn1.compat import string
from pyasn1.type import char
from pyasn1.type impo... | --- +++ @@ -39,6 +39,7 @@ _shortTZ = False
class FixedOffset(datetime.tzinfo):
+ """Fixed offset in minutes east from UTC."""
# defaulted arguments required
# https: // docs.python.org / 2.3 / lib / datetime - tzinfo.html
@@ -59,6 +60,13 @@
@property
def asDateTime(self)... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pyasn1/type/useful.py |
Generate docstrings for exported functions | #
# This file is part of pyasn1 software.
#
# Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com>
# License: http://snmplabs.com/pyasn1/license.html
#
from pyasn1 import error
__all__ = ['tagClassUniversal', 'tagClassApplication', 'tagClassContext',
'tagClassPrivate', 'tagFormatSimple', 'tagFormatCons... | --- +++ @@ -35,6 +35,25 @@
class Tag(object):
+ """Create ASN.1 tag
+
+ Represents ASN.1 tag that can be attached to a ASN.1 type to make
+ types distinguishable from each other.
+
+ *Tag* objects are immutable and duck-type Python :class:`tuple` objects
+ holding three integer components of a tag.
+... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pyasn1/type/tag.py |
Create docstrings for reusable components | #
# This file is part of pyasn1 software.
#
# Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com>
# License: http://snmplabs.com/pyasn1/license.html
#
from pyasn1 import error
__all__ = ['TagMap']
class TagMap(object):
def __init__(self, presentTypes=None, skipTypes=None, defaultType=None):
self.__... | --- +++ @@ -10,6 +10,28 @@
class TagMap(object):
+ """Map *TagSet* objects to ASN.1 types
+
+ Create an object mapping *TagSet* object to ASN.1 type.
+
+ *TagMap* objects are immutable and duck-type read-only Python
+ :class:`dict` objects holding *TagSet* objects as keys and ASN.1
+ type objects as ... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pyasn1/type/tagmap.py |
Write docstrings for this repository | #
# This file is part of pyasn1-modules software.
#
# Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com>
# License: http://snmplabs.com/pyasn1/license.html
#
# Certificate Management Protocol structures as per RFC4210
#
# Based on Alex Railean's work
#
from pyasn1.type import char
from pyasn1.type import constra... | --- +++ @@ -40,11 +40,21 @@
class PKIFreeText(univ.SequenceOf):
+ """
+ PKIFreeText ::= SEQUENCE SIZE (1..MAX) OF UTF8String
+ """
componentType = char.UTF8String()
sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint(1, MAX)
class PollRepContent(univ.SequenceOf):
+ """
+ ... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pyasn1_modules/rfc4210.py |
Add detailed documentation for each class | #
# This file is part of pyasn1 software.
#
# Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com>
# License: http://snmplabs.com/pyasn1/license.html
#
# Original concept and code by Mike C. Fletcher.
#
import sys
from pyasn1.type import error
__all__ = ['SingleValueConstraint', 'ContainedSubtypeConstraint',
... | --- +++ @@ -98,6 +98,37 @@
class SingleValueConstraint(AbstractConstraint):
+ """Create a SingleValueConstraint object.
+
+ The SingleValueConstraint satisfies any value that
+ is present in the set of permitted values.
+
+ The SingleValueConstraint object can be applied to
+ any ASN.1 type.
+
+ P... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pyasn1/type/constraint.py |
Generate docstrings with parameter types | #
# This file is part of pyasn1 software.
#
# Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com>
# License: http://snmplabs.com/pyasn1/license.html
#
import sys
from pyasn1 import error
from pyasn1.type import tag
from pyasn1.type import tagmap
__all__ = ['NamedType', 'OptionalNamedType', 'DefaultedNamedType',... | --- +++ @@ -21,6 +21,21 @@
class NamedType(object):
+ """Create named field object for a constructed ASN.1 type.
+
+ The |NamedType| object represents a single name and ASN.1 type of a constructed ASN.1 type.
+
+ |NamedType| objects are immutable and duck-type Python :class:`tuple` objects
+ holding *na... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pyasn1/type/namedtype.py |
Write docstrings describing functionality | #-----------------------------------------------------------------
# pycparser: __init__.py
#
# This package file exports some convenience functions for
# interacting with pycparser
#
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#-----------------------------------------------------------------
__all... | --- +++ @@ -16,6 +16,19 @@
def preprocess_file(filename, cpp_path='cpp', cpp_args=''):
+ """ Preprocess a file using cpp.
+
+ filename:
+ Name of the file you want to preprocess.
+
+ cpp_path:
+ cpp_args:
+ Refer to the documentation of parse_file for the meaning of the... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pycparser/__init__.py |
Turn comments into proper docstrings | #-----------------------------------------------------------------
# _ast_gen.py
#
# Generates the AST Node classes from a specification given in
# a configuration file
#
# The design of this module was inspired by astgen.py from the
# Python 2.5 code-base.
#
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: ... | --- +++ @@ -16,11 +16,16 @@
class ASTCodeGenerator(object):
def __init__(self, cfg_filename='_c_ast.cfg'):
+ """ Initialize the code generator from a configuration
+ file.
+ """
self.cfg_filename = cfg_filename
self.node_cfg = [NodeCfg(name, contents)
for (... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pycparser/_ast_gen.py |
Create docstrings for each class method | import weakref
from pydispatch import saferef, robustapply, errors
class _Parameter:
def __repr__(self):
return self.__class__.__name__
class _Any(_Parameter):
Any = _Any()
class _Anonymous(_Parameter):
Anonymous = _Anonymous()
WEAKREF_TYPES = (weakref.ReferenceType, saferef.BoundMethodWeakref)
connect... | --- +++ @@ -1,14 +1,66 @@+"""Multiple-producer-multiple-consumer signal-dispatching
+
+dispatcher is the core of the PyDispatcher system,
+providing the primary API and the core logic for the
+system.
+
+Module attributes of note:
+
+ Any -- Singleton used to signal either "Any Sender" or
+ "Any Signal". See... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pydispatch/dispatcher.py |
Add docstrings with type hints explained | import sys
if sys.hexversion >= 0x3000000:
im_func = '__func__'
im_self = '__self__'
im_code = '__code__'
func_code = '__code__'
else:
im_func = 'im_func'
im_self = 'im_self'
im_code = 'im_code'
func_code = 'func_code'
def function( receiver ):
if hasattr(receiver, '__call__'):
... | --- +++ @@ -1,3 +1,10 @@+"""Robust apply mechanism
+
+Provides a function "call", which can sort out
+what arguments a given callable object can take,
+and subset the given arguments to match only
+those which are acceptable.
+"""
import sys
if sys.hexversion >= 0x3000000:
im_func = '__func__'
@@ -11,6 +18,13 @@... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pydispatch/robustapply.py |
Generate documentation strings for clarity | import weakref, traceback, sys
if sys.hexversion >= 0x3000000:
im_func = '__func__'
im_self = '__self__'
else:
im_func = 'im_func'
im_self = 'im_self'
def safeRef(target, onDelete = None):
if hasattr(target, im_self):
if getattr(target, im_self) is not None:
# Turn a bound metho... | --- +++ @@ -1,3 +1,4 @@+"""Refactored "safe reference" from dispatcher.py"""
import weakref, traceback, sys
if sys.hexversion >= 0x3000000:
@@ -7,6 +8,16 @@ im_func = 'im_func'
im_self = 'im_self'
def safeRef(target, onDelete = None):
+ """Return a *safe* weak reference to a callable target
+
+ targ... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pydispatch/saferef.py |
Write docstrings including parameters and return values | #------------------------------------------------------------------------------
# pycparser: c_lexer.py
#
# CLexer class: lexer for the C language
#
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#------------------------------------------------------------------------------
import re
import sys
from ... | --- +++ @@ -14,8 +14,32 @@
class CLexer(object):
+ """ A lexer for the C language. After building it, set the
+ input text with input(), and call token() to get new
+ tokens.
+
+ The public attribute filename can be set to an initial
+ filaneme, but the lexer will update it upon #line... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pycparser/c_lexer.py |
Add docstrings that explain logic | # Copyright 2017 MongoDB, Inc.
#
# 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 applicable law or agreed to in writing, s... | --- +++ @@ -12,6 +12,7 @@ # implied. See the License for the specific language governing
# permissions and limitations under the License.
+"""Watch changes on a collection, a database, or the entire cluster."""
import copy
@@ -40,6 +41,16 @@
class ChangeStream(object):
+ """The internal abstract base cl... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/change_stream.py |
Document this module using docstrings | # Copyright 2017 MongoDB, Inc.
#
# 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 applicable law or agreed to in writing, so... | --- +++ @@ -12,6 +12,87 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Logical sessions for ordering sequential operations.
+
+Requires MongoDB 3.6.
+
+.. versionadded:: 3.6
+
+Causally Consistent Reads
+=========================
+
+.. code-block:: pytho... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/client_session.py |
Replace inline comments with docstrings | #------------------------------------------------------------------------------
# pycparser: c_generator.py
#
# C code generator from pycparser AST nodes.
#
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#------------------------------------------------------------------------------
from . import c_ast... | --- +++ @@ -10,6 +10,10 @@
class CGenerator(object):
+ """ Uses the same visitor pattern as c_ast.NodeVisitor, but modified to
+ return a value from each visit method, using string accumulation in
+ generic_visit.
+ """
def __init__(self):
# Statements start with indentation of sel... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pycparser/c_generator.py |
Generate descriptive docstrings automatically | #------------------------------------------------------------------------------
# pycparser: c_parser.py
#
# CParser class: Parser and AST builder for the C language
#
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#------------------------------------------------------------------------------
import r... | --- +++ @@ -27,6 +27,55 @@ yacctab='pycparser.yacctab',
yacc_debug=False,
taboutputdir=''):
+ """ Create a new CParser.
+
+ Some arguments for controlling the debug/optimization
+ level of the parser are provided. The defaults are
+ tuned for... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pycparser/c_parser.py |
Write docstrings including parameters and return values | #------------------------------------------------------------------------------
# pycparser: ast_transforms.py
#
# Some utilities used by the parser to create a friendlier AST.
#
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#----------------------------------------------------------------------------... | --- +++ @@ -11,6 +11,56 @@
def fix_switch_cases(switch_node):
+ """ The 'case' statements in a 'switch' come out of parsing with one
+ child node, so subsequent statements are just tucked to the parent
+ Compound. Additionally, consecutive (fall-through) case statements
+ come out messy. Thi... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pycparser/ast_transforms.py |
Help me add docstrings to my project | # Copyright 2014-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wr... | --- +++ @@ -12,6 +12,7 @@ # implied. See the License for the specific language governing
# permissions and limitations under the License.
+"""Tools to parse mongo client options."""
from bson.codec_options import _parse_codec_options
from pymongo.auth import _build_credentials_tuple
@@ -30,6 +31,7 @@
def _p... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/client_options.py |
Generate docstrings for script automation | #-----------------------------------------------------------------
# ** ATTENTION **
# This code was automatically generated from the file:
# _c_ast.cfg
#
# Do not modify it directly. Modify the configuration file and
# run the generator again.
# ** ** *** ** **
#
# pycparser: c_ast.py
#
# AST Node classes.
#
# Eli Ben... | --- +++ @@ -19,6 +19,9 @@ import sys
def _repr(obj):
+ """
+ Get the representation of an object, with dedicated pprint-like format for lists.
+ """
if isinstance(obj, list):
return '[' + (',\n '.join((_repr(e).replace('\n', '\n ') for e in obj))) + '\n]'
else:
@@ -29,6 +32,8 @@ """ A... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pycparser/c_ast.py |
Create Google-style docstrings for my code | # Copyright 2016 MongoDB, Inc.
#
# 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 applicable law or agreed to in writing, so... | --- +++ @@ -12,11 +12,19 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Tools for working with `collations`_.
+
+.. _collations: http://userguide.icu-project.org/collation/concepts
+"""
from pymongo import common
class CollationStrength(object):
... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/collation.py |
Create documentation strings for testing functions | # Copyright 2014-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wri... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""CommandCursor class to iterate over command results."""
from collections import deque
@@ -26,11 +27,16 @@
class CommandCursor(object):
+ """A cursor / iterator over command... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/command_cursor.py |
Create Google-style docstrings for my code | # Copyright 2011-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wr... | --- +++ @@ -13,6 +13,7 @@ # permissions and limitations under the License.
+"""Functions and classes common to multiple pymongo modules."""
import datetime
import warnings
@@ -115,6 +116,7 @@
def partition_node(node):
+ """Split a host:port string into (host, int(port)) pair."""
host = node
por... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/common.py |
Improve my code by adding docstrings | # Copyright 2009-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wri... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Collection level utilities for Mongo."""
import datetime
import warnings
@@ -59,6 +60,10 @@
class ReturnDocument(object):
+ """An enum used with
+ :meth:`~pymongo.collect... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/collection.py |
Document classes and their methods | # Copyright 2014-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wri... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Parse a response to the 'ismaster' command."""
import itertools
@@ -21,6 +22,7 @@
def _get_server_type(doc):
+ """Determine the server type from an ismaster response."""
... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/ismaster.py |
Document all public functions with docstrings | #-----------------------------------------------------------------
# plyparser.py
#
# PLYParser class and other utilites for simplifying programming
# parsers with PLY
#
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#-----------------------------------------------------------------
import warnings
c... | --- +++ @@ -11,6 +11,11 @@ import warnings
class Coord(object):
+ """ Coordinates of a syntactic element. Consists of:
+ - File name
+ - Line number
+ - (optional) column number, for the Lexer
+ """
__slots__ = ('file', 'line', 'column', '__weakref__')
def __init__(se... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pycparser/plyparser.py |
Provide docstrings following PEP 257 | # Copyright 2009-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wri... | --- +++ @@ -12,6 +12,13 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Tools for creating `messages
+<http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol>`_ to be sent to
+MongoDB.
+
+.. note:: This module is for internal use and is generally not nee... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/message.py |
Add detailed docstrings explaining each function | # Copyright 2016 MongoDB, Inc.
#
# 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 applicable law or agreed to in writing, s... | --- +++ @@ -12,6 +12,20 @@ # implied. See the License for the specific language governing
# permissions and limitations under the License.
+"""Criteria to select ServerDescriptions based on maxStalenessSeconds.
+
+The Max Staleness Spec says: When there is a known primary P,
+a secondary S's staleness is estimated ... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/max_staleness_selectors.py |
Write docstrings for this repository | # Copyright 2015-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wri... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Internal network layer helper methods."""
import datetime
import errno
@@ -60,6 +61,35 @@ use_op_msg=False,
unacknowledged=False,
user_fields=... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/network.py |
Write docstrings for data processing functions | from pydispatch.dispatcher import Any, Anonymous, liveReceivers, getAllReceivers
from pydispatch.robustapply import robustApply
def sendRobust(
signal=Any,
sender=Anonymous,
*arguments, **named
):
# Call each receiver with whatever arguments it can accept.
# Return a list of tuple pairs [(receive... | --- +++ @@ -1,3 +1,4 @@+"""Module implementing error-catching version of send (sendRobust)"""
from pydispatch.dispatcher import Any, Anonymous, liveReceivers, getAllReceivers
from pydispatch.robustapply import robustApply
@@ -6,6 +7,37 @@ sender=Anonymous,
*arguments, **named
):
+ """Send signal from ... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pydispatch/robust.py |
Document classes and their methods |
class DispatcherError(Exception):
class DispatcherKeyError(KeyError, DispatcherError):
class DispatcherTypeError(TypeError, DispatcherError): | --- +++ @@ -1,4 +1,9 @@+"""Error types for dispatcher mechanism
+"""
class DispatcherError(Exception):
+ """Base class for all Dispatcher errors"""
class DispatcherKeyError(KeyError, DispatcherError):
-class DispatcherTypeError(TypeError, DispatcherError):+ """Error raised when unknown (sender,signal) set spe... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pydispatch/errors.py |
Can you add docstrings to this Python file? | # Copyright 2011-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wr... | --- +++ @@ -120,6 +120,7 @@ try:
from fcntl import fcntl, F_GETFD, F_SETFD, FD_CLOEXEC
def _set_non_inheritable_non_atomic(fd):
+ """Set the close-on-exec flag on the given file descriptor."""
flags = fcntl(fd, F_GETFD)
fcntl(fd, F_SETFD, flags | FD_CLOEXEC)
except ImportError:
@@ -1... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/pool.py |
Add return value explanations in docstrings | # Copyright 2014-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wr... | --- +++ @@ -12,6 +12,7 @@ # implied. See the License for the specific language governing
# permissions and limitations under the License.
+"""Run a target function on a background thread."""
import atexit
import threading
@@ -23,6 +24,17 @@
class PeriodicExecutor(object):
def __init__(self, interval, min... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/periodic_executor.py |
Add return value explanations in docstrings | # Copyright 2009-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wri... | --- +++ @@ -12,6 +12,20 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""DEPRECATED - A manager to handle when cursors are killed after they are
+closed.
+
+New cursor managers should be defined as subclasses of CursorManager and can be
+installed on a cli... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/cursor_manager.py |
Add docstrings that explain logic | # Copyright 2013-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wri... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Authentication helpers."""
import functools
import hashlib
@@ -100,6 +101,8 @@
def _build_credentials_tuple(mech, source, user, passwd, extra, database):
+ """Build and retu... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/auth.py |
Write documentation strings for class attributes | # Copyright 2019-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wr... | --- +++ @@ -12,6 +12,7 @@ # implied. See the License for the specific language governing
# permissions and limitations under the License.
+"""Perform aggregation operations on a collection or database."""
from bson.son import SON
@@ -22,6 +23,12 @@
class _AggregationCommand(object):
+ """The internal ab... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/aggregation.py |
Fully document this Python code with docstrings | # Copyright 2014-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wr... | --- +++ @@ -12,6 +12,7 @@ # implied. See the License for the specific language governing
# permissions and limitations under the License.
+"""A fake SSLContext implementation."""
try:
import ssl
@@ -20,6 +21,16 @@
class SSLContext(object):
+ """A fake SSLContext.
+
+ This implements an API similar... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/ssl_context.py |
Insert docstrings into my code | # Copyright 2015-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wri... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Operation class definitions."""
from pymongo.common import validate_boolean, validate_is_mapping, validate_list
from pymongo.collation import validate_collation_or_none
@@ -19,13 +... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/operations.py |
Add docstrings explaining edge cases | # Copyright 2014-2016 MongoDB, Inc.
#
# 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 applicable law or agreed to in writi... | --- +++ @@ -12,11 +12,13 @@ # implied. See the License for the specific language governing
# permissions and limitations under the License.
+"""Criteria to select some ServerDescriptions from a TopologyDescription."""
from pymongo.server_type import SERVER_TYPE
class Selection(object):
+ """Input or outp... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/server_selectors.py |
Add docstrings to improve readability | # Copyright 2014-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wr... | --- +++ @@ -12,6 +12,7 @@ # implied. See the License for the specific language governing
# permissions and limitations under the License.
+"""Communicate with one MongoDB server in a topology."""
from datetime import datetime
@@ -29,6 +30,7 @@ class Server(object):
def __init__(self, server_description, p... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/server.py |
Replace inline comments with docstrings | # Copyright 2014-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wri... | --- +++ @@ -12,6 +12,10 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""The bulk write operations interface.
+
+.. versionadded:: 2.7
+"""
import copy
from itertools import islice
@@ -57,21 +61,39 @@
class _Run(object):
+ """Represents a batch ... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/bulk.py |
Add inline docstrings for readability | # Copyright 2009-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wri... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Database level operations."""
import warnings
@@ -40,6 +41,8 @@
def _check_name(name):
+ """Check if a database name is valid.
+ """
if not name:
raise Inv... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/database.py |
Write documentation strings for class attributes | # Copyright 2019-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wri... | --- +++ @@ -12,6 +12,11 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Support for automatic client side encryption.
+
+**Support for client side encryption is in beta. Backwards-breaking changes
+may be made before the final release.**
+"""
import co... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/encryption_options.py |
Write clean docstrings for readability | # Copyright 2009-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wri... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Cursor class to iterate over Mongo query results."""
import copy
import warnings
@@ -81,6 +82,8 @@ # This has to be an old style class due to
# http://bugs.jython.org/issue1057
c... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/cursor.py |
Add inline docstrings for readability | # Copyright 2012-2015 MongoDB, Inc.
#
# 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 applicable law or agreed to in writin... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Utilities for multi-threading support."""
import threading
try:
@@ -74,6 +75,7 @@
class BoundedSemaphore(Semaphore):
+ """Semaphore that checks that # releases is <= # acqui... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/thread_util.py |
Can you add docstrings to this Python file? | # Copyright 2018-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wr... | --- +++ @@ -12,6 +12,7 @@ # implied. See the License for the specific language governing
# permissions and limitations under the License.
+"""Advanced options for MongoDB drivers implemented on top of PyMongo."""
from collections import namedtuple
@@ -19,6 +20,14 @@
class DriverInfo(namedtuple('DriverInfo'... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/driver_info.py |
Add return value explanations in docstrings | # Copyright 2019-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wri... | --- +++ @@ -12,6 +12,11 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Support for explicit client side encryption.
+
+**Support for client side encryption is in beta. Backwards-breaking changes
+may be made before the final release.**
+"""
import con... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/encryption.py |
Improve documentation using docstrings | # Copyright 2014-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wri... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Represent one server the driver is connected to."""
from bson import EPOCH_NAIVE
from pymongo.server_type import SERVER_TYPE
@@ -20,6 +21,14 @@
class ServerDescription(object):... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/server_description.py |
Add docstrings to improve code quality | # Copyright 2009-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wr... | --- +++ @@ -12,6 +12,24 @@ # implied. See the License for the specific language governing
# permissions and limitations under the License.
+"""Tools for connecting to MongoDB.
+
+.. seealso:: :doc:`/examples/high_availability` for examples of connecting
+ to replica sets or sets of mongos servers.
+
+To get a :cl... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/mongo_client.py |
Add standardized docstrings across the file | # Copyright 2009-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wri... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Exceptions raised by PyMongo."""
import sys
@@ -24,18 +25,25 @@
class PyMongoError(Exception):
+ """Base class for all PyMongo exceptions."""
def __init__(self, messag... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/errors.py |
Add docstrings for better understanding | # Copyright 2011-2015 MongoDB, Inc.
#
# 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 applicable law or agreed to in writi... | --- +++ @@ -12,6 +12,7 @@ # implied. See the License for the specific language governing
# permissions and limitations under the License.
+"""Deprecated. See :doc:`/examples/high_availability`."""
import warnings
@@ -19,6 +20,23 @@
class MongoReplicaSetClient(mongo_client.MongoClient):
+ """Deprecated a... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/mongo_replica_set_client.py |
Add docstrings to make code maintainable | # Copyright 2009-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wri... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Bits and pieces used by the driver that don't really fit elsewhere."""
import sys
import traceback
@@ -54,10 +55,15 @@
def _gen_index_name(keys):
+ """Generate an index name... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/helpers.py |
Auto-generate documentation strings for this file | # Copyright 2012-present MongoDB, Inc.
#
# 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 applicable law or agreed to in writ... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Utilities for choosing which member of a replica set to read from."""
from bson.py3compat import abc, integer_types
from pymongo import max_staleness_selectors
@@ -37,6 +38,8 @@
... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/read_preferences.py |
Add docstrings to incomplete code | # Copyright 2015 MongoDB, Inc.
#
# 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 applicable law or agreed to in writing, sof... | --- +++ @@ -12,11 +12,24 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Tools for working with read concerns."""
from bson.py3compat import string_type
class ReadConcern(object):
+ """ReadConcern
+
+ :Parameters:
+ - `level`: (string... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/read_concern.py |
Generate consistent documentation across files | import threading
import time as mod_time
import uuid
from redis.exceptions import LockError, LockNotOwnedError
from redis.utils import dummy
class Lock(object):
lua_release = None
lua_extend = None
lua_reacquire = None
# KEYS[1] - lock name
# ARGS[1] - token
# return 1 if the lock was releas... | --- +++ @@ -6,6 +6,13 @@
class Lock(object):
+ """
+ A shared, distributed Lock. Using Redis for locking allows the Lock
+ to be shared across processes and/or machines.
+
+ It's left to the user to resolve deadlock issues and make sure
+ multiple clients play nicely together.
+ """
lua_rel... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/redis/lock.py |
Insert docstrings into my code | import random
import weakref
from redis.client import Redis
from redis.connection import ConnectionPool, Connection
from redis.exceptions import (ConnectionError, ResponseError, ReadOnlyError,
TimeoutError)
from redis._compat import iteritems, nativestr, xrange
class MasterNotFoundError... | --- +++ @@ -66,6 +66,12 @@
class SentinelConnectionPool(ConnectionPool):
+ """
+ Sentinel backed connection pool.
+
+ If ``check_connection`` flag is set to True, SentinelManagedConnection
+ sends a PING command right after establishing the connection.
+ """
def __init__(self, service_name, se... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/redis/sentinel.py |
Add professional docstrings to my codebase | # Copyright 2014-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wr... | --- +++ @@ -12,6 +12,7 @@ # implied. See the License for the specific language governing
# permissions and limitations under the License.
+"""Class to monitor a MongoDB server on a background thread."""
import weakref
@@ -26,18 +27,29 @@
class MonitorBase(object):
def __init__(self, *args, **kwargs):
+ ... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/monitor.py |
Add standardized docstrings across the file | # Copyright 2014-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wri... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Represent a response from the server."""
class Response(object):
@@ -20,6 +21,15 @@
def __init__(self, data, address, request_id, duration, from_command,
d... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/response.py |
Write docstrings for data processing functions | # Copyright 2011-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wr... | --- +++ @@ -13,6 +13,7 @@ # permissions and limitations under the License.
+"""Tools to parse and validate a MongoDB URI."""
import re
import warnings
@@ -38,6 +39,19 @@
def parse_userinfo(userinfo):
+ """Validates the format of user information in a MongoDB URI.
+ Reserved characters like ':', '/', '... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/uri_parser.py |
Document all endpoints with docstrings |
class RedisError(Exception):
pass
class ConnectionError(RedisError):
pass
class TimeoutError(RedisError):
pass
class AuthenticationError(ConnectionError):
pass
class BusyLoadingError(ConnectionError):
pass
class InvalidResponse(RedisError):
pass
class ResponseError(RedisError):
... | --- +++ @@ -1,3 +1,4 @@+"Core exceptions raised by the Redis client"
class RedisError(Exception):
@@ -53,10 +54,12 @@
class LockError(RedisError, ValueError):
+ "Errors acquiring or releasing a lock"
# NOTE: For backwards compatability, this class derives from ValueError.
# This was originally cho... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/redis/exceptions.py |
Write docstrings for data processing functions | import os
import glob
import json
import struct
import sqlite3
from collections import deque
class FifoMemoryQueue(object):
def __init__(self):
self.q = deque()
self.push = self.q.append
def pop(self):
q = self.q
return q.popleft() if q else None
def close(self):
... | --- +++ @@ -7,6 +7,7 @@
class FifoMemoryQueue(object):
+ """In-memory FIFO queue, API compliant with FifoDiskQueue."""
def __init__(self):
self.q = deque()
@@ -24,6 +25,7 @@
class LifoMemoryQueue(FifoMemoryQueue):
+ """In-memory LIFO queue, API compliant with LifoDiskQueue."""
def p... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/queuelib/queue.py |
Write docstrings for backend logic | import errno
import socket
import sys
def sendall(sock, *args, **kwargs):
return sock.sendall(*args, **kwargs)
def shutdown(sock, *args, **kwargs):
return sock.shutdown(*args, **kwargs)
def ssl_wrap_socket(context, sock, *args, **kwargs):
return context.wrap_socket(sock, *args, **kwargs)
# For Pytho... | --- +++ @@ -1,3 +1,4 @@+"""Internal module for Python 2 backwards compatibility."""
import errno
import socket
import sys
@@ -82,6 +83,7 @@ from ssl import SSLError as _SSLError
except ImportError:
class _SSLError(Exception):
+ """A replacement in case ssl.SSLError is not available."... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/redis/_compat.py |
Add docstrings to improve readability | # Copyright 2015-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wr... | --- +++ @@ -12,6 +12,169 @@ # implied. See the License for the specific language governing
# permissions and limitations under the License.
+"""Tools to monitor driver events.
+
+.. versionadded:: 3.1
+
+Use :func:`register` to register global listeners for specific events.
+Listeners must inherit from one of the a... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/monitoring.py |
Generate consistent documentation across files | from contextlib import contextmanager
try:
import hiredis
HIREDIS_AVAILABLE = True
except ImportError:
HIREDIS_AVAILABLE = False
def from_url(url, db=None, **kwargs):
from redis.client import Redis
return Redis.from_url(url, db, **kwargs)
@contextmanager
def pipeline(redis_obj):
p = redis_... | --- +++ @@ -9,6 +9,12 @@
def from_url(url, db=None, **kwargs):
+ """
+ Returns an active Redis client generated from the given database URL.
+
+ Will attempt to extract the database id from the path url fragment, if
+ none is provided.
+ """
from redis.client import Redis
return Redis.from_... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/redis/utils.py |
Add docstrings to make code maintainable | from __future__ import unicode_literals
from distutils.version import StrictVersion
from itertools import chain
from time import time
import errno
import io
import os
import socket
import sys
import threading
import warnings
from redis._compat import (xrange, imap, byte_to_chr, unicode, long,
... | --- +++ @@ -91,6 +91,7 @@
class Encoder(object):
+ "Encode strings to bytes and decode bytes to strings"
def __init__(self, encoding, encoding_errors, decode_responses):
self.encoding = encoding
@@ -98,6 +99,7 @@ self.decode_responses = decode_responses
def encode(self, value):
+ ... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/redis/connection.py |
Create documentation strings for testing functions | from __future__ import unicode_literals
from itertools import chain
import datetime
import sys
import warnings
import time
import threading
import time as mod_time
import re
import hashlib
from redis._compat import (basestring, imap, iteritems, iterkeys,
itervalues, izip, long, nativestr, saf... | --- +++ @@ -47,6 +47,7 @@
def timestamp_to_datetime(response):
+ "Converts a unix timestamp to a Python datetime object"
if not response:
return None
try:
@@ -68,6 +69,7 @@
class CaseInsensitiveDict(dict):
+ "Case insensitive dict implementation. Assumes string keys only."
def __... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/redis/client.py |
Add docstrings following best practices | from __future__ import print_function
import os
import shutil
import string
from importlib import import_module
from os.path import join, dirname, abspath, exists, splitext
import scrapy
from scrapy.commands import ScrapyCommand
from scrapy.utils.template import render_templatefile, string_camelcase
from scrapy.excep... | --- +++ @@ -13,6 +13,10 @@
def sanitize_module_name(module_name):
+ """Sanitize the given module name, by replacing dashes and points
+ with underscores and prefixing it with a letter if it doesn't start
+ with one
+ """
module_name = module_name.replace('-', '_').replace('.', '_')
if module_n... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/commands/genspider.py |
Add minimal docstrings for each function | # Copyright 2014-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wr... | --- +++ @@ -12,6 +12,7 @@ # implied. See the License for the specific language governing
# permissions and limitations under the License.
+"""Represent a deployment of MongoDB servers."""
from collections import namedtuple
@@ -40,6 +41,17 @@ max_set_version,
max_election_id,
... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/topology_description.py |
Add detailed docstrings explaining each function | # Backport of the match_hostname logic from python 3.5, with small
# changes to support IP address matching on python 2.7 and 3.4.
import re
import sys
try:
# Python 3.4+, or the ipaddress module from pypi.
from ipaddress import ip_address
except ImportError:
ip_address = lambda address: None
# ipaddress... | --- +++ @@ -22,6 +22,10 @@
def _dnsname_match(dn, hostname, max_wildcards=1):
+ """Matching according to RFC 6125, section 6.4.3
+
+ http://tools.ietf.org/html/rfc6125#section-6.4.3
+ """
pats = []
if not dn:
return False
@@ -69,12 +73,24 @@
def _ipaddress_match(ipname, host_ip):
+ ... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/ssl_match_hostname.py |
Auto-generate documentation strings for this file | # Copyright 2015-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wri... | --- +++ @@ -12,11 +12,13 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Result class definitions."""
from pymongo.errors import InvalidOperation
class _WriteResult(object):
+ """Base class for write result classes."""
__slots__ = ("__ac... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/results.py |
Create simple docstrings for beginners | # Copyright 2016-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wri... | --- +++ @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""An implementation of RFC4013 SASLprep."""
from bson.py3compat import text_type as _text_type
@@ -20,6 +21,7 @@ except ImportError:
HAVE_STRINGPREP = False
def saslprep(d... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/saslprep.py |
Annotate my code with docstrings | # Copyright 2014-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wr... | --- +++ @@ -12,6 +12,7 @@ # implied. See the License for the specific language governing
# permissions and limitations under the License.
+"""Support for SSL in PyMongo."""
import atexit
import sys
@@ -53,6 +54,10 @@ from pymongo.ssl_context import SSLContext
def validate_cert_reqs(option, value)... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/ssl_support.py |
Include argument descriptions in docstrings | # Copyright 2014-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wr... | --- +++ @@ -12,6 +12,7 @@ # implied. See the License for the specific language governing
# permissions and limitations under the License.
+"""Represent MongoClient's configuration."""
import threading
@@ -37,6 +38,10 @@ heartbeat_frequency=common.HEARTBEAT_FREQUENCY,
server_s... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/settings.py |
Add docstrings to my Python code | # Copyright 2014-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wri... | --- +++ @@ -12,12 +12,39 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""Tools for working with write concerns."""
from bson.py3compat import integer_types, string_type
from pymongo.errors import ConfigurationError
class WriteConcern(object):
+ ... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/write_concern.py |
Generate missing documentation strings | from scrapy.item import BaseItem
from scrapy.http import Request
from scrapy.exceptions import ContractFail
from . import Contract
# contracts
class UrlContract(Contract):
name = 'url'
def adjust_request_args(self, args):
args['url'] = self.args[0]
return args
class ReturnsContract(Contra... | --- +++ @@ -7,6 +7,9 @@
# contracts
class UrlContract(Contract):
+ """ Contract to set the url of the request (mandatory)
+ @url http://scrapy.org
+ """
name = 'url'
@@ -16,6 +19,17 @@
class ReturnsContract(Contract):
+ """ Contract to check the output of a callback
+
+ general fo... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/contracts/default.py |
Add docstrings to clarify complex logic | # Copyright 2014-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wr... | --- +++ @@ -12,6 +12,7 @@ # implied. See the License for the specific language governing
# permissions and limitations under the License.
+"""Internal class to monitor a topology of one or more servers."""
import os
import random
@@ -63,6 +64,7 @@
class Topology(object):
+ """Monitor a topology of one or... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/topology.py |
Annotate my code with docstrings | import os
from optparse import OptionGroup
from twisted.python import failure
from scrapy.utils.conf import arglist_to_dict
from scrapy.exceptions import UsageError
class ScrapyCommand(object):
requires_project = False
crawler_process = None
# default settings to be used for this command instead of glo... | --- +++ @@ -1,3 +1,6 @@+"""
+Base class for Scrapy commands
+"""
import os
from optparse import OptionGroup
from twisted.python import failure
@@ -24,18 +27,35 @@ self._crawler = crawler
def syntax(self):
+ """
+ Command syntax (preferably one-line). Do not include command name.
+ ... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/commands/__init__.py |
Write docstrings for this repository | # Copyright 2009-present MongoDB, Inc.
#
# 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 applicable law or agreed to in wri... | --- +++ @@ -12,6 +12,26 @@ # See the License for the specific language governing permissions and
# limitations under the License.
+"""**DEPRECATED**: Manipulators that can edit SON objects as they enter and exit
+a database.
+
+The :class:`~pymongo.son_manipulator.SONManipulator` API has limitations as a
+technique ... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pymongo/son_manipulator.py |
Write Python docstrings for this snippet | # -*- coding: utf-8 -*-
from __future__ import absolute_import
import re
import logging
import six
from w3lib import html
from scrapy.exceptions import NotConfigured
from scrapy.http import HtmlResponse
logger = logging.getLogger(__name__)
class AjaxCrawlMiddleware(object):
def __init__(self, settings):
... | --- +++ @@ -14,6 +14,10 @@
class AjaxCrawlMiddleware(object):
+ """
+ Handle 'AJAX crawlable' pages marked as crawlable via meta tag.
+ For more info see https://developers.google.com/webmasters/ajax-crawling/docs/getting-started.
+ """
def __init__(self, settings):
if not settings.getbo... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/downloadermiddlewares/ajaxcrawl.py |
Generate docstrings with parameter types | from threading import Thread
from scrapy.commands import ScrapyCommand
from scrapy.shell import Shell
from scrapy.http import Request
from scrapy.utils.spider import spidercls_for_request, DefaultSpider
from scrapy.utils.url import guess_scheme
class Command(ScrapyCommand):
requires_project = False
default_... | --- +++ @@ -1,3 +1,8 @@+"""
+Scrapy Shell
+
+See documentation in docs/topics/shell.rst
+"""
from threading import Thread
from scrapy.commands import ScrapyCommand
@@ -36,6 +41,9 @@ default=False, help="do not handle HTTP 3xx status codes and print response as-is")
def update_vars(self, vars):
+ ... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/commands/shell.py |
Write docstrings for utility functions |
from w3lib.http import basic_auth_header
from scrapy import signals
class HttpAuthMiddleware(object):
@classmethod
def from_crawler(cls, crawler):
o = cls()
crawler.signals.connect(o.spider_opened, signal=signals.spider_opened)
return o
def spider_opened(self, spider):
... | --- +++ @@ -1,3 +1,8 @@+"""
+HTTP basic auth downloader middleware
+
+See documentation in docs/topics/downloader-middleware.rst
+"""
from w3lib.http import basic_auth_header
@@ -5,6 +10,8 @@
class HttpAuthMiddleware(object):
+ """Set Basic HTTP Authorization header
+ (http_user and http_pass spider clas... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/downloadermiddlewares/httpauth.py |
Add docstrings to my Python code | from OpenSSL import SSL
from twisted.internet.ssl import ClientContextFactory
from scrapy import twisted_version
if twisted_version >= (14, 0, 0):
from zope.interface.declarations import implementer
from twisted.internet.ssl import (optionsForClientTLS,
CertificateOptio... | --- +++ @@ -18,6 +18,15 @@
@implementer(IPolicyForHTTPS)
class ScrapyClientContextFactory(BrowserLikePolicyForHTTPS):
+ """
+ Non-peer-certificate verifying HTTPS context factory
+
+ Default OpenSSL method is TLS_METHOD (also called SSLv23_METHOD)
+ which allows TLS protocol negot... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/core/downloader/contextfactory.py |
Please document this code using docstrings |
import logging
from twisted.internet import defer
import six
from scrapy.exceptions import NotSupported, NotConfigured
from scrapy.utils.httpobj import urlparse_cached
from scrapy.utils.misc import load_object
from scrapy.utils.python import without_none_values
from scrapy import signals
logger = logging.getLogger(_... | --- +++ @@ -1,3 +1,4 @@+"""Download handlers for different schemes"""
import logging
from twisted.internet import defer
@@ -28,6 +29,9 @@ crawler.signals.connect(self._close, signals.engine_stopped)
def _get_handler(self, scheme):
+ """Lazy-load the downloadhandler for a scheme
+ only o... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/core/downloader/handlers/__init__.py |
Create docstrings for all classes and functions |
import bz2
import gzip
import zipfile
import tarfile
import logging
from tempfile import mktemp
import six
try:
from cStringIO import StringIO as BytesIO
except ImportError:
from io import BytesIO
from scrapy.responsetypes import responsetypes
logger = logging.getLogger(__name__)
class DecompressionMiddl... | --- +++ @@ -1,3 +1,6 @@+""" This module implements the DecompressionMiddleware which tries to recognise
+and extract the potentially compressed responses that may arrive.
+"""
import bz2
import gzip
@@ -19,6 +22,8 @@
class DecompressionMiddleware(object):
+ """ This middleware tries to recognise and extract ... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/downloadermiddlewares/decompression.py |
Auto-generate documentation strings for this file | from twisted.internet import reactor
from scrapy.utils.misc import load_object
from scrapy.utils.python import to_unicode
class HTTP10DownloadHandler(object):
lazy = False
def __init__(self, settings):
self.HTTPClientFactory = load_object(settings['DOWNLOADER_HTTPCLIENTFACTORY'])
self.ClientC... | --- +++ @@ -1,3 +1,5 @@+"""Download handlers for http and https schemes
+"""
from twisted.internet import reactor
from scrapy.utils.misc import load_object
from scrapy.utils.python import to_unicode
@@ -11,6 +13,7 @@ self.ClientContextFactory = load_object(settings['DOWNLOADER_CLIENTCONTEXTFACTORY'])
... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/core/downloader/handlers/http10.py |
Document all public functions with docstrings |
import re
import logging
from io import BytesIO
from time import time
import warnings
from six.moves.urllib.parse import urldefrag
from zope.interface import implementer
from twisted.internet import defer, reactor, protocol
from twisted.web.http_headers import Headers as TxHeaders
from twisted.web.iweb import IBodyPr... | --- +++ @@ -1,3 +1,4 @@+"""Download handlers for http and https schemes"""
import re
import logging
@@ -59,6 +60,7 @@ self._disconnect_timeout = 1
def download_request(self, request, spider):
+ """Return a deferred for the HTTP download"""
agent = ScrapyAgent(contextFactory=self._cont... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/core/downloader/handlers/http11.py |
Add docstrings that explain inputs and outputs | from time import time
from six.moves.urllib.parse import urlparse, urlunparse, urldefrag
from twisted.web.client import HTTPClientFactory
from twisted.web.http import HTTPClient
from twisted.internet import defer
from scrapy.http import Headers
from scrapy.utils.httpobj import urlparse_cached
from scrapy.utils.python... | --- +++ @@ -27,6 +27,11 @@
def _parse(url):
+ """ Return tuple of (scheme, netloc, host, port, path),
+ all in bytes except for port which is int.
+ Assume url is from Request.url, which was passed via safe_url_string
+ and is ascii-only.
+ """
url = url.strip()
parsed = urlparse(url)
... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/core/downloader/webclient.py |
Create simple docstrings for beginners | import logging
from time import time
from twisted.internet import defer, task
from twisted.python.failure import Failure
from scrapy import signals
from scrapy.core.scraper import Scraper
from scrapy.exceptions import DontCloseSpider
from scrapy.http import Response, Request
from scrapy.utils.misc import load_object
... | --- +++ @@ -1,3 +1,9 @@+"""
+This is the Scrapy engine which controls the Scheduler, Downloader and Spiders.
+
+For more information see docs/topics/architecture.rst
+
+"""
import logging
from time import time
@@ -66,6 +72,7 @@
@defer.inlineCallbacks
def start(self):
+ """Start the execution engin... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/core/engine.py |
Document helper functions with docstrings |
from scrapy import signals
class UserAgentMiddleware(object):
def __init__(self, user_agent='Scrapy'):
self.user_agent = user_agent
@classmethod
def from_crawler(cls, crawler):
o = cls(crawler.settings['USER_AGENT'])
crawler.signals.connect(o.spider_opened, signal=signals.spider... | --- +++ @@ -1,8 +1,10 @@+"""Set User-Agent header per spider or use a default value from settings"""
from scrapy import signals
class UserAgentMiddleware(object):
+ """This middleware allows spiders to override the user_agent"""
def __init__(self, user_agent='Scrapy'):
self.user_agent = user_... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/downloadermiddlewares/useragent.py |
Help me write clear docstrings | from six.moves.urllib.parse import unquote
from scrapy.exceptions import NotConfigured
from scrapy.utils.httpobj import urlparse_cached
from scrapy.utils.boto import is_botocore
from .http import HTTPDownloadHandler
def _get_boto_connection():
from boto.s3.connection import S3Connection
class _v19_S3Connect... | --- +++ @@ -10,10 +10,12 @@ from boto.s3.connection import S3Connection
class _v19_S3Connection(S3Connection):
+ """A dummy S3Connection wrapper that doesn't do any synchronous download"""
def _mexe(self, method, bucket, key, headers, *args, **kwargs):
return headers
class... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/core/downloader/handlers/s3.py |
Fill in missing docstrings in my code |
import csv
import io
import sys
import pprint
import marshal
import six
from six.moves import cPickle as pickle
from xml.sax.saxutils import XMLGenerator
from scrapy.utils.serialize import ScrapyJSONEncoder
from scrapy.utils.python import to_bytes, to_unicode, to_native_str, is_listlike
from scrapy.item import BaseIt... | --- +++ @@ -1,3 +1,6 @@+"""
+Item Exporters are used to export/serialize items into different formats.
+"""
import csv
import io
@@ -26,6 +29,10 @@ self._configure(kwargs)
def _configure(self, options, dont_fail=False):
+ """Configure the exporter by poping options from the ``options`` dict.
+... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/exporters.py |
Document classes and their methods | import os
import json
import logging
import warnings
from os.path import join, exists
from queuelib import PriorityQueue
from scrapy.utils.misc import load_object, create_instance
from scrapy.utils.job import job_dir
from scrapy.utils.deprecate import ScrapyDeprecationWarning
logger = logging.getLogger(__name__)
... | --- +++ @@ -15,6 +15,30 @@
class Scheduler(object):
+ """
+ Scrapy Scheduler. It allows to enqueue requests and then get
+ a next request to download. Scheduler is also handling duplication
+ filtering, via dupefilter.
+
+ Prioritization and queueing is not performed by the Scheduler.
+ User sets ... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/core/scheduler.py |
Write docstrings including parameters and return values |
# Internal
class NotConfigured(Exception):
pass
class _InvalidOutput(TypeError):
pass
# HTTP and crawling
class IgnoreRequest(Exception):
class DontCloseSpider(Exception):
pass
class CloseSpider(Exception):
def __init__(self, reason='cancelled'):
super(CloseSpider, self).__init__()
... | --- +++ @@ -1,20 +1,34 @@+"""
+Scrapy core exceptions
+
+These exceptions are documented in docs/topics/exceptions.rst. Please don't add
+new exceptions here without documenting them there.
+"""
# Internal
class NotConfigured(Exception):
+ """Indicates a missing configuration situation"""
pass
class _I... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/exceptions.py |
Document classes and their methods | from zope.interface import Interface
class ISpiderLoader(Interface):
def from_settings(settings):
def load(spider_name):
def list():
def find_by_request(request):
| --- +++ @@ -3,9 +3,16 @@ class ISpiderLoader(Interface):
def from_settings(settings):
+ """Return an instance of the class for the given settings"""
def load(spider_name):
+ """Return the Spider class for the given spider name. If the spider
+ name is not found, it must raise a KeyErr... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/interfaces.py |
Add docstrings for production code | import sys
import socket
import logging
from pprint import pformat
from importlib import import_module
from twisted.internet import task
from scrapy import signals
from scrapy.exceptions import NotConfigured
from scrapy.mail import MailSender
from scrapy.utils.engine import get_engine_status
logger = logging.getLogg... | --- +++ @@ -1,3 +1,8 @@+"""
+MemoryUsage extension
+
+See documentation in docs/topics/extensions.rst
+"""
import sys
import socket
import logging
@@ -104,6 +109,7 @@ self.warned = True
def _send_report(self, rcpts, subject):
+ """send notification mail with some additional useful info"""
... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/extensions/memusage.py |
Add docstrings to meet PEP guidelines | try:
from collections import ChainMap
except ImportError:
from scrapy.utils.datatypes import MergeDict as ChainMap
from scrapy.utils.misc import arg_to_iter
from scrapy.loader.common import wrap_loader_context
class MapCompose(object):
def __init__(self, *functions, **default_loader_context):
se... | --- +++ @@ -1,3 +1,8 @@+"""
+This module provides some commonly used processors for Item Loaders.
+
+See documentation in docs/topics/loaders.rst
+"""
try:
from collections import ChainMap
except ImportError:
@@ -74,12 +79,22 @@
class SelectJmes(object):
+ """
+ Query the input string for the jmesp... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/loader/processors.py |
Add docstrings to incomplete code | import six
from six.moves.urllib.parse import urljoin
import warnings
from sgmllib import SGMLParser
from w3lib.url import safe_url_string, canonicalize_url
from w3lib.html import strip_html5_whitespace
from scrapy.link import Link
from scrapy.linkextractors import FilteringLinkExtractor
from scrapy.utils.misc import... | --- +++ @@ -1,3 +1,6 @@+"""
+SGMLParser-based Link extractors
+"""
import six
from six.moves.urllib.parse import urljoin
import warnings
@@ -37,6 +40,7 @@ keep_fragments=True)
def _extract_links(self, response_text, response_url, response_encoding, bas... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/linkextractors/sgml.py |
Help me write clear docstrings | import functools
import hashlib
import os
import os.path
import time
import logging
from email.utils import parsedate_tz, mktime_tz
from six.moves.urllib.parse import urlparse
from collections import defaultdict
import six
try:
from cStringIO import StringIO as BytesIO
except ImportError:
from io import BytesI... | --- +++ @@ -1,3 +1,8 @@+"""
+Files Pipeline
+
+See documentation in topics/media-pipeline.rst
+"""
import functools
import hashlib
import os
@@ -31,6 +36,7 @@
class FileException(Exception):
+ """General media error exception"""
class FSFilesStore(object):
@@ -138,6 +144,7 @@ return threads.d... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/pipelines/files.py |
Write docstrings that follow conventions | import six
from six.moves.urllib.parse import urljoin
import lxml.etree as etree
from w3lib.html import strip_html5_whitespace
from w3lib.url import canonicalize_url
from scrapy.link import Link
from scrapy.utils.misc import arg_to_iter, rel_has_nofollow
from scrapy.utils.python import unique as unique_list, to_nativ... | --- +++ @@ -1,3 +1,6 @@+"""
+Link extractor based on lxml.html
+"""
import six
from six.moves.urllib.parse import urljoin
@@ -77,6 +80,10 @@ return self._extract_links(response.selector, response.url, response.encoding, base_url)
def _process_links(self, links):
+ """ Normalize and filter extr... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/linkextractors/lxmlhtml.py |
Add docstrings that explain purpose and usage | from six.moves.urllib.parse import urljoin
from scrapy.http.request import Request
from scrapy.http.headers import Headers
from scrapy.link import Link
from scrapy.utils.trackref import object_ref
from scrapy.http.common import obsolete_setter
from scrapy.exceptions import NotSupported
class Response(object_ref):
... | --- +++ @@ -1,3 +1,9 @@+"""
+This module implements the Response class which is used to represent HTTP
+responses in Scrapy.
+
+See documentation in docs/topics/request-response.rst
+"""
from six.moves.urllib.parse import urljoin
from scrapy.http.request import Request
@@ -62,31 +68,56 @@ __repr__ = __str__
... | https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/scrapy/http/response/__init__.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.