a
    sd_à  ã                   @   s,   d Z ddlZG dd„ dejjƒZdd„ ZdS )zDNS TTL conversion.é    Nc                   @   s   e Zd ZdZdS )ÚBadTTLz!DNS TTL value is not well-formed.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   ú)/usr/lib/python3/dist-packages/dns/ttl.pyr      s   r   c                 C   s   |   ¡ rt| ƒ}nÒ| d   ¡ s"t‚d}d}| D ]¤}|  ¡ rP|d9 }|t|ƒ7 }q.| ¡ }|dkrn||d 7 }n`|dkr„||d 7 }nJ|dkrš||d 7 }n4|d	kr°||d
 7 }n|dkrÂ||7 }ntd| ƒ‚d}q.|dksätdƒ‚|dk sô|dkrütdƒ‚|S )zûConvert 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   é
   Úwi€:	 Údi€Q Úhi  Úmé<   Úszunknown unit '%s'ztrailing integeriÿÿÿz0TTL should be between 0 and 2^31 - 1 (inclusive))ÚisdigitÚintr   Úlower)ÚtextÚtotalZcurrentÚcr   r   r   Ú	from_text   s8    

r   )r   Zdns.exceptionZdnsZ	exceptionÚSyntaxErrorr   r   r   r   r   r   Ú<module>   s   