%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/fail2ban/server/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/fail2ban/server/mytime.pyc

�
��&dc@sMdZdZdZddlZddlZddlZddd��YZdS(s
Cyril Jaquiers Copyright (c) 2004 Cyril JaquiertGPLi����NtMyTimecBs�eZdZdZdZdZed��Zed��Z	ed��Z
ed��Zed��Zedd��Z
edd��Zejd	�Zejd
�ZdZejed�d
ed �fejed�d
ed#�fejed�d
ed(dd�fejed�d
ed-d�fejed�d
ed�fejed�d
ed�fejed�d
ed.�ffZed��ZRS(/s`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.
	cCs4|t_|dk	r'tjj|�ndt_dS(srSet current time.

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

		@param t the time to set or None
		N(RtalternateNowTimetNonetdatetimet
fromtimestamptalternateNow(tt((s:/usr/lib/python2.7/site-packages/fail2ban/server/mytime.pytsetAlternateNow/s		cCs
|t_dS(srSet current time.

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

		@param t the time to set or None
		N(RtmyTime(R((s:/usr/lib/python2.7/site-packages/fail2ban/server/mytime.pytsetTime<s	cCs$tjdkrtj�StjSdS(sqDecorate time.time() for the purpose of testing mocking

		@return time.time() if setTime was called with None
		N(RR	Rttime(((s:/usr/lib/python2.7/site-packages/fail2ban/server/mytime.pyRGs
cCs-tjdkrtj�Stjtj�SdS(suDecorate time.gmtime() for the purpose of testing mocking

		@return time.gmtime() if setTime was called with None
		N(RR	RRtgmtime(((s:/usr/lib/python2.7/site-packages/fail2ban/server/mytime.pyRSs
cCsHtjdkrtjj�Stjtjkr5tjStjjtj�S(swDecorate datetime.now() for the purpose of testing mocking

		@return datetime.now() if setTime was called with None
		N(RR	RRtnowRRR(((s:/usr/lib/python2.7/site-packages/fail2ban/server/mytime.pyR
^s

cCs<tjdks|dk	r(tj|�Stjtj�SdS(s{Decorate time.localtime() for the purpose of testing mocking

		@return time.localtime() if setTime was called with None
		N(RR	RRt	localtime(tx((s:/usr/lib/python2.7/site-packages/fail2ban/server/mytime.pyRjs
s%Y-%m-%d %H:%M:%ScCsU|dkr*tjj|�jdd�ntjdddddd�}|j|�S(	s�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
		I��:tmicrosecondii'iiii;(RRtreplacetstrftime(tunixTimetformattdt((s:/usr/lib/python2.7/site-packages/fail2ban/server/mytime.pyttime2strus
Hs(?i)(?<=[a-z])(\d)s(\d)\s+(\d)s(?i)(?<=[\d\s])(%s)\bsdays?|da|dd?t*ii<sweeks?|wee?|ww?ismonths?|mon?imiiniisyears?|yea?|yy?sseconds?|sec?|ss?isminutes?|min?|mm?shours?|hou?|hh?cCst|ttttf�r|Stjjd|�}x)tjD]\}}|j||�}q>Wtj	jd|�}t
|�S(s)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")
		s \1s\1+\2(t
isinstancetinttlongtfloattcomplexRt
_str2sec_preptsubt_str2sec_partst
_str2sec_finiteval(tvaltrexptrpl((s:/usr/lib/python2.7/site-packages/fail2ban/server/mytime.pytstr2seconds�sNi�i�Qi�i`'i�:	iGi�i��i  i��iGi�i��i  i��i(t__name__t
__module__t__doc__RR	RRtstaticmethodRR
RRR
RRtretcompileRR t_str2sec_subparttstrRR%(((s:/usr/lib/python2.7/site-packages/fail2ban/server/mytime.pyR!s0

  ($  &((t
__author__t
__copyright__t__license__RR*RR(((s:/usr/lib/python2.7/site-packages/fail2ban/server/mytime.pyt<module>s

Zerion Mini Shell 1.0