B
    P•\U  ã               @   sf   d dl mZ d dlZd dlZd dlmZ e d¡Ze dej¡Z	e d¡Z
dd„ Zd	d
„ Zdd„ ZdS )é    )Úabsolute_importN)Únumbersz%^(?P<number>\-?[0-9]*\.?[0-9]*\s?)\%$z´
^(?: # HH:MM and HH:MM:SS
(?P<hour>[0-1]{0,1}[0-9]{2}):
(?P<minute>[0-5][0-9]):?
(?P<second>[0-5][0-9])?$)
|
^(?: # MM:SS.
([0-5][0-9]):
([0-5][0-9])?\.
(?P<microsecond>\d{1,6}))
zD^-?([\d]|[\d]+\.[\d]*|\.[\d]+|[1-9][\d]+\.?[\d]*)((E|e)[-+]?[\d]+)?$c             C   s0   t  | ¡r,yt| ƒS  tk
r*   t| ƒS X dS )z-Explicity convert a string to a numeric valueN)ÚNUMBER_REGEXÚmatchÚintÚ
ValueErrorÚfloat)Úvalue© r
   ú7lib/python3.7/site-packages/openpyxl/utils/inference.pyÚcast_numeric   s
    
r   c             C   s$   t  | ¡}|r t| d¡ƒd S dS )zKExplicitly convert a string to numeric value and format as a
    percentageZnumberéd   N)ÚPERCENT_REGEXr   r   Úgroup)r	   r   r
   r
   r   Úcast_percentage$   s    
r   c             C   s`   t  | ¡}|r\| d¡dk	r.| dd… } d}n| d¡dkrBd}nd}tj | |¡} |  ¡ S dS )zJExplicitly convert a string to a number and format as datetime or
    timeZmicrosecondNé   z%M:%S.%fÚsecondz%H:%Mz%H:%M:%S)Ú
TIME_REGEXr   r   ÚdatetimeZstrptimeZtime)r	   r   Úpatternr
   r
   r   Ú	cast_time-   s    
r   )Z
__future__r   r   ÚreZopenpyxl.stylesr   Úcompiler   ÚVERBOSEr   r   r   r   r   r
   r
   r
   r   Ú<module>   s   



		