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

54 lines
10 KiB
Plaintext
Raw Normal View History

Ë
JÀj4ãó†—dZddlZddlZddlmZmZddlmZgd¢Zd„Zd„ZGd„d «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óH—eZdZdZdZd„Zd„Zed„«Zd„Z d„Z
d„Z 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ó8—d|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—9‘9˜fŸk™k›mÓ,Ð,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 qÓ)ˆØ � Š �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Ó,Ñ,Ñ,ˆØ �Š�DÑ�Ø � Š �TÑŽ rcóv—t|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?„áað€Iò
ò;ðñ-óð-ò$ò0òóMrr có^—eZdZdZgd¢Zdd„Zd„Zd„Zd„Zd„Z d„Z
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)aÑ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__csñ€ðˆŒØˆŒ
؈Œä �j¤#Ô &؉Bä—‘˜¤R§[¡[´7¼2¸zÈ1Ó3MÑ%MÐPUÑ%UÓVˆBð ܤ°SÔ9ˆFØ!ˆN؈Gô
œbŸh™h r›l×2Ñ2°WÑ<¸nÓMˆKܘB  Ñ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.size›s €à�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 §¡¨$¯*©*Ñ 4Ñ4Ð4Ñ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.