
    -	                     `    d Z ddlZddlmZ  G d dej
                  j                        Zd Zy)zDNS TTL conversion.    N   )longc                       e Zd ZdZy)BadTTLz!DNS TTL value is not well-formed.N)__name__
__module____qualname____doc__     lib/third_party/dns/ttl.pyr   r      s    +r   r   c                 n   | j                         rt        |       }n| d   j                         st        t        d      }t        d      }| D ]  }|j                         r|dz  }|t        |      z  }'|j                         }|dk(  r||t        d      z  z  }n^|dk(  r||t        d      z  z  }nG|dk(  r||t        d      z  z  }n0|d	k(  r||t        d
      z  z  }n|dk(  r||z  }nt        d|z        d} |dk(  st        d      |t        d      k  s|t        d      kD  rt        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 ``text``, the textual TTL.

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

    Returns an ``int``.
    r   
   wi:	 diQ 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cs       r   	from_textr      s<    ||~T
Aw LQq'Ayy{247"GGI8WtF|33E#XWtE{22E#XWtDz11E#XWtBx//E#XW$E !4q!899% & !|+,,tAw%$z"22GHHLr   )	r
   dns.exceptiondns_compatr   	exceptionSyntaxErrorr   r   r   r   r   <module>r"      s+   $   ,S]]&& ,*r   