HEX
Server: LiteSpeed
System: Linux standart9.isimtescil.net 3.10.0-962.3.2.lve1.5.26.7.el7.x86_64 #1 SMP Wed Oct 2 07:53:12 EDT 2019 x86_64
User: karalev (5310)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/paste/util/__pycache__/dateinterval.cpython-37.pyc
B

b�Nn	�@s�dZddlZddgZdZedZedZedZedZed	Zed
Z	e	eeeeeed�Z
e
��Ze�
dd
��ddd�Ze�d�Zdd�Zdd�Zedkr�ddlZe��dS)a
DateInterval.py

Convert interval strings (in the form of 1w2d, etc) to
seconds, and back again.  Is not exactly about months or
years (leap years in particular).

Accepts (y)ear, (b)month, (w)eek, (d)ay, (h)our, (m)inute, (s)econd.

Exports only timeEncode and timeDecode functions.  
�N�interval_decode�interval_encode��<���im)�y�b�w�d�h�m�scCst|d|d�S)Nr)�cmp)�ar
�r�H/opt/alt/python37/lib/python3.7/site-packages/paste/util/dateinterval.py�<lambda>"�rFcCsrd}|}t|�}x6tD].\}}||krt||�\}}|d||f7}qW|dkrZd|}n|sbdS|rnd|}|S)z�Encodes a number of seconds (representing a time interval)
    into a form like 1h2d3s.

    >>> interval_encode(10)
    '10s'
    >>> interval_encode(493939)
    '5d17h12m19s'
    �z%i%sr�-�0�+)�abs�timeOrdered�divmod)�secondsZinclude_signr�orig�char�amount�irrrr$s	
z[0-9]+[a-zA-Z]cCs�d}d}|��}|�d�r,|dd�}d}n|�d�rB|dd�}xRt|t�D]D}|�d�d��}t�|�spqN|t|�d�dd��t|7}qNW|S)z�Decodes a number in the format 1h4d3m (1 hour, 3 days, 3 minutes)
    into a number of seconds

    >>> interval_decode('40s')
    40
    >>> interval_decode('10000s')
    10000
    >>> interval_decode('3d1w45s')
    864045
    rrrN���r)	�strip�
startswith�
allMatches�_timeRE�group�lower�
timeValuesZhas_key�int)r�time�sign�matchrrrrr=s


&cCsDd}t|�}g}|�||�}x"|r>|�|�|�||���}qW|S)z1Return a list of matches for regex in source
    r)�len�search�append�end)�source�regex�posr1�rvr-rrrr%Ys
r%�__main__)F)�__doc__�re�__all__�second�minute�hour�day�week�month�yearr)�itemsr�sortr�compiler&rr%�__name__ZdoctestZtestmodrrrr�<module>s2