HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /proc/1991111/cwd/lib/python3/dist-packages/fail2ban/server/__pycache__/
Upload File :
Current File : //proc/1991111/cwd/lib/python3/dist-packages/fail2ban/server/__pycache__/mytime.cpython-311.pyc
�

�Bd���D�dZdZdZddlZddlZddlZGd�d��ZdS)z
Cyril Jaquierz Copyright (c) 2004 Cyril Jaquier�GPL�Nc���eZdZdZdZdZdZed���Zed���Z	ed���Z
ed���Zed���Zed d���Z
ed!d
���Zejd��Zejd��Zd
Zejedz��ded��zfejedz��ded��zfejedz��ded��zfejedz��ded��zfejedz��ded��zfejedz��ded��zfejedz��ded��zffZed���ZGd�d��ZdS)"�MyTimea`A wrapper around time module primarily for testing purposes

	This class is a wrapper around time.time()  and time.gmtime(). When
	performing unit test, it is very useful to get a fixed value from
	these functions.  Thus, time.time() and time.gmtime() should never
	be called directly.  This wrapper should be called instead. The API
	are equivalent.
	Nc�x�|t_|�tj�|��ndt_dS�zrSet current time.

		Use None in order to always get the real current time.

		@param t the time to set or None
		N)r�alternateNowTime�datetime�
fromtimestamp�alternateNow��ts �8/usr/lib/python3/dist-packages/fail2ban/server/mytime.py�setAlternateNowzMyTime.setAlternateNow/s7���&��)*��8��"�"�1�%�%�%�D�	����c��|t_dSr)r�myTimers r�setTimezMyTime.setTime<s���&�-�-�-rc�X�tj�tj��StjS)zqDecorate time.time() for the purpose of testing mocking

		@return time.time() if setTime was called with None
		)rr�time�rrrzMyTime.timeGs ���]��
�)�+�+��
�-�rc�|�tj�tj��Stjtj��S)zuDecorate time.gmtime() for the purpose of testing mocking

		@return time.gmtime() if setTime was called with None
		)rrr�gmtimerrrrz
MyTime.gmtimeSs*���]��
�+�-�-��
�+�f�m�
$�
$�$rc���tj�tj���StjtjkrtjStj�tj��S)zwDecorate datetime.now() for the purpose of testing mocking

		@return datetime.now() if setTime was called with None
		)rrr	�nowrrr
rrrrz
MyTime.now^sS���]��
�
�
�
�
!�
!�!��]�f�-�-�-�
�
��	�	�	(�	(���	7�	7�7rc��tj�|�tj|��Stjtj��S)z{Decorate time.localtime() for the purpose of testing mocking

		@return time.localtime() if setTime was called with None
		)rrr�	localtime)�xs rrzMyTime.localtimejs2���]��a�m�
�.��
�
��
�.���
'�
'�'r�%Y-%m-%d %H:%M:%Sc���|dkr3tj�|���d���ntjdddddd��}|�|��S)	z�Convert time to a string representing as date and time using given format.
		Default format is ISO 8601, YYYY-MM-DD HH:MM:SS without microseconds.

		@return ISO-capable string representation of given unixTime
		lp��r)�microsecondi'����;)r	r
�replace�strftime)�unixTime�format�dts   r�time2strzMyTime.time2struss���,�����&�&��
�
�
�W��W����$,�$5�d�B��B��B�$O�$O��
���V�	�	�rz(?i)(?<=[a-z])(\d)z(\d)\s+(\d)z(?i)(?<=[\d\s])(%s)\bzdays?|da|dd?�*�Qzweeks?|wee?|ww?�:	zmonths?|mon?gTDAzyears?|yea?|yy?g~~Azseconds?|sec?|ss?�zminutes?|min?|mm?�<zhours?|hou?|hh?�c�8�t|tttf��r|Stj�d|��}tjD]\}}|�||��}�tj�d|��}t|��S)a)Wraps string expression like "1h 2m 3s" into number contains seconds (3723).
		The string expression will be evaluated as mathematical expression, spaces between each groups 
		  will be wrapped to "+" operand (only if any operand does not specified between).
		Because of case insensitivity and overwriting with minutes ("m" or "mm"), the short replacement for month
		  are "mo" or "mon".
		Ex: 1hour+30min = 5400
		    0d 1h 30m   = 5400
		    1year-6mo   = 15778800
		    6 months    = 15778800
		warn: month is not 30 days, it is a year in seconds / 12, the leap years will be respected also:
		      >>>> float(str2seconds("1month")) / 60 / 60 / 24
		      30.4375
		      >>>> float(str2seconds("1year")) / 60 / 60 / 24
		      365.25	
		
		@returns number (calculated seconds from expression "val")
		z \1z\1+\2)
