9!-Xc@sbddlZddlZddlmZdefdYZddlmZddlm Z dS(iN(tArgtRegionConfigurableMixincBs\eZdZeddddd ddgZd d dZd d dZed 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--regiontmetavars USER@REGIONtroute_tothelpsCregion and/or user names to search when looking up config file datacCs|r||j_n|r*||j_n|jjdro|jdj|jd|j|jdnt|dd}t |t t frx|D]D}t j|r|jdj||jt j|PqqWnRt |tjr: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|jdr,|jddfSd|krH|jddSd|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__RRtARGSRR t 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__.pyts  X