%PDF- %PDF-
Direktori : /lib/python3/dist-packages/twisted/names/__pycache__/ |
Current File : //lib/python3/dist-packages/twisted/names/__pycache__/_rfc1982.cpython-312.pyc |
� Ϫ�f�# � �X � d Z ddlZddlmZmZ ddlmZ ddlmZ dZ G d� de� Z dgZ y) a� Utilities for handling RFC1982 Serial Number Arithmetic. @see: U{http://tools.ietf.org/html/rfc1982} @var RFC4034_TIME_FORMAT: RRSIG Time field presentation format. The Signature Expiration Time and Inception Time field values MUST be represented either as an unsigned decimal integer indicating seconds since 1 January 1970 00:00:00 UTC, or in the form YYYYMMDDHHmmSS in UTC. See U{RRSIG Presentation Format<https://tools.ietf.org/html/rfc4034#section-3.2>} � N)�datetime� timedelta)�nativeString)� FancyStrMixinz%Y%m%d%H%M%Sc �� � e Zd ZdZdZddedefd�Zdedd fd�Zde fd �Z d � Zdedefd�Z dedefd�Zdedefd �Zdedefd�Zdedefd�Zdedd fd�Zd� Zed� � Zd� Zy)�SerialNumbera� An RFC1982 Serial Number. This class implements RFC1982 DNS Serial Number Arithmetic. SNA is used in DNS and specifically in DNSSEC as defined in RFC4034 in the DNSSEC Signature Expiration and Inception Fields. @see: U{https://tools.ietf.org/html/rfc1982} @see: U{https://tools.ietf.org/html/rfc4034} @ivar _serialBits: See C{serialBits} of L{__init__}. @ivar _number: See C{number} of L{__init__}. @ivar _modulo: The value at which wrapping will occur. @ivar _halfRing: Half C{_modulo}. If another L{SerialNumber} value is larger than this, it would lead to a wrapped value which is larger than the first and comparisons are therefore ambiguous. @ivar _maxAdd: Half C{_modulo} plus 1. If another L{SerialNumber} value is larger than this, it would lead to a wrapped value which is larger than the first. Comparisons with the original value would therefore be ambiguous. ))�_number�number�%d)�_serialBits� serialBitsr r r c � � || _ d|z | _ d|dz z | _ d|dz z dz | _ t |� | j z | _ y)a� Construct an L{SerialNumber} instance. @param number: An L{int} which will be stored as the modulo C{number % 2 ^ serialBits} @type number: L{int} @param serialBits: The size of the serial number space. The power of two which results in one larger than the largest integer corresponding to a serial number value. @type serialBits: L{int} � � N)r �_modulo� _halfRing�_maxAdd�intr )�selfr r s �8/usr/lib/python3/dist-packages/twisted/names/_rfc1982.py�__init__zSerialNumber.__init__8 sP � � &����*�}����J��N�3����Z�!�^�,�q�0�����K�$�,�,�6��� �other�returnc � � t |t � st d| �d|��� �| j |j k7 rt d| �d|��� �|S )a} Check that a foreign object is suitable for use in the comparison or arithmetic magic methods of this L{SerialNumber} instance. Raise L{TypeError} if not. @param other: The foreign L{object} to be checked. @return: C{other} after compatibility checks and possible coercion. @raise TypeError: If C{other} is not compatible. zcannot compare or combine z and zLcannot compare or combine SerialNumber instances with different serialBits. )� isinstancer � TypeErrorr �r r s r � _convertOtherzSerialNumber._convertOtherK sZ � � �%��.��8����e�Y�O�P�P����u�0�0�0��59�5�B�� � �r c �4 � t d| j fz � S )zs Return a string representation of this L{SerialNumber} instance. @rtype: L{nativeString} r )r r �r s r �__str__zSerialNumber.__str__` s � � �D�D�L�L�?�2�3�3r c � � | j S )ze @return: The integer value of this L{SerialNumber} instance. @rtype: L{int} )r r! s r �__int__zSerialNumber.__int__h s � � �|�|�r c � � | j |� }|j | j k( S # t $ r t cY S w xY w)zW Allow rich equality comparison with another L{SerialNumber} instance. )r r �NotImplementedr r s r �__eq__zSerialNumber.__eq__o sC � � "��&�&�u�-�E� �}�}����,�,�� � "�!�!� "�s �, �>�>c �X � | j |� }| j |j k xr& |j | j z | j k xsA | j |j kD xr& | j |j z | j kD S # t $ r t cY S w xY w)zV Allow I{less than} comparison with another L{SerialNumber} instance. �r r r&