3
[_ð]-	  ã               @   s8   d Z ddlZddlmZ G dd„ dejjƒZdd„ ZdS )	zDNS TTL conversion.é    Né   )Úlongc               @   s   e Zd ZdZdS )ÚBadTTLz!DNS TTL value is not well-formed.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r	   r	   ú,/tmp/pip-build-yz_zf6az/dnspython/dns/ttl.pyr      s   r   c             C   s*  | j ƒ rt| ƒ}nð| d j ƒ s"t‚tdƒ}tdƒ}x¼| D ]´}|j ƒ rZ|d9 }|t|ƒ7 }q8|jƒ }|dkr|||tdƒ 7 }nl|dkr–||tdƒ 7 }nR|dkr°||tdƒ 7 }n8|d	krÊ||td
ƒ 7 }n|dkrÜ||7 }ntd| ƒ‚d}q8W |dk�stdƒ‚|tdƒk �s|t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 ``text``, 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))Úisdigitr   r   Úlower)ÚtextÚtotalÚcurrentÚcr	   r	   r
   Ú	from_text   s8    



r   )	r   Zdns.exceptionZdnsÚ_compatr   Ú	exceptionÚSyntaxErrorr   r   r	   r	   r	   r
   Ú<module>   s   