SILENT KILLERPanel

Current Path: > > usr > lib > python2.7 > site-packages > pip > _vendor > cachecontrol


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: //usr/lib/python2.7/site-packages/pip/_vendor/cachecontrol

NameTypeSizeLast ModifiedActions
caches Directory - -
__init__.py File 302 bytes April 21 2022 18:08:21.
__init__.pyc File 583 bytes April 21 2022 18:08:34.
__init__.pyo File 583 bytes April 21 2022 18:08:34.
_cmd.py File 1320 bytes April 21 2022 18:08:21.
_cmd.pyc File 2059 bytes April 21 2022 18:08:34.
_cmd.pyo File 2059 bytes April 21 2022 18:08:34.
adapter.py File 4608 bytes April 21 2022 18:08:21.
adapter.pyc File 3523 bytes April 21 2022 18:08:34.
adapter.pyo File 3523 bytes April 21 2022 18:08:34.
cache.py File 790 bytes April 21 2022 18:08:21.
cache.pyc File 2401 bytes April 21 2022 18:08:34.
cache.pyo File 2401 bytes April 21 2022 18:08:34.
compat.py File 380 bytes April 21 2022 18:08:21.
compat.pyc File 618 bytes April 21 2022 18:08:34.
compat.pyo File 618 bytes April 21 2022 18:08:34.
controller.py File 13024 bytes April 21 2022 18:08:21.
controller.pyc File 9078 bytes April 21 2022 18:08:34.
controller.pyo File 9078 bytes April 21 2022 18:08:34.
filewrapper.py File 2531 bytes April 21 2022 18:08:21.
filewrapper.pyc File 2667 bytes April 21 2022 18:08:34.
filewrapper.pyo File 2667 bytes April 21 2022 18:08:34.
heuristics.py File 4141 bytes April 21 2022 18:08:21.
heuristics.pyc File 5937 bytes April 21 2022 18:08:34.
heuristics.pyo File 5937 bytes April 21 2022 18:08:34.
serialize.py File 6536 bytes April 21 2022 18:08:21.
serialize.pyc File 6096 bytes April 21 2022 18:08:34.
serialize.pyo File 6096 bytes April 21 2022 18:08:34.
wrapper.py File 498 bytes April 21 2022 18:08:21.
wrapper.pyc File 696 bytes April 21 2022 18:08:34.
wrapper.pyo File 696 bytes April 21 2022 18:08:34.

Reading File: //usr/lib/python2.7/site-packages/pip/_vendor/cachecontrol/filewrapper.py

from io import BytesIO


class CallbackFileWrapper(object):
    """
    Small wrapper around a fp object which will tee everything read into a
    buffer, and when that file is closed it will execute a callback with the
    contents of that buffer.

    All attributes are proxied to the underlying file object.

    This class uses members with a double underscore (__) leading prefix so as
    not to accidentally shadow an attribute.
    """

    def __init__(self, fp, callback):
        self.__buf = BytesIO()
        self.__fp = fp
        self.__callback = callback

    def __getattr__(self, name):
        # The vaguaries of garbage collection means that self.__fp is
        # not always set.  By using __getattribute__ and the private
        # name[0] allows looking up the attribute value and raising an
        # AttributeError when it doesn't exist. This stop thigns from
        # infinitely recursing calls to getattr in the case where
        # self.__fp hasn't been set.
        #
        # [0] https://docs.python.org/2/reference/expressions.html#atom-identifiers
        fp = self.__getattribute__('_CallbackFileWrapper__fp')
        return getattr(fp, name)

    def __is_fp_closed(self):
        try:
            return self.__fp.fp is None
        except AttributeError:
            pass

        try:
            return self.__fp.closed
        except AttributeError:
            pass

        # We just don't cache it then.
        # TODO: Add some logging here...
        return False

    def _close(self):
        if self.__callback:
            self.__callback(self.__buf.getvalue())

        # We assign this to None here, because otherwise we can get into
        # really tricky problems where the CPython interpreter dead locks
        # because the callback is holding a reference to something which
        # has a __del__ method. Setting this to None breaks the cycle
        # and allows the garbage collector to do it's thing normally.
        self.__callback = None

    def read(self, amt=None):
        data = self.__fp.read(amt)
        self.__buf.write(data)
        if self.__is_fp_closed():
            self._close()

        return data

    def _safe_read(self, amt):
        data = self.__fp._safe_read(amt)
        if amt == 2 and data == b'\r\n':
            # urllib executes this read to toss the CRLF at the end
            # of the chunk.
            return data

        self.__buf.write(data)
        if self.__is_fp_closed():
            self._close()

        return data

SILENT KILLER Tool