/usr/lib/python2.6/site-packages/cinderclient/openstack/common
NameSizeModeActions
apiclient/-0755rm
gettextutils.py180410644editdlrm
gettextutils.pyc167620644editdlrm
importutils.py21890644editdlrm
importutils.pyc23650644editdlrm
strutils.py102290644editdlrm
strutils.pyc95520644editdlrm
__init__.py6440644editdlrm
__init__.pyc2750644editdlrm
Edit: /usr/lib/python2.6/site-packages/cinderclient/openstack/common/strutils.pyc (9552B)
Ñò =vVc @sÙdZddkZddkZddkZddkZddkZddklZh dd6dd6dd6dd 6dd 6d d 6d d 6dd6dd6Zhdei dƒfd6dei dƒfd6Z d:Z d;Z ei d#ƒZ ei d$ƒZd%d&d'd(gZgZd)d*d+d,d-d.gZxLeD]DZx;eD]3Zei ehed/6eiƒZeieƒq7Wq*Wd0„Zeed1„Zdd2d3„Zdd4d2d5„Zded6„Zdd2d7„Zd8d9„ZdS(<s. System-level utilities and helper functions. iÿÿÿÿN(t_itktKtKiitMtMiitGtGiitTtTiis&(^[-+]?\d*\.?\d+)([KMGT]i?)?(b|bit|B)$tIECiès$(^[-+]?\d*\.?\d+)([kMGT])?(b|bit|B)$tSIt1ttttruetontytyest0tftfalsetofftntnos[^\w\s-]s[-\s]+t adminPasst admin_passtpasswordtadmin_passwords#(%(key)s\s*[=]\s*[\"\']).*?([\"\'])s(<%(key)s>).*?()s-([\"\']%(key)s[\"\']\s*:\s*[\"\']).*?([\"\'])s.([\'"].*?%(key)s[\'"]\s*:\s*u?[\'"]).*?([\'"])sA([\'"].*?%(key)s[\'"]\s*,\s*\'--?[A-z]+\'\s*,\s*u?[\'"]).*?(['"])s (%(key)s\s*--?[A-z]+\s*)\S+(\s*)tkeycCst|ƒodpdS(såInterpret a string as a boolean and return either 1 or 0. Any string value in: ('True', 'true', 'On', 'on', '1') is interpreted as a boolean True. Useful for JSON-decoded stuff and config file parsing ii(tbool_from_string(tsubject((sS/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/strutils.pytint_from_bool_as_stringKs cCs¼t|tiƒpti|ƒ}n|iƒiƒ}|tjotS|tjot S|oQdi d„t ttƒDƒƒ}t dƒh|d6|d6}t |ƒ‚n|SdS(sInterpret a string as a boolean. A case-insensitive match is performed such that strings matching 't', 'true', 'on', 'y', 'yes', or '1' are considered True and, when `strict=False`, anything else returns the value specified by 'default'. Useful for JSON-decoded stuff and config file parsing. If `strict=True`, unrecognized values, including None, will raise a ValueError which is useful when parsing values passed in from an API call. Strings yielding False are 'f', 'false', 'off', 'n', 'no', or '0'. s, cssx|]}d|VqWdS(s'%s'N((t.0ts((sS/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/strutils.pys qs sCUnrecognized value '%(val)s', acceptable values are: %(acceptable)stvalt acceptableN(t isinstancetsixt string_typest text_typetstriptlowert TRUE_STRINGStTruet FALSE_STRINGStFalsetjointsortedRt ValueError(RtstricttdefaulttloweredR#tmsg((sS/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/strutils.pyRYs      R1cCs­t|titifƒptdt|ƒƒ‚nt|tiƒo|S|ptii p ti ƒ}ny|i ||ƒSWn t j o|i d|ƒSXdS(s™Decodes incoming text/bytes string using `incoming` if they're not already unicode. :param incoming: Text's current encoding :param errors: Errors handling policy. See here for valid values http://docs.python.org/2/library/codecs.html :returns: text or a unicode `incoming` encoded representation of it. :raises TypeError: If text is not an instance of str s%s can't be decodedsutf-8N( R$R%R&t binary_typet TypeErrorttypeR'tsyststdintencodingtgetdefaultencodingtdecodetUnicodeDecodeError(ttexttincomingterrors((sS/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/strutils.pyt safe_decodezs   sutf-8cCs½t|titifƒptdt|ƒƒ‚n|ptiip ti ƒ}nt|ti ƒo|i ||ƒS|o0||jo#t |||ƒ}|i ||ƒS|SdS(s?Encodes incoming text/bytes string using `encoding`. If incoming is not specified, text is expected to be encoded with current python's default encoding. (`sys.getdefaultencoding`) :param incoming: Text's current encoding :param encoding: Expected encoding for text (Default UTF-8) :param errors: Errors handling policy. See here for valid values http://docs.python.org/2/library/codecs.html :returns: text or a bytestring `encoding` encoded representation of it. :raises TypeError: If text is not an instance of str s%s can't be encodedN( R$R%R&R5R6R7R8R9R:R;R'tencodeRA(R>R?R:R@((sS/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/strutils.pyt safe_encode¡s c Cs yt|\}}Wn/tj o#tdƒ|}t|ƒ‚nX|i|ƒ}|oLt|idƒƒ}|idƒ}|idƒd jo|d:}qÄntdƒ|}t|ƒ‚|p |} n|t|t|ƒ} |ot t i | ƒƒS| S( sãConverts a string into an float representation of bytes. The units supported for IEC :: Kb(it), Kib(it), Mb(it), Mib(it), Gb(it), Gib(it), Tb(it), Tib(it) KB, KiB, MB, MiB, GB, GiB, TB, TiB The units supported for SI :: kb(it), Mb(it), Gb(it), Tb(it) kB, MB, GB, TB Note that the SI unit system does not support capital letter 'K' :param text: String input for bytes size conversion. :param unit_system: Unit system for byte size conversion. :param return_int: If True, returns integer representation of text in bytes. (default: decimal) :returns: Numerical representation of text in bytes. :raises ValueError: If text has an invalid value. sInvalid unit system: "%s"iiitbtbitisInvalid string format: %s(RDsbit( tUNIT_SYSTEM_INFOtKeyErrorRR0tmatchtfloattgrouptpowtUNIT_PREFIX_EXPONENTtinttmathtceil( R>t unit_systemt return_inttbasetreg_exR4RHt magnitudet unit_prefixtres((sS/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/strutils.pytstring_to_bytesÁs&  cCsgt|||ƒ}tid|ƒiddƒidƒ}tid|ƒiƒiƒ}t id|ƒS(sÙNormalize string. Convert to lowercase, remove non-word characters, and convert spaces to hyphens. Inspired by Django's `slugify` filter. :param value: Text to slugify :param incoming: Text's current encoding :param errors: Errors handling policy. See here for valid values http://docs.python.org/2/library/codecs.html :returns: slugified unicode representation of `value` :raises TypeError: If text is not an instance of str tNFKDtasciitignorett-( RAt unicodedatat normalizeRBR<tSLUGIFY_STRIP_REtsubR(R)tSLUGIFY_HYPHENATE_RE(tvalueR?R@((sS/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/strutils.pytto_slugïs s***csitiˆƒ‰t‡fd†tDƒƒpˆSd|d}x#tD]}ti||ˆƒ‰qFWˆS(s¢Replace password with 'secret' in message. :param message: The string which includes security information. :param secret: value with which to replace passwords. :returns: The unicode value of message with the password fields masked. For example: >>> mask_password("'adminPass' : 'aaaaa'") "'adminPass' : '***'" >>> mask_password("'admin_pass' : 'aaaaa'") "'admin_pass' : '***'" >>> mask_password('"password" : "aaaaa"') '"password" : "***"' >>> mask_password("'original_password' : 'aaaaa'") "'original_password' : '***'" >>> mask_password("u'original_password' : u'aaaaa'") "u'original_password' : u'***'" c3sx|]}|ˆjVqWdS(N((R R(tmessage(sS/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/strutils.pys !s s\g<1>s\g<2>(R%R'tanyt_SANITIZE_KEYSt_SANITIZE_PATTERNStreR`(Rdtsecrettpattern((RdsS/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/strutils.pyt mask_passwords(R R struesonRsyes(RRsfalsesoffRsno( t__doc__RNRhR8R]R%t*cinderclient.openstack.common.gettextutilsRRLtcompileRFR*R,R_RaRfRgt_FORMAT_PATTERNSRRjtDOTALLRStappendRR-RtNoneRARCRWRcRk(((sS/tmp/pip-build-cD3xZi/python-cinderclient/cinderclient/openstack/common/strutils.pytsZ         !'.