????
Your IP : 3.22.234.133
�
и)�X�#��:�dZddlmZddlZddlZddlZddlZddl m
Z
ddlmZddlm
Z
ddlmZdd lmZdd
lmZgd�ZeGd�d
e
����ZdEd�ZdFd�Zdd�dGd�Z dHdId"�Z dJdKd'�ZdLd*�ZdMdNd.�ZdOd/�ZdPd6�ZdQd<�ZdRd=�Z dSd?�Z! dTdUdD�Z"dS)VzYTime humanizing functions.
These are largely borrowed from Django's `contrib.humanize`.
�)�annotationsN)�Enum)�total_ordering)�Any�)�_gettext)� _ngettext)�intcomma)�naturaldelta�naturaltime�
naturalday�naturaldate�precisedeltac�6�eZdZdZdZdZdZdZdZdZ dZ
dd�Zd
S)�Unitrr�������other�
typing.Any�returnc�L�|j|jur|j|jkStS�N)� __class__�value�NotImplemented)�selfrs �m/builddir/build/BUILD/imunify360-venv-2.5.0/opt/imunify360/venv/lib/python3.11/site-packages/humanize/time.py�__lt__zUnit.__lt__'s&���>�U�_�,�,��:���+�+���N)rrrr)�__name__�
__module__�__qualname__�MICROSECONDS�MILLISECONDS�SECONDS�MINUTES�HOURS�DAYS�MONTHS�YEARSr"�r#r!rrsP�������L��L��G��G�
�E��D�
�F�
�E������r#rr�dt.datetimec�>�tj���Sr)�dt�datetime�nowr/r#r!�_nowr5-s��
�;�?�?���r#�delta�dt.timedeltac�H�|jdkrt��}|||zz
S|S)z�Return an "absolute" value for a timedelta, always representing a time distance.
Args:
delta (datetime.timedelta): Input timedelta.
Returns:
datetime.timedelta: Absolute timedelta.
r)�daysr5)r6r4s r!�_abs_timedeltar:1s,��
�z�A�~�~��f�f���c�E�k�"�"��Lr#�r4rrr4�dt.datetime | None�tuple[typing.Any, typing.Any]c�X�|st��}t|tj��r|}||z
}nht|tj��r||z
}|}nF t|��}tj|���}||z
}n#ttf$rd|fcYSwxYw|t|��fS)z�Turn a value into a date and a timedelta which represents how long ago it was.
If that's not possible, return `(None, value)`.
��secondsN) r5�
isinstancer2r3� timedelta�int�
ValueError� TypeErrorr:)rr4�dater6s r!�_date_and_deltarG@s������f�f���%���%�%�����e���� �E�2�<� (� (� ��U�{����� ���J�J�E��L��/�/�/�E���;�D�D���I�&� � � ���;���� �������&�&�&�&s�)B�B�BTr@�dt.timedelta | float�months�bool�minimum_unit�strc��t|���}|tjtjtjfvrd|�d�}t|���|}t
|tj��r|}nL t|��}tj|���}n&#t
tf$rt|��cYSwxYw|}t|j
��}t|j��} | dz}
| dz} t| dz��}|
�sk| dk�rd|dkr�|tjkr)|jdkrt!d d
|j��|jzS|tjks%|tjkr@d|jcxkrdkr.nn+|jdz}t!dd
t|����|zSt#d��S|dkrt#d��S|dkrt!dd|��|zSd|cxkrdkrnnt#d��Sd|cxkrdkrnn|dz}
t!dd|
��|
zSd|cxkrdkrnnt#d��Sd|kr|dz}t!dd|��|zSn�|
dkrj| dkrt#d��S|st!dd| ��| zS|st!dd| ��| zS|dkrt#d��St!d d!|��|zS|
dkrh|s| st#d"��S|st!d#d$| ��| zS|r)|dkrt#d%��St!d&d'|��|zSt!d#d$| ��| zSt!d(d)|
���d*d+��t'|
��zS),aTReturn a natural representation of a timedelta or number of seconds.
This is similar to `naturaltime`, but does not add tense to the result.
Args:
value (datetime.timedelta, int or float): A timedelta or a number of seconds.
months (bool): If `True`, then a number of months (based on 30.5 days) will be
used for fuzziness between years.
minimum_unit (str): The lowest unit that can be used.
Returns:
str (str or `value`): A natural representation of the amount of time
elapsed unless `value` is not datetime.timedelta or cannot be
converted to int. In that case, a `value` is returned unchanged.
Raises:
OverflowError: If `value` is too large to convert to datetime.timedelta.
Examples
Compare two timestamps in a custom local timezone::
import datetime as dt
from dateutil.tz import gettz
berlin = gettz("Europe/Berlin")
now = dt.datetime.now(tz=berlin)
later = now + dt.timedelta(minutes=30)
assert naturaldelta(later - now) == "30 minutes"
zMinimum unit 'z' not supportedr?�m��>@rr���%d microsecond�%d microsecondsi@B�%d millisecond�%d milliseconds�a momentza second�<� %d second�
%d seconds�xza minute�� %d minute�
%d minutesi zan hour�%d hour�%d hoursza day�%d day�%d daysza month�%d month� %d monthsza yearz1 year, %d dayz1 year, %d daysz1 year, 1 monthz1 year, %d monthz1 year, %d months�%d year�%d years�%d�%s)r�upperr)r(r'rDrAr2rBrCrErL�absr@r9�microsecondsr �_�replacer
)rrIrK�tmp�msg�min_unitr6�
use_monthsr@r9�years�
num_months�milliseconds�minutes�hourss r!rrYsD��F�|�!�!�#�#�
$�C�
�4�<��!2�D�4E�F�F�F�<�|�<�<�<����o�o���H��%���&�&����� ���J�J�E��L��/�/�/�E�E���I�&� � � ��u�:�:���� �����J��%�-� � �G��u�z�?�?�D��C�K�E��#�:�D��T�T�\�"�"�J��EK�T�A�X�X��a�<�<��4�,�,�,��1C�d�1J�1J��.�0A�5�CU�V�V��(�)��
�4�,�,�,��D�-�-�-�$�%�:L�2X�2X�2X�2X�y�2X�2X�2X�2X�2X�$�1�D�8���.�0A�3�|�CT�CT�U�U�"�#���Z�=�=� ��a�<�<��Z�=�=� ��R�<�<��[�,��@�@�7�J�J�
������3�������Z�=�=� ��'� � � � �D� � � � � ���m�G��[�,��@�@�7�J�J��7�%�%�%�%�X�%�%�%�%�%��Y�<�<���'�>�>��t�O�E��Y�
�E�:�:�U�B�B��
�!����1�9�9��W�:�:��� ?��X�y�$�7�7�$�>�>�� ?��X�y�$�7�7�$�>�>���?�?��Y�<�<����[�*�=�=�
�J�J� �!���� �$� ��X�;�;��� O��-�/@�$�G�G�$�N�N�� ��Q����*�+�+�+��,�.A�:�N�N���
�
�)�+<�d�C�C�d�J�J��Y�
�E�2�2�:�:�4��F�F��RW���X�Xs�:$B� C�CF�"dt.datetime | dt.timedelta | float�future�whenc���t|��}t|��}|p
t��}t||���\}}|�t|��St |t
jt
jf��r||k}|rtd��ntd��}t|||��}|td��krtd��St||z��S)a�Return a natural representation of a time in a resolution that makes sense.
This is more or less compatible with Django's `naturaltime` filter.
Args:
value (datetime.datetime, datetime.timedelta, int or float): A `datetime`, a
`timedelta`, or a number of seconds.
future (bool): Ignored for `datetime`s and `timedelta`s, where the tense is
always figured out based on the current time. For integers and floats, the
return value will be past tense by default, unless future is `True`.
months (bool): If `True`, then a number of months (based on 30.5 days) will be
used for fuzziness between years.
minimum_unit (str): The lowest unit that can be used.
when (datetime.datetime): Point in time relative to which _value_ is
interpreted. Defaults to the current time in the local timezone.
Returns:
str: A natural representation of the input in a resolution that makes sense.
r;Nz%s from nowz%s agorUr4)
�_convert_aware_datetimer5rGrLrAr2r3rBrjr) rrvrIrKrwr4rFr6�agos r!rr�s���4
$�E�*�*�E�"�4�(�(�D�
�.�$�&�&�C�!�%�S�1�1�1�K�D�%��|��5�z�z���%�"�+�r�|�4�5�5������$�
5�!�M�
�
�
�!�H�+�+�C�����5�5�E���*�
�
�����x�x���s�U�{���r#�)dt.datetime | dt.timedelta | float | Nonerc��t|tj��r8|j�1tj�|�����}|S)zIConvert aware datetime to naive datetime and pass through any other type.)rAr2r3�tzinfo�
fromtimestamp� timestamp)rs r!ryrysC���%���%�%�=�%�,�*B���)�)�%�/�/�*;�*;�<�<���Lr#�%b %d�dt.date | dt.datetime�formatc��� tj|j|j|j��}n@#t
$rt
|��cYSttf$rt
|��cYSwxYw|tj� ��z
}|j
dkrtd��S|j
dkrtd��S|j
dkrtd��S|�|��S)z�Return a natural day.
For date values that are tomorrow, today or yesterday compared to
present day return representing string. Otherwise, return a string
formatted according to `format`.
r�todayr�tomorrow���� yesterday)
r2rF�year�month�day�AttributeErrorrL�
OverflowErrorrDr�r9rj�strftime)rr�r6s r!r
r
s�������
�E�K���;�;���������5�z�z�����:�&�����5�z�z��������
�B�G�M�M�O�O�#�E��z�Q�����z�z���z�Q�����}�}���z�R�����~�~���>�>�&�!�!�!��%(�A%�A%�$A%c�� tj|j|j|j��}n@#t
$rt
|��cYSttf$rt
|��cYSwxYwt|tj�
��z
��}|jdkrt|d��St|��S)zKLike `naturalday`, but append a year for dates more than ~five months away.g�����c@z%b %d %Y)
r2rFr�r�r�r�rLr�rDr:r�r9r
)rr6s r!rr3s�������
�E�K���;�;���������5�z�z�����:�&�����5�z�z��������
�5�2�7�=�=�?�?�2�3�3�E��z�\�!�!��%��,�,�,��e���r��float�divisor�unit�suppress�collections.abc.Iterable[Unit]�tuple[float, float]c�L�||kr||zdfS||vrd|fSt||��S)a�Divide `value` by `divisor` returning the quotient and remainder.
If `unit` is `minimum_unit`, makes the quotient a float number and the remainder
will be zero. The rational is that if `unit` is the unit of the quotient, we cannot
represent the remainder because it would require a unit smaller than the
`minimum_unit`.
>>> from humanize.time import _quotient_and_remainder, Unit
>>> _quotient_and_remainder(36, 24, Unit.DAYS, Unit.DAYS, [])
(1.5, 0)
If unit is in `suppress`, the quotient will be zero and the remainder will be the
initial value. The idea is that if we cannot use `unit`, we are forced to use a
lower unit so we cannot do the division.
>>> _quotient_and_remainder(36, 24, Unit.DAYS, Unit.HOURS, [Unit.DAYS])
(0, 36)
In other case return quotient and remainder as `divmod` would do it.
>>> _quotient_and_remainder(36, 24, Unit.DAYS, Unit.HOURS, [])
(1, 12)
r)�divmod)rr�r�rKr�s r!�_quotient_and_remainderr�CsB��>�|����w���!�!��x����%�x���%��!�!�!r#�value1�value2�ratiorn�typing.Iterable[Unit]c�F�||kr
|||zzdfS||vr
d|||zzfS||fS)a�Return a tuple with two values.
If the unit is in `suppress`, multiply `value1` by `ratio` and add it to `value2`
(carry to right). The idea is that if we cannot represent `value1` we need to
represent it in a lower unit.
>>> from humanize.time import _carry, Unit
>>> _carry(2, 6, 24, Unit.DAYS, Unit.SECONDS, [Unit.DAYS])
(0, 54)
If the unit is the minimum unit, `value2` is divided by `ratio` and added to
`value1` (carry to left). We assume that `value2` has a lower unit so we need to
carry it to `value1`.
>>> _carry(2, 6, 24, Unit.DAYS, Unit.DAYS, [])
(2.25, 0)
Otherwise, just return the same input:
>>> _carry(2, 6, 24, Unit.DAYS, Unit.SECONDS, [])
(2, 6)
rr/)r�r�r�r�rnr�s r!�_carryr�ksL��<�x�������&��)�)��x����&�6�E�>�)�)�)��6�>�r#c�`�||vr)tD]}||kr||vr|cS�d}t|���|S)a�Return a minimum unit suitable that is not suppressed.
If not suppressed, return the same unit:
>>> from humanize.time import _suitable_minimum_unit, Unit
>>> _suitable_minimum_unit(Unit.HOURS, []).name
'HOURS'
But if suppressed, find a unit greater than the original one that is not
suppressed:
>>> _suitable_minimum_unit(Unit.HOURS, [Unit.HOURS]).name
'DAYS'
>>> _suitable_minimum_unit(Unit.HOURS, [Unit.HOURS, Unit.DAYS]).name
'MONTHS'
z@Minimum unit is suppressed and no suitable replacement was found)rrD)rnr�r�rms r!�_suitable_minimum_unitr��sQ��$�8���� � �D��h���4�x�#7�#7������P����o�o���Or#� set[Unit]c�r�t|��}tD]}||krn|�|��� |S)aExtend suppressed units (if any) with all units lower than the minimum unit.
>>> from humanize.time import _suppress_lower_units, Unit
>>> [x.name for x in sorted(_suppress_lower_units(Unit.SECONDS, [Unit.DAYS]))]
['MICROSECONDS', 'MILLISECONDS', 'DAYS']
)�setr�add)rnr�r�s r!�_suppress_lower_unitsr��sH���8�}�}�H������8����E����T������Or#r/�%0.2f�dt.timedelta | int | None�typing.Iterable[str]c
��t|��\}}|�t|��Sd�|D��}t|���}t ||��}~t||��}|j}|j} |j}
tt��\}}}
}}}}}t|d|||��\}}t|d|||��\}}t|| d|||��\}} t| d|||��\}} t| d|||��\}} t| |
d|
||��\} }
t|
d |||��\}}
t|
d
d|||��\}
}dd
|fdd|fdd|fdd|fdd|fdd| fdd|fdd|
fg}g}ttt��|��D]�\}}|\}}}|d
ks|s�||kr�d|cxkrdkrnndnt|��} t||| ��}!||kr5t!j|��d
d
kr|!�d|��}!nB||kr<|!�dd��}!|�|!t)|��z����|�|!|z��||krn��t+|��dkr|d
Sd�|dd ���}"|d }#t/d!��|"|#fzS)"a%Return a precise representation of a timedelta.
```pycon
>>> import datetime as dt
>>> from humanize.time import precisedelta
>>> delta = dt.timedelta(seconds=3633, days=2, microseconds=123000)
>>> precisedelta(delta)
'2 days, 1 hour and 33.12 seconds'
```
A custom `format` can be specified to control how the fractional part
is represented:
```pycon
>>> precisedelta(delta, format="%0.4f")
'2 days, 1 hour and 33.1230 seconds'
```
Instead, the `minimum_unit` can be changed to have a better resolution;
the function will still readjust the unit to use the greatest of the
units that does not lose precision.
For example setting microseconds but still representing the date with milliseconds:
```pycon
>>> precisedelta(delta, minimum_unit="microseconds")
'2 days, 1 hour, 33 seconds and 123 milliseconds'
```
If desired, some units can be suppressed: you will not see them represented and the
time of the other units will be adjusted to keep representing the same timedelta:
```pycon
>>> precisedelta(delta, suppress=['days'])
'49 hours and 33.12 seconds'
```
Note that microseconds precision is lost if the seconds and all
the units below are suppressed:
```pycon
>>> delta = dt.timedelta(seconds=90, microseconds=100)
>>> precisedelta(delta, suppress=['seconds', 'milliseconds', 'microseconds'])
'1.50 minutes'
```
If the delta is too small to be represented with the minimum unit,
a value of zero will be returned:
```pycon
>>> delta = dt.timedelta(seconds=1)
>>> precisedelta(delta, minimum_unit="minutes")
'0.02 minutes'
>>> delta = dt.timedelta(seconds=0.1)
>>> precisedelta(delta, minimum_unit="minutes")
'0 minutes'
```
Nc�L�h|]!}t|�����"Sr/)rrg)�.0�ss r!� <setcomp>zprecisedelta.<locals>.<setcomp>s$��6�6�6��D������O�6�6�6r#rNrOi�QrZrVg��.ArPrrrcrdrarbr_r`r]r^r[r\rWrXrSrTrQrRrrerfz, r�z %s and %s)rGrLrrgr�r�r9r@ri�listr�r��zip�reversedrCr �math�modfrk�appendr
�len�joinrj)$rrKr�r�rFr6�suppress_setrnr9�secs�usecsr'r(r)r*r+r,r-r.rprIrtrs�msecs�_unused�fmts�textsr��fmt�singular_txt�
plural_txt� fmt_value�
_fmt_value�fmt_txt�head�tails$ r!rr�sh��P"�%�(�(�K�D�%��|��5�z�z��6�6�X�6�6�6�L��L�&�&�(�(�)�H�%�h��=�=�H��)��<�@�@�L��:�D��=�D���E�OS��P�P�L�L�,���%��v�u� *�$��U�H�l�S�S�K�E�4�*�4��v�x��V�V�L�F�D���d�I�t�X�|�L�L�J�D�$�)�$��e�X�|�T�T�K�E�4�+�D�"�g�x��V�V�M�G�T���u�c�7�H�l�K�K�K�D�%�*�
�t�\�8�\���L�E�5�
�E�1�a��x��N�N�N�E�7�
�J��&� �[�&�)� �9�d�#� �J��&� �l�G�,� �l�D�)� �,�e�4� �,�e�4� �D��E���$����.�.��� ��c�.1�+��j�)��q�=�=��=�4�8�+;�+;��)�/�/�/�/�a�/�/�/�/�/���S��^�^�J���j�*�E�E�G��x���D�I�i�$8�$8��$;�a�$?�$?�!�/�/�$��7�7�������!�/�/�$��5�5�����W�x� �':�':�:�;�;�;���L�L��9�,�-�-�-��8����E���5�z�z�Q����Q�x���9�9�U�3�B�3�Z� � �D���9�D��[�>�>�T�4�L�(�(r#)rr0)r6r7rr7)rrr4r<rr=)Tr@)rrHrIrJrKrLrrL)FTr@N)rrurvrJrIrJrKrLrwr<rrL)rr{rr)r�)rr�r�rLrrL)rr�rrL)rr�r�r�r�rrKrr�r�rr�)r�r�r�r�r�r�r�rrnrr�r�rr�)rnrr�r�rr)rnrr�r�rr�)r@r/r�)
rr�rKrLr�r�r�rLrrL)#�__doc__�
__future__r�collections.abc�collectionsr3r2r��typing�enumr� functoolsrr�i18nrrjr �numberr
�__all__rr5r:rGrrryr
rr�r�r�r�rr/r#r!�<module>r�sg����#�"�"�"�"�"�������������
�
�
�
�������$�$�$�$�$�$������������������������������
�
�
�
�
�4�
�
���
� �������� 59�'�'�'�'�'�'�6�!�AY�AY�AY�AY�AY�L��!�#�,�,�,�,�,�^����"�"�"�"�"�<
�
�
�
� %"�%"�%"�%"�P$�$�$�$�N����:
�
�
�
�$"�%'�� f)�f)�f)�f)�f)�f)�f)r#