Hackfut Security File Manager
Current Path:
/usr/lib/python2.6/site-packages/pip/_vendor/cachecontrol
usr
/
lib
/
python2.6
/
site-packages
/
pip
/
_vendor
/
cachecontrol
/
📁
..
📄
__init__.py
(302 B)
📄
__init__.pyc
(583 B)
📄
__init__.pyo
(583 B)
📄
adapter.py
(4.1 KB)
📄
adapter.pyc
(3.06 KB)
📄
adapter.pyo
(3.06 KB)
📄
cache.py
(790 B)
📄
cache.pyc
(2.41 KB)
📄
cache.pyo
(2.41 KB)
📁
caches
📄
compat.py
(311 B)
📄
compat.pyc
(560 B)
📄
compat.pyo
(560 B)
📄
controller.py
(9.89 KB)
📄
controller.pyc
(7.27 KB)
📄
controller.pyo
(7.27 KB)
📄
filewrapper.py
(2.12 KB)
📄
filewrapper.pyc
(2.11 KB)
📄
filewrapper.pyo
(2.11 KB)
📄
heuristics.py
(3.96 KB)
📄
heuristics.pyc
(5.78 KB)
📄
heuristics.pyo
(5.78 KB)
📄
serialize.py
(6.04 KB)
📄
serialize.pyc
(5.6 KB)
📄
serialize.pyo
(5.6 KB)
📄
wrapper.py
(498 B)
📄
wrapper.pyc
(697 B)
📄
wrapper.pyo
(697 B)
Editing: 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 read(self, amt=None): data = self.__fp.read(amt) self.__buf.write(data) if self.__is_fp_closed(): 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 return data
Upload File
Create Folder