Current File : //usr/lib/python2.7/site-packages/requestbuilder/mixins/__init__.pyc
�
9!-Xc@sbddlZddlZddlmZdefd��YZddlmZddlm	Z	dS(i����N(tArgtRegionConfigurableMixincBs\eZdZeddddd
dd�gZd
d
d�Zd
d
d�Zed	��Z	RS(sG
    A mixin that allows the user to specify which user/region names to use
    for the configuration via a --region arg and, if a 'REGION_ENVVAR' class
    variable is set, an environment variable as well.  The included
    update_config_view method actually reads these data and updates
    self.config to point to them.
    s--regiontmetavarsUSER@REGIONtroute_tothelpsCregion and/or user names to search when looking up config file datacCs�|r||j_n|r*||j_n|jjd�ro|jdj|jd�|j|jd��nt|dd�}t
|ttf�r�x�|D]D}t
j|�r�|jdj|�|jt
j|���Pq�q�WnRt
|tj�r:t
j|�r:|jdj|�|jt
j|���q:n|jdd|jjd��|jjd�\}}|jdj|�d|�dS(	Ntregions--region CLI option "{0}"t
REGION_ENVVARsenvironment variable "{0}"s%"default-region" global config optionsdefault-regiontusers%"user" config option for region "{0}"(tconfigRRtargstgett/_RegionConfigurableMixin__setdefault_view_attrstformatt&_RegionConfigurableMixin__parse_regiontgetattrtNonet
isinstancetlistttupletostgetenvtsixtstring_typestget_global_optiontget_region_option2(tselfRRt
region_envvartvartsection((sB/usr/lib/python2.7/site-packages/requestbuilder/mixins/__init__.pytupdate_config_view#s8
cCst|r8|jjr8|jjd||�||j_n|rp|jjrp|jjd||�||j_ndS(Nsselected region "%s" from %ssselected user "%s" from %s(RRtlogtinfoR(RtcauseRR((sB/usr/lib/python2.7/site-packages/requestbuilder/mixins/__init__.pyt__setdefault_view_attrsMscCsV|s
dS|jd�r,|jd�dfSd|krH|jdd�Sd|fSdS(s|
        Given a string with pattern "[USER@][REGION]", return the user
        and region names that that string represents, if any, and None
        for the values it does not represent.

        Examples:
         - ""          -> (None, None)
         - "spam"      -> (None, "spam")
         - "eggs@"     -> ("eggs", None)
         - "eggs@spam" -> ("eggs", "spam")
        t@iN(NN(Rtendswithtrstriptsplit(t	regionish((sB/usr/lib/python2.7/site-packages/requestbuilder/mixins/__init__.pyt__parse_regionUsN(
t__name__t
__module__t__doc__RRtARGSRRtstaticmethodR
(((sB/usr/lib/python2.7/site-packages/requestbuilder/mixins/__init__.pyRs*i(tTabifyingMixin(tFileTransferProgressBarMixin(
RRtrequestbuilderRtobjectRt
formattingR-tprogressR.(((sB/usr/lib/python2.7/site-packages/requestbuilder/mixins/__init__.pyt<module>s
X