U
    yfB                     @   s   d Z G dd dZdS )u  
   La librería de Numlet te permite convertir más de dos duocentillones de números distintos a letras.
   La clase 'Numeros' toma como parámetro un valor (tipo int o float) y retorna un string mediante el método 'a_letras',
   además on el fin de trabajar números decimales muy largos Numlet también acepta strings y números en notación
   científica.

   Las instrucciones y ejemplos están dentro de la clase Numero.

   ¡Espero que les guste!

   Repositorio: https://github.com/roylanmartinez/Numlet
c                e   @   s  e Zd ZdZdd Zddgddgdd	gd
dgddgddgddgddgddgddgddgddgddgddgddgd d!gd"d#gd$d%gd&d'gd(d)gd*d+gd,d-gd.d/gd0d1gddgd2d3gd4d5gd6d7gd8d9gd:d;gd<d=gd>d?gd@dAgdBdCgddgdDdEgdFdGgdHdIgdJdKgdLdMgdNdOgdPdQgdRdSgdTdUgddgdVdWgdXdYgdZd[gd\d]gd^d_gd`dagdbdcgdddegdfdggddgdhdigdjdkgdldmgdndogdpdqgdrdsgdtdugdvdwgdxdygdzd{gd|d}gd~dgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddgddggdZedeedddĄZe	edŜddǄZ
e	deedddɄZe	deeddd˄Ze	deeddd̈́Ze	deedddτZdddфZddӄ ZeddՄ ZdS )Numerou3  
        Esta clase básicamente controla el uso de las funciones compactadores ninf() y n6(), que a su vez coordinan el
        uso de las funciones base ni(), nni() y nnni(). Además, incluye los datos que posteriormente se ordenan
        y se pasan como parámetros a la propiedad a_letras para dar con el dato facilitado.

           Ejemplos de uso:

        Primer ejemplo:
           n = 1
           resultado = Numero(n).a_letras
           print(resultado)
           --- Uno

        Segundo ejemplo:
            n = -1000.123
            resultado = Numero(n).a_letras.lower()
            print(resultado)
           --- menos mil con ciento veintitrés milésimas

        Tercer ejemplo:
            # recuerda poner los números décimales muy pequeños en comillas, pues el intérprete los trunca.
            Más información: https://docs.python.org/3/tutorial/floatingpoint.html
            n = '0.0000000000000000001'
            resultado = Numero(n).a_letras.upper()
            print(resultado)
           --- CERO CON UNA DIEZTRILLONÉSIMA

        c                 C   s   |  t| | _d S )N)
