Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
ó
MEYc@s
dZddlZddlZddlZddlZddlmZddlZddlmZ	ddl
Z
ddlZddlm
Z
dZdZeZdZejd	d
ddd
dƒded„ƒZd„Zejd	dddd
dƒded„ƒZed„Zd„Zd„Zd„Zed„Zed„Zejd	dddd
dƒed„ƒZde_dd„Z d„Z!d„Z"d„Z#dd„Z$d „Z%d!„Z&d"„Z'd#e(fd$„ƒYZ)ej*d%e+d&d'„Z,d(e(fd)„ƒYZ-dS(*s.
Time related utilities and helper functions.
iÿÿÿÿN(tremovals(t	monotonic(t
reflections%Y-%m-%dT%H:%M:%S.%fs%Y-%m-%dT%H:%M:%Si;tmessages!use datetime.datetime.isoformat()tversions1.6tremoval_versiont?cCsn|stƒ}n|j|s$tntƒ}|jrH|jjdƒnd}||dkrcdn|7}|S(sStringify time in ISO 8601 format.

    .. deprecated:: 1.5.0
       Use :func:`utcnow` and :func:`datetime.datetime.isoformat` instead.
    tUTCtZN(tutcnowtstrftimet_ISO8601_TIME_FORMATt_ISO8601_TIME_FORMAT_SUBSECONDttzinfottznametNone(tatt	subsecondtstttz((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pytisotime)s	!cCsjytj|ƒSWnRtjk
r>}ttj|ƒƒ‚n(tk
re}ttj|ƒƒ‚nXdS(s Parse time from ISO 8601 format.N(tiso8601t
parse_datet
ParseErrort
ValueErrortsixt	text_typet	TypeError(ttimestrte((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pyt
parse_isotime>ssPuse either datetime.datetime.isoformat() or datetime.datetime.strftime() insteadcCs|stƒ}n|j|ƒS(s|Returns formatted utcnow.

    .. deprecated:: 1.5.0
       Use :func:`utcnow()`, :func:`datetime.datetime.isoformat`
       or :func:`datetime.strftime` instead:

       * ``strtime()`` => ``utcnow().isoformat()``
       * ``strtime(fmt=...)`` => ``utcnow().strftime(fmt)``
       * ``strtime(at)`` => ``at.isoformat()``
       * ``strtime(at, fmt)`` => ``at.strftime(fmt)``
    (R	R
(Rtfmt((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pytstrtimeHscCstjj||ƒS(s+Turn a formatted time back into a datetime.(tdatetimetstrptime(RR((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pyt
parse_strtime_scCs0|jƒ}|dkr|S|jddƒ|S(s9Normalize time in arbitrary timezone to UTC naive object.R
N(t	utcoffsetRtreplace(t	timestamptoffset((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pytnormalize_timedscCsJt|tjƒr!t|ƒ}nt|ƒ}tƒ|tjd|ƒkS(s»Return True if before is older than seconds.

    .. versionchanged:: 1.7
       Accept datetime string with timezone information.
       Fix comparison with timezone aware datetime.
    tseconds(t
isinstanceRtstring_typesRR(R	R!t	timedelta(tbeforeR)((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pyt
is_older_thanlscCsJt|tjƒr!t|ƒ}nt|ƒ}|tƒtjd|ƒkS(sºReturn True if after is newer than seconds.

    .. versionchanged:: 1.7
       Accept datetime string with timezone information.
       Fix comparison with timezone aware datetime.
    R)(R*RR+RR(R	R!R,(tafterR)((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pyt
is_newer_than{scCsvtjdkr4tjƒ}|s0t|ƒ}n|Stƒ}tj|jƒƒ}|rr|t|j	ƒd7}n|S(s¯Timestamp version of our utcnow function.

    See :py:class:`oslo_utils.fixture.TimeFixture`.

    .. versionchanged:: 1.3
       Added optional *microsecond* parameter.
    i@BN(
R	t
override_timeRttimetinttcalendarttimegmt	timetupletfloattmicrosecond(R8R&tnow((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pyt	utcnow_tsŠs	cCsdtjr8ytjjdƒSWq8tk
r4tjSXn|rWtjjdtjjƒStjjƒS(sÇOverridable version of utils.utcnow that can return a TZ-aware datetime.

    See :py:class:`oslo_utils.fixture.TimeFixture`.

    .. versionchanged:: 1.6
       Added *with_timezone* parameter.
    iR(R	R1tpoptAttributeErrorR!R9RR(t
with_timezone((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pyR	£s	
s4use datetime.datetime.utcfromtimestamp().isoformat()cCsttjj|ƒ|ƒS(sReturns an iso8601 formatted date from timestamp.

    .. versionchanged:: 1.3
       Added optional *microsecond* parameter.

    .. deprecated:: 1.5.0
       Use :func:`datetime.datetime.utcfromtimestamp` and
       :func:`datetime.datetime.isoformat` instead.
    (RR!tutcfromtimestamp(R&R8((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pytiso8601_from_timestampµscCs|ptjjƒt_dS(sOverrides utils.utcnow.

    Make it return a constant time or a list thereof, one at a time.

    See :py:class:`oslo_utils.fixture.TimeFixture`.

    :param override_time: datetime instance or list thereof. If not
                          given, defaults to the current UTC time.
    N(R!R	R1(R1((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pytset_time_overrideÊs
cCs^tjdk	st‚y"xtjD]}||7}q"WWn tk
rYtj|7_nXdS(snAdvance overridden time using a datetime.timedelta.

    See :py:class:`oslo_utils.fixture.TimeFixture`.

    N(R	R1RtAssertionErrorR(R,tdt((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pytadvance_time_delta×s
cCsttjd|ƒƒdS(s^Advance overridden time by seconds.

    See :py:class:`oslo_utils.fixture.TimeFixture`.

    iN(RCR!R,(R)((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pytadvance_time_secondsåscCs
dt_dS(sVRemove the overridden time.

    See :py:class:`oslo_utils.fixture.TimeFixture`.

    N(RR	R1(((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pytclear_time_overrideîscCs€|stƒ}ntd|jd|jd|jd|jd|jd|jd|jƒ}|j	r||j	j
d	ƒ|d<n|S(
s—Make an rpc-safe datetime with microseconds.

    .. versionchanged:: 1.6
       Timezone information is now serialized instead of being stripped.
    tdaytmonthtyearthourtminutetsecondR8RN(R	tdictRFRGRHRIRJRKR8R
RR(R9td((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pytmarshall_now÷s*	cCs›t|dtƒ}tjd|dd|dd|dd|dd|dd|d|dƒ}|jdƒ}|r—tj|ƒ}|j|ƒ}n|S(	s¢Unmarshall a datetime dict.

    .. versionchanged:: 1.5
       Drop leap second.

    .. versionchanged:: 1.6
       Added support for timezone information.
    RKRFRGRHRIRJR8R(tmint_MAX_DATETIME_SECR!tgettpytzttimezonetlocalize(ttymeRKRBRR
((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pytunmarshall_times





cCs||}|jƒS(s¶Return the difference between two timing objects.

    Compute the difference in seconds between two date, time, or
    datetime objects (as a float, to microsecond resolution).
    (t
total_seconds(R-R/tdelta((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pyt
delta_seconds#s
cCs)tƒtjd|ƒ}t|ƒ|kS(sèDetermines if time is going to happen in the next window seconds.

    :param dt: the time
    :param window: minimum seconds to remain to consider the time not soon

    :return: True if expiration is within the given duration
    R)(R	R!R,R((RBtwindowtsoon((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pytis_soon-stSplitcBsJeZdZddgZd„Zed„ƒZed„ƒZd„ZRS(sŒA *immutable* stopwatch split.

    See: http://en.wikipedia.org/wiki/Stopwatch for what this is/represents.

    .. versionadded:: 1.4
    t_elapsedt_lengthcCs||_||_dS(N(R^R_(tselftelapsedtlength((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pyt__init__Cs	cCs|jS(sDuration from stopwatch start.(R^(R`((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pyRaGscCs|jS(s@Seconds from last split (or the elapsed time if no prior split).(R_(R`((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pyRbLscCs3tj|dtƒ}|d|j|jf7}|S(Ntfully_qualifieds(elapsed=%s, length=%s)(Rtget_class_nametFalseR^R_(R`tr((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pyt__repr__Qs(	t__name__t
__module__t__doc__t	__slots__RctpropertyRaRbRh(((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pyR]9s	s>It took %(seconds).02f seconds to run function '%(func_name)s'g{®Gáz„?cs‡‡‡‡‡fd†}|S(sÿDecorator that will log how long its decorated function takes to run.

    This does **not** output a log if the decorated function fails
    with an exception.

    :param logger: logger instance to use when logging elapsed time
    :param log_level: logger logging level to use when logging elapsed time
    :param message: customized message to use when logging elapsed time,
                    the message may use automatically provide values
                    ``%(seconds)`` and ``%(func_name)`` if it finds those
                    values useful to record
    :param enabled: whether to enable or disable this decorator (useful to
                    decorate a function with this decorator, and then easily
                    be able to switch that decoration off by some config or
                    other value)
    :param min_duration: argument that determines if logging is triggered
                         or not, it is by default set to 0.01 seconds to avoid
                         logging when durations and/or elapsed function call
                         times are less than 0.01 seconds, to disable
                         any ``min_duration`` checks this value should be set
                         to less than or equal to zero or set to none
    cs8ˆs
ˆStjˆƒ‡‡‡‡‡fd†ƒ}|S(Ncsvtƒ}ˆ||Ž}WdQX|jƒ}ˆdksE|ˆkrrˆjˆˆi|d6tjˆƒd6ƒn|S(NR)t	func_name(t	StopWatchRaRtlogRtget_callable_name(targstkwargstwtresultt
time_taken(tfunct	log_leveltloggerRtmin_duration(sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pytwrappervs
(Rtwraps(RwR{(tenabledRxRyRRz(RwsI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pyt	decoratorrs*((RyRxRR}RzR~((R}RxRyRRzsI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pyttime_itWsRocBs¶eZdZdZdZdd„Zd„Zed„ƒZ	d„Z
d„Zed„ƒZ
dd	„Zd
„Zd„Zed„Zd
„Zd„Zd„Zd„Zd„ZRS(s“A simple timer/stopwatch helper class.

    Inspired by: apache-commons-lang java stopwatch.

    Not thread-safe (when a single watch is mutated by multiple threads at
    the same time). Thread-safe when used by a single thread (not shared) or
    when operations are performed in a thread-safe manner on these objects by
    wrapping those operations with locks.

    It will use the `monotonic`_ pypi library to find an appropriate
    monotonically increasing time providing function (which typically varies
    depending on operating system and python version).

    .. _monotonic: https://pypi.python.org/pypi/monotonic/

    .. versionadded:: 1.4
    tSTARTEDtSTOPPEDcCs\|dk	r+|dkr+td|ƒ‚n||_d|_d|_d|_d|_dS(Nis4Duration must be greater or equal to zero and not %s((RRt	_durationt_started_att_stopped_att_statet_splits(R`tduration((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pyRc›s
				cCsD|j|jkr|Stƒ|_d|_|j|_d|_|S(s|Starts the watch (if not already started).

        NOTE(harlowja): resets any splits previously captured (if any).
        N((R…t_STARTEDR9RƒRR„R†(R`((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pytstart¥s		cCs|jS(s3Accessor to all/any splits that have been captured.(R†(R`((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pytsplits²scCsƒ|j|jkrs|jƒ}|jrF|j|jdj|ƒ}n|}|jt||ƒf|_|jdStdƒ‚dS(s=Captures a split/elapsed since start time (and doesn't stop).iÿÿÿÿs_Can not create a split time of a stopwatch if it has not been started or if it has been stoppedN(R…RˆRaR†t_delta_secondsR]tRuntimeError(R`RaRb((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pytsplit·s	cCs-|j|jkr|jƒn|jƒ|S(s0Restarts the watch from a started/stopped state.(R…RˆtstopR‰(R`((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pytrestartÆs

cCstd||ƒS(Ng(tmax(tearliertlater((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pyR‹ÍscCs|j|j|jfkr*tdƒ‚n|j|jkrW|j|j|jƒ}n|j|jtƒƒ}|dk	r™||kr™t	d|ƒ}n|S(s&Returns how many seconds have elapsed.sNCan not get the elapsed time of a stopwatch if it has not been started/stoppedgN(
R…Rˆt_STOPPEDRŒR‹RƒR„R9RR(R`tmaximumRa((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pyRaÒscCs|jƒ|S(sStarts the watch.(R‰(R`((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pyt	__enter__ßs
cCs&y|jƒWntk
r!nXdS(s0Stops the watch (ignoring errors if stop fails).N(RŽRŒ(R`ttypetvaluet	traceback((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pyt__exit__äs
cCsc|j|jkr!tdƒ‚n|jdkrI|sEtdƒ‚ndStd|j|jƒƒS(s5Returns how many seconds are left until the watch expires.

        :param return_none: when ``True`` instead of raising a ``RuntimeError``
                            when no duration has been set this call will
                            return ``None`` instead.
        :type return_none: boolean
        sFCan not get the leftover time of a stopwatch that has not been starteds=Can not get the leftover time of a watch that has no durationgN(R…RˆRŒR‚RRRa(R`treturn_none((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pytleftoverëscCsP|j|j|jfkr*tdƒ‚n|jdkr=tS|jƒ|jkS(sAReturns if the watch has expired (ie, duration provided elapsed).sKCan not check if a stopwatch has expired if it has not been started/stoppedN(R…RˆR“RŒR‚RRfRa(R`((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pytexpiredýs
cCs|j|jkS(s0Returns True if the watch is in a started state.(R…Rˆ(R`((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pythas_startedscCs|j|jkS(s0Returns True if the watch is in a stopped state.(R…R“(R`((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pythas_stopped
scCs2|j|jkr"|j|_|Stdƒ‚dS(s'Resumes the watch from a stopped state.s4Can not resume a stopwatch that has not been stoppedN(R…R“RˆRŒ(R`((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pytresumescCsS|j|jkr|S|j|jkr7tdƒ‚ntƒ|_|j|_|S(sStops the watch.s2Can not stop a stopwatch that has not been started(R…R“RˆRŒR9R„(R`((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pyRŽsN(RiRjRkRˆR“RRcR‰RmRŠRRtstaticmethodR‹RaR•R™RfR›RœRRžRŸRŽ(((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pyRo†s$
	
		
								(.RkR4R!tloggingR2t
debtcollectorRRRR9RRRt
oslo_utilsRRRtPERFECT_TIME_FORMATRPtremoveRRfRRR R#R(R.R0R:R	R?R1R@RCRDRERNRVRYR\tobjectR]tDEBUGtTrueRRo(((sI/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_utils/timeutils.pyt<module>sd		
					
	
							
	,