o
    S`
                     @   s   d Z ddlZdZdZdZdZdZdZd	d
 Zdj	eeeeeeeeeeeedZ
dddddddZdd Zdd ZdS )z
timeparse.py
(c) Will Roberts <wildwilhelm@gmail.com>  1 February, 2014

This is a vendored and modified copy of:
github.com/wroberts/pytimeparse @ cc0550d

It has been modified to mimic the behaviour of
https://golang.org/pkg/time/#ParseDuration
    Nz(?P<hours>[\d.]+)hz(?P<mins>[\d.]+)mz(?P<secs>[\d.]+)sz(?P<milli>[\d.]+)msu   (?P<micro>[\d.]+)(?:us|µs)z(?P<nano>[\d.]+)nsc                 C   s   dj | dS )Nz(?:{x})?x)formatr    r   3/usr/lib/python3/dist-packages/compose/timeparse.pyopt+   s   r   z'{HOURS}{MINS}{SECS}{MILLI}{MICRO}{NANO})HOURSMINSSECSMILLIMICRONANOi  <      gMbP?gư>g&.>)hoursminssecsmillimicronanoc                 C   sL   t dt d | t j}|r|d sdS | }tdd | D S )a  Parse a time expression, returning it as a number of seconds.  If
    possible, the return value will be an `int`; if this is not
    possible, the return will be a `float`.  Returns `None` if a time
    expression cannot be parsed from the given string.

    Arguments:
    - `sval`: the string value to parse

    >>> timeparse('1m24s')
    84
    >>> timeparse('1.2 minutes')
    72
    >>> timeparse('1.2 seconds')
    1.2
    z\s*z\s*$r   Nc                 s   s,    | ]\}}|d urt | t| V  qd S N)MULTIPLIERScast).0kvr   r   r   	<genexpr>W   s    
ztimeparse.<locals>.<genexpr>)	rematch
TIMEFORMATIgroupstrip	groupdictsumitems)svalr   mdictr   r   r   	timeparseB   s   r(   c                 C   s   |   rt| S t| S r   )isdigitintfloat)valuer   r   r   r   [   s   r   )__doc__r   r   r	   r
   r   r   r   r   r   r   r   r(   r   r   r   r   r   <module>   s4   