moldecimalstrstripnum)selfnumero r   ./tmp/pip-unpacked-wheel-a7wxbz77/nlt/numlet.py__init__.   s    zNumero.__init__u    Un Centillónz Centillonesu    Un Novenonigintillónz Novenonigintillonesu    Un Octononigintillónz Octononigintillonesu    Un Septenonigintillónz Septenonigintillonesu    Un Sexvigintillónz Sexvigintillonesu    Un Quinonintillónz Quinonigintillonesu    Un Cuatornonigintillónz Cuatornonigintillonesu    Un Trenonigintillónz Trenonigintillonesu    Un Duononigintillónz Duononigintillonesu    Un Unonigintillónz Unonigintillonesu    Un Nonigintillónz Nonigintillonesu    Un Novenoctigintillónz Novenoctigintillonesu    Un Octooctigintillónz Octooctigintillonesu    Un Septenoctigintillónz Septenoctigintillonesu    Un Quinoctintillónz Quinoctigintillonesu    Un Cuatoroctigintillónz Cuatoroctigintillonesu    Un Treoctigintillónz Treoctigintillonesu    Un Duooctigintillónz Duooctigintillonesu    Un Unoctigintillónz Unoctigintillonesu    Un Octigintillónz Octigintillonesu    Un Novenseptigintillónz Novenseptigintillonesu    Un Octoseptigintillónz Octoseptigintillonesu    Un Septenseptigintillónz Septenseptigintillonesu    Un Quinseptintillónz Quinseptigintillonesu    Un Cuatorseptigintillónz Cuatorseptigintillonesu    Un Treseptigintillónz Treseptigintillonesu    Un Duoseptigintillónz Duoseptigintillonesu    Un Unseptigintillónz Unseptigintillonesu    Un Septigintillónz Septigintillonesu    Un Novensextigintillónz Novensextigintillonesu    Un Octosextigintillónz Octosextigintillonesu    Un Septensextigintillónz Septensextigintillonesu    Un Quinsextintillónz Quinsextigintillonesu    Un Cuatorsextigintillónz Cuatorsextigintillonesu    Un Tresextigintillónz Tresextigintillonesu    Un Duosextigintillónz Duosextigintillonesu    Un Unsextigintillónz Unsextigintillonesu    Un Sextigintillónz Sextigintillonesu    Un Novenquintigintillónz Novenquintigintillonesu    Un Octoquintigintillónz Octoquintigintillonesu    Un Septenquintigintillónz Septenquintigintillonesu    Un Quinquintintillónz Quinquintigintillonesu    Un Cuatorquintigintillónz Cuatorquintigintillonesu    Un Trequintigintillónz Trequintigintillonesu    Un Duoquintigintillónz Duoquintigintillonesu    Un Unquintigintillónz Unquintigintillonesu    Un Quintigintillónz Quintigintillonesu    Un Novencuatrigintillónz Novencuatrigintillonesu    Un Octocuatrigintillónz Octocuatrigintillonesu    Un Septencuatrigintillónz Septencuatrigintillonesu    Un Quincuatrintillónz Quincuatrigintillonesu    Un Cuatorcuatrigintillónz Cuatorcuatrigintillonesu    Un Trecuatrigintillónz Trecuatrigintillonesu    Un Duocuatrigintillónz Duocuatrigintillonesu    Un Uncuatrigintillónz Uncuatrigintillonesu    Un Cuatrigintillónz Cuatrigintillonesu    Un Noventrigintillónz Noventrigintillonesu    Un Octotrigintillónz Octotrigintillonesu    Un Septentrigintillónz Septentrigintillonesu    Un Sextrigintillónz Sextrigintillonesu    Un Quintrintillónz Quintrigintillonesu    Un Cuatortrigintillónz Cuatortrigintillonesu    Un Tretrigintillónz Tretrigintillonesu    Un Duotrigintillónz Duotrigintillonesu    Un Untrigintillónz Untrigintillonesu    Un Trigintillónz Trigintillonesu    Un Novenvigintillónz Novenvigintillonesu    Un Octovigintillónz Octovigintillonesu    Un Septenvigintillónz Septenvigintillonesu    Un Quinvigintillónz Quinvigintillonesu    Un Cuatorvigintillónz Cuatorvigintillonesu    Un Trevigintillónz Trevigintillonesu    Un Duovigintillónz Duovigintillonesu    Un Unvigintillónz Unvigintillonesu    Un Vigintillónz Vigintillonesu    Un Novendecillónz Novendecillonesu    Un Octodecillónz Octodecillonesu    Un Septendecillónz Septendecillonesu    Un Sexdecillónz Sexdecillonesu    Un Quindecillónz Quindecillonesu    Un Cuatordecillónz Cuatordecillonesu    Un Tredecillónz Tredecillonesu    Un Duodecillónz Duodecillonesu    Un Undecillónz Undecillonesu    Un Decillónz Decillonesu    Un Nonillónz Nonillonesu    Un Octillónz Octillonesu    Un Septillónz Septillonesu    Un Sextillónz Sextillonesu    Un Quintillónz Quintillonesu    Un Cuatrillónz Cuatrillonesu    Un Trillónz
 Trillonesu    Un billónz	 Billones    Un Millón	 MillonesTF)valorreturnc                 C   s   | dkr&|r|rdS dS |r dS dS nd| dkr2dS | dkr>dS | d	krJd