�
isinstance�int�float�complexr�
_str2sec_prep�sub�_str2sec_parts�
_str2sec_fini�eval)�val�rexp�rpls   r�str2secondszMyTime.str2seconds�s���&��c�5�'�*�+�+��

�:��� � ���-�-�#��(���i�d�C�	
���#�s�	�	�3�3��� � ��3�/�/�#�	
�c���rc�$�eZdZdZd�Zd�Zd�ZdS)�MyTime.seconds2stra�Converts seconds to string on demand (if string representation needed).
		Ex: seconds2str(86400*390)            = 1y 3w 4d
		    seconds2str(86400*368)            = 1y 3d
		    seconds2str(86400*365.5)          = 1y
		    seconds2str(86400*2+3600*7+60*15) = 2d 7h 15m
		    seconds2str(86400*2+3599)         = 2d 1h
		    seconds2str(3600-5)               = 1h
		    seconds2str(3600-10)              = 59m 50s
		    seconds2str(59)                   = 59s
		c��||_dS�N)�sec)�selfrCs  r�__init__zMyTime.seconds2str.__init__�s
���4�8�8�8rc��|j}d}|dkr�ttt|��dz����}t	|dz��dz}|dz}|dkr|t	|dz��dzz
}|dz}|r|t	|��dzz
}|dd	�S|d
kr�ttt|��dz����}t	|dz��dz}|dz}|d
kr|t	|d
z��dzz
}|d
z}|r|t	|��dzz
}|dd	�S|dkr�ttt|��dz����}t	|dz��dz}|dz}|dkr|t	|dz��dzz
}|dz}|r|t	|��dzz
}|dd	�S|dkrsttt|��dz����}t	|dz��dz}|dz}|dkr|t	|dz��dzz
}|dz}|dd	�Sd}|dkr|t	|dz��dzz
}|dz}|r|t	|��dzz
}n	|jsd}|dd	�S)N�i�3�r,imzy �zw zd ���r-r0��zh r/i�zm i�
ih��zs z0 )rCr3�roundr4�str)rD�s�c�rs    r�__str__zMyTime.seconds2str.__str__�s����x�1�Q���8�m�m��E�%��(�(�5�.�!�!�"�"�A��A�s�F���d��A�A��H�A��A�v�v��#�a��d�)�)�d�
��Q�A��F�A����#�a�&�&�4�-��Q��S�b�S�6�M��6�k�k��E�%��(�(�4�-� � �!�!�A��A�s�F���d��A�A��H�A��B�w�w��#�a��e�*�*�t�
��Q�Q�"�W�Q����#�a�&�&�4�-��Q��S�b�S�6�M��5�j�j��E�%��(�(�2�+�����A��A�t�G���t��A�Q�$�Y�Q��B�w�w��#�a��e�*�*�t�
��Q�Q�"�W�Q����#�a�&�&�4�-��Q��S�b�S�6�M��4�i�i��E�%��(�(�2�+�����A��A�s�F���d��A�A��H�A��A�v�v��#�a��d�)�)�d�
��Q�A��F�A��S�b�S�6�M�	�1��2�g�g���Q��U���d�	��A�A��G�A��
���Q���$���A�A��H�
��A�
�C�R�C�&�=rc�*�|���SrB)rT)rDs r�__repr__zMyTime.seconds2str.__repr__�s��
�,�,�.�.�rN)�__name__�
__module__�__qualname__�__doc__rErTrVrrr�seconds2strr@�sL������	�	����*�*�*�V����rr[rB)r)rWrXrYrZrrr�staticmethodrrrrrrr*�re�compiler6r9�_str2sec_subpartrPr8r>r[rrrrr!s����������������
A�
A��,�
A�����,���	�	��,�	��%�%��,�%��	8�	8��,�	8��(�(�(��,�(��
�
�
��,�
����1�2�2�����N�+�+��,���2�:���0�1�1��C�C��M�M�8I�J�
�2�:��!3�3�4�4��C�C�
�O�O�8K�L�
�2�:���0�1�1��C�C�@Y�<Z�<Z�8Z�[�
�2�:��!3�3�4�4��C�C�@V�<W�<W�8W�X�
�2�:��!5�5�6�6��C�C��F�F�
�C�
�2�:��!5�5�6�6��C�C��G�G��D�
�2�:��!3�3�4�4��C�C��J�J��G�������,��89�9�9�9�9�9�9�9�9�9rr)�
__author__�
__copyright__�__license__r	r]rrrrr�<module>rcsm��(�
�2�
�������	�	�	�	�����J�J�J�J�J�J�J�J�J�Jr