1010
1111
1212class SlidingWindowMapBuffer (object ):
13+
1314 """A buffer like object which allows direct byte-wise object and slicing into
1415 memory of a mapped file. The mapping is controlled by the provided cursor.
1516
@@ -20,9 +21,9 @@ class SlidingWindowMapBuffer(object):
2021 underneath, it can unfortunately not be used in any non-pure python method which
2122 needs a buffer or string"""
2223 __slots__ = (
23- '_c' , # our cursor
24- '_size' , # our supposed size
25- )
24+ '_c' , # our cursor
25+ '_size' , # our supposed size
26+ )
2627
2728 def __init__ (self , cursor = None , offset = 0 , size = sys .maxsize , flags = 0 ):
2829 """Initalize the instance to operate on the given cursor.
@@ -57,7 +58,7 @@ def __getitem__(self, i):
5758 if not c .includes_ofs (i ):
5859 c .use_region (i , 1 )
5960 # END handle region usage
60- return c .buffer ()[i - c .ofs_begin ()]
61+ return c .buffer ()[i - c .ofs_begin ()]
6162
6263 def __getslice__ (self , i , j ):
6364 c = self ._c
@@ -72,9 +73,9 @@ def __getslice__(self, i, j):
7273 j = self ._size + j
7374 if (c .ofs_begin () <= i ) and (j < c .ofs_end ()):
7475 b = c .ofs_begin ()
75- return c .buffer ()[i - b :j - b ]
76+ return c .buffer ()[i - b :j - b ]
7677 else :
77- l = j - i # total length
78+ l = j - i # total length
7879 ofs = i
7980 # It's fastest to keep tokens and join later, especially in py3, which was 7 times slower
8081 # in the previous iteration of this code
@@ -86,7 +87,7 @@ def __getslice__(self, i, j):
8687 ofs += len (d )
8788 l -= len (d )
8889 md .append (d )
89- #END while there are bytes to read
90+ # END while there are bytes to read
9091 return bytes ().join (md )
9192 # END fast or slow path
9293 #{ Interface
@@ -100,7 +101,7 @@ def begin_access(self, cursor=None, offset=0, size=sys.maxsize, flags=0):
100101 :return: True if the buffer can be used"""
101102 if cursor :
102103 self ._c = cursor
103- #END update our cursor
104+ # END update our cursor
104105
105106 # reuse existing cursors if possible
106107 if self ._c is not None and self ._c .is_associated ():
@@ -112,9 +113,9 @@ def begin_access(self, cursor=None, offset=0, size=sys.maxsize, flags=0):
112113 # If not, the user is in trouble.
113114 if size > self ._c .file_size ():
114115 size = self ._c .file_size () - offset
115- #END handle size
116+ # END handle size
116117 self ._size = size
117- #END set size
118+ # END set size
118119 return res
119120 # END use our cursor
120121 return False
@@ -128,7 +129,7 @@ def end_access(self):
128129 self ._size = 0
129130 if self ._c is not None :
130131 self ._c .unuse_region ()
131- #END unuse region
132+ # END unuse region
132133
133134 def cursor (self ):
134135 """:return: the currently set cursor which provides access to the data"""
0 commit comments