Viewing File: /opt/imunify360/venv/lib/python3.11/site-packages/humanize/__pycache__/time.cpython-311.pyc



]j3I:dZddlmZddlZddlZddlZddlZddl	m
Z
ddlmZddlm
Z
ddlmZdd	lmZdd
lmZgdZeGdd
e
ZdEdZdFdZdddGdZ		dHdId"Z				dJdKd'ZdLd*ZdMdNd.ZdOd/ZdPd6ZdQd<ZdRd=Z dSd?Z!			dTdUdDZ"dS)VzYTime humanizing functions.

These are largely borrowed from Django's `contrib.humanize`.
)annotationsN)Enum)total_ordering)Any)_gettext)	_ngettext)intcomma)naturaldeltanaturaltime
naturaldaynaturaldateprecisedeltac6eZdZdZdZdZdZdZdZdZ	dZ
ddZd
S)Unitrrother
typing.AnyreturncL|j|jur|j|jkStSN)	__class__valueNotImplemented)selfrs  m/builddir/build/BUILD/imunify360-venv-2.6.3/opt/imunify360/venv/lib/python3.11/site-packages/humanize/time.py__lt__zUnit.__lt__'s&>U_,,:++N)rrrr)__name__
__module____qualname__MICROSECONDSMILLISECONDSSECONDSMINUTESHOURSDAYSMONTHSYEARSr"r#r!rrsPLLGG
ED
F
Er#rrdt.datetimec>tjSr)dtdatetimenowr/r#r!_nowr5-s
;??r#deltadt.timedeltacH|jdkrt}|||zz
S|S)zReturn 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,
zA~~ffcEk""Lr#r4rrr4dt.datetime | Nonetuple[typing.Any, typing.Any]cX|st}t|tjr|}||z
}nht|tjr||z
}|}nF	t|}tj|}||z
}n#ttf$rd|fcYSwxYw|t|fS)zTurn 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	timedeltaint
ValueError	TypeErrorr:)rr4dater6s    r!_date_and_deltarG@sff%%%e	E2<	(	(	U{	JJEL///E;DDI&			;	&&&&s)BBBTr@dt.timedelta | floatmonthsboolminimum_unitstrct|}|tjtjtjfvrd|d}t||}t
|tjr|}nL	t|}tj|}n&#t
tf$rt|cYSwxYw|}t|j
}t|j}	|	dz}
|	dz}	t|	dz}|
sk|	dkrd|dkr|tjkr)|jdkrt!d	d
|j|jzS|tjks%|tjkr@d|jcxkrdkr.nn+|jdz}t!dd
t||zSt#dS|dkrt#dS|dkrt!dd||zSd|cxkrdkrnnt#dSd|cxkrdkrnn|dz}
t!dd|
|
zSd|cxkrdkrnnt#dSd|kr|dz}t!dd||zSn|
dkrj|	dkrt#dS|st!dd|	|	zS|st!dd|	|	zS|dkrt#dSt!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 millisecondsa momentza second<	%d second
%d secondsxza 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)rupperr)r(r'rDrAr2rBrCrErLabsr@r9microsecondsr	_replacer
)rrIrKtmpmsgmin_unitr6
use_monthsr@r9years
num_monthsmillisecondsminuteshourss               r!rrYsDF|!!##
$C
4<!2D4EFFF<|<<<ooH%&&	JJEL///EEI&			u::	J%-  Guz??DCKE#:DTT\""JEKTAXXa<<4,,,1Cd1J1J.0A5CUVV()
4,,,D---$%:L2X2X2X2Xy2X2X2X2X2X$1D8.0A3|CTCTUU"#Z== a<<Z== R<<[,@@7JJ
3Z== '    D     mG[,@@7JJ7%%%%X%%%%%Y<<'>>tOEY
E::UBB
!199W::	?Xy$77$>>	?Xy$77$>>??Y<<[*==
JJ	!	$	X;;	O-/@$GG$NN	Q*+++,.A:NN

)+<dCCdJJY
E22::4FFRWXXs:$B CCF"dt.datetime | dt.timedelta | floatfuturewhenct|}t|}|p
t}t||\}}|t|St	|t
jt
jfr||k}|rtdntd}t|||}|tdkrtdSt||zS)aReturn 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)	rrvrIrKrwr4rFr6agos	         r!rrs4
$E**E"4((D
.$&&C!%S111KD%|5zz%"+r|455$
5!M


!H++C55E*

xxsU{r#)dt.datetime | dt.timedelta | float | Nonerct|tjr8|j1tj|}|S)zIConvert aware datetime to naive datetime and pass through any other type.)rAr2r3tzinfo
fromtimestamp	timestamp)rs r!ryrysC%%%=%,*B))%//*;*;<<Lr#%b %ddt.date | dt.datetimeformatc	tj|j|j|j}n@#t
$rt
|cYSttf$rt
|cYSwxYw|tj	z
}|j
dkrtdS|j
dkrtdS|j
dkrtdS||S)zReturn 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`.

    rtodayrtomorrow	yesterday)
r2rFyearmonthdayAttributeErrorrL
OverflowErrorrDrr9rjstrftime)rrr6s   r!r
r
s
EK;;5zz:&5zz
BGMMOO#EzQzzzQ}}zR~~>>&!!!%(A%A%$A%c	tj|j|j|j}n@#t
$rt
|cYSttf$rt
|cYSwxYwt|tj
z
}|jdkrt|dSt|S)zKLike `naturalday`, but append a year for dates more than ~five months away.gc@z%b %d %Y)
r2rFrrrrrLrrDr:rr9r
)rr6s  r!rr3s
EK;;5zz:&5zz
527==??233Ez\!!%,,,erfloatdivisorunitsuppresscollections.abc.Iterable[Unit]tuple[float, float]cL||kr||zdfS||vrd|fSt||S)aDivide `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)rrrrKrs     r!_quotient_and_remainderrCsB>|w!!x%x%!!!r#value1value2ratiorntyping.Iterable[Unit]cF||kr
|||zzdfS||vr
d|||zzfS||fS)aReturn 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/)rrrrrnrs      r!_carryrksL<x&))x&6E>)))6>r#c`||vr)tD]}||kr||vr|cSd}t||S)aReturn 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)rnrrrms    r!_suitable_minimum_unitrsQ$8		Dh4x#7#7PooOr#	set[Unit]crt|}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']
    )setradd)rnrrs   r!_suppress_lower_unitsrsH8}}H8ETOr#r/%0.2fdt.timedelta | int | Nonetyping.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|||\}
}dd
|fdd|fdd|fdd|fdd|fdd|	fdd|fdd|
fg}g}ttt|D]\}}|\}}}|d
ks|s||krd|cxkrdkrnndnt|} t||| }!||kr5t!j|d
d
kr|!d|}!nB||kr<|!dd}!||!t)|z||!|z||krnt+|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'

    ```
    NcLh|]!}t|"Sr/)rrg).0ss  r!	<setcomp>zprecisedelta.<locals>.<setcomp>s$666DO666r#rNrOiQrZrVg.ArPrrrcrdrarbr_r`r]r^r[r\rWrXrSrTrQrRrrerfz, rz	%s and %s)rGrLrrgrrr9r@rilistrrzipreversedrCr	mathmodfrkappendr
lenjoinrj)$rrKrrrFr6suppress_setrnr9secsusecsr'r(r)r*r+r,r-r.rprIrtrsmsecs_unusedfmtstextsrfmtsingular_txt
plural_txt	fmt_value
_fmt_valuefmt_txtheadtails$                                    r!rrshP"%((KD%|5zz66X666LL&&(()H%h==H)<@@L:D=DEOSPPLL,%vu *$UHlSSKE4*4vxVVLFDdItX|LLJD$)$eX|TTKE4+D"gxVVMGTuc7HlKKKD%*
t\8\LE5
E1axNNNE7
J&	[&)	9d#	J&	lG,	lD)	,e4	,e4	DE$..	c.1+j)q===48+;+;)////a/////S^^Jj*EEGxDIi$8$8$;a$?$?!//$77!//$55Wx	':'::;;;LL9,---8E5zzQQx99U3B3Z  D9D[>>T4L((r#)rr0)r6r7rr7)rrr4r<rr=)Tr@)rrHrIrJrKrLrrL)FTr@N)rrurvrJrIrJrKrLrwr<rrL)rr{rr)r)rrrrLrrL)rrrrL)rrrrrrrKrrrrr)rrrrrrrrrnrrrrr)rnrrrrr)rnrrrrr)r@r/r)
rrrKrLrrrrLrrL)#__doc__
__future__rcollections.abccollectionsr3r2rtypingenumr	functoolsrri18nrrjr	numberr
__all__rr5r:rGrrryr
rrrrrrr/r#r!<module>rsg#"""""



$$$$$$




4


  59''''''6!AYAYAYAYAYL!#,,,,,^"""""<



 %"%"%"%"P$$$$N:



$"%'	f)f)f)f)f)f)f)r#
Back to Directory File Manager