B
    Khhu                 @   sd   d Z ddlmZ eedddZeedddZeeddd	Zeedd
dZeddddZdS )z
Formatting numeric literals.
    )Leaf)textreturnc             C   s*   | dd | dd  }}| |   S )z4
    Formats a hexadecimal string like "0x12B3"
    N   )upper)r   beforeafter r	   1/tmp/pip-install-vv81h98y/black/black/numerics.py
format_hex   s    r   c             C   s^   |  d\}}d}|dr.|dd }d}n|drD|dd }t|}| d| | S )z5Formats a numeric string utilizing scentific notatione -   N+)split
startswithformat_float_or_int_string)r   r   r   signr	   r	   r
   format_scientific_notation   s    

r   c             C   s$   | dd }| d }t | | S )z#Formats a complex string like `10j`N)r   )r   numbersuffixr	   r	   r
   format_complex_number   s    r   c             C   s0   d| kr| S |  d\}}|p d d|p*d S )z"Formats a float string like "1.0"..r   )r   )r   r   r   r	   r	   r
   r   #   s    r   N)leafr   c             C   sb   | j  }|drnB|dr*t|}n.d|kr<t|}n|drPt|}nt|}|| _ dS )zNormalizes numeric (float, int, and complex) literals.

    All letters used in the representation are normalized to lowercase.)Z0o0b0xr   jN)valuelowerr   r   r   endswithr   r   )r   r   r	   r	   r
   normalize_numeric_literal,   s    






r"   )	__doc__Zblib2to3.pytreer   strr   r   r   r   r"   r	   r	   r	   r
   <module>   s   	