instruction
stringclasses
100 values
code
stringlengths
78
193k
response
stringlengths
259
170k
file
stringlengths
59
203
Write docstrings for algorithm functions
# This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. from __future__ import absolute_import, division, print_function import abc import six from cryptography import utils from cryptography....
--- +++ @@ -19,28 +19,49 @@ class HashAlgorithm(object): @abc.abstractproperty def name(self): + """ + A string naming this algorithm (e.g. "sha256", "md5"). + """ @abc.abstractproperty def digest_size(self): + """ + The size of the resulting digest in bytes. + ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/cryptography/hazmat/primitives/hashes.py
Create documentation strings for testing functions
# This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. from __future__ import absolute_import, division, print_function import abc try: # Only available in math in 3.5+ from math import...
--- +++ @@ -22,48 +22,87 @@ class RSAPrivateKey(object): @abc.abstractmethod def signer(self, padding, algorithm): + """ + Returns an AsymmetricSignatureContext used for signing data. + """ @abc.abstractmethod def decrypt(self, ciphertext, padding): + """ + Decry...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/cryptography/hazmat/primitives/asymmetric/rsa.py
Generate documentation strings for clarity
# This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. from __future__ import absolute_import, division, print_function import abc import six from cryptography.exceptions import UnsupportedAl...
--- +++ @@ -26,6 +26,9 @@ @abc.abstractmethod def public_bytes(self, encoding=None, format=None): + """ + The serialized bytes of the public key. + """ @six.add_metaclass(abc.ABCMeta) @@ -53,9 +56,18 @@ @abc.abstractmethod def public_key(self): + """ + The s...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/cryptography/hazmat/primitives/asymmetric/x25519.py
Generate consistent documentation across files
# This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. from __future__ import absolute_import, division, print_function from enum import Enum import six from cryptography import utils from cr...
--- +++ @@ -52,6 +52,7 @@ def _escape_dn_value(val): + """Escape special characters in RFC4514 Distinguished Name value.""" # See https://tools.ietf.org/html/rfc4514#section-2.4 val = val.replace('\\', '\\\\') @@ -115,6 +116,12 @@ value = utils.read_only_property("_value") def rfc4514_stri...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/cryptography/x509/name.py
Add detailed documentation for each class
# This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. from __future__ import absolute_import, division, print_function import abc import six @six.add_metaclass(abc.ABCMeta) class KeyDerivat...
--- +++ @@ -13,6 +13,14 @@ class KeyDerivationFunction(object): @abc.abstractmethod def derive(self, key_material): + """ + Deterministically generates and returns a new key based on the existing + key material. + """ @abc.abstractmethod - def verify(self, key_material, e...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/cryptography/hazmat/primitives/kdf/__init__.py
Add docstrings to my Python code
# This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. from __future__ import absolute_import, division, print_function import abc import six from cryptography import utils from cryptography....
--- +++ @@ -21,45 +21,76 @@ class CipherAlgorithm(object): @abc.abstractproperty def name(self): + """ + A string naming this mode (e.g. "AES", "Camellia"). + """ @abc.abstractproperty def key_size(self): + """ + The size of the key being used as an integer in bi...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/cryptography/hazmat/primitives/ciphers/base.py
Document all public functions with docstrings
# This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. from __future__ import absolute_import, division, print_function import base64 import struct import six from cryptography import utils f...
--- +++ @@ -114,6 +114,11 @@ def _ssh_read_next_string(data): + """ + Retrieves the next RFC 4251 string value from the data. + + While the RFC calls these strings, in Python they are bytes objects. + """ if len(data) < 4: raise ValueError("Key is not in the proper format") @@ -125,6 +13...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/cryptography/hazmat/primitives/serialization/ssh.py
Add docstrings to clarify complex logic
# -*- coding: utf-8 -*- import sys import re from cssselect.parser import parse, parse_series, SelectorError if sys.version_info[0] < 3: _basestring = basestring _unicode = unicode else: _basestring = str _unicode = str def _unicode_safe_getattr(obj, name, default=None): # getattr() with a non...
--- +++ @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +""" + cssselect.xpath + =============== + + Translation of parsed CSS selectors to XPath expressions. + + + :copyright: (c) 2007-2012 Ian Bicking and contributors. + See AUTHORS for more details. + :license: BSD, see LICENSE for more detail...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/cssselect/xpath.py
Add docstrings to improve collaboration
# Copyright 2009-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,17 +12,22 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Exceptions raised by the :mod:`gridfs` package""" from pymongo.errors import PyMongoError class GridFSError(PyMongoError): + """Base class for all GridFS exceptions.""" ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/gridfs/errors.py
Generate helpful docstrings for debugging
# This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. from __future__ import absolute_import, division, print_function import abc import six from cryptography import utils @six.add_metacla...
--- +++ @@ -15,33 +15,52 @@ class Mode(object): @abc.abstractproperty def name(self): + """ + A string naming this mode (e.g. "ECB", "CBC"). + """ @abc.abstractmethod def validate_for_algorithm(self, algorithm): + """ + Checks that all the necessary invariants of...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/cryptography/hazmat/primitives/ciphers/modes.py
Document helper functions with docstrings
# -*- coding: utf-8 -*- import sys import re import operator if sys.version_info[0] < 3: _unicode = unicode _unichr = unichr else: _unicode = str _unichr = chr def ascii_lower(string): return string.encode('utf8').lower().decode('utf8') class SelectorError(Exception): class SelectorSyntaxErr...
--- +++ @@ -1,4 +1,16 @@ # -*- coding: utf-8 -*- +""" + cssselect.parser + ================ + + Tokenizer, parser and parsed objects for CSS selectors. + + + :copyright: (c) 2007-2012 Ian Bicking and contributors. + See AUTHORS for more details. + :license: BSD, see LICENSE for more detail...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/cssselect/parser.py
Add docstrings explaining edge cases
# This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. from __future__ import absolute_import, division, print_function import abc import six from cryptography import utils def generate_par...
--- +++ @@ -119,12 +119,21 @@ class DHParameters(object): @abc.abstractmethod def generate_private_key(self): + """ + Generates and returns a DHPrivateKey. + """ @abc.abstractmethod def parameter_bytes(self, encoding, format): + """ + Returns the parameters seria...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/cryptography/hazmat/primitives/asymmetric/dh.py
Create documentation strings for testing functions
# This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. from __future__ import absolute_import, division, print_function import abc import warnings import six from cryptography import utils fr...
--- +++ @@ -39,66 +39,118 @@ class EllipticCurve(object): @abc.abstractproperty def name(self): + """ + The name of the curve. e.g. secp256r1. + """ @abc.abstractproperty def key_size(self): + """ + Bit size of a secret scalar for the curve. + """ @si...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/cryptography/hazmat/primitives/asymmetric/ec.py
Include argument descriptions in docstrings
# This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. from __future__ import absolute_import, division, print_function import abc import six @six.add_metaclass(abc.ABCMeta) class Asymmetric...
--- +++ @@ -13,15 +13,28 @@ class AsymmetricSignatureContext(object): @abc.abstractmethod def update(self, data): + """ + Processes the provided bytes and returns nothing. + """ @abc.abstractmethod def finalize(self): + """ + Returns the signature as bytes. + ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/cryptography/hazmat/primitives/asymmetric/__init__.py
Document this code for team use
# This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. from __future__ import absolute_import, division, print_function import abc import datetime from enum import Enum import six from crypto...
--- +++ @@ -272,77 +272,158 @@ class OCSPRequest(object): @abc.abstractproperty def issuer_key_hash(self): + """ + The hash of the issuer public key + """ @abc.abstractproperty def issuer_name_hash(self): + """ + The hash of the issuer name + """ @a...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/cryptography/x509/ocsp.py
Write docstrings that follow conventions
# This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. from __future__ import absolute_import, division, print_function import abc import six from cryptography import utils from cryptography....
--- +++ @@ -17,9 +17,15 @@ class PaddingContext(object): @abc.abstractmethod def update(self, data): + """ + Pads the provided bytes and returns any available data as bytes. + """ @abc.abstractmethod def finalize(self): + """ + Finalize the padding, returns bytes...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/cryptography/hazmat/primitives/padding.py
Create documentation for each function signature
from __future__ import absolute_import __author__ = "Jon Reid" __copyright__ = "Copyright 2011 hamcrest.org" __license__ = "BSD, see License.txt" import warnings import six from hamcrest.core.description import Description from hamcrest.core.selfdescribingvalue import SelfDescribingValue from hamcrest.core.helpers.ha...
--- +++ @@ -11,6 +11,10 @@ from hamcrest.core.helpers.hasmethod import hasmethod class BaseDescription(Description): + """Base class for all :py:class:`~hamcrest.core.description.Description` + implementations. + + """ def append_text(self, text): self.append(text) @@ -65,6 +69,7 @@ ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/hamcrest/core/base_description.py
Generate docstrings with parameter types
# This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. from __future__ import absolute_import, division, print_function import abc from enum import Enum import six class LogEntryType(Enum): ...
--- +++ @@ -23,12 +23,24 @@ class SignedCertificateTimestamp(object): @abc.abstractproperty def version(self): + """ + Returns the SCT version. + """ @abc.abstractproperty def log_id(self): + """ + Returns an identifier indicating which log this SCT is for. + ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/cryptography/x509/certificate_transparency.py
Fully document this Python code with 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. +"""Tools for representing files stored in GridFS.""" import datetime import hashlib import io @@ -56,6 +57,7 @@ def _grid_in_property(field_name, docstring, read_only=False, ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/gridfs/grid_file.py
Write docstrings including parameters and return values
# This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. from __future__ import absolute_import, division, print_function import abc import datetime import os from enum import Enum import six f...
--- +++ @@ -30,6 +30,11 @@ def _convert_to_naive_utc_time(time): + """Normalizes a datetime to a naive datetime in UTC. + + time -- datetime to normalize. Assumed to be in UTC if not timezone + aware. + """ if time.tzinfo is not None: offset = time.utcoffset() offset = off...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/cryptography/x509/base.py
Generate descriptive docstrings automatically
# 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. +"""GridFS is a specification for storing large objects in Mongo. + +The :mod:`gridfs` package is an implementation of GridFS on top of +:mod:`pymongo`, exposing a file-like interface. + ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/gridfs/__init__.py
Write docstrings describing functionality
# This file is dual licensed under the terms of the Apache License, Version # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. from __future__ import absolute_import, division, print_function import abc import six from cryptography.exceptions import UnsupportedAl...
--- +++ @@ -30,9 +30,15 @@ @abc.abstractmethod def public_bytes(self, encoding, format): + """ + The serialized bytes of the public key. + """ @abc.abstractmethod def verify(self, signature, data): + """ + Verify the signature. + """ @six.add_metacla...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/cryptography/hazmat/primitives/asymmetric/ed25519.py
Fully document this Python code with docstrings
from __future__ import absolute_import __author__ = "Jon Reid" __copyright__ = "Copyright 2011 hamcrest.org" __license__ = "BSD, see License.txt" from hamcrest.core.base_matcher import BaseMatcher, Matcher from hamcrest.core.helpers.wrap_matcher import wrap_matcher, is_matchable_type from .isequal import equal_to from...
--- +++ @@ -29,7 +29,29 @@ def is_not(match): + """Inverts the given matcher to its logical negation. + + :param match: The matcher to negate. + + This matcher compares the evaluated object to the negation of the given + matcher. If the ``match`` argument is not a matcher, it is implicitly + wrapped ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/hamcrest/core/core/isnot.py
Fill in missing docstrings in my code
from weakref import ref import re import sys from hamcrest.core.base_matcher import BaseMatcher from hamcrest.core.compat import is_callable __author__ = "Per Fagrell" __copyright__ = "Copyright 2013 hamcrest.org" __license__ = "BSD, see License.txt" class Raises(BaseMatcher): def __init__(self, expected, patter...
--- +++ @@ -60,6 +60,21 @@ def raises(exception, pattern=None): + """Matches if the called function raised the expected exception. + + :param exception: The class of the expected exception + :param pattern: Optional regular expression to match exception message. + + Expects the actual to be wrapped ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/hamcrest/core/core/raises.py
Add detailed documentation for each class
import six from hamcrest.core.base_matcher import BaseMatcher from math import fabs __author__ = "Jon Reid" __copyright__ = "Copyright 2011 hamcrest.org" __license__ = "BSD, see License.txt" def isnumeric(value): if isinstance(value, (float, complex) + six.integer_types): return True try: _ ...
--- +++ @@ -8,6 +8,8 @@ def isnumeric(value): + """Confirm that 'value' can be treated numerically; duck-test accordingly + """ if isinstance(value, (float, complex) + six.integer_types): return True @@ -54,4 +56,19 @@ def close_to(value, delta): - return IsCloseTo(value, delta)+ """...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/hamcrest/library/number/iscloseto.py
Add docstrings with type hints explained
__author__ = "Jon Reid" __copyright__ = "Copyright 2011 hamcrest.org" __license__ = "BSD, see License.txt" class Description(object): def append_text(self, text): raise NotImplementedError('append_text') def append_description_of(self, value): raise NotImplementedError('append_description_of...
--- +++ @@ -4,15 +4,55 @@ class Description(object): + """A description of a :py:class:`~hamcrest.core.matcher.Matcher`. + + A :py:class:`~hamcrest.core.matcher.Matcher` will describe itself to a + description which can later be used for reporting. + + """ def append_text(self, text): + ""...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/hamcrest/core/description.py
Add docstrings to make code maintainable
__author__ = "Jon Reid" __copyright__ = "Copyright 2011 hamcrest.org" __license__ = "BSD, see License.txt" class SelfDescribing(object): def describe_to(self, description): raise NotImplementedError('describe_to')
--- +++ @@ -4,6 +4,15 @@ class SelfDescribing(object): + """The ability of an object to describe itself.""" def describe_to(self, description): - raise NotImplementedError('describe_to')+ """Generates a description of the object. + + The description may be part of a description of a l...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/hamcrest/core/selfdescribing.py
Add well-formatted docstrings
from hamcrest.core.selfdescribing import SelfDescribing import warnings __author__ = "Jon Reid" __copyright__ = "Copyright 2011 hamcrest.org" __license__ = "BSD, see License.txt" class SelfDescribingValue(SelfDescribing): def __init__(self, value): warnings.warn('SelfDescribingValue no longer needed', ...
--- +++ @@ -8,6 +8,14 @@ class SelfDescribingValue(SelfDescribing): + """Wrap any value in a ``SelfDescribingValue`` to satisfy the + :py:class:`~hamcrest.core.selfdescribing.SelfDescribing` interface. + + **Deprecated:** No need for this class now that + :py:meth:`~hamcrest.core.description.Description...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/hamcrest/core/selfdescribingvalue.py
Write docstrings for backend logic
from . import idnadata import bisect import unicodedata import re import sys from .intranges import intranges_contain _virama_combining_class = 9 _alabel_prefix = b'xn--' _unicode_dots_re = re.compile(u'[\u002e\u3002\uff0e\uff61]') if sys.version_info[0] == 3: unicode = str unichr = chr class IDNAError(Unico...
--- +++ @@ -14,18 +14,22 @@ unichr = chr class IDNAError(UnicodeError): + """ Base exception for all IDNA-encoding related problems """ pass class IDNABidiError(IDNAError): + """ Exception when bidirectional requirements are not satisfied """ pass class InvalidCodepoint(IDNAError): + ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/idna/core.py
Add docstrings to improve readability
__author__ = "Jon Reid" __copyright__ = "Copyright 2011 hamcrest.org" __license__ = "BSD, see License.txt" from hamcrest.core.base_matcher import BaseMatcher from hamcrest.core.core.allof import all_of from hamcrest.core.helpers.hasmethod import hasmethod from hamcrest.core.helpers.wrap_matcher import wrap_matcher c...
--- +++ @@ -51,11 +51,39 @@ def has_item(match): + """Matches if any element of sequence satisfies a given matcher. + + :param match: The matcher to satisfy, or an expected value for + :py:func:`~hamcrest.core.core.isequal.equal_to` matching. + + This matcher iterates the evaluated sequence, searchi...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/hamcrest/library/collection/issequence_containing.py
Add docstrings to meet PEP guidelines
from hamcrest.core.base_matcher import BaseMatcher import operator __author__ = "Jon Reid" __copyright__ = "Copyright 2011 hamcrest.org" __license__ = "BSD, see License.txt" class OrderingComparison(BaseMatcher): def __init__(self, value, comparison_function, comparison_description): self.value = value ...
--- +++ @@ -24,16 +24,36 @@ def greater_than(value): + """Matches if object is greater than a given value. + + :param value: The value to compare against. + + """ return OrderingComparison(value, operator.gt, 'greater than') def greater_than_or_equal_to(value): + """Matches if object is greate...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/hamcrest/library/number/ordering_comparison.py
Write docstrings for backend logic
from __future__ import absolute_import from .selfdescribing import SelfDescribing __author__ = "Jon Reid" __copyright__ = "Copyright 2011 hamcrest.org" __license__ = "BSD, see License.txt" class Matcher(SelfDescribing): def matches(self, item, mismatch_description=None): raise NotImplementedError('match...
--- +++ @@ -7,9 +7,46 @@ class Matcher(SelfDescribing): + """A matcher over acceptable values. + + A matcher is able to describe itself to give feedback when it fails. + + Matcher implementations should *not* directly implement this protocol. + Instead, *extend* the :py:class:`~hamcrest.core.base_matche...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/hamcrest/core/matcher.py
Add docstrings to existing functions
from hamcrest.core.base_matcher import BaseMatcher from hamcrest.core.helpers.hasmethod import hasmethod from hamcrest.core.helpers.wrap_matcher import wrap_matcher __author__ = "Jon Reid" __copyright__ = "Copyright 2011 hamcrest.org" __license__ = "BSD, see License.txt" class IsDictContainingEntries(BaseMatcher): ...
--- +++ @@ -51,6 +51,7 @@ self.matches(item, mismatch_description) def describe_keyvalue(self, index, value, description): + """Describes key-value pair at given index.""" description.append_description_of(index) \ .append_text(': ') ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/hamcrest/library/collection/isdict_containingentries.py
Fully document this Python code with docstrings
# Copyright (c) 2004 Ian Bicking. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the fo...
--- +++ @@ -28,6 +28,8 @@ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +"""The ``lxml.html`` tool set for HTML handling. +""" from __future__ import absolute_import @@ -109,6 +111,8 @@ def _transform_result(typ, result): ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/lxml/html/__init__.py
Add minimal docstrings for each function
# -*- coding: utf-8 -*- import re import sys import string import socket from unicodedata import normalize try: from socket import inet_pton except ImportError: inet_pton = None # defined below try: from collections.abc import Mapping except ImportError: # Python 2 from collections import Mapping # ...
--- +++ @@ -1,4 +1,19 @@ # -*- coding: utf-8 -*- +u"""Hyperlink provides Pythonic URL parsing, construction, and rendering. + +Usage is straightforward:: + + >>> from hyperlink import URL + >>> url = URL.from_text(u'http://github.com/mahmoud/hyperlink?utm_source=docs') + >>> url.host + u'github.com' + >>> sec...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/hyperlink/_url.py
Can you add docstrings to this Python file?
import sys import os.path from lxml import etree as _etree # due to validator __init__ signature # some compat stuff, borrowed from lxml.html try: unicode except NameError: # Python 3 unicode = str try: basestring except NameError: # Python 3 basestring = str __all__ = ['extract_xsd', 'extr...
--- +++ @@ -1,3 +1,6 @@+"""The ``lxml.isoschematron`` package implements ISO Schematron support on top +of the pure-xslt 'skeleton' implementation. +""" import sys import os.path @@ -65,6 +68,20 @@ def stylesheet_params(**kwargs): + """Convert keyword args to a dictionary of stylesheet parameters. + XSL s...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/lxml/isoschematron/__init__.py
Document all endpoints with docstrings
# cython: language_level=3 from __future__ import absolute_import import difflib from lxml import etree from lxml.html import fragment_fromstring import re __all__ = ['html_annotate', 'htmldiff'] try: from html import escape as html_escape except ImportError: from cgi import escape as html_escape try: _...
--- +++ @@ -33,6 +33,26 @@ html_escape(_unicode(version), 1), text) def html_annotate(doclist, markup=default_markup): + """ + doclist should be ordered from oldest to newest, like:: + + >>> version1 = 'Hello World' + >>> version2 = 'Goodbye World' + >>> print(html_annotate([(versi...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/lxml/html/diff.py
Auto-generate documentation strings for this file
from __future__ import absolute_import import codecs import six from .base_description import BaseDescription __author__ = "Jon Reid" __copyright__ = "Copyright 2011 hamcrest.org" __license__ = "BSD, see License.txt" def tostring(selfdescribing): return str(StringDescription().append_description_of(selfdescrib...
--- +++ @@ -11,16 +11,28 @@ def tostring(selfdescribing): + """Returns the description of a + :py:class:`~hamcrest.core.selfdescribing.SelfDescribing` object as a + string. + + :param selfdescribing: The object to be described. + :returns: The description of the object. + """ return str(Strin...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/hamcrest/core/string_description.py
Generate documentation strings for clarity
from hamcrest.core.base_matcher import BaseMatcher from hamcrest.core import anything from hamcrest.core.core.allof import all_of from hamcrest.core.string_description import StringDescription from hamcrest.core.helpers.hasmethod import hasmethod from hamcrest.core.helpers.wrap_matcher import wrap_matcher as wrap_short...
--- +++ @@ -55,6 +55,31 @@ def has_property(name, match=None): + """Matches if object has a property with a given name whose value satisfies + a given matcher. + + :param name: The name of the property. + :param match: Optional matcher to satisfy. + + This matcher determines if the evaluated object h...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/hamcrest/library/object/hasproperty.py
Help me document legacy Python code
import bisect def intranges_from_list(list_): sorted_list = sorted(list_) ranges = [] last_write = -1 for i in range(len(sorted_list)): if i+1 < len(sorted_list): if sorted_list[i] == sorted_list[i+1]-1: continue current_range = sorted_list[last_write+1:i+1...
--- +++ @@ -1,7 +1,19 @@+""" +Given a list of integers, made up of (hopefully) a small number of long runs +of consecutive integers, compute a representation of the form +((start1, end1), (start2, end2) ...). Then answer the question "was x present +in the original list?" in time O(log(# runs)). +""" import bisect ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/idna/intranges.py
Document all endpoints with docstrings
import re from lxml import etree from six import string_types from w3lib.html import HTML5_WHITESPACE regex = '[{}]+'.format(HTML5_WHITESPACE) replace_html5_whitespaces = re.compile(regex).sub def set_xpathfunc(fname, func): ns_fns = etree.FunctionNamespace(None) if func is not None: ns_fns[fname] ...
--- +++ @@ -10,6 +10,19 @@ def set_xpathfunc(fname, func): + """Register a custom extension function to use in XPath expressions. + + The function ``func`` registered under ``fname`` identifier will be called + for every matching node, being passed a ``context`` parameter as well as + any parameters pas...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/parsel/xpathfuncs.py
Annotate my code with docstrings
import six if six.PY2: from functools32 import lru_cache else: from functools import lru_cache from cssselect import GenericTranslator as OriginalGenericTranslator from cssselect import HTMLTranslator as OriginalHTMLTranslator from cssselect.xpath import XPathExpr as OriginalXPathExpr from cssselect.xpath imp...
--- +++ @@ -49,12 +49,19 @@ class TranslatorMixin(object): + """This mixin adds support to CSS pseudo elements via dynamic dispatch. + + Currently supported pseudo-elements are ``::text`` and ``::attr(ATTR_NAME)``. + """ def xpath_element(self, selector): xpath = super(TranslatorMixin, self...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/parsel/csstranslator.py
Auto-generate documentation strings for this file
__all__ = ["fromstring", "parse", "convert_tree"] import re from lxml import etree, html try: from bs4 import ( BeautifulSoup, Tag, Comment, ProcessingInstruction, NavigableString, Declaration, Doctype) _DECLARATION_OR_DOCTYPE = (Declaration, Doctype) except ImportError: from BeautifulSou...
--- +++ @@ -1,3 +1,5 @@+"""External interface to the BeautifulSoup HTML parser. +""" __all__ = ["fromstring", "parse", "convert_tree"] @@ -17,10 +19,29 @@ def fromstring(data, beautifulsoup=None, makeelement=None, **bsargs): + """Parse a string of HTML data into an Element tree using the + BeautifulSoup ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/lxml/html/soupparser.py
Create docstrings for each class method
from __future__ import absolute_import import logging import optparse import sys import textwrap from distutils.util import strtobool from pip._vendor.six import string_types from pip._internal.cli.status_codes import UNKNOWN_ERROR from pip._internal.configuration import Configuration, ConfigurationError from pip._i...
--- +++ @@ -1,3 +1,4 @@+"""Base option parser setup""" from __future__ import absolute_import import logging @@ -16,6 +17,7 @@ class PrettyHelpFormatter(optparse.IndentedHelpFormatter): + """A prettier/less verbose help formatter for optparse.""" def __init__(self, *args, **kwargs): # help po...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/cli/parser.py
Add docstrings that explain purpose and usage
import re import six from w3lib.html import replace_entities as w3lib_replace_entities def flatten(x): return list(iflatten(x)) def iflatten(x): for el in x: if _is_listlike(el): for el_ in flatten(el): yield el_ else: yield el def _is_listlike(x): ...
--- +++ @@ -4,10 +4,26 @@ def flatten(x): + """flatten(sequence) -> list + Returns a single, flat list which contains all elements retrieved + from the sequence and all recursively contained sub-sequences + (iterables). + Examples: + >>> [1, 2, [3,4], (5,6)] + [1, 2, [3, 4], (5, 6)] + >>> fl...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/parsel/utils.py
Add verbose docstrings with examples
# cython: language_level=2 # # Element generator factory by Fredrik Lundh. # # Source: # http://online.effbot.org/2006_11_01_archive.htm#et-builder # http://effbot.python-hosting.com/file/stuff/sandbox/elementlib/builder.py # # -------------------------------------------------------------------- # The ElementTre...
--- +++ @@ -35,6 +35,9 @@ # OF THIS SOFTWARE. # -------------------------------------------------------------------- +""" +The ``E`` Element factory for generating XML documents. +""" from __future__ import absolute_import @@ -54,6 +57,93 @@ class ElementMaker(object): + """Element generator factory. + +...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/lxml/builder.py
Write reusable docstrings
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. from __future__ import division, absolute_import import sys import warnings # # Compat functions # if sys.version_info < (3, 0): _PY3 = False else: _PY3 = True try: _cmp = cmp except NameError: def _cmp(a, b): if a < b...
--- +++ @@ -1,6 +1,11 @@ # Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. +""" +Versions for Python packages. + +See L{Version}. +""" from __future__ import division, absolute_import @@ -20,6 +25,12 @@ _cmp = cmp except NameError: def _cmp(a, b): + """ + Compare tw...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/incremental/__init__.py
Write docstrings for utility functions
import sys import six from lxml import etree, html from .utils import flatten, iflatten, extract_regex, shorten from .csstranslator import HTMLTranslator, GenericTranslator class SafeXMLParser(etree.XMLParser): def __init__(self, *args, **kwargs): kwargs.setdefault('resolve_entities', False) su...
--- +++ @@ -1,3 +1,6 @@+""" +XPath selectors based on lxml +""" import sys @@ -33,6 +36,8 @@ def create_root_node(text, parser_cls, base_url=None): + """Create root node for text using given parser class. + """ body = text.strip().replace('\x00', '').encode('utf8') or b'<html/>' parser = parser...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/parsel/selector.py
Add minimal docstrings for each function
from __future__ import absolute_import from . import etree try: import cssselect as external_cssselect except ImportError: raise ImportError( 'cssselect does not seem to be installed. ' 'See http://packages.python.org/cssselect/') SelectorSyntaxError = external_cssselect.SelectorSyntaxError ...
--- +++ @@ -1,3 +1,10 @@+"""CSS Selectors based on XPath. + +This module supports selecting XML/HTML tags based on CSS selectors. +See the `CSSSelector` class for details. + +This is a thin wrapper around cssselect 0.7 or later. +""" from __future__ import absolute_import @@ -20,6 +27,9 @@ class LxmlTranslator...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/lxml/cssselect.py
Document this module using docstrings
from __future__ import absolute_import import textwrap import warnings from distutils.util import strtobool from functools import partial from optparse import SUPPRESS_HELP, Option, OptionGroup from pip._internal.exceptions import CommandError from pip._internal.locations import USER_CACHE_DIR, src_prefix from pip._i...
--- +++ @@ -1,3 +1,12 @@+""" +shared options and groups + +The principle here is to define options once, but *not* instantiate them +globally. One reason being that options with action='append' can carry state +between parses. pip parses general options twice internally, and shouldn't +pass on state. To be consistent, ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/cli/cmdoptions.py
Create documentation for each function signature
# cython: language_level=2 from __future__ import absolute_import import re import copy try: from urlparse import urlsplit from urllib import unquote_plus except ImportError: # Python 3 from urllib.parse import urlsplit, unquote_plus from lxml import etree from lxml.html import defs from lxml.html im...
--- +++ @@ -1,5 +1,10 @@ # cython: language_level=2 +"""A cleanup tool for HTML. + +Removes unwanted tags and content. See the `Cleaner` class for +details. +""" from __future__ import absolute_import @@ -92,6 +97,99 @@ class Cleaner(object): + """ + Instances cleans the document of each of the possib...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/lxml/html/clean.py
Create docstrings for API functions
import locale import logging import os from pip._vendor import six from pip._vendor.six.moves import configparser from pip._internal.exceptions import ( ConfigurationError, ConfigurationFileCouldNotBeLoaded, ) from pip._internal.locations import ( legacy_config_file, new_config_file, running_under_virtualenv...
--- +++ @@ -1,3 +1,15 @@+"""Configuration management setup + +Some terminology: +- name + As written in config files. +- value + Value associated with a name +- key + Name combined with it's section (section.name) +- variant + A single word describing where the configuration key-value pair came from +""" import ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/configuration.py
Write proper docstrings for these functions
# cython: language_level=2 from __future__ import absolute_import from xml.sax.handler import ContentHandler from lxml import etree from lxml.etree import ElementTree, SubElement from lxml.etree import Comment, ProcessingInstruction class SaxError(etree.LxmlError): def _getNsTag(tag): if tag[0] == '{': ...
--- +++ @@ -1,5 +1,16 @@ # cython: language_level=2 +""" +SAX-based adapter to copy trees from/to the Python standard library. + +Use the `ElementTreeContentHandler` class to build an ElementTree from +SAX events. + +Use the `ElementTreeProducer` class or the `saxify()` function to fire +the SAX events of an ElementT...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/lxml/sax.py
Improve documentation using docstrings
from __future__ import absolute_import, print_function import logging import logging.config import optparse import os import platform import sys import traceback from pip._internal.cli import cmdoptions from pip._internal.cli.parser import ( ConfigOptionParser, UpdatingDefaultsHelpFormatter, ) from pip._internal....
--- +++ @@ -1,3 +1,4 @@+"""Base Command class, and related routines""" from __future__ import absolute_import, print_function import logging @@ -247,6 +248,9 @@ wheel_cache # type: Optional[WheelCache] ): # type: (...) -> None + ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/cli/base_command.py
Expand my code with proper documentation strings
from __future__ import absolute_import from itertools import chain, groupby, repeat from pip._vendor.six import iteritems from pip._internal.utils.typing import MYPY_CHECK_RUNNING if MYPY_CHECK_RUNNING: from typing import Optional # noqa: F401 from pip._internal.req.req_install import InstallRequirement #...
--- +++ @@ -1,3 +1,4 @@+"""Exceptions used throughout package""" from __future__ import absolute_import from itertools import chain, groupby, repeat @@ -12,42 +13,56 @@ class PipError(Exception): + """Base pip exception""" class ConfigurationError(PipError): + """General exception in configuration"""...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/exceptions.py
Add docstrings including usage examples
import posixpath import re from pip._vendor.six.moves.urllib import parse as urllib_parse from pip._internal.download import path_to_url from pip._internal.utils.misc import ( WHEEL_EXTENSION, redact_password_from_url, splitext, ) from pip._internal.utils.models import KeyBasedCompareMixin from pip._internal.util...
--- +++ @@ -16,9 +16,21 @@ class Link(KeyBasedCompareMixin): + """Represents a parsed link from a Package Index's simple URL + """ def __init__(self, url, comes_from=None, requires_python=None): # type: (str, Optional[Union[str, HTMLPage]], Optional[str]) -> None + """ + url: + ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/models/link.py
Help me add docstrings to my project
import logging from collections import namedtuple from pip._vendor.packaging.utils import canonicalize_name from pip._vendor.pkg_resources import RequirementParseError from pip._internal.operations.prepare import make_abstract_dist from pip._internal.utils.misc import get_installed_distributions from pip._internal.u...
--- +++ @@ -1,3 +1,5 @@+"""Validation of dependencies of packages +""" import logging from collections import namedtuple @@ -31,6 +33,8 @@ def create_package_set_from_installed(**kwargs): # type: (**Any) -> Tuple[PackageSet, bool] + """Converts a list of distributions into a PackageSet. + """ # De...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/operations/check.py
Help me document legacy Python code
from __future__ import absolute_import import logging import warnings from pip._vendor.packaging.version import parse from pip import __version__ as current_version from pip._internal.utils.typing import MYPY_CHECK_RUNNING if MYPY_CHECK_RUNNING: from typing import Any, Optional # noqa: F401 class PipDeprecat...
--- +++ @@ -1,3 +1,6 @@+""" +A module that implements tooling to enable easy warnings about deprecations. +""" from __future__ import absolute_import import logging @@ -51,6 +54,25 @@ def deprecated(reason, replacement, gone_in, issue=None): # type: (str, Optional[str], Optional[str], Optional[int]) -> None ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/utils/deprecation.py
Please document this code using docstrings
from __future__ import absolute_import import cgi import email.utils import getpass import json import logging import mimetypes import os import platform import re import shutil import sys from pip._vendor import requests, six, urllib3 from pip._vendor.cachecontrol import CacheControlAdapter from pip._vendor.cachecon...
--- +++ @@ -73,6 +73,9 @@ def user_agent(): + """ + Return a string representing the user agent. + """ data = { "installer": {"name": "pip", "version": pip.__version__}, "python": platform.python_version(), @@ -254,6 +257,10 @@ class SafeFileCache(FileCache): + """ + A file...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/download.py
Generate docstrings for script automation
import errno import hashlib import logging import os from pip._vendor.packaging.utils import canonicalize_name from pip._internal.download import path_to_url from pip._internal.models.link import Link from pip._internal.utils.compat import expanduser from pip._internal.utils.temp_dir import TempDirectory from pip._i...
--- +++ @@ -1,3 +1,5 @@+"""Cache Management +""" import errno import hashlib @@ -21,6 +23,15 @@ class Cache(object): + """An abstract class - provides cache directories for data from links + + + :param cache_dir: The root of the cache. + :param format_control: An object of FormatControl class t...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/cache.py
Generate missing documentation strings
import logging import os import subprocess from pip._internal.cli.base_command import Command from pip._internal.cli.status_codes import ERROR, SUCCESS from pip._internal.configuration import Configuration, kinds from pip._internal.exceptions import PipError from pip._internal.locations import venv_config_file from pi...
--- +++ @@ -13,6 +13,21 @@ class ConfigurationCommand(Command): + """Manage local and global configuration. + + Subcommands: + + list: List the active configuration (or from the file specified) + edit: Edit the configuration file in an editor + get: Get the value associated with name ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/commands/configuration.py
Generate docstrings for exported functions
from __future__ import absolute_import from pip._internal.commands.completion import CompletionCommand from pip._internal.commands.configuration import ConfigurationCommand from pip._internal.commands.download import DownloadCommand from pip._internal.commands.freeze import FreezeCommand from pip._internal.commands.ha...
--- +++ @@ -1,3 +1,6 @@+""" +Package containing all pip commands +""" from __future__ import absolute_import from pip._internal.commands.completion import CompletionCommand @@ -40,6 +43,7 @@ def get_summaries(ordered=True): + """Yields sorted (command name, command summary) tuples.""" if ordered: ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/commands/__init__.py
Insert docstrings into my code
from __future__ import absolute_import import logging import sys import textwrap from collections import OrderedDict from pip._vendor import pkg_resources from pip._vendor.packaging.version import parse as parse_version # NOTE: XMLRPC Client is not annotated in typeshed as on 2017-07-17, which is # why we ignor...
--- +++ @@ -23,6 +23,7 @@ class SearchCommand(Command): + """Search for PyPI packages whose name or summary contains <query>.""" name = 'search' usage = """ %prog [options] <query>""" @@ -66,6 +67,11 @@ def transform_hits(hits): + """ + The list from pypi is really a list of versions. ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/commands/search.py
Add docstrings with type hints explained
import logging import os import sys import textwrap from collections import OrderedDict from distutils.sysconfig import get_python_lib from sysconfig import get_paths from pip._vendor.pkg_resources import Requirement, VersionConflict, WorkingSet from pip import __file__ as pip_location from pip._internal.utils.misc ...
--- +++ @@ -1,3 +1,5 @@+"""Build Environment used for isolation during sdist building +""" import logging import os @@ -43,6 +45,8 @@ class BuildEnvironment(object): + """Creates and manages an isolated environment to install build deps + """ def __init__(self): # type: () -> None @@ -132,...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/build_env.py
Add professional docstrings to my codebase
import logging import os from pip._vendor import pkg_resources, requests from pip._internal.build_env import BuildEnvironment from pip._internal.download import ( is_dir_url, is_file_url, is_vcs_url, unpack_url, url_to_path, ) from pip._internal.exceptions import ( DirectoryUrlHashUnsupported, HashUnpinned, ...
--- +++ @@ -1,3 +1,5 @@+"""Prepares a distribution for installation +""" import logging import os @@ -31,6 +33,13 @@ def make_abstract_dist(req): # type: (InstallRequirement) -> DistAbstraction + """Factory to make an abstract dist object. + + Preconditions: Either an editable req with a source_dir, or...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/operations/prepare.py
Generate missing documentation strings
from __future__ import absolute_import import cgi import itertools import logging import mimetypes import os import posixpath import re import sys from collections import namedtuple from pip._vendor import html5lib, requests, six from pip._vendor.distlib.compat import unescape from pip._vendor.packaging import specif...
--- +++ @@ -1,3 +1,4 @@+"""Routines related to PyPI, indexes""" from __future__ import absolute_import import cgi @@ -75,6 +76,10 @@ def _match_vcs_scheme(url): # type: (str) -> Optional[str] + """Look for VCS schemes in the URL. + + Returns the matched VCS scheme, or None if there's no match. + """...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/index.py
Add docstrings for better understanding
from __future__ import absolute_import import sys import textwrap from pip._internal.cli.base_command import Command from pip._internal.utils.misc import get_prog BASE_COMPLETION = """ # pip %(shell)s completion start%(script)s# pip %(shell)s completion end """ COMPLETION_SCRIPTS = { 'bash': """ _pip_co...
--- +++ @@ -46,6 +46,7 @@ class CompletionCommand(Command): + """A helper command to be used for command completion.""" name = 'completion' summary = 'A helper command used for command completion.' ignore_require_venv = True @@ -77,6 +78,7 @@ self.parser.insert_option_group(0, cmd_opts) ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/commands/completion.py
Document helper functions with docstrings
from __future__ import absolute_import import distutils.util import logging import platform import re import sys import sysconfig import warnings from collections import OrderedDict import pip._internal.utils.glibc from pip._internal.utils.compat import get_extension_suffixes from pip._internal.utils.typing import MY...
--- +++ @@ -1,3 +1,4 @@+"""Generate and work with PEP 425 Compatibility Tags.""" from __future__ import absolute_import import distutils.util @@ -36,6 +37,7 @@ def get_abbr_impl(): # type: () -> str + """Return abbreviated implementation name.""" if hasattr(sys, 'pypy_version_info'): pyimpl ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/pep425tags.py
Create documentation for each function signature
import optparse import os import sys from pip._internal.cli.main_parser import create_main_parser from pip._internal.commands import commands_dict, get_summaries from pip._internal.utils.misc import get_installed_distributions def autocomplete(): # Don't complete if user hasn't sourced bash_completion file. ...
--- +++ @@ -1,3 +1,5 @@+"""Logic that powers autocompletion installed by ``pip completion``. +""" import optparse import os @@ -9,6 +11,8 @@ def autocomplete(): + """Entry Point for completion of main and subcommand options. + """ # Don't complete if user hasn't sourced bash_completion file. if ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/cli/autocompletion.py
Create docstrings for reusable components
from __future__ import absolute_import import os import os.path import platform import site import sys import sysconfig from distutils import sysconfig as distutils_sysconfig from distutils.command.install import SCHEME_KEYS # type: ignore from pip._internal.utils import appdirs from pip._internal.utils.compat impor...
--- +++ @@ -1,3 +1,4 @@+"""Locations where we look for configs, install stuff, etc""" from __future__ import absolute_import import os @@ -33,6 +34,9 @@ def write_delete_marker_file(directory): # type: (str) -> None + """ + Write the pip delete marker file into this directory. + """ filepath = ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/locations.py
Add docstrings to clarify complex logic
import os import sys from pip import __version__ from pip._internal.cli import cmdoptions from pip._internal.cli.parser import ( ConfigOptionParser, UpdatingDefaultsHelpFormatter, ) from pip._internal.commands import ( commands_dict, get_similar_commands, get_summaries, ) from pip._internal.exceptions import ...
--- +++ @@ -1,3 +1,5 @@+"""A single place for constructing and exposing the main parser +""" import os import sys @@ -23,6 +25,8 @@ def create_main_parser(): # type: () -> ConfigOptionParser + """Creates and returns the main parser for pip's CLI + """ parser_kw = { 'usage': '\n%prog <co...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/cli/main_parser.py
Annotate my code with docstrings
from __future__ import absolute_import import contextlib import errno import io import locale # we have a submodule named 'logging' which would shadow this if we used the # regular name: import logging as std_logging import os import posixpath import re import shutil import stat import subprocess import sys import tar...
--- +++ @@ -92,6 +92,7 @@ def ensure_dir(path): # type: (AnyStr) -> None + """os.path.makedirs without EEXIST.""" try: os.makedirs(path) except OSError as e: @@ -121,6 +122,9 @@ def rmtree_errorhandler(func, path, exc_info): + """On Windows, the files in .svn are read-only, so when r...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/utils/misc.py
Create structured documentation for my script
from __future__ import absolute_import import hashlib import logging import sys from pip._internal.cli.base_command import Command from pip._internal.cli.status_codes import ERROR from pip._internal.utils.hashes import FAVORITE_HASH, STRONG_HASHES from pip._internal.utils.misc import read_chunks logger = logging.get...
--- +++ @@ -13,6 +13,13 @@ class HashCommand(Command): + """ + Compute a hash of a local package archive. + + These can be used with --hash in a requirements file to do repeatable + installs. + + """ name = 'hash' usage = '%prog [options] <file> ...' summary = 'Compute hashes of packag...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/commands/hash.py
Please document this code using docstrings
from __future__ import absolute_import import logging import os from email.parser import FeedParser # type: ignore from pip._vendor import pkg_resources from pip._vendor.packaging.utils import canonicalize_name from pip._internal.cli.base_command import Command from pip._internal.cli.status_codes import ERROR, SUCC...
--- +++ @@ -14,6 +14,11 @@ class ShowCommand(Command): + """ + Show information about one or more installed packages. + + The output is in RFC-compliant mail header format. + """ name = 'show' usage = """ %prog [options] <package> ...""" @@ -45,6 +50,12 @@ def search_packages_info(q...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/commands/show.py
Add docstrings to improve code quality
from __future__ import absolute_import import logging import os import shutil import sys import sysconfig import zipfile from distutils.util import change_root from pip._vendor import pkg_resources, six from pip._vendor.packaging.requirements import Requirement from pip._vendor.packaging.utils import canonicalize_nam...
--- +++ @@ -56,6 +56,11 @@ class InstallRequirement(object): + """ + Represents something that may be installed later on, may have information + about where to fetch the relavant requirement and also contains logic for + installing the said requirement. + """ def __init__( self, @@ -1...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/req/req_install.py
Add docstrings to my Python code
from __future__ import absolute_import import errno import logging import os import shutil import sys from pip._vendor.six.moves.urllib import parse as urllib_parse from pip._internal.exceptions import BadCommand from pip._internal.utils.misc import ( display_path, backup_dir, call_subprocess, rmtree, ask_path_e...
--- +++ @@ -1,3 +1,4 @@+"""Handles all VCS (version control) support""" from __future__ import absolute_import import errno @@ -34,9 +35,21 @@ class RevOptions(object): + """ + Encapsulates a VCS-specific revision to install, along with any VCS + install options. + + Instances of this class should b...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/vcs/__init__.py
Add inline docstrings for readability
from __future__ import absolute_import import errno import logging import operator import os import shutil from optparse import SUPPRESS_HELP from pip._vendor import pkg_resources from pip._internal.cache import WheelCache from pip._internal.cli import cmdoptions from pip._internal.cli.base_command import Requiremen...
--- +++ @@ -34,6 +34,17 @@ class InstallCommand(RequirementCommand): + """ + Install packages from: + + - PyPI (and other indexes) using requirement specifiers. + - VCS project urls. + - Local project directories. + - Local or remote source archives. + + pip also supports installing from "requi...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/commands/install.py
Write docstrings for this repository
from __future__ import absolute_import import optparse import os import re import shlex import sys from pip._vendor.six.moves import filterfalse from pip._vendor.six.moves.urllib import parse as urllib_parse from pip._internal.cli import cmdoptions from pip._internal.download import get_file_content from pip._inter...
--- +++ @@ -1,3 +1,6 @@+""" +Requirements file parsing +""" from __future__ import absolute_import @@ -78,6 +81,18 @@ use_pep517=None # type: Optional[bool] ): # type: (...) -> Iterator[InstallRequirement] + """Parse a requirements file and yield InstallRequirement instances. + + :param filename: ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/req/req_file.py
Create Google-style docstrings for my code
import sys import string from html5lib import HTMLParser as _HTMLParser from html5lib.treebuilders.etree_lxml import TreeBuilder from lxml import etree from lxml.html import Element, XHTML_NAMESPACE, _contains_block_level_tag # python3 compatibility try: _strings = basestring except NameError: _strings = (byt...
--- +++ @@ -1,3 +1,6 @@+""" +An interface to html5lib that mimics the lxml.html interface. +""" import sys import string @@ -22,6 +25,7 @@ class HTMLParser(_HTMLParser): + """An html5lib HTML parser with lxml as tree.""" def __init__(self, strict=False, **kwargs): _HTMLParser.__init__(self, s...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/lxml/html/html5parser.py
Add docstrings with type hints explained
from __future__ import absolute_import import logging from collections import OrderedDict from pip._internal.exceptions import InstallationError from pip._internal.utils.logging import indent_log from pip._internal.utils.typing import MYPY_CHECK_RUNNING from pip._internal.wheel import Wheel if MYPY_CHECK_RUNNING: ...
--- +++ @@ -20,6 +20,8 @@ def __init__(self, require_hashes=False, check_supported_wheels=True): # type: (bool, bool) -> None + """Create a RequirementSet. + """ self.requirements = OrderedDict() # type: Dict[str, InstallRequirement] # noqa: E501 self.require_hashes = ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/req/req_set.py
Write docstrings including parameters and return values
from __future__ import absolute_import import json import logging from pip._vendor import six from pip._vendor.six.moves import zip_longest from pip._internal.cli import cmdoptions from pip._internal.cli.base_command import Command from pip._internal.exceptions import CommandError from pip._internal.index import Pac...
--- +++ @@ -19,6 +19,11 @@ class ListCommand(Command): + """ + List installed packages, including editables. + + Packages are listed in a case-insensitive sorted order. + """ name = 'list' usage = """ %prog [options]""" @@ -105,6 +110,9 @@ self.parser.insert_option_group(0, cmd_...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/commands/list.py
Generate docstrings for script automation
import logging import os import re from pip._vendor.packaging.markers import Marker from pip._vendor.packaging.requirements import InvalidRequirement, Requirement from pip._vendor.packaging.specifiers import Specifier from pip._vendor.pkg_resources import RequirementParseError, parse_requirements from pip._internal....
--- +++ @@ -1,3 +1,12 @@+"""Backing implementation for InstallRequirement's various constructors + +The idea here is that these formed a major chunk of InstallRequirement's size +so, moving them and support code dedicated to them outside of that class +helps creates for better understandability for the rest of the code...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/req/constructors.py
Add clean documentation to messy code
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2005-2010 ActiveState Software Inc. # Copyright (c) 2013 Eddy Petrișor # Dev Notes: # - MSDN on where to store app data files: # http://support.microsoft.com/default.aspx?scid=kb;en-us;310294#XSLTH3194121123120121120120 # - Mac OS X: http://developer.appl...
--- +++ @@ -3,6 +3,10 @@ # Copyright (c) 2005-2010 ActiveState Software Inc. # Copyright (c) 2013 Eddy Petrișor +"""Utilities for determining application-specific dirs. + +See <http://github.com/ActiveState/appdirs> for details and usage. +""" # Dev Notes: # - MSDN on where to store app data files: # http://sup...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_vendor/appdirs.py
Create docstrings for API functions
import logging from collections import defaultdict from itertools import chain from pip._internal.exceptions import ( BestVersionAlreadyInstalled, DistributionNotFound, HashError, HashErrors, UnsupportedPythonVersion, ) from pip._internal.req.constructors import install_req_from_req_string from pip._internal....
--- +++ @@ -1,3 +1,14 @@+"""Dependency Resolution + +The dependency resolution in pip is performed as follows: + +for top-level requirements: + a. only one spec allowed per project, regardless of conflicts or not. + otherwise a "double requirement" exception is raised + b. they override sub-dependency requi...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/resolve.py
Add documentation for all methods
from __future__ import absolute_import import csv import functools import logging import os import sys import sysconfig from pip._vendor import pkg_resources from pip._internal.exceptions import UninstallationError from pip._internal.locations import bin_py, bin_user from pip._internal.utils.compat import WINDOWS, c...
--- +++ @@ -23,6 +23,10 @@ def _script_names(dist, script_name, is_gui): + """Create the fully qualified name of the files created by + {console,gui}_scripts for the given ``dist``. + Returns the list of file names + """ if dist_in_usersite(dist): bin_dir = bin_user else: @@ -52,6 +56...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/req/req_uninstall.py
Document this script properly
from __future__ import absolute_import import os import sys from pip._vendor.six import PY2, text_type from pip._internal.utils.compat import WINDOWS, expanduser from pip._internal.utils.typing import MYPY_CHECK_RUNNING if MYPY_CHECK_RUNNING: from typing import ( # noqa: F401 List, Union ) def us...
--- +++ @@ -1,3 +1,7 @@+""" +This code was taken from https://github.com/ActiveState/appdirs and modified +to suit our purposes. +""" from __future__ import absolute_import import os @@ -16,6 +20,26 @@ def user_cache_dir(appname): # type: (str) -> str + r""" + Return full path to the user-specific cach...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/utils/appdirs.py
Add minimal docstrings for each function
from __future__ import absolute_import import ctypes import re import warnings from pip._internal.utils.typing import MYPY_CHECK_RUNNING if MYPY_CHECK_RUNNING: from typing import Optional, Tuple # noqa: F401 def glibc_version_string(): # type: () -> Optional[str] # ctypes.CDLL(None) internally calls ...
--- +++ @@ -12,6 +12,7 @@ def glibc_version_string(): # type: () -> Optional[str] + "Returns glibc version string, or None if not using glibc." # ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen # manpage says, "If filename is NULL, then the returned handle is for the @@ -80,8 +8...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/utils/glibc.py
Create Google-style docstrings for my code
from __future__ import absolute_import, division import codecs import locale import logging import os import shutil import sys from pip._vendor.six import text_type from pip._internal.utils.typing import MYPY_CHECK_RUNNING if MYPY_CHECK_RUNNING: from typing import Tuple, Text # noqa: F401 try: import ipad...
--- +++ @@ -1,3 +1,5 @@+"""Stuff that differs in different Python versions and platform +distributions.""" from __future__ import absolute_import, division import codecs @@ -72,6 +74,15 @@ def console_to_str(data): # type: (bytes) -> Text + """Return a string, safe for output, of subprocess output. + + ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/utils/compat.py
Add docstrings to incomplete code
from __future__ import division from datetime import datetime from pip._vendor.cachecontrol.cache import BaseCache class RedisCache(BaseCache): def __init__(self, conn): self.conn = conn def get(self, key): return self.conn.get(key) def set(self, key, value, expires=None): if n...
--- +++ @@ -23,8 +23,11 @@ self.conn.delete(key) def clear(self): + """Helper for clearing all the keys in a database. Use with + caution!""" for key in self.conn.keys(): self.conn.delete(key) def close(self): - pass+ """Redis uses connection pooli...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_vendor/cachecontrol/caches/redis_cache.py
Add structured docstrings to improve clarity
from __future__ import absolute_import import hashlib from pip._vendor.six import iteritems, iterkeys, itervalues from pip._internal.exceptions import ( HashMismatch, HashMissing, InstallationError, ) from pip._internal.utils.misc import read_chunks from pip._internal.utils.typing import MYPY_CHECK_RUNNING if M...
--- +++ @@ -32,12 +32,26 @@ class Hashes(object): + """A wrapper that builds multiple hashes at once and checks them against + known-good values + + """ def __init__(self, hashes=None): # type: (Dict[str, List[str]]) -> None + """ + :param hashes: A dict of algorithm names point...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/utils/hashes.py
Generate docstrings for this script
from __future__ import absolute_import import contextlib import errno import logging import logging.handlers import os import sys from pip._vendor.six import PY2 from pip._internal.utils.compat import WINDOWS from pip._internal.utils.misc import ensure_dir try: import threading except ImportError: import du...
--- +++ @@ -31,6 +31,9 @@ class BrokenStdoutLoggingError(Exception): + """ + Raised if BrokenPipeError occurs for the stdout stream while logging. + """ pass @@ -42,25 +45,39 @@ # https://bugs.python.org/issue30418 if PY2: def _is_broken_pipe_error(exc_class, exc): + "...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/utils/logging.py
Add docstrings that explain purpose and usage
from __future__ import absolute_import import datetime import json import logging import os.path import sys from pip._vendor import lockfile, pkg_resources from pip._vendor.packaging import version as packaging_version from pip._internal.index import PackageFinder from pip._internal.utils.compat import WINDOWS from ...
--- +++ @@ -78,6 +78,11 @@ def was_installed_by_pip(pkg): # type: (str) -> bool + """Checks whether pkg was installed by pip + + This is used not to display the upgrade message when pip is in fact + installed by system package manager, such as dnf on Fedora. + """ try: dist = pkg_resour...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/utils/outdated.py
Create documentation for each function signature
from __future__ import absolute_import import logging import os from pip._vendor.six.moves.urllib import parse as urllib_parse from pip._internal.download import path_to_url from pip._internal.utils.misc import ( display_path, make_vcs_requirement_url, rmtree, ) from pip._internal.utils.temp_dir import TempDirec...
--- +++ @@ -35,6 +35,9 @@ return ['-r', rev] def export(self, location): + """ + Export the Bazaar repository at the url to the destination location + """ # Remove the location to make sure Bazaar can export it correctly if os.path.exists(location): rmt...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/vcs/bazaar.py
Generate documentation strings for clarity
from __future__ import absolute_import, division import contextlib import itertools import logging import sys import time from signal import SIGINT, default_int_handler, signal from pip._vendor import six from pip._vendor.progress.bar import ( Bar, ChargingBar, FillingCirclesBar, FillingSquaresBar, IncrementalBar...
--- +++ @@ -64,8 +64,27 @@ class InterruptibleMixin(object): + """ + Helper to ensure that self.finish() gets called on keyboard interrupt. + + This allows downloads to be interrupted without leaving temporary state + (like hidden cursors) behind. + + This class is similar to the progress library's e...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/utils/ui.py
Add structured docstrings to improve clarity
from __future__ import absolute_import import errno import itertools import logging import os.path import tempfile from pip._internal.utils.misc import rmtree logger = logging.getLogger(__name__) class TempDirectory(object): def __init__(self, path=None, delete=None, kind="temp"): super(TempDirectory,...
--- +++ @@ -12,6 +12,29 @@ class TempDirectory(object): + """Helper class that owns and cleans up a temporary directory. + + This class can be used as a context manager or as an OO representation of a + temporary directory. + + Attributes: + path + Location to the created temporary dir...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/utils/temp_dir.py
Document classes and their methods
from __future__ import absolute_import import logging import os import re from pip._internal.utils.logging import indent_log from pip._internal.utils.misc import ( display_path, make_vcs_requirement_url, rmtree, split_auth_from_netloc, ) from pip._internal.vcs import VersionControl, vcs _svn_xml_url_re = re.comp...
--- +++ @@ -29,6 +29,7 @@ return ['-r', rev] def export(self, location): + """Export the svn repository at the url to the destination location""" url, rev_options = self.get_url_rev_options(self.url) logger.info('Exporting svn repository %s to %s', url, location) @@ -61,6 +62,9...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_internal/vcs/subversion.py
Write docstrings for utility functions
import logging import re import calendar import time from email.utils import parsedate_tz from pip._vendor.requests.structures import CaseInsensitiveDict from .cache import DictCache from .serialize import Serializer logger = logging.getLogger(__name__) URI = re.compile(r"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([...
--- +++ @@ -1,3 +1,6 @@+""" +The httplib2 algorithms ported for use with requests. +""" import logging import re import calendar @@ -16,11 +19,17 @@ def parse_uri(uri): + """Parses a URI using the regex given in Appendix B of RFC 3986. + + (scheme, authority, path, query, fragment) = parse_uri(uri) + ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_vendor/cachecontrol/controller.py
Document my Python code with docstrings
class InputState(object): PURE_ASCII = 0 ESC_ASCII = 1 HIGH_BYTE = 2 class LanguageFilter(object): CHINESE_SIMPLIFIED = 0x01 CHINESE_TRADITIONAL = 0x02 JAPANESE = 0x04 KOREAN = 0x08 NON_CJK = 0x10 ALL = 0x1F CHINESE = CHINESE_SIMPLIFIED | CHINESE_TRADITIONAL CJK = CHINESE...
--- +++ @@ -1,12 +1,24 @@+""" +All of the Enums that are used throughout the chardet package. + +:author: Dan Blanchard (dan.blanchard@gmail.com) +""" class InputState(object): + """ + This enum represents the different states a universal detector can be in. + """ PURE_ASCII = 0 ESC_ASCII = 1 ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_vendor/chardet/enums.py
Turn comments into proper docstrings
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is Mozilla Universal charset detector code. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 2001 # the Initial Developer. All R...
--- +++ @@ -25,6 +25,15 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA # 02110-1301 USA ######################### END LICENSE BLOCK ######################### +""" +Module containing the UniversalDetector detector class, which is the primary +class a user of ``chardet`` should use. + +:author: Mark Pi...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_vendor/chardet/universaldetector.py
Write docstrings including parameters and return values
#------------------------------------------------------------------- # tarfile.py #------------------------------------------------------------------- # Copyright (C) 2002 Lars Gustaebel <lars@gustaebel.de> # All rights reserved. # # Permission is hereby granted, free of charge, to any person # obtaining a copy ...
--- +++ @@ -183,16 +183,22 @@ #--------------------------------------------------------- def stn(s, length, encoding, errors): + """Convert a string to a null-terminated bytes object. + """ s = s.encode(encoding, errors) return s[:length] + (length - len(s)) * NUL def nts(s, encoding, errors): + ...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_vendor/distlib/_backport/tarfile.py