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:
ó
~˜EYc@s$dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	e
dƒZd	Zd
„Z
d„Zeed„Zd
„Zdd„Zd„Zdefd„ƒYZdefd„ƒYZdefd„ƒYZd„Zd„Zd„ZdS(s3Miscellaneous utility functions for use with Swift.iÿÿÿÿNttruet1tyestontttyt d41d8cd98f00b204e9800998ecf8427ecCs.|tkp-t|tjƒo-|jƒtkS(s¯
    Returns True if the value is either True or a string in TRUE_VALUES.
    Returns False otherwise.
    This function comes from swift.common.utils.config_true_value()
    (tTruet
isinstancetsixtstring_typestlowertTRUE_VALUES(tvalue((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pytconfig_true_valuescCs |sd|St|ƒ}d
gtdƒ}x6|d D] }|dkrNPn|d:}q8W|d}|std|S|dkrŽd||fSd	||fSd
S(s
    convert a number > 1024 to printable format, either in 4 char -h format as
    with ls -lh or return as 12 char right justified string
    s%12stKMGTPEZYiÿÿÿÿiÿg@s%4si
s%3d%ss%.1f%sN(tfloattNonetlist(t	num_bytest
human_flagtnumtsuffixestsuffix((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pyt	prt_bytes(s
c	Cs„yLt|ƒ}|jƒs'tƒ‚nt|ƒ}|dkrKtƒ‚nWntk
rktdƒ‚nXt|tjƒr´y|jdƒ}Wqºtk
r°tdƒ‚qºXn|}|j	ddƒ}t
|ƒdks|dst|d|rýdnd!ƒr,|rtd	ƒ‚q,td
ƒ‚nddd
ddg}|jƒ|kr{t
jdƒ}	|	jd|jƒƒn|sšttjƒ|ƒ}
n|}
dj|jƒt|
ƒ|rÄdnd|gƒ}t|tjƒsø|jdƒ}ntj||jdƒtjƒjƒ}djd|d|d|
ƒ}
|r]|
dj|dƒ7}
nt|tjƒr||
jdƒS|
SdS(sÅGenerates a temporary URL that gives unauthenticated access to the
    Swift object.

    :param path: The full path to the Swift object or prefix if
         a prefix-based temporary URL should be generated. Example:
        /v1/AUTH_account/c/o or /v1/AUTH_account/c/prefix.
    :param seconds: If absolute is False then this specifies the amount of time
        in seconds for which the temporary URL will be valid. If absolute is
        True then this specifies an absolute time at which the temporary URL
        will expire.
    :param key: The secret temporary URL key set on the Swift
        cluster. To set a key, run 'swift post -m
        "Temp-URL-Key: <substitute tempurl key here>"'
    :param method: A HTTP method, typically either GET or PUT, to allow
        for this temporary URL.
    :param absolute: if True then the seconds parameter is interpreted as an
        absolute Unix time, otherwise seconds is interpreted as a relative time
        offset from current time.
    :param prefix: if True then a prefix-based temporary URL will be generated.
    :raises: ValueError if seconds is not a whole number or path is not to
        an object.
    :return: the path portion of a temporary URL
    isseconds must be a whole numbersutf-8s#path must be representable as UTF-8t/iiis#path must at least contain /v1/a/c/s2path must be full path to an object e.g. /v1/a/c/otGETtPUTtHEADtPOSTtDELETEtswiftclientsCNon default HTTP method %s for tempurl specified, possibly an erroru
sprefix:tu0{path}?temp_url_sig={sig}&temp_url_expires={exp}tpathtsigtexpu&temp_url_prefix={}N(Rt
is_integert
ValueErrortintRR	tbinary_typetdecodetUnicodeDecodeErrortsplittlentalltuppertloggingt	getLoggertwarningttimetjointstrtencodethmactnewthashlibtsha1t	hexdigesttformat(R!tsecondstkeytmethodtabsolutetprefixt
path_for_bodytpartststandard_methodstloggert
expirationt	hmac_bodyR"ttemp_url((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pytgenerate_temp_urlBsP

<	'	
cCs±|jdƒdkrNtjdtj|ƒddƒ}|jƒ}WdQXnd}|jddƒ}d	|kr›|jd	d
ƒd
jdd
ƒd}ntj|j	|ƒƒS(
Nscontent-encodingtgziptfileobjtmodetrsutf-8scontent-typeR s
; charset=it;i(
tgetRHtGzipFileR	tBytesIOtreadR*tjsontloadsR((theaderstbodytgztcharsettcontent_type((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pytparse_api_response’s$)R cCsÌi}t|tjƒr'|jƒ}nxž|D]–}t|tjƒrzd|kretd|ƒ‚n|jddƒ}nt|ƒdkr¢td|fƒ‚n|dj	ƒ|||dj
ƒ<q.W|S(Nt:sOMetadata parameter %s must contain a ':'.
Example: 'Color:Blue' or 'Size:Large'iisbMetadata parameter %r must have exactly two items.
Example: ('Color', 'Blue') or ['Size', 'Large']i(RtcollectionstMappingtitemsR	R
R%R*R+tstripttitle(toptionsR?RStitem((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pytsplit_request_headers s 

&cCs?y&tjƒ}tjƒ}||fSWntk
r:dSXdS(ss
    Reports a timestamp and full traceback for a given exception.

    :return: Full traceback and timestamp.
    N(NN(t	tracebackt
format_excR1tAttributeErrorR(tformatted_linestnow((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pytreport_traceback·s
tNoopMD5cBs#eZd„Zd„Zd„ZRS(cOsdS(N((tselftatkw((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pyt__init__ÆscOsdS(N((RiRjRk((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pytupdateÉscOsdS(NR ((RiRjRk((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pyR9Ìs(t__name__t
__module__RlRmR9(((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pyRhÅs		tReadableToIterablecBsAeZdZded„Zd„Zd„Zd„Zd„ZRS(s˜
    Wrap a filelike object and act as an iterator.

    It is recommended to use this class only on files opened in binary mode.
    Due to the Unicode changes in Python 3, files are now opened using an
    encoding not suitable for use with the md5 class and because of this
    hit the exception on every call to next. This could cause problems,
    especially with large files and small chunk sizes.
    icCs4|rtjƒntƒ|_||_||_dS(sõ
        :param content: The filelike object that is yielded from.
        :param chunk_size: The max size of each yielded item.
        :param md5: Flag to enable calculating the MD5 of the content
                    as it is yielded.
        N(R7tmd5Rhtmd5sumtcontentt
chunk_size(RiRsRtRq((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pyRlÛs	cCs
|jjƒS(N(RrR9(Ri((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pyt
get_md5sumæscCsf|jj|jƒ}|s$t‚ny|jj|ƒWn'tk
ra|jj|jƒƒnX|S(sÉ
        Both ``__next__`` and ``next`` are provided to allow compatibility
        with python 2 and python 3 and their use of ``iterable.next()``
        and ``next(iterable)`` respectively.
        (RsRPRtt
StopIterationRrRmt	TypeErrorR4(Ritchunk((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pyt__next__és	
cCs
|jƒS(N(Ry(Ri((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pytnextúscCs|S(N((Ri((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pyt__iter__ýs(	RnRot__doc__tFalseRlRuRyRzR{(((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pyRpÐs				t
LengthWrappercBsYeZdZed„Zd„Zd„Zd„Zdd„Ze	d„ƒZ
d„ZRS(	sÇ
    Wrap a filelike object with a maximum length.

    Fix for https://github.com/kennethreitz/requests/issues/1648.
    It is recommended to use this class only on files opened in binary mode.
    csj||_|jƒ||_|_ˆ|_t‡fd†dDƒƒ|_|jrfˆjƒ|_ndS(s^
        :param readable: The filelike object to read from.
        :param length: The maximum amount of content that can be read from
                       the filelike object before it is simulated to be
                       empty.
        :param md5: Flag to enable calculating the MD5 of the content
                    as it is read.
        c3s|]}tˆ|ƒVqdS(N(thasattr(t.0tattr(treadable(sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pys	<genexpr>stseekttellN(sseekstell(	t_md5t
_reset_md5t_lengtht
_remainingt	_readableR,t
_can_resetR„t_start(RiR‚tlengthRq((R‚sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pyRls		
		cCs|jS(N(R‡(Ri((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pyt__len__scCs%|jrtjƒntƒ|_dS(N(R…R7RqRhRr(Ri((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pyR†scCs
|jjƒS(N(RrR9(Ri((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pyRu siÿÿÿÿcCs£|jdkrdS|dkr(|jnt||jƒ}|jj|ƒ}|jt|ƒ8_y|jj|ƒWn'tk
rž|jj|jƒƒnX|S(NiR (	RˆtminR‰RPR+RrRmRwR4(Ritsizetto_readRx((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pyRP#s'
cCs-|jr|jStdt|ƒjƒ‚dS(Ns"%r object has no attribute 'reset'(RŠt_resetRdttypeRn(Ri((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pytreset2s	cOsU|js(tdt|jƒjƒ‚n|jj|jƒ|jƒ|j|_	dS(Ns;%r object cannot be reset; needs both seek and tell methods(
RŠRwR’R‰RnRƒR‹R†R‡Rˆ(Ritargstkwargs((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pyR‘9s	
(RnRoR|R}RlRR†RuRPtpropertyR“R‘(((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pyR~s			ccs2x+|D]#}t|ƒdkr%qn|VqWdS(Ni(R+(titerableRx((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pytiter_wrapperBs
ccs7x0tdt|ƒ|ƒD]}||||!VqWdS(Ni(trangeR+(tseqtnti((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pytn_at_a_timeKscCs%t|ƒd|d}t||ƒS(Ni(R+R(RšR›titems_per_group((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pytn_groupsPs(strueRsyessonRR(R|RZRHR7R5RQR.R	R1RbtsetRt
EMPTY_ETAGRRR}RGRXRaRgtobjectRhRpR~R˜RRŸ(((sF/home/tvault/.virtenv/lib/python2.7/site-packages/swiftclient/utils.pyt<module>s0	
	O		1A