CasperSecurity

Current Path : /lib/python3/dist-packages/fail2ban/server/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/fail2ban/server/__pycache__/mytime.cpython-310.pyc

o

;s*bX�@s6dZdZdZddlZddlZddlZGdd�d�ZdS)z
Cyril Jaquierz Copyright (c) 2004 Cyril Jaquier�GPL�Nc
@sDeZdZdZdZdZdZedd��Zedd��Z	edd��Z
ed	d
��Zedd��Zed&d
d��Z
ed'dd��Ze�d�Ze�d�ZdZe�ed�ded�fe�ed�ded�fe�ed�ded�fe�ed�ded�fe�ed�ded�fe�ed �ded!�fe�ed"�ded#�ffZed$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.
	NcCs*|t_|durtj�|�t_dSdt_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��t�r�8/usr/lib/python3/dist-packages/fail2ban/server/mytime.py�setAlternateNow/s
	��zMyTime.setAlternateNowcCs
|t_dSr)r�myTimer	rrr�setTime<s
	zMyTime.setTimecCstjdur	t��StjS)zqDecorate time.time() for the purpose of testing mocking

		@return time.time() if setTime was called with None
		N)rr�timerrrrrGs
zMyTime.timecCstjdur	t��St�tj�S)zuDecorate time.gmtime() for the purpose of testing mocking

		@return time.gmtime() if setTime was called with None
		N)rrr�gmtimerrrrrSs
z
MyTime.gmtimecCs4tjdur
tj��StjtjkrtjStj�tj�S)zwDecorate datetime.now() for the purpose of testing mocking

		@return datetime.now() if setTime was called with None
		N)rrr�nowrrrrrrrr^s


z
MyTime.nowcCs(tjdus	|durt�|�St�tj�S)z{Decorate time.localtime() for the purpose of testing mocking

		@return time.localtime() if setTime was called with None
		N)rrr�	localtime)�xrrrrjs
zMyTime.localtime�%Y-%m-%d %H:%M:%ScCs:|dkrtj�|�jdd�n	t�dddddd�}|�|�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'����;)rr�replace�strftime)�unixTime�format�dtrrr�time2strus
����
zMyTime.time2strz(?i)(?<=[a-z])(\d)z(\d)\s+(\d)z(?i)(?<=[\d\s])(%s)\bzdays?|da|dd?�*i�Qzweeks?|wee?|ww?i�:	zmonths?|mon?gTDAzyears?|yea?|yy?g~~Azseconds?|sec?|ss?�zminutes?|min?|mm?�<zhours?|hou?|hh?icCsTt|tttf�r
|Stj�d|�}tjD]
\}}|�||�}qtj�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�rplrrr�str2seconds�szMyTime.str2seconds)N)r)�__name__�
__module__�__qualname__�__doc__rrr�staticmethodr
rrrrrr �re�compiler(r+�_str2sec_subpart�strr*r0rrrrr!s@	









�
r)�
__author__�
__copyright__�__license__rr6rrrrrr�<module>s
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY