관리-도구
편집 파일: time.cpython-311.pyc
� ���и)�X�#��������������������:����d�Z�ddlmZ�ddlZddlZddlZddlZddl m Z �ddlmZ�ddlm Z �ddlmZ�dd lmZ�dd lmZ�g�d�Ze�G�d��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�����e�Zd�ZdZdZdZdZdZdZdZ dZ dd�Zd S�)�Unitr���r����������������������������other� typing.Any�returnc�����������������L�����|�j���������|j���������u�r|�j��������|j��������k�����S�t����������S��N)� __class__�value�NotImplemented)�selfr���s��� �m/builddir/build/BUILD/imunify360-venv-2.5.2/opt/imunify360/venv/lib/python3.11/site-packages/humanize/time.py�__lt__zUnit.__lt__'���s&�������>�U�_�,�,��:���+�+�������N)r���r���r���r���)�__name__� __module__�__qualname__�MICROSECONDS�MILLISECONDS�SECONDS�MINUTES�HOURS�DAYS�MONTHS�YEARSr"�����r#���r!���r���r������sP���������������L��L��G��G� �E��D� �F� �E�����������r#���r���r����dt.datetimec������������������>�����t�����������j�������������������������������������������S�r���)�dt�datetime�nowr/���r#���r!����_nowr5���-���s������ �;�?�?���r#����delta�dt.timedeltac�����������������H�����|�j���������dk�����rt������������������������}|||�z���z ��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���)r6���r4���s��� r!����_abs_timedeltar:���1���s,������� �z�A�~�~��f�f���c�E�k�"�"��Lr#����r4���r���r���r4����dt.datetime | None�tuple[typing.Any, typing.Any]c����������������X����|st������������������������}t����������|�t����������j��������������������r|�}||�z ��}nht����������|�t����������j��������������������r||�z ��}|�}nF �t����������|�������������}�t����������j��������|��������������}||z ��}n#�t����������t����������f$�r�d|�fcY�S�w�xY�w|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���� isinstancer2���r3���� timedelta�int� ValueError� TypeErrorr:���)r���r4����dater6���s��� 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�����������|��������������������������������������������}|t�����������j��������t�����������j��������t�����������j��������fvrd|��d�}t����������|�������������|}t ����������|�t����������j��������������������r|�}nL �t����������|�������������}�t����������j��������|��������������}n&#�t ����������t����������f$�r�t����������|�������������cY�S�w�xY�w|}t����������|j ��������������������}t����������|j��������������������} | dz��} | dz��} t����������| dz��������������}| �sk| dk������rd|dk����r�|t�����������j��������k����r)|j��������dk�����rt!����������d d |j��������������������|j��������z��S�|t�����������j��������k����s%|t�����������j��������k����r@d|j��������cxk����rdk�����r.n�n+|j��������dz��}t!����������dd t����������|������������������������|z��S�t#����������d������������S�|dk����rt#����������d������������S�|dk�����rt!����������dd|������������|z��S�d|cxk����rdk�����rn�nt#����������d������������S�d|cxk����rdk�����rn�n|dz��} t!����������dd| ������������| z��S�d|cxk����rdk�����rn�nt#����������d������������S�d|k�����r|dz��}t!����������dd|������������|z��S�n�| dk����rj| dk����rt#����������d������������S�|st!����������dd| ������������| z��S�|st!����������dd| ������������| z��S�|dk����rt#����������d������������S�t!����������d d!|������������|z��S�| dk����rh|s| st#����������d"������������S�|st!����������d#d$| ������������| z��S�|r)|dk����rt#����������d%������������S�t!����������d&d'|������������|z��S�t!����������d#d$| ������������| z��S�t!����������d(d)| ���������������������������������d*d+������������t'����������| ������������z��S�),aT��Return 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���������>@r���r��������%d microsecond�%d microsecondsi@B��%d millisecond�%d milliseconds�a momentza second�<���� %d second� %d seconds�x���za 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'���rD���rA���r2���rB���rC���rE���rL����absr@���r9����microsecondsr ����_�replacer ���)r���rI���rK����tmp�msg�min_unitr6���� use_monthsr@���r9����years� num_months�milliseconds�minutes�hourss��� r!���r���r���Y���sD�����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����������|�������������S�t ����������|�t ����������j��������t ����������j��������f������������r||k����}|rt����������d������������nt����������d������������}t����������|||������������}|t����������d������������k����rt����������d������������S�t����������||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 agorU���r4���) �_convert_aware_datetimer5���rG���rL���rA���r2���r3���rB���rj���r���) r���rv���rI���rK���rw���r4���rF���r6����agos ��� r!���r���r�������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 | Noner���c����������������������t����������|�t����������j��������������������r8|�j���������1t����������j�����������������������������|������������������������������������������������}�|�S�)zIConvert aware datetime to naive datetime and pass through any other type.)rA���r2���r3����tzinfo� fromtimestamp� timestamp)r���s��� r!���ry���ry�����sC��������%���%�%��=�%�,�*B���)�)�%�/�/�*;�*;�<�<���Lr#����%b %d�dt.date | dt.datetime�formatc���������������������� �t����������j��������|�j��������|�j��������|�j��������������������}�n@#�t ����������$�r�t ����������|�������������cY�S�t����������t����������f$�r�t ����������|�������������cY�S�w�xY�w|�t�����������j��������� ����������������������������������z ��}|j ��������dk����rt����������d������������S�|j ��������dk����rt����������d������������S�|j ��������dk����rt����������d������������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) r2���rF����year�month�day�AttributeErrorrL���� OverflowErrorrD���r����r9���rj����strftime)r���r����r6���s��� 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��������������������� �t����������j��������|�j��������|�j��������|�j��������������������}�n@#�t ����������$�r�t ����������|�������������cY�S�t����������t����������f$�r�t ����������|�������������cY�S�w�xY�wt����������|�t�����������j��������� ����������������������������������z ��������������}|j��������dk����rt����������|�d������������S�t����������|�������������S�)zKLike `naturalday`, but append a year for dates more than ~five months away.g�����c@z%b %d %Y) r2���rF���r����r����r����r����rL���r����rD���r:���r����r9���r ���)r���r6���s��� r!���r���r���3��s����������� �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�����||k����r|�|z��dfS�||v�rd|�fS�t����������|�|������������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)r���r����r����rK���r����s��� r!����_quotient_and_remainderr����C��sB������>��|����w���!�!��x����%�x���%��!�!�!r#����value1�value2�ratiorn����typing.Iterable[Unit]c�����������������F�����||k����r |�||z��z���dfS�||v�r d||�|z��z���fS�|�|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) r���r/���)r����r����r����r����rn���r����s��� r!����_carryr����k��sL������<��x�������&��)�)��x����&�6�E�>�)�)�)��6�>�r#���c�����������������`�����|�|v�r)t�����������D�]}||�k����r||vr|c�S��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)r���rD���)rn���r����r����rm���s��� r!����_suitable_minimum_unitr�������sQ������$��8����� �� �D��h���4�x�#7�#7������P����o�o���Or#���� set[Unit]c�����������������r�����t����������|������������}t����������D�]}||�k����r�n|���������������������|�������������� |S�)a��Extend 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)rn���r����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����������|�������������S�d��|D���������������}t����������|��������������������������������������������}t ����������||������������}~t����������||������������}|j��������}|j��������} |j��������} t����������t����������������������\��}}} }}}}}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�}t����������t����������t����������������������|������������D�]�\��}}|\��}}}|d k����s|s�||k����r�d|cxk�����rdk�����rn�ndnt����������|������������} t����������||| ������������}!||k����r5t!����������j��������|������������d ���������d k����r|!���������������������d|������������}!nB||k����r<|!���������������������dd������������}!|���������������������|!t)����������|������������z�����������������|���������������������|!|z���������������||k����r�n��t+����������|������������dk����r|d ���������S�d���������������������|dd ����������������������}"|d ���������}#t/����������d!������������|"|#fz��S�)"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�����������|����������������������������������������������"S�r/���)r���rg���)�.0�ss��� r!���� <setcomp>zprecisedelta.<locals>.<setcomp>��s$������6�6�6��D������O�6�6�6r#���rN���rO���i�Q�rZ���rV���g������.ArP���r���r���rc���rd���ra���rb���r_���r`���r]���r^���r[���r\���rW���rX���rS���rT���rQ���rR���r���re���rf���z, r����z %s and %s)rG���rL���r���rg���r����r����r9���r@���ri����listr����r�����zip�reversedrC���r ����math�modfrk����appendr ����len�joinrj���)$r���rK���r����r����rF���r6����suppress_setrn���r9����secs�usecsr'���r(���r)���r*���r+���r,���r-���r.���rp���rI���rt���rs����msecs�_unused�fmts�textsr�����fmt�singular_txt� plural_txt� fmt_value� _fmt_value�fmt_txt�head�tails$��� r!���r���r������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#���)r���r0���)r6���r7���r���r7���)r���r���r4���r<���r���r=���)Tr@���)r���rH���rI���rJ���rK���rL���r���rL���)FTr@���N)r���ru���rv���rJ���rI���rJ���rK���rL���rw���r<���r���rL���)r���r{���r���r���)r����)r���r����r����rL���r���rL���)r���r����r���rL���)r���r����r����r����r����r���rK���r���r����r����r���r����)r����r����r����r����r����r����r����r���rn���r���r����r����r���r����)rn���r���r����r����r���r���)rn���r���r����r����r���r����)r@���r/���r����) r���r����rK���rL���r����r����r����rL���r���rL���)#�__doc__� __future__r����collections.abc�collectionsr3���r2���r�����typing�enumr���� functoolsr���r����i18nr���rj���r ����numberr ����__all__r���r5���r:���rG���r���r���ry���r ���r���r����r����r����r����r���r/���r#���r!����<module>r�������sg��������#��"��"��"��"��"����������������������� � � � ��������������$��$��$��$��$��$��������������������������������������������������������� �� �� �� �� �4�� �� ���� � �������������� �59�'��'��'��'��'��'�6��!�AY��AY��AY��AY��AY�L���!�#�,��,��,��,��,�^�������"��"��"��"��"�< �� �� �� � %"��%"��%"��%"�P$��$��$��$�N�������: �� �� �� �$�"�%'�� f)��f)��f)��f)��f)��f)��f)r#���