1818
1919
2020class WindowCursor (object ):
21- """Pointer into the mapped region of the memory manager, keeping the map
21+ """
22+ Pointer into the mapped region of the memory manager, keeping the map
2223 alive until it is destroyed and no other client uses it.
2324
2425 Cursors should not be created manually, but are instead returned by the SlidingWindowMapManager
25- :note: The current implementation is suited for static and sliding window managers, but it also means
26- that it must be suited for the somewhat quite different sliding manager. It could be improved, but
27- I see no real need to do so."""
26+
27+ **Note**: The current implementation is suited for static and sliding window managers, but it also means
28+ that it must be suited for the somewhat quite different sliding manager. It could be improved, but
29+ I see no real need to do so."""
2830 __slots__ = (
2931 '_manager' , # the manger keeping all file regions
3032 '_rlist' , # a regions list with regions for our file
@@ -91,8 +93,9 @@ def use_region(self, offset = 0, size = 0, flags = 0):
9193 for mapping. Has no effect if a region can actually be reused.
9294 :return: this instance - it should be queried for whether it points to a valid memory region.
9395 This is not the case if the mapping failed becaues we reached the end of the file
94- :note: The size actually mapped may be smaller than the given size. If that is the case,
95- either the file has reached its end, or the map was created between two existing regions"""
96+
97+ **note**: The size actually mapped may be smaller than the given size. If that is the case,
98+ either the file has reached its end, or the map was created between two existing regions"""
9699 need_region = True
97100 man = self ._manager
98101 fsize = self ._rlist .file_size ()
@@ -123,19 +126,22 @@ def use_region(self, offset = 0, size = 0, flags = 0):
123126
124127 def unuse_region (self ):
125128 """Unuse the ucrrent region. Does nothing if we have no current region
126- :note: the cursor unuses the region automatically upon destruction. It is recommended
127- to unuse the region once you are done reading from it in persistent cursors as it
128- helps to free up resource more quickly"""
129+
130+ **note** the cursor unuses the region automatically upon destruction. It is recommended
131+ to unuse the region once you are done reading from it in persistent cursors as it
132+ helps to free up resource more quickly"""
129133 self ._region = None
130134 # note: should reset ofs and size, but we spare that for performance. Its not
131135 # allowed to query information if we are not valid !
132136
133137 def buffer (self ):
134138 """Return a buffer object which allows access to our memory region from our offset
135139 to the window size. Please note that it might be smaller than you requested when calling use_region()
136- :note: You can only obtain a buffer if this instance is_valid() !
137- :note: buffers should not be cached passed the duration of your access as it will
138- prevent resources from being freed even though they might not be accounted for anymore !"""
140+
141+ **note** You can only obtain a buffer if this instance is_valid() !
142+
143+ **note** buffers should not be cached passed the duration of your access as it will
144+ prevent resources from being freed even though they might not be accounted for anymore !"""
139145 return buffer (self ._region .buffer (), self ._ofs , self ._size )
140146
141147 def map (self ):
@@ -155,7 +161,8 @@ def is_associated(self):
155161
156162 def ofs_begin (self ):
157163 """:return: offset to the first byte pointed to by our cursor
158- :note: only if is_valid() is True"""
164+
165+ **note** only if is_valid() is True"""
159166 return self ._region ._b + self ._ofs
160167
161168 def ofs_end (self ):
@@ -177,7 +184,8 @@ def region_ref(self):
177184 def includes_ofs (self , ofs ):
178185 """:return: True if the given absolute offset is contained in the cursors
179186 current region
180- :note: cursor must be valid for this to work"""
187+
188+ **note** cursor must be valid for this to work"""
181189 # unroll methods
182190 return (self ._region ._b + self ._ofs ) <= ofs < (self ._region ._b + self ._ofs + self ._size )
183191
@@ -199,7 +207,8 @@ def path(self):
199207
200208 def fd (self ):
201209 """:return: file descriptor used to create the underlying mapping.
202- :note: it is not required to be valid anymore
210+
211+ **note** it is not required to be valid anymore
203212 :raise ValueError: if the mapping was not created by a file descriptor"""
204213 if isinstance (self ._rlist .path_or_fd (), basestring ):
205214 raise ValueError ("File descriptor queried although mapping was generated from path" )
0 commit comments