S | dkrVdS | dkrbdS | dkrndS | dkrzdS | dkrdS dS d S )N1z Unaz Unz Uno2z Dos3z Tres4z Cuatro5z Cinco6z Seis7z Siete8z Ocho9z Nueve r   )r   befdecr   r   r	   ni   s*    z	Numero.ni)r   c                 C   s   dt |krt |d}t|d t|d d  }}}t|dkr|t |dd7 }|ddd tdt|tt |dd  D 7 }nNt|dk r|d7 }|dd	d tdt|d D 7 }|t |dd7 }|S |S )
Ne       r   .c                 S   s   g | ]}d qS 0r   .0_r   r   r	   
<listcomp>   s     z%Numero.moldecimal.<locals>.<listcomp>z0.c                 S   s   g | ]}d qS r    r   r"   r   r   r	   r%      s     )	r   splitfloatintreplacejoinrangeabslen)clsZfltZstr_valsZcoefexp
return_valr   r   r	   r      s     &zNumero.moldecimalc                 C   s  |d dkr|dkrdS |dkr$dS |dkr0dS |d	kr<d
S |dkrHdS |dkrTdS |dkr`dS |dkrldS |dkrxdS dS n|d dkr|dkrdS |dkr|rdS dS |dkrdS |dkrdS |d krd!S |d"krd#S |d$k rd%S |d&k rd'S |d(krd)S d*S n|d d+krVd, d-|d. d/kr6d,nd, d0| |d. ||ggS |d d1krd, d2|d. d/kr|d,nd, d0| |d. ||ggS |d d3krd, d4|d. d/krd,nd, d0| |d. ||ggS |d d5kr(d, d6|d. d/krd,nd, d0| |d. ||ggS |d d7krnd, d8|d. d/krNd,nd, d0| |d. ||ggS |d d9krd, d:|d. d/krd,nd, d0| |d. ||ggS |d d;krd, d<|d. d/krd,nd, d0| |d. ||ggS | |d. ||S d S )=Nr   r   10z DiezZ11z OnceZ12z DoceZ13z TreceZ14z CatorceZ15z QuinceZ16u    DieciséisZ17z DiecisieteZ18z
 Dieciochoz Diecinuever   Z20z VeinteZ21z
 Veintiunou
    VeintiúnZ22u    VeintidósZ23u    VeintitrésZ24z VeinticuatroZ25z VeinticincoZ26u    VeinteséisZ27z VeintisieteZ28z Veintiochoz Veintinuever   r   z Treintar   r!   z yr   z	 Cuarentar   z
 Cincuentar   z Sesentar   z Setentar   z Ochentar   z Noventa)r*   r   r.   r   r   r   r   r   r	   nni   sn    


8888888z
Numero.nnic                 C   st  |d dkrD|dd  dkr dS d d| |dd ||gS n,|d d	krd d
|dd dkrjdn| |dd ||gS |d dkrd d|dd dkrdn| |dd ||gS |d dkrd d|dd dkrdn| |dd ||gS |d dkrJd d|dd dkr0dn| |dd ||gS |d dkrd d|dd dkrtdn| |dd ||gS |d dkrd d|dd dkrdn| |dd ||gS |d dkrd d|dd dkrdn| |dd ||gS |d dkrZd d|dd dkr@dn| |dd ||gS | |dd  ||S d S )Nr   r   r   Z00z Cienr   z Ciento   r   z Doscientosr   z Trescientosr   z Cuatrocientosr   z Quinientosr   z Seiscientosr   z Setecientosr   z Ochocientosr   z Novecientos)r*   r3   r2   r   r   r	   nnni  s*    $44466666zNumero.nnnic              	   C   s   |dkrdS |d d dkr<d d| |dd  ||gS |d d dkrb| |dd  ||S d | j|d d ddd| |dd  ||gS d S )	N000000r   r4   Z001z MilZ000F)r   )r*   r5   r2   r   r   r	   n6  s     z	Numero.n6c                 C   s6   |dkrdS |dkr|S d | j|ddd|gS d S )Nr6   r   Z000001F)r   r   )r*   r7   )r.   r   v1v2r   r   r	   ninf+  s
    zNumero.ninfc           
         s  t |d dk}|r|n$dtdtt |d  d |g t  dk rp dk}|rZdS |  d|d	d  S d}t  d d	 } fd
dtdt  dD }t| j| d  D ](\}}	|| j|| |	d |	d	 d7 }qd|| |d d|gd	d  S d S )N   r   r   r!      r6   ZCeroTr   c                    s   g | ]} ||d   qS )r;   r   )r#   iZenteror   r	   r%   A  s     z!Numero.lector.<locals>.<listcomp>)r8   r9   )r-   r*   r(   r7   r+   	enumeratebaser:   )
r   r   r   ZcambioZcerofinalZlrgZgruposZindiceZelementor   r>   r	   lector5  s      
zNumero.lectorc           
      C   s   |dkrdS | d}|d}t|dk rxdddddgt|d	  }|d
krZ|d d n|}dd| |dd|gS t|d }t||d  }|d
krdnd}ddddddg| }d|| j|  d	  d |g}	dd| |dd|	 gS d S )Nr!   r   r;   u   Décimasu   Centésimasu
   Milésimasu   Diezmilésimasu   Cienmilésimasr   r   r?   z Con T u   ésimau   ésimasZDiezZCienZMilZDiezmilZCienmiles)rstriplstripr-   r*   rC   rA   r   
capitalize)
r   xZnozerosrZlimpiorZrpluralZposicioncolZinicioZmedior   r   r	   
lectordcmlH  s6    

    
zNumero.lectordcmlc                 C   s  zt | j d| jkr| jd}tt|d }|d }|t||d  kr^|d dkr^d}||g}|d d dkrzdnd}d|| |d d| 	|d gW S | jd dkrdnd}d|| tt| jdgW S W n t
k
r   t
dY nX d S )	Nr   r   r   r!   -zMenos r   z9argumento pasado a Numlet no es entero ni tampoco decimal)r'   r   r&   r   r(   r-   r*   rC   rG   rL   
ValueError)r   decimalZd0d1Zmenosr   r   r	   a_letrasb  s"    

 ,*zNumero.a_letrasN)TF)TF)TF)TF)r   r   )F)__name__
__module____qualname____doc__r
   rA   staticmethodr   r   classmethodr   r3   r5   r7   r:   rC   rL   propertyrQ   r   r   r   r	   r      s                                              d@	
r   N)rU   r   r   r   r   r	   <module>   s   