Files
intellecton/venv/lib/python3.12/site-packages/smmap/__pycache__/util.cpython-312.pyc
T

54 lines
10 KiB
Plaintext
Raw Normal View History

Ë
j4ãó†dZddlZddlZddlmZmZddlmZgd¢ZdZdZGdd «Z Gd
d «Z
Gd d
e «Z y)zlModule containing a memory memory manager which provides a sliding window on a number of memory mapped fileséN)ÚmmapÚ ACCESS_READ©ÚALLOCATIONGRANULARITY)Ú
align_to_mmapÚ is_64_bitÚ MapWindowÚ MapRegionÚ
MapRegionListrcóF|tztz}|r||k7r |tz
}|S)a=
Align the given integer number to the closest page offset, which usually is 4096 bytes.
:param round_up: if True, the next higher multiple of page size is used, otherwise
the lower page_size will be used (i.e. if True, 1 becomes 4096, otherwise it becomes 0)
:return: num rounded to closest pager)ÚnumÚround_upÚress úM/home/antigravity/intellecton/venv/lib/python3.12/site-packages/smmap/util.pyrrs.ð Ô 'Ô+@Ñ
@€CÙS˜C’ZØ Ôà €Jócó(tjdkDS)zO:return: True if the system is 64 bit. Otherwise it can be assumed to be 32 bitlÿÿ)ÚsysÚmaxsize©rrrrsä ;‰;˜Ñ &rcóHeZdZdZdZdZdZed«ZdZ dZ
dZ d „Z y
) r zWUtility type which is used to snap windows towards each other, and to adjust their size©ÚofsÚsizecó ||_||_y©Nr)ÚselfÚoffsetrs rÚ__init__zMapWindow.__init__-s؈ŒØˆ rcó8d|j|jfzS)NzMapWindow(%i, %i)r©rs rÚ__repr__zMapWindow.__repr__1sØ" d§h¡h°· ± Ð%:Ñ:rcóD||j|j««S)z!:return: new window from a region©Ú_br)ÚclsÚregions rÚ from_regionzMapWindow.from_region4sñ6—99˜fŸk™k,rcó4|j|jzSrrr s rÚofs_endzMapWindow.ofs_end9sØx‰x˜$Ÿ)™)Ñ#rcó¸t|jd«}|xj|j|z
z
c_||_t|jd«|_y)z<Assures the previous window area is contained in the new oneréN)rrr)rÚnofss rÚalignzMapWindow.align<sAä˜TŸX™X Ø Š T—X‘X ‘_Ñ$ ؈ŒÜ! $§)¡)¨QÓ/ˆ rcóÔ|j|j«z
}||jz}||t||«z
z}|xj|zc_|xj|z
c_y)zÛAdjust the offset to start where the given window on our left ends if possible,
but don't make yourself larger than max_size.
The resize will assure that the new window still contains the old window areaN)rr)rÚmin)rÚwindowÚmax_sizeÚrofsÚnsizes rÚextend_left_tozMapWindow.extend_left_toCsYðx‰x˜&Ÿ.™.Ó*ˆØt—y‘yÑ ˆØ œ˜E 8ÓØ ŠØ Š Ž rcóvt|j|j|j«z
z|«|_y)zpAdjust the size to make our window end where the right window begins, but don't
get larger than max_sizeN)r/rrr))rr0r1s rÚextend_right_tozMapWindow.extend_right_toMs*ô˜Ÿ ™  V§Z¡Z°$·,±,³.Ñ%@ÑAÀ8ÓLˆ rN)
Ú__name__Ú
__module__Ú __qualname__Ú__doc__Ú __slots__rr!Ú classmethodr'r)r-r4r6rrrr r %s?á€Iò
òñðóMrr có^eZdZdZgd¢ZddZdZdZdZdZ dZ
d „Z d
Z d Z
dd Zd
Zy)r
z{Defines a mapped region of memory, aligned to pagesizes
**Note:** deallocates used region automatically on destruction)r$Ú_mfÚ_ucÚ_sizeÚ __weakref__c ód||_d|_d|_t|t«r|}n9t j |t
jtt
dd«z|z«} tt|¬«}|}|}tt j|«j|z
|«} t|| fi|¤Ž|_t!|j«|_t|t"«rt j$|« |j'«y#t|t"«rt j$|«wwxYw)Initialize a region, allocate the memory map
:param path_or_fd: path to the file to map, or the opened file descriptor
:param ofs: **aligned** offset into the file to be mapped
:param size: if size is larger then the file on disk, the whole file will be
allocated the the size automatically adjusted
:param flags: additional flags to be given when opening the file.
:raise Exception: if no memory can be allocatedrÚO_BINARY)ÚaccessrN)r$r@r?Ú
isinstanceÚintÚosÚopenÚO_RDONLYÚgetattrÚdictrr/ÚfstatÚst_sizerr>ÚlenÚstrÚcloseÚincrement_client_count)
rÚ
path_or_fdrrÚflagsÚfdÚkwargsÚcorrected_sizeÚsizeofsÚ actual_sizes
rrzMapRegion.__init__cðˆŒØˆŒ
؈Œä j¤#Ô ‰B䘤R§[¡[´7¼2¸zÈ1Ó3MÑ%MÐPUÑ%UÓVˆ ܤ°SÔ9ˆFØ!ˆN؈Gô
œbŸh™h rl×2°WÑ<¸Mˆ˜ Ñ6¨vÑ6ˆDŒHô˜TŸX™X›ˆDŒJä˜*¤cÔ˜ ð
×%øô ˜*¤cÔ˜ ð+ús
Á#A-DÄ(D/có@d|j|j«fzS)NzMapRegion<%i, %i>r#r s rr!zMapRegion.__repr__ŠsØ" d§g¡g¨t¯y©y«{Ð%;Ñ;rcó|jS)z':return: a buffer containing the memory©r>r s rÚbufferzMapRegion.bufferó àx‰xˆrcó|jS)z+:return: a memory map containing the memoryr[r s rÚmapz
MapRegion.map“r]rcó|jS)z>:return: absolute byte offset to the first byte of the mapping)r$r s rÚ ofs_beginzMapRegion.ofs_begin—s àw‰wˆrcó|jS)z1:return: total size of the mapped region in bytes)r@r s rrzMapRegion.sizes àz‰zÐrcó4|j|jzS)zE:return: Absolute offset to one byte beyond the mapping into the file©r$r@r s rr)zMapRegion.ofs_endŸsàw‰w˜ŸÑ#rcód|j|cxkxr|j|jzkScS)zB:return: True if the given offset can be read in our mapped regionrd©rrs rÚ includes_ofszMapRegion.includes_ofs£s)àw‰w˜#Ö§¡¨$¯*©*Ñ 4Ñ4rcó|jS)z6:return: number of clients currently using this region)r?r s rÚ client_countzMapRegion.client_count§r]rcó¼|xj|z
c_|jdkDsJd|jz«|j«dk(r|j«yy)zîAdjust the usage count by the given positive or negative offset.