OpenQuizz
Une application de gestion des contenus pédagogiques
|
Public Member Functions | |
def | __init__ (self, manager=None, regions=None) |
def | __del__ (self) |
def | __enter__ (self) |
def | __exit__ (self, exc_type, exc_value, traceback) |
def | __copy__ (self) |
def | assign (self, rhs) |
def | use_region (self, offset=0, size=0, flags=0) |
def | unuse_region (self) |
def | buffer (self) |
def | map (self) |
def | is_valid (self) |
def | is_associated (self) |
def | ofs_begin (self) |
def | ofs_end (self) |
def | size (self) |
def | region (self) |
def | includes_ofs (self, ofs) |
def | file_size (self) |
def | path_or_fd (self) |
def | path (self) |
def | fd (self) |
Pointer into the mapped region of the memory manager, keeping the map alive until it is destroyed and no other client uses it. Cursors should not be created manually, but are instead returned by the SlidingWindowMapManager **Note:**: The current implementation is suited for static and sliding window managers, but it also means that it must be suited for the somewhat quite different sliding manager. It could be improved, but I see no real need to do so.
def __init__ | ( | self, | |
manager = None , |
|||
regions = None |
|||
) |
def __del__ | ( | self | ) |
def __copy__ | ( | self | ) |
copy module interface
def __enter__ | ( | self | ) |
def __exit__ | ( | self, | |
exc_type, | |||
exc_value, | |||
traceback | |||
) |
def assign | ( | self, | |
rhs | |||
) |
Assign rhs to this instance. This is required in order to get a real copy. Alternativly, you can copy an existing instance using the copy module
def buffer | ( | self | ) |
Return a buffer object which allows access to our memory region from our offset to the window size. Please note that it might be smaller than you requested when calling use_region() **Note:** You can only obtain a buffer if this instance is_valid() ! **Note:** buffers should not be cached passed the duration of your access as it will prevent resources from being freed even though they might not be accounted for anymore !
def fd | ( | self | ) |
:return: file descriptor used to create the underlying mapping. **Note:** it is not required to be valid anymore :raise ValueError: if the mapping was not created by a file descriptor
def file_size | ( | self | ) |
:return: size of the underlying file
def includes_ofs | ( | self, | |
ofs | |||
) |
:return: True if the given absolute offset is contained in the cursors current region **Note:** cursor must be valid for this to work
def is_associated | ( | self | ) |
:return: True if we are associated with a specific file already
def is_valid | ( | self | ) |
:return: True if we have a valid and usable region
def map | ( | self | ) |
:return: the underlying raw memory map. Please not that the offset and size is likely to be different to what you set as offset and size. Use it only if you are sure about the region it maps, which is the whole file in case of StaticWindowMapManager
def ofs_begin | ( | self | ) |
:return: offset to the first byte pointed to by our cursor **Note:** only if is_valid() is True
def ofs_end | ( | self | ) |
:return: offset to one past the last available byte
def path | ( | self | ) |
:return: path of the underlying mapped file :raise ValueError: if attached path is not a path
def path_or_fd | ( | self | ) |
:return: path or file descriptor of the underlying mapped file
def region | ( | self | ) |
:return: our mapped region, or None if nothing is mapped yet :raise AssertionError: if we have no current region. This is only useful for debugging
def size | ( | self | ) |
:return: amount of bytes we point to
def unuse_region | ( | self | ) |
Unuse the current region. Does nothing if we have no current region **Note:** the cursor unuses the region automatically upon destruction. It is recommended to un-use the region once you are done reading from it in persistent cursors as it helps to free up resource more quickly
def use_region | ( | self, | |
offset = 0 , |
|||
size = 0 , |
|||
flags = 0 |
|||
) |
Assure we point to a window which allows access to the given offset into the file :param offset: absolute offset in bytes into the file :param size: amount of bytes to map. If 0, all available bytes will be mapped :param flags: additional flags to be given to os.open in case a file handle is initially opened for mapping. Has no effect if a region can actually be reused. :return: this instance - it should be queried for whether it points to a valid memory region. This is not the case if the mapping failed because we reached the end of the file **Note:**: The size actually mapped may be smaller than the given size. If that is the case, either the file has reached its end, or the map was created between two existing regions