/usr/lib/python2.6/site-packages/keystoneauth1
NameSizeModeActions
access/-0755rm
exceptions/-0755rm
extras/-0755rm
fixture/-0755rm
hacking/-0755rm
identity/-0755rm
loading/-0755rm
tests/-0755rm
adapter.py82660644editdlrm
adapter.pyc89020644editdlrm
discover.py123720644editdlrm
discover.pyc120440644editdlrm
plugin.py78220644editdlrm
plugin.pyc83050644editdlrm
session.py305020644editdlrm
session.pyc263890644editdlrm
token_endpoint.py13630644editdlrm
token_endpoint.pyc14490644editdlrm
_utils.py71270644editdlrm
_utils.pyc80590644editdlrm
__init__.py00644editdlrm
__init__.pyc1480644editdlrm
Edit: /usr/lib/python2.6/site-packages/keystoneauth1/_utils.pyc (8059B)
Ñò DVc @s›ddkZddkZddkZddkZddkZddkZd„ZeeƒZde fd„ƒYZ d„Z d„Z d„Z d„ZdS( iÿÿÿÿNcCs,|itidƒddƒ}ti|ƒS(Nt.it keystoneauth(treplacet__name__tsplittloggingt getLogger(tname((s;/tmp/pip-build-lt8jXN/keystoneauth1/keystoneauth1/_utils.pyt get_loggerst positionalcBsVeZdZdZdZded„Zeded„ƒZed„ƒZd„Z RS(sŠ A decorator which enforces only some args may be passed positionally. This idea and some of the code was taken from the oauth2 client of the google-api client. This decorator makes it easy to support Python 3 style key-word only parameters. For example, in Python 3 it is possible to write:: def fn(pos1, *, kwonly1, kwonly2=None): ... All named parameters after * must be a keyword:: fn(10, 'kw1', 'kw2') # Raises exception. fn(10, kwonly1='kw1', kwonly2='kw2') # Ok. To replicate this behaviour with the positional decorator you simply specify how many arguments may be passed positionally. To replicate the example above:: @positional(1) def fn(pos1, kwonly1=None, kwonly2=None): ... If no default value is provided to a keyword argument, it becomes a required keyword argument:: @positional(0) def fn(required_kw): ... This must be called with the keyword parameter:: fn() # Raises exception. fn(10) # Raises exception. fn(required_kw=10) # Ok. When defining instance or class methods always remember that in python the first positional argument passed is always the instance so you will need to account for `self` and `cls`:: class MyClass(object): @positional(2) def my_method(self, pos1, kwonly1=None): ... @classmethod @positional(2) def my_method(cls, pos1, kwonly1=None): ... If you would prefer not to account for `self` and `cls` you can use the `method` and `classmethod` helpers which do not consider the initial positional argument. So the following class is exactly the same as the one above:: class MyClass(object): @positional.method(1) def my_method(self, pos1, kwonly1=None): ... @positional.classmethod(1) def my_method(cls, pos1, kwonly1=None): ... If a value isn't provided to the decorator then it will enforce that every variable without a default value will be required to be a kwarg:: @positional() def fn(pos1, kwonly1=None): ... fn(10) # Ok. fn(10, 20) # Raises exception. fn(10, kwonly1=20) # Ok. This behaviour will work with the `positional.method` and `positional.classmethod` helper functions as well:: class MyClass(object): @positional.classmethod() def my_method(cls, pos1, kwonly1=None): ... MyClass.my_method(10) # Ok. MyClass.my_method(10, 20) # Raises exception. MyClass.my_method(10, kwonly1=20) # Ok. For compatibility reasons you may wish to not always raise an exception so a WARN mode is available. Rather than raise an exception a warning message will be logged:: @positional(1, enforcement=positional.WARN): def fn(pos1, kwonly=1): ... Available modes are: - positional.EXCEPT - the default, raise an exception. - positional.WARN - log a warning on mistake. texcepttwarncCs||_||_dS(N(t_max_positional_argst _enforcement(tselftmax_positional_argst enforcement((s;/tmp/pip-build-lt8jXN/keystoneauth1/keystoneauth1/_utils.pyt__init__‹s cs4ˆdj oˆd7‰n‡‡‡fd†}|S(Nicsˆˆˆƒ|ƒS(N((tfunc(RRtcls(s;/tmp/pip-build-lt8jXN/keystoneauth1/keystoneauth1/_utils.pytf”s(tNone(RRRR((RRRs;/tmp/pip-build-lt8jXN/keystoneauth1/keystoneauth1/_utils.pytmethods cs‡‡‡fd†}|S(NcstˆiˆˆŽ|ƒƒS(N(t classmethodR(R(tkwargstargsR(s;/tmp/pip-build-lt8jXN/keystoneauth1/keystoneauth1/_utils.pyRšs((RRRR((RRRs;/tmp/pip-build-lt8jXN/keystoneauth1/keystoneauth1/_utils.pyR˜scs‡ˆidjo2tiˆƒ}t|iƒt|iƒˆ_nˆidjodnd‰tiˆƒ‡‡‡fd†ƒ}|S(Nittscs t|ƒˆijo}dhˆid6ˆid6t|ƒd6ˆd6}ˆiˆijot|ƒ‚q“ˆiˆijoti|ƒq“nˆ||ŽS(NsN%(name)s takes at most %(max)d positional argument%(plural)s (%(given)d given)Rtmaxtgiventplural( tlenR RR tEXCEPTt TypeErrortWARNtloggertwarning(RRtmessage(RRR(s;/tmp/pip-build-lt8jXN/keystoneauth1/keystoneauth1/_utils.pytinner¥s    ( R Rtinspectt getargspecRRtdefaultst functoolstwraps(RRtspecR&((RRRs;/tmp/pip-build-lt8jXN/keystoneauth1/keystoneauth1/_utils.pyt__call__žs #$N( Rt __module__t__doc__R R"RRRRR-(((s;/tmp/pip-build-lt8jXN/keystoneauth1/keystoneauth1/_utils.pyR shcCs2|iƒ}|djo|S|iddƒ|S(s9Normalize time in arbitrary timezone to UTC naive object.ttzinfoN(t utcoffsetRR(t timestamptoffset((s;/tmp/pip-build-lt8jXN/keystoneauth1/keystoneauth1/_utils.pytnormalize_time¹s  cCsnyti|ƒSWnVtij o}tti|ƒƒ‚n+tj o}tti|ƒƒ‚nXdS(s Parse time from ISO 8601 format.N(tiso8601t parse_datet ParseErrort ValueErrortsixt text_typeR!(ttimestrte((s;/tmp/pip-build-lt8jXN/keystoneauth1/keystoneauth1/_utils.pyt parse_isotimeÁs cKs&tiiƒ}ti|}||S(s(Calculate the time in the future from utcnow. :param \*\*timedelta_kwargs: Passed directly to :class:`datetime.timedelta` to add to the current time in UTC. :returns: The time in the future based on ``timedelta_kwargs``. :rtype: datetime.datetime (tdatetimetutcnowt timedelta(ttimedelta_kwargstnowtdelta((s;/tmp/pip-build-lt8jXN/keystoneauth1/keystoneauth1/_utils.pyt from_utcnowËs cKs&tiiƒ}ti|}||S(s+Calculate the time in the past from utcnow. :param \*\*timedelta_kwargs: Passed directly to :class:`datetime.timedelta` to subtract from the current time in UTC. :returns: The time in the past based on ``timedelta_kwargs``. :rtype: datetime.datetime (R>R?R@(RARBRC((s;/tmp/pip-build-lt8jXN/keystoneauth1/keystoneauth1/_utils.pyt before_utcnowÛs (R>R*R'RR5R9RRR#tobjectR R4R=RDRE(((s;/tmp/pip-build-lt8jXN/keystoneauth1/keystoneauth1/_utils.pyt s        ›