o
    hy                     @   sP   d Z ddlZdZG dd dejjZdedefdd	Z	d
eeB defddZ
dS )zDNS TTL conversion.    Nl    c                   @   s   e Zd ZdZdS )BadTTLz!DNS TTL value is not well-formed.N)__name__
__module____qualname____doc__ r   r   I/var/www/html/pro-man-master/venv/lib/python3.10/site-packages/dns/ttl.pyr      s    r   textreturnc                 C   s  |   r	t| }nut| dkrtd}d}d}| D ]\}|  r,|d9 }|t|7 }d}q|r0t| }|dkr?||d 7 }n2|dkrJ||d 7 }n'|d	krU||d
 7 }n|dkr`||d 7 }n|dkri||7 }ntd| dd}d}q|dks~td|dk s|tkrtd|S )zConvert the text form of a TTL to an integer.

    The BIND 8 units syntax for TTLs (e.g. '1w6d4h3m10s') is supported.

    *text*, a ``str``, the textual TTL.

    Raises ``dns.ttl.BadTTL`` if the TTL is not well-formed.

    Returns an ``int``.
    r   T
   Fwi:	 diQ hi  m<   szunknown unit ''ztrailing integerz1TTL should be between 0 and 2**32 - 1 (inclusive))isdigitintlenr   lowerMAX_TTL)r	   totalcurrent
need_digitcr   r   r   	from_text"   sB   

r   valuec                 C   s(   t | tr| S t | trt| S td)Nzcannot convert value to TTL)
isinstancer   strr   
ValueError)r   r   r   r   makeT   s
   

r!   )r   dns.exceptiondnsr   	exceptionSyntaxErrorr   r   r   r   r!   r   r   r   r   <module>   s   2