add-determinism 0.7.3

RPM buildroot helper to strip nondeterministic bits in files
Documentation
�

�WcJ-cs��dZddlZddlZddlZddlZddgZ	dZ
eZGd�dejj�Zdd
�ZdS)a�A dumb and slow but simple dbm clone.

For database spam, spam.dir contains the index (a text file),
spam.bak *may* contain a backup of the index (also a text file),
while spam.dat contains the data (a binary file).

XXX TO DO:

- seems to contain a bug when updating...

- reclaim free space (currently, space once occupied by deleted or expanded
items is never reused)

- support concurrent access (currently, if two processes take turns making
updates, they can mess up the index)

- support efficient access to large databases (currently, the whole index
is read when the database is opened, and some updates rewrite the whole index)

- support opening for read-only (flag = 'm')

�N�error�openics��eZdZeZeZdd�Zd�Zd�Zd�ZeZ	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�Zd
�Zd�Zd�Zd�ZeZd�Zd�ZeZd�Zd�Zd�ZdS)�	_Database�ccs��|jj|�}||_|dk|_|dz|_|dz|_|dz|_d|_|j|�|j|�dS)N�rs.dirs.dats.bak)
�_osZfsencode�_mode�	_readonly�_dirfile�_datfile�_bakfile�_index�_create�_update)�selfZfilebasename�mode�flag�    �!/usr/lib64/python3.12/dbm/dumb.py�__init__z_Database.__init__0s���x�x�(�(��6����
��#�+���%�w�.��
�%�w�.��
�$�w�.��
����	
���T������T�����cs��|dkr?|j|j|jfD]}	tj|��	t
j|jdd��}|j�dS#t
$rY�`wxYw#t
$ra|dvr�t
j|jdd��5}|j|j�ddd�YdS#1swYYdSxYwwxYw)N�nr�Latin-1�Zencoding�rr�w)
r
rr	rZremove�OSError�_ior�close�_chmod)rrZfilename�frrr
z_Database._createJsS���3�;�;�!�]�]�D�M�M�4�=�=�I�
�
����J�J�x�(�(�(�	��������i�@�@�A�
�G�G�I�I�I�I�������D������
�	+�	+�	+��:�%�%�����$�-�-��y�A�A�
+�Q����D�M�M�*�*�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+����	+���s;�A>�$B�>
B�
B�3C9�C*�	C9�*C5	�/C9�5C9cs~�d|_i|_	tj|jdd��}|5|D]N}|j�}t
j|�\}}|jd�}||j|<�P	ddd�dS#1swYdSxYw#t$r|dvr�d|_YdSwxYw)NFrrrrT)
�	_modifiedrrrr	Zrstrip�_astZliteral_eval�encoder)rrrZline�key�pos_and_siz_pair�      rrz_Database._update]s!��������	8��������i�@�@�A��
8�
8��8�8�D��;�;�=�D�,0�,=�,=�d�,C�)�C�)��*�*�Y�/�C�'7�D�K�K��$�$�	8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8�
8������	"�	"�	"��:�%�%��!�D�N�N�N�N�	"���s�$B"�AB�B�"B<�;B<cs~�|j�|jsdS	|jj|j�	|jj
|j|j�|jj|jdd��5}|j|j�|jj�D]/\}}|jd��d|�d�}|j|��1	ddd�dS#t
$rY��wxYw#t
$rY��wxYw#1swYdSxYw)Nrrr�, �
)rr rZunlinkrrZrenamer	rrr�items�decode�write)rrr#r$Zentry�     r�_commitz_Database._commitqs����;�;��d�n�n�n��F�	��H�H�O�O�D�M�M�*�*�	��H�H�O�O�D�M�M�4�=�=�9�9��X�X�]�]�4�=�=�#�	�]�
B�	�a��K�K��
�
�&�&�)-���):�):�)<�
�
�%��%�'*�j�j��&;�&;�&;�=M�=M�=M�N���������	
�	�	�	�	�	�	�	���	�	�	��D�	�����
�	�	�	��D�	����	�	�	�	�	�	�	�	�	�	���s0�&D�1D"�A)D2�
D�D�"
D/�.D/�2D<cs8�|j�
td��dS�N�"DBM object has already been closed)rr�r� r�_verify_openz_Database._verify_open�s ���;�;���<�=�=��rcsV�t|t�r|jd�}|j�|j|\}}tj|jd�5}|j|�|j|�}ddd�|S#1swYSxYw)N�utf-8Zrb)
�
isinstance�strr"r1rrrr
�seekZread)rr#�pos�sizrZdatr%r�__getitem__z_Database.__getitem__�s����c�3����*�*�W�%�C�������;�;�s�#���S�
�X�X�d�m�m�T�
*�	�a�
�F�F�3�K�K��&�&��+�C�	�	�	�	�	��
�	�	�	�	�	�	�	�	��
���s�.%B�B(cs��tj|jd�5}|jdd�t	|j��}|tzdz
tztz}|jd||z
z�|}|j|�ddd�t|�fS#1swY�xYw)N�rb+ri�s)	rrr
r5ZintZtell�
_BLOCKSIZEr*�len)r�valrr6Znposr+r�_addvalz_Database._addval�s���
�X�X�d�m�m�U�
+�	�q�
�F�F�1�a�L�L��a�f�f�h�-�C��:�%��)�j�8�J�F�D�
�G�G�E�4��8�$�%�%��C�
�G�G�C�L�L�
	�	�	�	�	��S��X���	�	�	�	�	�	�	�	�	���s�A9B4�4B=cs��tj|jd�5}|j|�|j	|�ddd�|t|�fS#1swY�xYw)Nr9)rrr
r5r*r<)rr6r=rrr�_setvalz_Database._setval�s���
�X�X�d�m�m�U�
+�	�q�
�F�F�3�K�K�
�G�G�C�L�L�	�	�	�	�	��S��X���	�	�	�	�	�	�	�	�	���s�%A � A)cs"�||j|<tj|jdd��5}|j	|j�|j|j
d��d|�d��ddd�dS#1swYdSxYw)NZarrr&r')rrrr	rr*r))rr#r$rrr�_addkeyz_Database._addkey�s���+����C��
�X�X�d�m�m�S�9�
=�
=�	L���K�K��
�
�&�&�
�G�G�#�*�*�Y�"7�"7�"7�9I�9I�9I�J�K�K�	L�	L�	L�	L�	L�	L�	L�	L�	L�	L�	L�	L�	L�	L�	L�	L�	L���s�AB�Bcs$�|jr
td��t|t�r|j	d�}n't|t
tf�s
td��t|t�r|j	d�}n't|t
tf�s
td��|j�d|_	||jvr%|j||j|��dS|j|\}}|tzdz
tz}t|�tzdz
tz}||kr"|j||�|j|<dS|j|�|j|<dS)N�'The database is opened for reading onlyr2zkeys must be bytes or stringszvalues must be bytes or stringsTr:)rrr3r4r"ZbytesZ	bytearray�	TypeErrorr1r rr@r>r;r<r?)rr#r=r6r7Z	oldblocksZ	newblockss       r�__setitem__z_Database.__setitem__�s[���>�>�>��A�B�B��c�3����*�*�W�%�C�C��C�%��!3�4�4��;�<�<��c�3����*�*�W�%�C�C��C�%��!3�4�4��=�>�>����������d�k�k�!�!��L�L��d�l�l�3�/�0�0�0�0��{�{�3�'�H�C���z�)�A�-�*�<�I��S��J�.��2�z�A�I��I�%�%�#'�<�<��S�#9����C� � � �
$(�<�<��#4����C� � � rcs��|jr
td��t|t�r|j	d�}|j�d|_|j|=|j�dS)NrAr2T)	rrr3r4r"r1r rr,�rr#�  r�__delitem__z_Database.__delitem__�se���>�>�>��A�B�B��c�3����*�*�W�%�C����������K�K���
	
������rc�j�	t|j�S#t$rtd�d�wxYwr-)ZlistrrBrr/r0r�keysz_Database.keys��D��	H�����$�$���	H�	H�	H��<�=�4�G�	H������2csp���j��fd��jj�D�S)Ncs&��g|]}|�|f��S�rK)Z.0r#rs  �rz
<listcomp>z#_Database.items.<locals>.<listcomp>�s"���?�?�?�S��d�3�i� � � �?r)r1rrHr/s`rr(z_Database.items�s6��������?�?�?�?�D�K�K�,<�,<�,>�?�?�?rcs��t|t�r|jd�}	||jvS#t$r|j�td�d��wxYw)Nr2r.)r3r4r"rrBrrDrEr�__contains__z_Database.__contains__�sg���c�3����*�*�W�%�C�	��$�+�+�%�%���	�	�	��{�{�"��@�A�t�K��		���s	�
5�&AcrGr-)ZiterrrBrr/r0r�iterkeysz_Database.iterkeysrIrJcrGr-)r<rrBrr/r0r�__len__z_Database.__len__sD��	H��t�{�{�#�#���	H�	H�	H��<�=�4�G�	H���rJcs��	|j�dx|_x|_x|_|_dS#dx|_x|_x|_|_wxYw�N)r,rr
r	rr/r0rrz_Database.closes[��	O��L�L�N�N�JN�N�D�K�N�$�-�N�$�-�$�-�-�-��$�N�D�K�N�$�-�N�$�-�$�-�N�N�N�Ns	�1�AcsT�|jj||j�dSrO)rZchmodr)r�filerErrz_Database._chmods!�������t�T�Z�Z�(�(�(�(rcs�|SrOrKr/r0r�	__enter__z_Database.__enter__s���rcs(�|j�dSrO)r)rZargsrEr�__exit__z_Database.__exit__s���
�
����rN)r)Z__name__Z
__module__Z__qualname__rrrr
rr,Zsyncr1r8r>r?r@rCrFrHr(rLrMZ__iter__rNrZ__del__rrQrRrKrrrr#sy�������C�

�C�����4���&8�8�8�(���2�D�>�>�>����������L�L�L�5�5�5�J
�
�
�H�H�H�@�@�@�	�	�	�H�H�H�
�H�H�H�H�O�O�O��G�)�)�)��������rrr�cs��	tjd�}tj|�||z}|dvr
td��t	|||��S#t$rY�-wxYw)aEOpen the database file, filename, and return corresponding object.

    The flag argument, used to control how the database is opened in the
    other DBM implementations, supports only the semantics of 'c' and 'n'
    values.  Other values will default to the semantics of 'c' value:
    the database will always opened for update and will be created if it
    does not exist.

    The optional mode argument is the UNIX mode of the file, used only when
    the database has to be created.  It defaults to octal code 0o666 (and
    will be modified by the prevailing umask).

    r)rrrrz)Flag must be one of 'r', 'w', 'c', or 'n')r)rZumaskZAttributeErrorZ
ValueErrorr)rPrrZumrrrr#sz�� �
�Y�Y�q�\���	�	�"�
�
�
��s�|���'�'�'��D�E�E��T�4�d�+�+�+���
�
�
���
���s�.A�
A$�#A$)rrS)Z__doc__Zastr!ZiorZosrZcollections.abcZcollectionsZ__all__r;rrZabcZMutableMappingrrrKrr�<module>rTs�����.�����������������F�
��
�
���}�}�}�}�}����.�.�}�}�@,�,�,�,�,�,r