instruction
stringclasses
100 values
code
stringlengths
78
193k
response
stringlengths
259
170k
file
stringlengths
59
203
Generate helpful docstrings for debugging
from __future__ import absolute_import import logging import os.path import re from pip._vendor.packaging.version import parse as parse_version from pip._vendor.six.moves.urllib import parse as urllib_parse from pip._vendor.six.moves.urllib import request as urllib_request from pip._internal.exceptions import BadCom...
--- +++ @@ -80,6 +80,10 @@ return parse_version(version) def get_current_branch(self, location): + """ + Return the current branch, or None if HEAD isn't at a branch + (e.g. detached HEAD). + """ # git-symbolic-ref exits with empty stdout if "HEAD" is a detached ...
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/git.py
Document functions with detailed explanations
from __future__ import absolute_import import logging import os from pip._vendor.six.moves import configparser from pip._internal.download import path_to_url from pip._internal.utils.misc import display_path, make_vcs_requirement_url from pip._internal.utils.temp_dir import TempDirectory from pip._internal.vcs impor...
--- +++ @@ -23,6 +23,7 @@ return [rev] def export(self, location): + """Export the Hg repository at the url to the destination location""" with TempDirectory(kind="export") as temp_dir: self.unpack(temp_dir.path) @@ -95,7 +96,8 @@ return make_vcs_requirement_url(rep...
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/mercurial.py
Document classes and their methods
# -*- coding: utf-8 -*- # # Copyright (C) 2012-2015 Vinay Sajip. # Licensed to the Python Software Foundation under a contributor agreement. # See LICENSE.txt and CONTRIBUTORS.txt. # import gzip from io import BytesIO import json import logging import os import posixpath import re try: import threading except Impo...
--- +++ @@ -39,6 +39,11 @@ DEFAULT_INDEX = 'https://pypi.python.org/pypi' def get_all_distribution_names(url=None): + """ + Return all distribution names known by an index. + :param url: The URL of the index. + :return: A list of all known distribution names. + """ if url is 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/_vendor/distlib/locators.py
Help me write clear docstrings
# -*- coding: utf-8 -*- # # Copyright (C) 2013 Vinay Sajip. # Licensed to the Python Software Foundation under a contributor agreement. # See LICENSE.txt and CONTRIBUTORS.txt. # import hashlib import logging import os import shutil import subprocess import tempfile try: from threading import Thread except ImportErr...
--- +++ @@ -26,10 +26,20 @@ DEFAULT_REALM = 'pypi' class PackageIndex(object): + """ + This class represents a package index compatible with PyPI, the Python + Package Index. + """ boundary = b'----------ThIs_Is_tHe_distlib_index_bouNdaRY_$' def __init__(self, url=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/_vendor/distlib/index.py
Create structured documentation for my script
from __future__ import absolute_import import collections import compileall import csv import hashlib import logging import os.path import re import shutil import stat import sys import warnings from base64 import urlsafe_b64encode from email.parser import Parser from pip._vendor import pkg_resources from pip._vendor...
--- +++ @@ -1,3 +1,6 @@+""" +Support for installing and building the "wheel" binary package format. +""" from __future__ import absolute_import import collections @@ -67,6 +70,7 @@ def rehash(path, blocksize=1 << 20): # type: (str, int) -> Tuple[str, str] + """Return (hash, length) for path using hashlib....
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/wheel.py
Write docstrings for utility functions
#!/usr/bin/env python from __future__ import absolute_import, print_function, unicode_literals import argparse import sys from pip._vendor.chardet import __version__ from pip._vendor.chardet.compat import PY2 from pip._vendor.chardet.universaldetector import UniversalDetector def description_of(lines, name='stdin'...
--- +++ @@ -1,4 +1,17 @@ #!/usr/bin/env python +""" +Script which takes one or more file paths and reports on their detected +encodings + +Example:: + + % chardetect somefile someotherfile + somefile: windows-1252 with confidence 0.5 + someotherfile: ascii with confidence 1.0 + +If no paths are provided, it ta...
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/cli/chardetect.py
Write documentation strings for class attributes
# -*- coding: utf-8 -*- # # Copyright (C) 2012-2017 The Python Software Foundation. # See LICENSE.txt and CONTRIBUTORS.txt. # from __future__ import unicode_literals import base64 import codecs import contextlib import hashlib import logging import os import posixpath import sys import zipimport from . import Distli...
--- +++ @@ -3,6 +3,7 @@ # Copyright (C) 2012-2017 The Python Software Foundation. # See LICENSE.txt and CONTRIBUTORS.txt. # +"""PEP 376 implementation.""" from __future__ import unicode_literals @@ -42,24 +43,48 @@ class _Cache(object): + """ + A simple cache mapping names and .dist-info paths to distr...
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/database.py
Write docstrings for utility functions
######################## BEGIN LICENSE BLOCK ######################## # The Original Code is Mozilla Communicator client code. # # The Initial Developer of the Original Code is # Netscape Communications Corporation. # Portions created by the Initial Developer are Copyright (C) 1998 # the Initial Developer. All Rights R...
--- +++ @@ -59,6 +59,7 @@ self.reset() def reset(self): + """reset analyser, clear any state""" # If this flag is set to True, detection is done and conclusion has # been made self._done = False @@ -67,6 +68,7 @@ self._freq_chars = 0 def feed(self, char, c...
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/chardistribution.py
Create docstrings for reusable components
import types import functools import zlib from pip._vendor.requests.adapters import HTTPAdapter from .controller import CacheController from .cache import DictCache from .filewrapper import CallbackFileWrapper class CacheControlAdapter(HTTPAdapter): invalidating_methods = {"PUT", "DELETE"} def __init__( ...
--- +++ @@ -34,6 +34,10 @@ ) def send(self, request, cacheable_methods=None, **kw): + """ + Send a request. Use the request information to see if it + exists in the cache and cache the response if we need to and can. + """ cacheable = cacheable_methods or self.cacheab...
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/adapter.py
Add docstrings to improve collaboration
# -*- coding: utf-8 -*- # # Copyright (C) 2012 The Python Software Foundation. # See LICENSE.txt and CONTRIBUTORS.txt. # import codecs import os import re import sys from os.path import pardir, realpath try: import configparser except ImportError: import ConfigParser as configparser __all__ = [ 'get_conf...
--- +++ @@ -3,6 +3,7 @@ # Copyright (C) 2012 The Python Software Foundation. # See LICENSE.txt and CONTRIBUTORS.txt. # +"""Access to Python's configuration information.""" import codecs import os @@ -130,6 +131,11 @@ def _subst_vars(path, local_vars): + """In the string `path`, replace tokens like {some.th...
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/sysconfig.py
Document functions with detailed explanations
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. import re import sys import os from .ansi import AnsiFore, AnsiBack, AnsiStyle, Style from .winterm import WinTerm, WinColor, WinStyle from .win32 import windll, winapi_test winterm = None if windll is not None: winterm = WinTerm() clas...
--- +++ @@ -14,6 +14,11 @@ class StreamWrapper(object): + ''' + Wraps a stream (such as stdout), acting as a transparent proxy for all + attribute access apart from method 'write()', which is delegated to our + Converter instance. + ''' def __init__(self, wrapped, converter): # double-u...
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/colorama/ansitowin32.py
Generate docstrings for each module
# -*- coding: utf-8 -*- # # Copyright (C) 2013-2017 Vinay Sajip. # Licensed to the Python Software Foundation under a contributor agreement. # See LICENSE.txt and CONTRIBUTORS.txt. # from __future__ import absolute_import import os import re import sys try: import ssl except ImportError: # pragma: no cover s...
--- +++ @@ -50,6 +50,7 @@ _userprog = None def splituser(host): + """splituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.""" global _userprog if _userprog is None: import re @@ -95,6 +96,10 @@ def _dnsname_match(dn, hostname, max_wildcards=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/distlib/compat.py
Write docstrings for data processing functions
# -*- coding: utf-8 -*- # # Copyright (C) 2012 The Python Software Foundation. # See LICENSE.txt and CONTRIBUTORS.txt. # import os import sys import stat from os.path import abspath import fnmatch import collections import errno from . import tarfile try: import bz2 _BZ2_SUPPORTED = True except ImportError: ...
--- +++ @@ -3,6 +3,11 @@ # Copyright (C) 2012 The Python Software Foundation. # See LICENSE.txt and CONTRIBUTORS.txt. # +"""Utility functions for copying and archiving files and directory trees. + +XXX The functions here don't copy the resource fork or other metadata on Mac. + +""" import os import sys @@ -40,12 ...
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/shutil.py
Add docstrings for utility scripts
from __future__ import absolute_import, division, unicode_literals from pip._vendor.six import unichr as chr from collections import deque from .constants import spaceCharacters from .constants import entities from .constants import asciiLetters, asciiUpper2Lower from .constants import digits, hexDigits, EOF from .c...
--- +++ @@ -19,6 +19,17 @@ class HTMLTokenizer(object): + """ This class takes care of tokenizing HTML. + + * self.currentToken + Holds the token that is currently being processed. + + * self.state + Holds a reference to the method to be invoked... XXX + + * self.stream + Points to HTMLIn...
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/html5lib/_tokenizer.py
Generate NumPy-style docstrings
from __future__ import absolute_import, division, unicode_literals from . import base class Filter(base.Filter): def __init__(self, source, encoding): base.Filter.__init__(self, source) self.encoding = encoding def __iter__(self): state = "pre_head" meta_found = (self.encodin...
--- +++ @@ -4,7 +4,15 @@ class Filter(base.Filter): + """Injects ``<meta charset=ENCODING>`` tag into head of document""" def __init__(self, source, encoding): + """Creates a Filter + + :arg source: the source token stream + + :arg encoding: the encoding to set + + """ 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/_vendor/html5lib/filters/inject_meta_charset.py
Auto-generate documentation strings for this file
# -*- coding: utf-8 -*- # # Copyright (C) 2012-2017 The Python Software Foundation. # See LICENSE.txt and CONTRIBUTORS.txt. # import logging import re from .compat import string_types from .util import parse_requirement __all__ = ['NormalizedVersion', 'NormalizedMatcher', 'LegacyVersion', 'LegacyMatcher',...
--- +++ @@ -3,6 +3,10 @@ # Copyright (C) 2012-2017 The Python Software Foundation. # See LICENSE.txt and CONTRIBUTORS.txt. # +""" +Implementation of a flexible versioning scheme providing support for PEP-440, +setuptools-compatible and semantic versioning. +""" import logging import re @@ -19,6 +23,7 @@ class...
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/version.py
Add docstrings that explain inputs and outputs
from __future__ import absolute_import, division, unicode_literals from pip._vendor.six import text_type from . import base from ..constants import namespaces, voidElements from ..constants import spaceCharacters spaceCharacters = "".join(spaceCharacters) class Filter(base.Filter): def __init__(self, source, r...
--- +++ @@ -10,7 +10,19 @@ class Filter(base.Filter): + """Lints the token stream for errors + + If it finds any errors, it'll raise an ``AssertionError``. + + """ def __init__(self, source, require_matching_tags=True): + """Creates a Filter + + :arg source: the source token stream + + ...
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/html5lib/filters/lint.py
Add minimal docstrings for each function
# -*- coding: utf-8 -*- # # Copyright (C) 2012-2013 Python Software Foundation. # See LICENSE.txt and CONTRIBUTORS.txt. # import fnmatch import logging import os import re import sys from . import DistlibException from .compat import fsdecode from .util import convert_path __all__ = ['Manifest'] logger = logging.ge...
--- +++ @@ -3,6 +3,11 @@ # Copyright (C) 2012-2013 Python Software Foundation. # See LICENSE.txt and CONTRIBUTORS.txt. # +""" +Class representing the list of files in a distribution. + +Equivalent to distutils.filelist, but fixes some problems. +""" import fnmatch import logging import os @@ -30,8 +35,16 @@ _PYTHO...
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/manifest.py
Add detailed docstrings explaining each function
from __future__ import absolute_import, division, unicode_literals from pip._vendor.six import with_metaclass, viewkeys import types from collections import OrderedDict from . import _inputstream from . import _tokenizer from . import treebuilders from .treebuilders.base import Marker from . import _utils from .con...
--- +++ @@ -25,12 +25,48 @@ def parse(doc, treebuilder="etree", namespaceHTMLElements=True, **kwargs): + """Parse an HTML document as a string or file-like object into a tree + + :arg doc: the document to parse as a string or file-like object + + :arg treebuilder: the treebuilder to use when parsing + + ...
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/html5lib/html5parser.py
Generate docstrings with examples
# -*- coding: utf-8 -*- # # Copyright (C) 2012-2017 Vinay Sajip. # Licensed to the Python Software Foundation under a contributor agreement. # See LICENSE.txt and CONTRIBUTORS.txt. # # Note: In PEP 345, the micro-language was Python compatible, so the ast # module could be used to parse it. However, PEP 508 introduced...
--- +++ @@ -4,6 +4,9 @@ # Licensed to the Python Software Foundation under a contributor agreement. # See LICENSE.txt and CONTRIBUTORS.txt. # +""" +Parser for the environment markers micro-language defined in PEP 508. +""" # Note: In PEP 345, the micro-language was Python compatible, so the ast # module could be ...
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/markers.py
Add docstrings with type hints explained
from __future__ import absolute_import, division, unicode_literals from pip._vendor.six import text_type, binary_type from pip._vendor.six.moves import http_client, urllib import codecs import re from pip._vendor import webencodings from .constants import EOF, spaceCharacters, asciiLetters, asciiUppercase from .con...
--- +++ @@ -55,6 +55,11 @@ class BufferedStream(object): + """Buffering for streams that do not have buffering of their own + + The buffer is implemented as a list of chunks on the assumption that + joining many strings will be slow since it is O(n**2) + """ def __init__(self, stream): s...
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/html5lib/_inputstream.py
Add docstrings to meet PEP guidelines
# -*- coding: utf-8 -*- # # Copyright (C) 2013-2017 Vinay Sajip. # Licensed to the Python Software Foundation under a contributor agreement. # See LICENSE.txt and CONTRIBUTORS.txt. # from __future__ import unicode_literals import bisect import io import logging import os import pkgutil import shutil import sys import ...
--- +++ @@ -33,10 +33,23 @@ super(ResourceCache, self).__init__(base) def is_stale(self, resource, path): + """ + Is the cache stale for the given resource? + + :param resource: The :class:`Resource` being cached. + :param path: The path of the resource in the cache. + ...
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/resources.py
Add docstrings to improve code quality
from __future__ import absolute_import, division, unicode_literals import re from xml.sax.saxutils import escape, unescape from pip._vendor.six.moves import urllib_parse as urlparse from . import base from ..constants import namespaces, prefixes __all__ = ["Filter"] allowed_elements = frozenset(( (namespaces[...
--- +++ @@ -705,6 +705,7 @@ class Filter(base.Filter): + """Sanitizes token stream of XHTML+MathML+SVG and of inline style attributes""" def __init__(self, source, allowed_elements=allowed_elements, @@ -717,6 +718,37 @@ attr_val_is_uri=attr_val_is_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/html5lib/filters/sanitizer.py
Add docstrings to my Python code
from __future__ import absolute_import, division, unicode_literals # pylint:disable=protected-access from pip._vendor.six import text_type import re from . import base from .. import _ihatexml from .. import constants from ..constants import namespaces from .._utils import moduleFactoryFactory tag_regexp = re.compi...
--- +++ @@ -86,6 +86,7 @@ childNodes = property(_getChildNodes, _setChildNodes) def hasContent(self): + """Return true if the node has children or text""" return bool(self._element.text or len(self._element)) def appendChild(self, node): @@ -256,6 +257,7 @@ ...
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/html5lib/treebuilders/etree.py
Include argument descriptions in docstrings
# -*- coding: utf-8 -*- # # Copyright (C) 2013-2015 Vinay Sajip. # Licensed to the Python Software Foundation under a contributor agreement. # See LICENSE.txt and CONTRIBUTORS.txt. # from io import BytesIO import logging import os import re import struct import sys from .compat import sysconfig, detect_encoding, ZipFi...
--- +++ @@ -80,6 +80,10 @@ class ScriptMaker(object): + """ + A class to copy or create scripts from source scripts or callable + specifications. + """ script_template = SCRIPT_TEMPLATE executable = None # for shebangs @@ -109,6 +113,10 @@ if sys.platform.startswith('java'): # pragma...
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/scripts.py
Add docstrings for utility scripts
from __future__ import absolute_import, division, unicode_literals from xml.dom import Node from ..constants import namespaces, voidElements, spaceCharacters __all__ = ["DOCUMENT", "DOCTYPE", "TEXT", "ELEMENT", "COMMENT", "ENTITY", "UNKNOWN", "TreeWalker", "NonRecursiveTreeWalker"] DOCUMENT = Node.DOCUMEN...
--- +++ @@ -18,16 +18,48 @@ class TreeWalker(object): + """Walks a tree yielding tokens + + Tokens are dicts that all have a ``type`` field specifying the type of the + token. + + """ def __init__(self, tree): + """Creates a TreeWalker + + :arg tree: the tree to walk + + """ ...
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/html5lib/treewalkers/base.py
Write beginner-friendly docstrings
# -*- coding: utf-8 -*- # # Copyright (C) 2012 The Python Software Foundation. # See LICENSE.txt and CONTRIBUTORS.txt. # from __future__ import unicode_literals import codecs from email import message_from_file import json import logging import re from . import DistlibException, __version__ from .compat import Strin...
--- +++ @@ -3,6 +3,10 @@ # Copyright (C) 2012 The Python Software Foundation. # See LICENSE.txt and CONTRIBUTORS.txt. # +"""Implementation of the Metadata for Python packages PEPs. + +Supports all metadata formats (1.0, 1.1, 1.2, and 2.0 experimental). +""" from __future__ import unicode_literals import codecs @@...
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/metadata.py
Generate docstrings with examples
import calendar import time from email.utils import formatdate, parsedate, parsedate_tz from datetime import datetime, timedelta TIME_FMT = "%a, %d %b %Y %H:%M:%S GMT" def expire_after(delta, date=None): date = date or datetime.utcnow() return date + delta def datetime_to_header(dt): return formatdat...
--- +++ @@ -20,9 +20,23 @@ class BaseHeuristic(object): def warning(self, response): + """ + Return a valid 1xx warning header value describing the cache + adjustments. + + The response is provided too allow warnings like 113 + http://tools.ietf.org/html/rfc7234#section-5.5.4 w...
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/heuristics.py
Write proper docstrings for these functions
# # Copyright (C) 2012-2017 The Python Software Foundation. # See LICENSE.txt and CONTRIBUTORS.txt. # import codecs from collections import deque import contextlib import csv from glob import iglob as std_iglob import io import json import logging import os import py_compile import re import socket try: import ssl ...
--- +++ @@ -54,6 +54,14 @@ def parse_marker(marker_string): + """ + Parse a marker string and return a dictionary containing a marker expression. + + The dictionary will contain keys "op", "lhs" and "rhs" for non-terminals in + the expression grammar, or strings. A string contained in quotes is to be + ...
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/util.py
Generate helpful docstrings for debugging
######################## 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...
--- +++ @@ -65,6 +65,19 @@ @staticmethod def filter_international_words(buf): + """ + We define three types of bytes: + alphabet: english alphabets [a-zA-Z] + international: international characters [\x80-\xFF] + marker: everything else [^a-zA-Z\x80-\xFF] + + The inp...
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/charsetprober.py
Help me comply with documentation standards
# Copyright 2015,2016,2017 Nir Cohen # # 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,21 @@ # See the License for the specific language governing permissions and # limitations under the License. +""" +The ``distro`` package (``distro`` stands for Linux Distribution) provides +information about the Linux distribution it runs on, such as a reliable +machine-readable distro ID, or v...
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/distro.py
Add docstrings to improve collaboration
# -*- coding: utf-8 -*- # # Copyright (C) 2013-2017 Vinay Sajip. # Licensed to the Python Software Foundation under a contributor agreement. # See LICENSE.txt and CONTRIBUTORS.txt. # from __future__ import unicode_literals import base64 import codecs import datetime import distutils.util from email import message_from...
--- +++ @@ -134,11 +134,17 @@ class Wheel(object): + """ + Class to build and install from Wheel files (PEP 427). + """ wheel_version = (1, 1) hash_kind = 'sha256' def __init__(self, filename=None, sign=False, verify=False): + """ + Initialise an instance using a (valid) fi...
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/wheel.py
Add detailed docstrings explaining each function
from __future__ import absolute_import, division, unicode_literals from . import base from collections import OrderedDict def _attr_key(attr): return (attr[0][0] or ''), attr[0][1] class Filter(base.Filter): def __iter__(self): for token in base.Filter.__iter__(self): if token["type"] ...
--- +++ @@ -6,10 +6,18 @@ def _attr_key(attr): + """Return an appropriate key for an attribute for sorting + + Attributes have a namespace that can be either ``None`` or a string. We + can't compare the two because they're different types, so we convert + ``None`` to an empty string first. + + """ ...
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/html5lib/filters/alphabeticalattributes.py
Document functions with clear intent
from __future__ import absolute_import, division, unicode_literals from .._utils import default_etree treeBuilderCache = {} def getTreeBuilder(treeType, implementation=None, **kwargs): treeType = treeType.lower() if treeType not in treeBuilderCache: if treeType == "dom": from . import ...
--- +++ @@ -1,3 +1,33 @@+"""A collection of modules for building different kinds of trees from HTML +documents. + +To create a treebuilder for a new type of tree, you need to do +implement several things: + +1. A set of classes for various types of elements: Document, Doctype, Comment, + Element. These must implement...
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/html5lib/treebuilders/__init__.py
Generate helpful docstrings for debugging
from __future__ import absolute_import, division import time import os import sys import errno from . import (LockBase, LockFailed, NotLocked, NotMyLock, LockTimeout, AlreadyLocked) class MkdirLockFile(LockBase): def __init__(self, path, threaded=True, timeout=None): LockBase.__init__(sel...
--- +++ @@ -10,7 +10,12 @@ class MkdirLockFile(LockBase): + """Lock file by creating a directory.""" def __init__(self, path, threaded=True, timeout=None): + """ + >>> lock = MkdirLockFile('somefile') + >>> lock = MkdirLockFile('somefile', threaded=False) + """ LockBase....
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/lockfile/mkdirlockfile.py
Document this script properly
from __future__ import absolute_import, division, unicode_literals from pip._vendor.six import text_type import re from codecs import register_error, xmlcharrefreplace_errors from .constants import voidElements, booleanAttributes, spaceCharacters from .constants import rcdataElements, entities, xmlEntities from . im...
--- +++ @@ -73,6 +73,28 @@ def serialize(input, tree="etree", encoding=None, **serializer_opts): + """Serializes the input token stream using the specified treewalker + + :arg input: the token stream to serialize + + :arg tree: the treewalker to use + + :arg encoding: the encoding to use + + :arg ser...
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/html5lib/serializer.py
Add docstrings to improve code quality
from __future__ import absolute_import, division, unicode_literals from pip._vendor.six import text_type from ..constants import scopingElements, tableInsertModeElements, namespaces # The scope markers are inserted when entering object elements, # marquees, table cells, and table captions, and are used to prevent for...
--- +++ @@ -21,7 +21,13 @@ class Node(object): + """Represents an item in the tree""" def __init__(self, name): + """Creates a Node + + :arg name: The tag name associated with the node + + """ # The tag name assocaited with the node self.name = name # The pare...
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/html5lib/treebuilders/base.py
Add docstrings to existing functions
from __future__ import absolute_import, division, unicode_literals from .. import constants from .._utils import default_etree __all__ = ["getTreeWalker", "pprint"] treeWalkerCache = {} def getTreeWalker(treeType, implementation=None, **kwargs): treeType = treeType.lower() if treeType not in treeWalkerCa...
--- +++ @@ -1,3 +1,12 @@+"""A collection of modules for iterating through different kinds of +tree, generating tokens identical to those produced by the tokenizer +module. + +To create a tree walker for a new type of tree, you need to do +implement a tree walker object (called TreeWalker by convention) that +implements...
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/html5lib/treewalkers/__init__.py
Add docstrings to incomplete code
from __future__ import absolute_import, division, unicode_literals # pylint:disable=protected-access import warnings import re import sys from . import base from ..constants import DataLossWarning from .. import constants from . import etree as etree_builders from .. import _ihatexml import lxml.etree as etree fu...
--- +++ @@ -1,3 +1,13 @@+"""Module for supporting the lxml.etree library. The idea here is to use as much +of the native library as possible, without using fragile hacks like custom element +names that break between releases. The downside of this is that we cannot represent +all possible trees; specifically the followi...
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/html5lib/treebuilders/etree_lxml.py
Annotate my code with docstrings
class UnpackException(Exception): class BufferFull(UnpackException): pass class OutOfData(UnpackException): pass class UnpackValueError(UnpackException, ValueError): class ExtraData(UnpackValueError): def __init__(self, unpacked, extra): self.unpacked = unpacked self.extra = extra ...
--- +++ @@ -1,4 +1,5 @@ class UnpackException(Exception): + """Deprecated. Use Exception instead to catch all exception during unpacking.""" class BufferFull(UnpackException): @@ -10,6 +11,7 @@ class UnpackValueError(UnpackException, ValueError): + """Deprecated. Use ValueError instead.""" class 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/_vendor/msgpack/exceptions.py
Can you add docstrings to this Python file?
from glob import glob from importlib import import_module import os from os.path import join as pjoin import re import shutil import sys # This is run as a script, not a module, so it can't do a relative import import compat class BackendUnavailable(Exception): def _build_backend(): ep = os.environ['PEP517_BUI...
--- +++ @@ -1,3 +1,15 @@+"""This is invoked in a subprocess to call the build backend hooks. + +It expects: +- Command line args: hook_name, control_dir +- Environment variable: PEP517_BUILD_BACKEND=entry.point:spec +- control_dir/input.json: + - {"kwargs": {...}} + +Results: +- control_dir/output.json + - {"return_v...
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/pep517/_in_process.py
Add docstrings to improve code quality
# 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 collections import itertools import re from ._structures import In...
--- +++ @@ -19,6 +19,11 @@ def parse(version): + """ + Parse the given version string and return either a :class:`Version` object + or a :class:`LegacyVersion` object depending on if the given version is + a valid PEP 440 version or a legacy version. + """ try: return Version(version) ...
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/packaging/version.py
Generate documentation strings for clarity
import argparse import logging import os import contextlib from pip._vendor import pytoml import shutil import errno import tempfile from .envbuild import BuildEnvironment from .wrappers import Pep517HookCaller log = logging.getLogger(__name__) @contextlib.contextmanager def tempdir(): td = tempfile.mkdtemp() ...
--- +++ @@ -1,3 +1,5 @@+"""Build a project using PEP 517 hooks. +""" import argparse import logging import os @@ -41,6 +43,9 @@ def mkdir_p(*args, **kwargs): + """Like `mkdir`, but does not raise an exception if the + directory already exists. + """ try: return os.mkdir(*args, **kwargs) ...
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/pep517/build.py
Generate docstrings with examples
from contextlib import contextmanager import os from os.path import dirname, abspath, join as pjoin import shutil from subprocess import check_call import sys from tempfile import mkdtemp from . import compat _in_proc_script = pjoin(dirname(abspath(__file__)), '_in_process.py') @contextmanager def tempdir(): td...
--- +++ @@ -21,12 +21,15 @@ class BackendUnavailable(Exception): + """Will be raised if the backend cannot be imported in the hook process.""" class UnsupportedOperation(Exception): + """May be raised by build_sdist if the backend indicates that it can't.""" def default_subprocess_runner(cmd, cwd=No...
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/pep517/wrappers.py
Generate consistent documentation across files
# -*- coding: utf-8 -*- from __future__ import absolute_import import functools import os import socket import threading import warnings # Work with PEP8 and non-PEP8 versions of threading module. if not hasattr(threading, "current_thread"): threading.current_thread = threading.currentThread if not hasattr(thre...
--- +++ @@ -1,5 +1,55 @@ # -*- coding: utf-8 -*- +""" +lockfile.py - Platform-independent advisory file locks. + +Requires Python 2.5 unless you apply 2.4.diff +Locking is done on a per-thread basis instead of a per-process basis. + +Usage: + +>>> lock = LockFile('somefile') +>>> try: +... lock.acquire() +... 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/_vendor/lockfile/__init__.py
Add return value explanations in docstrings
# Copyright 2007 Google Inc. # Licensed to PSF under a Contributor Agreement. from __future__ import unicode_literals import itertools import struct __version__ = '1.0.22' # Compatibility functions _compat_int_types = (int,) try: _compat_int_types = (int, long) except NameError: pass try: _compat_str...
--- +++ @@ -1,6 +1,12 @@ # Copyright 2007 Google Inc. # Licensed to PSF under a Contributor Agreement. +"""A fast, lightweight IPv4/IPv6 manipulation library in Python. + +This library is used to create/poke/manipulate IPv4 and IPv6 addresses +and networks. + +""" from __future__ import unicode_literals @@ -11...
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/ipaddress.py
Replace inline comments with docstrings
import os import logging from pip._vendor import pytoml import shutil from subprocess import check_call import sys from sysconfig import get_paths from tempfile import mkdtemp from .wrappers import Pep517HookCaller log = logging.getLogger(__name__) def _load_pyproject(source_dir): with open(os.path.join(source...
--- +++ @@ -1,3 +1,5 @@+"""Build wheels/sdists by installing build deps to a temporary environment. +""" import os import logging @@ -21,6 +23,10 @@ class BuildEnvironment(object): + """Context manager to install build deps in a simple temporary environment + + Based on code I wrote for pip, which is MIT ...
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/pep517/envbuild.py
Document my Python code with docstrings
# coding: utf-8 from __future__ import absolute_import import sys import os import io import time import re import types import zipfile import zipimport import warnings import stat import functools import pkgutil import operator import platform import collections import plistlib import email.parser import errno impor...
--- +++ @@ -1,4 +1,19 @@ # coding: utf-8 +""" +Package resource API +-------------------- + +A resource is a logical file contained within a package, or a logical +subdirectory thereof. The package resource API expects resource names +to have their path parts separated with ``/``, *not* whatever the local +path separa...
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/pkg_resources/__init__.py
Generate missing documentation strings
# 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 functools import itertools import re from ._compat impo...
--- +++ @@ -13,32 +13,65 @@ class InvalidSpecifier(ValueError): + """ + An invalid specifier was found, users should refer to PEP 440. + """ class BaseSpecifier(with_metaclass(abc.ABCMeta, object)): @abc.abstractmethod def __str__(self): + """ + Returns the str representation o...
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/packaging/specifiers.py
Add docstrings to clarify complex logic
# coding: utf-8 from pip._vendor.msgpack._version import version from pip._vendor.msgpack.exceptions import * from collections import namedtuple class ExtType(namedtuple('ExtType', 'code data')): def __new__(cls, code, data): if not isinstance(code, int): raise TypeError("code must be int") ...
--- +++ @@ -6,6 +6,7 @@ class ExtType(namedtuple('ExtType', 'code data')): + """ExtType represents ext type in msgpack.""" def __new__(cls, code, data): if not isinstance(code, int): raise TypeError("code must be int") @@ -28,15 +29,31 @@ def pack(o, stream, **kwargs): + """ + ...
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/msgpack/__init__.py
Write docstrings for this repository
# -*- coding: utf-8 -*- import os.path import socket from pip._vendor.urllib3.poolmanager import PoolManager, proxy_from_url from pip._vendor.urllib3.response import HTTPResponse from pip._vendor.urllib3.util import parse_url from pip._vendor.urllib3.util import Timeout as TimeoutSauce from pip._vendor.urllib3.util....
--- +++ @@ -1,5 +1,12 @@ # -*- coding: utf-8 -*- +""" +requests.adapters +~~~~~~~~~~~~~~~~~ + +This module contains the transport adapters that Requests uses to define +and maintain connections. +""" import os.path import socket @@ -46,19 +53,60 @@ class BaseAdapter(object): + """The Base Transport Adapter...
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/requests/adapters.py
Annotate my code 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 string import re from pip._vendor.pyparsing import stringStart, st...
--- +++ @@ -16,6 +16,9 @@ class InvalidRequirement(ValueError): + """ + An invalid requirement was found, users should refer to PEP 508. + """ ALPHANUM = Word(string.ascii_letters + string.digits) @@ -73,6 +76,12 @@ class Requirement(object): + """Parse a requirement. + + Parse a given 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/_vendor/packaging/requirements.py
Generate docstrings with parameter types
# -*- coding: utf-8 -*- from .compat import is_py2, builtin_str, str def to_native_string(string, encoding='ascii'): if isinstance(string, builtin_str): out = string else: if is_py2: out = string.encode(encoding) else: out = string.decode(encoding) return...
--- +++ @@ -1,10 +1,21 @@ # -*- coding: utf-8 -*- +""" +requests._internal_utils +~~~~~~~~~~~~~~ + +Provides utility functions that are consumed internally by Requests +which depend on extremely few external helpers (such as compat) +""" from .compat import is_py2, builtin_str, str def to_native_string(string...
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/requests/_internal_utils.py
Add clean documentation to messy code
# -*- coding: utf-8 -*- from . import sessions def request(method, url, **kwargs): # By using the 'with' statement we are sure the session is closed, thus we # avoid leaving sockets open which can trigger a ResourceWarning in some # cases, and look like a memory leak in others. with sessions.Sessio...
--- +++ @@ -1,10 +1,57 @@ # -*- coding: utf-8 -*- +""" +requests.api +~~~~~~~~~~~~ + +This module implements the Requests API. + +:copyright: (c) 2012 by Kenneth Reitz. +:license: Apache2, see LICENSE for more details. +""" from . import sessions def request(method, url, **kwargs): + """Constructs and send...
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/requests/api.py
Create documentation strings for testing functions
# Copyright 2012 Facebook # # 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, softwar...
--- +++ @@ -1,3 +1,7 @@+"""Nicer log formatting with colours. + +Code copied from Tornado, Apache licensed. +""" # Copyright 2012 Facebook # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -34,6 +38,8 @@ class LogFormatter(logging.Formatter): + """Log formatter with colour support...
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/pep517/colorlog.py
Add well-formatted docstrings
# -*- coding: utf-8 -*- import os import re import time import hashlib import threading import warnings from base64 import b64encode from .compat import urlparse, str, basestring from .cookies import extract_cookies_to_jar from ._internal_utils import to_native_string from .utils import parse_dict_header CONTENT_T...
--- +++ @@ -1,5 +1,11 @@ # -*- coding: utf-8 -*- +""" +requests.auth +~~~~~~~~~~~~~ + +This module contains the authentication handlers for Requests. +""" import os import re @@ -20,6 +26,7 @@ def _basic_auth_str(username, password): + """Returns a Basic Auth string.""" # "I want us to put a big-ol'...
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/requests/auth.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 operator import os import platform import sys from pip._vendor.pyp...
--- +++ @@ -26,12 +26,22 @@ class InvalidMarker(ValueError): + """ + An invalid marker was found, users should refer to PEP 508. + """ class UndefinedComparison(ValueError): + """ + An invalid operation was attempted on a value that doesn't support it. + """ class UndefinedEnvironmentNam...
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/packaging/markers.py
Add docstrings to incomplete code
# -*- coding: utf-8 -*- # pidlockfile.py # # Copyright © 2008–2009 Ben Finney <ben+python@benfinney.id.au> # # This is free software: you may copy, modify, and/or distribute this work # under the terms of the Python Software Foundation License, version 2 or # later as published by the Python Software Foundation. # No ...
--- +++ @@ -9,6 +9,8 @@ # later as published by the Python Software Foundation. # No warranty expressed or implied. See the file LICENSE.PSF-2 for details. +""" Lockfile behaviour implemented via Unix PID files. + """ from __future__ import absolute_import @@ -19,8 +21,17 @@ from . import (LockBase, AlreadyL...
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/lockfile/pidlockfile.py
Write proper docstrings for these functions
import sys import struct import warnings if sys.version_info[0] == 3: PY3 = True int_types = int Unicode = str xrange = range def dict_iteritems(d): return d.items() else: PY3 = False int_types = (int, long) Unicode = unicode def dict_iteritems(d): return d.iteritem...
--- +++ @@ -1,3 +1,4 @@+"""Fallback pure Python implementation of msgpack""" import sys import struct @@ -108,6 +109,12 @@ def unpackb(packed, **kwargs): + """ + Unpack an object from `packed`. + + Raises `ExtraData` when `packed` contains extra bytes. + See :class:`Unpacker` for options. + """ ...
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/msgpack/fallback.py
Add docstrings to clarify complex logic
# -*- coding: utf-8 -*- import os import sys import time from datetime import timedelta from .auth import _basic_auth_str from .compat import cookielib, is_py3, OrderedDict, urljoin, urlparse, Mapping from .cookies import ( cookiejar_from_dict, extract_cookies_to_jar, RequestsCookieJar, merge_cookies) from .model...
--- +++ @@ -1,5 +1,12 @@ # -*- coding: utf-8 -*- +""" +requests.session +~~~~~~~~~~~~~~~~ + +This module provides a Session object to manage and persist settings across +requests (cookies, auth, proxies). +""" import os import sys import time @@ -40,6 +47,10 @@ def merge_setting(request_setting, session_settin...
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/requests/sessions.py
Add docstrings that explain inputs and outputs
from __future__ import absolute_import from logging import getLogger from ntlm import ntlm from .. import HTTPSConnectionPool from ..packages.six.moves.http_client import HTTPSConnection log = getLogger(__name__) class NTLMConnectionPool(HTTPSConnectionPool): scheme = 'https' def __init__(self, user, pw...
--- +++ @@ -1,3 +1,8 @@+""" +NTLM authenticating pool, contributed by erikcederstran + +Issue #10, see: http://code.google.com/p/urllib3/issues/detail?id=10 +""" from __future__ import absolute_import from logging import getLogger @@ -11,10 +16,18 @@ class NTLMConnectionPool(HTTPSConnectionPool): + """ + ...
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/urllib3/contrib/ntlmpool.py
Create documentation strings for testing functions
# -*- coding: utf-8 -*- HOOKS = ['response'] def default_hooks(): return {event: [] for event in HOOKS} # TODO: response is the only one def dispatch_hook(key, hooks, hook_data, **kwargs): hooks = hooks or {} hooks = hooks.get(key) if hooks: if hasattr(hooks, '__call__'): hooks...
--- +++ @@ -1,5 +1,16 @@ # -*- coding: utf-8 -*- +""" +requests.hooks +~~~~~~~~~~~~~~ + +This module provides the capabilities for the Requests hooks system. + +Available hooks: + +``response``: + The response generated from a Request. +""" HOOKS = ['response'] @@ -10,6 +21,7 @@ def dispatch_hook(key, hoo...
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/requests/hooks.py
Create Google-style docstrings for my code
# -*- coding: utf-8 -*- from pip._vendor.urllib3.exceptions import HTTPError as BaseHTTPError class RequestException(IOError): def __init__(self, *args, **kwargs): response = kwargs.pop('response', None) self.response = response self.request = kwargs.pop('request', None) if (resp...
--- +++ @@ -1,11 +1,21 @@ # -*- coding: utf-8 -*- +""" +requests.exceptions +~~~~~~~~~~~~~~~~~~~ + +This module contains the set of Requests' exceptions. +""" from pip._vendor.urllib3.exceptions import HTTPError as BaseHTTPError class RequestException(IOError): + """There was an ambiguous exception that occu...
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/requests/exceptions.py
Add documentation for all methods
from __future__ import absolute_import import platform from ctypes.util import find_library from ctypes import ( c_void_p, c_int32, c_char_p, c_size_t, c_byte, c_uint32, c_ulong, c_long, c_bool ) from ctypes import CDLL, POINTER, CFUNCTYPE security_path = find_library('Security') if not security_path: ra...
--- +++ @@ -1,3 +1,34 @@+""" +This module uses ctypes to bind a whole bunch of functions and constants from +SecureTransport. The goal here is to provide the low-level API to +SecureTransport. These are essentially the C-level functions and constants, and +they're pretty gross to work with. + +This code is a bastardise...
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/urllib3/contrib/_securetransport/bindings.py
Add missing documentation to my Python functions
# -*- coding: utf-8 -*- from __future__ import absolute_import try: import socks except ImportError: import warnings from ..exceptions import DependencyWarning warnings.warn(( 'SOCKS support in urllib3 requires the installation of optional ' 'dependencies: specifically, PySocks. For m...
--- +++ @@ -1,4 +1,26 @@ # -*- coding: utf-8 -*- +""" +This module contains provisional support for SOCKS proxies from within +urllib3. This module supports SOCKS4 (specifically the SOCKS4A variant) and +SOCKS5. To enable its functionality, either install PySocks or install this +module with the ``socks`` extra. + +The...
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/urllib3/contrib/socks.py
Add structured docstrings to improve clarity
from __future__ import absolute_import from .packages.six.moves.http_client import ( IncompleteRead as httplib_IncompleteRead ) # Base Exceptions class HTTPError(Exception): pass class HTTPWarning(Warning): pass class PoolError(HTTPError): def __init__(self, pool, message): self.pool = poo...
--- +++ @@ -6,14 +6,17 @@ class HTTPError(Exception): + "Base exception used by this module." pass class HTTPWarning(Warning): + "Base warning used by this module." pass class PoolError(HTTPError): + "Base exception for errors caused within a pool." def __init__(self, pool, message...
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/urllib3/exceptions.py
Add docstrings to meet PEP guidelines
# -*- coding: utf-8 -*- from .compat import OrderedDict, Mapping, MutableMapping class CaseInsensitiveDict(MutableMapping): def __init__(self, data=None, **kwargs): self._store = OrderedDict() if data is None: data = {} self.update(data, **kwargs) def __setitem__(self, ...
--- +++ @@ -1,10 +1,41 @@ # -*- coding: utf-8 -*- +""" +requests.structures +~~~~~~~~~~~~~~~~~~~ + +Data structures that power Requests. +""" from .compat import OrderedDict, Mapping, MutableMapping class CaseInsensitiveDict(MutableMapping): + """A case-insensitive ``dict``-like object. + + Implements a...
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/requests/structures.py
Write clean docstrings for readability
from __future__ import absolute_import import contextlib import ctypes import errno import os.path import shutil import socket import ssl import threading import weakref from .. import util from ._securetransport.bindings import ( Security, SecurityConst, CoreFoundation ) from ._securetransport.low_level import (...
--- +++ @@ -1,3 +1,29 @@+""" +SecureTranport support for urllib3 via ctypes. + +This makes platform-native TLS available to urllib3 users on macOS without the +use of a compiler. This is an important feature because the Python Package +Index is moving to become a TLSv1.2-or-higher server, and the default OpenSSL +that ...
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/urllib3/contrib/securetransport.py
Create docstrings for each class method
# -*- coding: utf-8 -*- import datetime import sys # Import encoding now, to avoid implicit import later. # Implicit import within threads may cause LookupError when standard library is in a ZIP, # such as in Embedded Python. See https://github.com/requests/requests/issues/3578. import encodings.idna from pip._vend...
--- +++ @@ -1,5 +1,11 @@ # -*- coding: utf-8 -*- +""" +requests.models +~~~~~~~~~~~~~~~ + +This module contains the primary objects that power Requests. +""" import datetime import sys @@ -54,6 +60,7 @@ class RequestEncodingMixin(object): @property def path_url(self): + """Build the path URL to u...
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/requests/models.py
Document this module using docstrings
from __future__ import absolute_import import errno import logging import sys import warnings from socket import error as SocketError, timeout as SocketTimeout import socket from .exceptions import ( ClosedPoolError, ProtocolError, EmptyPoolError, HeaderParsingError, HostChangedError, Locatio...
--- +++ @@ -53,6 +53,10 @@ # Pool objects class ConnectionPool(object): + """ + Base class for all connection pools, such as + :class:`.HTTPConnectionPool` and :class:`.HTTPSConnectionPool`. + """ scheme = None QueueCls = LifoQueue @@ -78,6 +82,9 @@ return False def close(self)...
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/urllib3/connectionpool.py
Add standardized docstrings across the file
# -*- coding: utf-8 -*- import copy import time import calendar from ._internal_utils import to_native_string from .compat import cookielib, urlparse, urlunparse, Morsel, MutableMapping try: import threading except ImportError: import dummy_threading as threading class MockRequest(object): def __init...
--- +++ @@ -1,5 +1,13 @@ # -*- coding: utf-8 -*- +""" +requests.cookies +~~~~~~~~~~~~~~~~ + +Compatibility code to be able to use `cookielib.CookieJar` with requests. + +requests.utils imports from here, so be careful with imports. +""" import copy import time @@ -15,6 +23,16 @@ class MockRequest(object): + ...
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/requests/cookies.py
Document this module using docstrings
from __future__ import absolute_import import datetime import logging import os import socket from socket import error as SocketError, timeout as SocketTimeout import warnings from .packages import six from .packages.six.moves.http_client import HTTPConnection as _HTTPConnection from .packages.six.moves.http_client imp...
--- +++ @@ -63,10 +63,33 @@ class DummyConnection(object): + """Used to detect a failed ConnectionCls import.""" pass class HTTPConnection(_HTTPConnection, object): + """ + Based on httplib.HTTPConnection but provides an extra constructor + backwards-compatibility layer between older and newer...
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/urllib3/connection.py
Add docstrings that explain purpose and usage
import base64 import ctypes import itertools import re import os import ssl import tempfile from .bindings import Security, CoreFoundation, CFConst # This regular expression is used to grab PEM data out of a PEM bundle. _PEM_CERTS_RE = re.compile( b"-----BEGIN CERTIFICATE-----\n(.*?)\n-----END CERTIFICATE-----",...
--- +++ @@ -1,3 +1,12 @@+""" +Low-level helpers for the SecureTransport bindings. + +These are Python functions that are not directly related to the high-level APIs +but are necessary to get them to work. They include a whole bunch of low-level +CoreFoundation messing about and memory management. The concerns in this m...
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/urllib3/contrib/_securetransport/low_level.py
Annotate my code with docstrings
from __future__ import absolute_import import email.utils import mimetypes from .packages import six def guess_content_type(filename, default='application/octet-stream'): if filename: return mimetypes.guess_type(filename)[0] or default return default def format_header_param(name, value): if not...
--- +++ @@ -6,12 +6,32 @@ def guess_content_type(filename, default='application/octet-stream'): + """ + Guess the "Content-Type" of a file. + + :param filename: + The filename to guess the "Content-Type" of using :mod:`mimetypes`. + :param default: + If no "Content-Type" can be guessed, 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/_vendor/urllib3/fields.py
Fully document this Python code with docstrings
from __future__ import print_function import json import platform import sys import ssl from pip._vendor import idna from pip._vendor import urllib3 from pip._vendor import chardet from . import __version__ as requests_version try: from pip._vendor.urllib3.contrib import pyopenssl except ImportError: pyopen...
--- +++ @@ -1,3 +1,4 @@+"""Module containing bug report helper(s).""" from __future__ import print_function import json @@ -23,6 +24,16 @@ def _implementation(): + """Return a dict with the Python implementation and version. + + Provide both the name and the version of the Python implementation + curre...
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/requests/help.py
Write Python docstrings for this snippet
from __future__ import absolute_import import OpenSSL.SSL from cryptography import x509 from cryptography.hazmat.backends.openssl import backend as openssl_backend from cryptography.hazmat.backends.openssl.x509 import _Certificate try: from cryptography.x509 import UnsupportedExtension except ImportError: # Un...
--- +++ @@ -1,3 +1,46 @@+""" +SSL with SNI_-support for Python 2. Follow these instructions if you would +like to verify SSL certificates in Python 2. Note, the default libraries do +*not* do certificate checking; you need to do additional work to validate +certificates yourself. + +This needs the following packages in...
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/urllib3/contrib/pyopenssl.py
Write docstrings for data processing functions
from __future__ import absolute_import import io import logging import warnings from ..packages.six.moves.urllib.parse import urljoin from ..exceptions import ( HTTPError, HTTPWarning, MaxRetryError, ProtocolError, TimeoutError, SSLError ) from ..request import RequestMethods from ..response ...
--- +++ @@ -1,3 +1,42 @@+""" +This module provides a pool manager that uses Google App Engine's +`URLFetch Service <https://cloud.google.com/appengine/docs/python/urlfetch>`_. + +Example usage:: + + from pip._vendor.urllib3 import PoolManager + from pip._vendor.urllib3.contrib.appengine import AppEngineManager, i...
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/urllib3/contrib/appengine.py
Add well-formatted docstrings
import errno from functools import partial import select import sys try: from time import monotonic except ImportError: from time import time as monotonic __all__ = ["NoWayToWaitForSocketError", "wait_for_read", "wait_for_write"] class NoWayToWaitForSocketError(Exception): pass # How should we wait on ...
--- +++ @@ -137,8 +137,14 @@ def wait_for_read(sock, timeout=None): + """ Waits for reading to be available on a given socket. + Returns True if the socket is readable, or False if the timeout expired. + """ return wait_for_socket(sock, read=True, timeout=timeout) def wait_for_write(sock, timeout...
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/urllib3/util/wait.py
Create docstrings for reusable components
from __future__ import absolute_import import errno import warnings import hmac import socket from binascii import hexlify, unhexlify from hashlib import md5, sha1, sha256 from ..exceptions import SSLError, InsecurePlatformWarning, SNIMissingWarning from ..packages import six SSLContext = None HAS_SNI = False IS_PY...
--- +++ @@ -25,6 +25,12 @@ def _const_compare_digest_backport(a, b): + """ + Compare two digests of equal length in constant time. + + The digests must be of type str/bytes. + Returns True if the digests match, and False otherwise. + """ result = abs(len(a) - len(b)) for l, r in zip(bytearr...
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/urllib3/util/ssl_.py
Help me write clear docstrings
from __future__ import absolute_import import warnings from .connectionpool import ( HTTPConnectionPool, HTTPSConnectionPool, connection_from_url ) from . import exceptions from .filepost import encode_multipart_formdata from .poolmanager import PoolManager, ProxyManager, proxy_from_url from .response im...
--- +++ @@ -1,3 +1,6 @@+""" +urllib3 - Thread-safe connection pooling and re-using. +""" from __future__ import absolute_import import warnings @@ -47,6 +50,12 @@ def add_stderr_logger(level=logging.DEBUG): + """ + Helper for quickly adding a StreamHandler to the logger. Useful for + debugging. + + ...
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/urllib3/__init__.py
Add docstrings to improve readability
# coding: utf-8 from __future__ import unicode_literals import codecs from .labels import LABELS VERSION = '0.5.1' # Some names in Encoding are not valid Python aliases. Remap these. PYTHON_NAMES = { 'iso-8859-8-i': 'iso-8859-8', 'x-mac-cyrillic': 'mac-cyrillic', 'macintosh': 'mac-roman', 'window...
--- +++ @@ -1,4 +1,16 @@ # coding: utf-8 +""" + + webencodings + ~~~~~~~~~~~~ + + This is a Python implementation of the `WHATWG Encoding standard + <http://encoding.spec.whatwg.org/>`. See README for details. + + :copyright: Copyright 2012 by Simon Sapin + :license: BSD, see LICENSE for details. + +"...
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/webencodings/__init__.py
Create documentation strings for testing functions
# Copyright (c) 2010-2015 Benjamin Peterson # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publ...
--- +++ @@ -1,3 +1,4 @@+"""Utilities for writing code that runs on Python 2 and 3""" # Copyright (c) 2010-2015 Benjamin Peterson # @@ -72,10 +73,12 @@ def _add_doc(func, doc): + """Add documentation to a function.""" func.__doc__ = doc def _import_module(name): + """Import module, returning the ...
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/urllib3/packages/six.py
Add structured docstrings to improve clarity
## Copyright 2013-2014 Ray Holder ## ## 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 ...
--- +++ @@ -24,6 +24,11 @@ def retry(*dargs, **dkw): + """ + Decorator function that instantiates the Retrying object + @param *dargs: positional arguments passed to Retrying object + @param **dkw: keyword arguments passed to the Retrying object + """ # support both @retry and @retry() as valid ...
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/retrying.py
Document this script properly
from __future__ import absolute_import import time import logging from collections import namedtuple from itertools import takewhile import email import re from ..exceptions import ( ConnectTimeoutError, MaxRetryError, ProtocolError, ReadTimeoutError, ResponseError, InvalidHeader, ) from ..pack...
--- +++ @@ -26,6 +26,125 @@ class Retry(object): + """ Retry configuration. + + Each retry attempt will create a new Retry object with updated values, so + they can be safely reused. + + Retries can be defined as a default for a pool:: + + retries = Retry(connect=5, read=2, redirect=5) + h...
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/urllib3/util/retry.py
Create Google-style docstrings for my code
# Copyright (c) 2010-2018 Benjamin Peterson # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publi...
--- +++ @@ -18,6 +18,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +"""Utilities for writing code that runs on Python 2 and 3""" from __future__ import absolute_import @@ -72,10 +73,12 @@ def _add_doc(func, doc): + """Add documentation to a function.""" ...
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/six.py
Generate docstrings for exported functions
from __future__ import absolute_import # The default socket timeout, used by httplib to indicate that no timeout was # specified by the user from socket import _GLOBAL_DEFAULT_TIMEOUT import time from ..exceptions import TimeoutStateError # A sentinel value to indicate that no timeout was specified by the user in # u...
--- +++ @@ -16,6 +16,76 @@ class Timeout(object): + """ Timeout configuration. + + Timeouts can be defined as a default for a pool:: + + timeout = Timeout(connect=2.0, read=7.0) + http = PoolManager(timeout=timeout) + response = http.request('GET', 'http://example.com/') + + Or per-req...
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/urllib3/util/timeout.py
Write reusable docstrings
# -*- coding: utf-8 -*- import io from socket import SocketIO def backport_makefile(self, mode="r", buffering=None, encoding=None, errors=None, newline=None): if not set(mode) <= {"r", "w", "b"}: raise ValueError( "invalid mode %r (only r, w, b allowed)" % (mode,) ...
--- +++ @@ -1,4 +1,11 @@ # -*- coding: utf-8 -*- +""" +backports.makefile +~~~~~~~~~~~~~~~~~~ + +Backports the Python 3 ``socket.makefile`` method for use with anything that +wants to create a "fake" socket object. +""" import io from socket import SocketIO @@ -6,6 +13,9 @@ def backport_makefile(self, mode="r", 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/_vendor/urllib3/packages/backports/makefile.py
Add missing documentation to my Python functions
from __future__ import absolute_import from collections import namedtuple from ..exceptions import LocationParseError url_attrs = ['scheme', 'auth', 'host', 'port', 'path', 'query', 'fragment'] # We only want to normalize urls with an HTTP(S) scheme. # urllib3 infers URLs without a scheme (None) to be http. NORMALI...
--- +++ @@ -12,6 +12,11 @@ class Url(namedtuple('Url', url_attrs)): + """ + Datastructure for representing an HTTP URL. Used as a return value for + :func:`parse_url`. Both the scheme and host are normalized as they are + both case-insensitive according to RFC 3986. + """ __slots__ = () d...
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/urllib3/util/url.py
Generate docstrings with examples
# -*- coding: utf-8 -*- import codecs import contextlib import io import os import re import socket import struct import sys import tempfile import warnings import zipfile from .__version__ import __version__ from . import certs # to_native_string is unused here, but imported here for backwards compatibility from ._...
--- +++ @@ -1,5 +1,12 @@ # -*- coding: utf-8 -*- +""" +requests.utils +~~~~~~~~~~~~~~ + +This module provides utility functions that are used within Requests +that are also useful for external consumption. +""" import codecs import contextlib @@ -77,6 +84,11 @@ return False def proxy_bypass(host): ...
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/requests/utils.py
Create simple docstrings for beginners
from __future__ import absolute_import try: from collections.abc import Mapping, MutableMapping except ImportError: from collections import Mapping, MutableMapping try: from threading import RLock except ImportError: # Platform-specific: No threads available class RLock: def __enter__(self): ...
--- +++ @@ -26,6 +26,18 @@ class RecentlyUsedContainer(MutableMapping): + """ + Provides a thread-safe dict-like container which maintains up to + ``maxsize`` keys while throwing away the least-recently-used keys beyond + ``maxsize``. + + :param maxsize: + Maximum number of recent elements to ...
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/urllib3/_collections.py
Document this code for team use
from __future__ import absolute_import import binascii import codecs import os from io import BytesIO from .packages import six from .packages.six import b from .fields import RequestField writer = codecs.lookup('utf-8')[3] def choose_boundary(): boundary = binascii.hexlify(os.urandom(16)) if six.PY3: ...
--- +++ @@ -13,6 +13,9 @@ def choose_boundary(): + """ + Our embarrassingly-simple replacement for mimetools.choose_boundary. + """ boundary = binascii.hexlify(os.urandom(16)) if six.PY3: boundary = boundary.decode('ascii') @@ -20,6 +23,13 @@ def iter_field_objects(fields): + """ ...
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/urllib3/filepost.py
Generate documentation strings for clarity
from __future__ import absolute_import from base64 import b64encode from ..packages.six import b, integer_types from ..exceptions import UnrewindableBodyError ACCEPT_ENCODING = 'gzip,deflate' _FAILEDTELL = object() def make_headers(keep_alive=None, accept_encoding=None, user_agent=None, basic_auth=...
--- +++ @@ -10,6 +10,40 @@ def make_headers(keep_alive=None, accept_encoding=None, user_agent=None, basic_auth=None, proxy_basic_auth=None, disable_cache=None): + """ + Shortcuts for generating request headers. + + :param keep_alive: + If ``True``, adds 'connection: keep-alive' heade...
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/urllib3/util/request.py
Add minimal docstrings for each function
from __future__ import absolute_import from .filepost import encode_multipart_formdata from .packages.six.moves.urllib.parse import urlencode __all__ = ['RequestMethods'] class RequestMethods(object): _encode_url_methods = {'DELETE', 'GET', 'HEAD', 'OPTIONS'} def __init__(self, headers=None): sel...
--- +++ @@ -8,6 +8,33 @@ class RequestMethods(object): + """ + Convenience mixin for classes who implement a :meth:`urlopen` method, such + as :class:`~urllib3.connectionpool.HTTPConnectionPool` and + :class:`~urllib3.poolmanager.PoolManager`. + + Provides behavior for making common types of HTTP req...
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/urllib3/request.py
Add docstrings including usage examples
# Note: This file is under the PSF license as the code comes from the python # stdlib. http://docs.python.org/3/license.html import re import sys # ipaddress has been backported to 2.6+ in pypi. If it is installed on the # system, use it to handle IPAddress ServerAltnames (this was added in # python-3.5) otherwis...
--- +++ @@ -1,3 +1,4 @@+"""The match_hostname() function from Python 3.3.3, essential when using SSL.""" # Note: This file is under the PSF license as the code comes from the python # stdlib. http://docs.python.org/3/license.html @@ -22,6 +23,10 @@ def _dnsname_match(dn, hostname, max_wildcards=1): + """Ma...
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/urllib3/packages/ssl_match_hostname/_implementation.py
Generate docstrings with examples
from __future__ import absolute_import from ..packages.six.moves import http_client as httplib from ..exceptions import HeaderParsingError def is_fp_closed(obj): try: # Check `isclosed()` first, in case Python3 doesn't set `closed`. # GH Issue #928 return obj.isclosed() except Attrib...
--- +++ @@ -5,6 +5,12 @@ def is_fp_closed(obj): + """ + Checks whether a given file-like object is closed. + + :param obj: + The file-like object to check. + """ try: # Check `isclosed()` first, in case Python3 doesn't set `closed`. @@ -30,6 +36,18 @@ def assert_header_parsing...
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/urllib3/util/response.py
Add docstrings to improve readability
from __future__ import absolute_import from contextlib import contextmanager import zlib import io import logging from socket import timeout as SocketTimeout from socket import error as SocketError from ._collections import HTTPHeaderDict from .exceptions import ( BodyNotHttplibCompatible, ProtocolError, DecodeErr...
--- +++ @@ -91,6 +91,13 @@ class MultiDecoder(object): + """ + From RFC7231: + If one or more encodings have been applied to a representation, the + sender that applied the encodings MUST generate a Content-Encoding + header field that lists the content codings in the order in which + ...
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/urllib3/response.py
Create docstrings for API functions
from __future__ import absolute_import import collections import functools import logging from ._collections import RecentlyUsedContainer from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool from .connectionpool import port_by_scheme from .exceptions import LocationValueError, MaxRetryError, ProxyScheme...
--- +++ @@ -56,6 +56,25 @@ def _default_key_normalizer(key_class, request_context): + """ + Create a pool key out of a request context dictionary. + + According to RFC 3986, both the scheme and host are case-insensitive. + Therefore, this function normalizes both before constructing the pool + key fo...
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/urllib3/poolmanager.py
Add docstrings for better understanding
from __future__ import absolute_import import socket from .wait import NoWayToWaitForSocketError, wait_for_read from ..contrib import _appengine_environ def is_connection_dropped(conn): # Platform-specific sock = getattr(conn, 'sock', False) if sock is False: # Platform-specific: AppEngine return Fa...
--- +++ @@ -5,6 +5,15 @@ def is_connection_dropped(conn): # Platform-specific + """ + Returns True if the connection is dropped and should be closed. + + :param conn: + :class:`httplib.HTTPConnection` object. + + Note: For platforms like AppEngine, this will always return ``False`` to + let 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/_vendor/urllib3/util/connection.py
Create simple docstrings for beginners
# # This file is part of pyasn1 software. # # Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com> # License: http://snmplabs.com/pyasn1/license.html # class PyAsn1Error(Exception): class ValueConstraintError(PyAsn1Error): class SubstrateUnderrunError(PyAsn1Error): class PyAsn1UnicodeError(PyAsn1Error, Uni...
--- +++ @@ -7,15 +7,42 @@ class PyAsn1Error(Exception): + """Base pyasn1 exception + + `PyAsn1Error` is the base exception class (based on + :class:`Exception`) that represents all possible ASN.1 related + errors. + """ class ValueConstraintError(PyAsn1Error): + """ASN.1 type constraints viol...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pyasn1/error.py
Add professional docstrings to my codebase
# # This file is part of pyasn1 software. # # Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com> # License: http://snmplabs.com/pyasn1/license.html # import math import sys from pyasn1 import error from pyasn1.codec.ber import eoo from pyasn1.compat import binary from pyasn1.compat import integer from pyasn1.co...
--- +++ @@ -32,6 +32,55 @@ class Integer(base.SimpleAsn1Type): + """Create |ASN.1| schema or value object. + + |ASN.1| class is based on :class:`~pyasn1.type.base.SimpleAsn1Type`, its + objects are immutable and duck-type Python :class:`int` objects. + + Keyword Args + ------------ + value: :class...
https://raw.githubusercontent.com/wistbean/learn_python3_spider/HEAD/stackoverflow/venv/lib/python3.6/site-packages/pyasn1/type/univ.py