ó £ÒðQc@sdZddlZddlmZmZddlZddlZddlZddlm Z m Z e ƒZ d„Z ejdejƒZd„Zd„Zd ejfd „ƒYZd d d d „Zdefd„ƒYZyejjZWnek r dd„ZnXdefd„ƒYZddlZddlmZejZ ej!Z!ej"Z"ej#Z#ej$Z$ej%Z%ej&Z&dS(s© babel.util ~~~~~~~~~~ Various utility classes and functions. :copyright: (c) 2013 by the Babel Team. :license: BSD, see LICENSE for more details. iÿÿÿÿN(t timedeltattzinfo(tiziptimapccsEtƒ}x5t|ƒD]'}||kr|V|j|ƒqqWdS(s”Yield all items in an iterable collection that are distinct. Unlike when using sets for a similar effect, the original ordering of the items in the collection is preserved by this function. >>> print list(distinct([1, 2, 1, 3, 4, 4])) [1, 2, 3, 4] >>> print list(distinct('foobar')) ['f', 'o', 'b', 'a', 'r'] :param iterable: the iterable collection providing the data N(tsettitertadd(titerabletseentitem((s4/usr/local/lib/python2.7/site-packages/babel/util.pytdistincts  s([ \t\f]* \# .* coding[=:][ \t]*([-\w.]+)cCs|jƒ}|jdƒzð|jƒ}|jtjƒ}|rV|ttjƒ}ntj|ƒ}|sÉy&ddl }|j |j dƒƒWnt t fk rªqÉX|jƒ}tj|ƒ}n|rè|rät dƒ‚ndS|r|jdƒj dƒSdSWd|j|ƒXdS(sDeduce the encoding of a source file from magic comment. It does this in the same way as the `Python interpreter`__ .. __: http://docs.python.org/ref/encodings.html The ``fp`` argument should be a seekable file object. (From Jeff Dairiki) iiÿÿÿÿNslatin-1s\python refuses to compile code with both a UTF8 byte-order-mark and a magic encoding commenttutf_8i(ttelltseektreadlinet startswithtcodecstBOM_UTF8tlentPYTHON_MAGIC_COMMENT_retmatchtparsertsuitetdecodet ImportErrort SyntaxErrortgrouptNone(tfptpostline1thas_bomtmRtline2((s4/usr/local/lib/python2.7/site-packages/babel/util.pytparse_encoding,s2      cCsÔidd6dd6dd6dd6d d 6d d 6}g}xcttjd |ƒƒD]I\}}|dry|j||ƒqO|rO|jtj|ƒƒqOqOWtjdj|ƒd|jtj dƒƒ}|dk S(sExtended pathname pattern matching. This function is similar to what is provided by the ``fnmatch`` module in the Python standard library, but: * can match complete (relative or absolute) path names, and not just file names, and * also supports a convenience pattern ("**") to match files at any directory level. Examples: >>> pathmatch('**.py', 'bar.py') True >>> pathmatch('**.py', 'foo/bar/baz.py') True >>> pathmatch('**.py', 'templates/index.html') False >>> pathmatch('**/templates/*.html', 'templates/index.html') True >>> pathmatch('**/templates/*.html', 'templates/foo/bar.html') False :param pattern: the glob pattern :param filename: the path name of the file to match against s[^/]t?s[^/]/s?/s[^/]+t*s[^/]+/s*/s (?:.+/)*?s**/s(?:.+/)*?[^/]+s**s ([?*]+/?)itt$t/N( t enumeratetretsplittappendtescapeRtjointreplacetostsepR(tpatterntfilenametsymbolstbuftidxtpartR((s4/usr/local/lib/python2.7/site-packages/babel/util.pyt pathmatch[s % .t TextWrappercBseZejdƒZRS(s((\s+|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))(t__name__t __module__R)tcompilet wordsep_re(((s4/usr/local/lib/python2.7/site-packages/babel/util.pyR8‰siFR%c Cs.td|d|d|dtƒ}|j|ƒS(sØSimple wrapper around the ``textwrap.wrap`` function in the standard library. This version does not wrap lines on hyphens in words. :param text: the text to wrap :param width: the maximum line width :param initial_indent: string that will be prepended to the first line of wrapped output :param subsequent_indent: string that will be prepended to all lines save the first of wrapped output twidthtinitial_indenttsubsequent_indenttbreak_long_words(R8tFalsetwrap(ttextR=R>R?twrapper((s4/usr/local/lib/python2.7/site-packages/babel/util.pytwraptexts  todictcBs¤eZdZdd„Zd„Zd„Zd„ZeZd„Z d„Z d„Z d„Z d „Z ed „Zd „Zdd „Zd „Zd„Zd„ZRS(skOrdered dict implementation. :see: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/107747 cCs2tj||piƒttj|ƒƒ|_dS(N(tdictt__init__tlisttkeyst_keys(tselftdata((s4/usr/local/lib/python2.7/site-packages/babel/util.pyRH¦scCs$tj||ƒ|jj|ƒdS(N(RGt __delitem__RKtremove(RLtkey((s4/usr/local/lib/python2.7/site-packages/babel/util.pyRNªscCs9tj|||ƒ||jkr5|jj|ƒndS(N(RGt __setitem__RKR+(RLRPR ((s4/usr/local/lib/python2.7/site-packages/babel/util.pyRQ®scCs t|jƒS(N(RRK(RL((s4/usr/local/lib/python2.7/site-packages/babel/util.pyt__iter__³scCstj|ƒg|_dS(N(RGtclearRK(RL((s4/usr/local/lib/python2.7/site-packages/babel/util.pyRS·s cCstƒ}|j|ƒ|S(N(RFtupdate(RLtd((s4/usr/local/lib/python2.7/site-packages/babel/util.pytcopy»s  cCst|j|jƒƒS(N(tzipRKtvalues(RL((s4/usr/local/lib/python2.7/site-packages/babel/util.pytitemsÀscCst|j|jƒƒS(N(RRKt itervalues(RL((s4/usr/local/lib/python2.7/site-packages/babel/util.pyt iteritemsÃscCs|jS(N(RK(RL((s4/usr/local/lib/python2.7/site-packages/babel/util.pyRJÆscCsO|tkrtj||ƒS||kr,|S|jj|ƒtj|||ƒS(N(tmissingRGtpopRKRO(RLRPtdefault((s4/usr/local/lib/python2.7/site-packages/babel/util.pyR]És   cCs|jj|ƒtj|ƒS(N(RKRORGtpopitem(RLRP((s4/usr/local/lib/python2.7/site-packages/babel/util.pyR_ÑscCs9tj|||ƒ||jkr5|jj|ƒndS(N(RGt setdefaultRKR+(RLRPtfailobj((s4/usr/local/lib/python2.7/site-packages/babel/util.pyR`ÕscCs+x$|jƒD]\}}|||>> relpath('foo/bar.txt', '').replace(os.sep, '/') 'foo/bar.txt' >>> relpath('foo/bar.txt', 'foo').replace(os.sep, '/') 'bar.txt' >>> relpath('foo/bar.txt', 'baz').replace(os.sep, '/') '../foo/bar.txt' ( R/tpathtabspathR*R0Rt commonprefixtpardirR-(Rhtstartt start_listt path_listtitrel_list((s4/usr/local/lib/python2.7/site-packages/babel/util.pytrelpathès %tFixedOffsetTimezonecBsGeZdZdd„Zd„Zd„Zd„Zd„Zd„Z RS(s&Fixed offset in minutes east from UTC.cCs8td|ƒ|_|dkr+d|}n||_dS(Ntminutess Etc/GMT+%d(Rt_offsetRtzone(RLtoffsettname((s4/usr/local/lib/python2.7/site-packages/babel/util.pyRHÿs  cCs|jS(N(Ru(RL((s4/usr/local/lib/python2.7/site-packages/babel/util.pyt__str__scCsd|j|jfS(Ns(RuRt(RL((s4/usr/local/lib/python2.7/site-packages/babel/util.pyt__repr__scCs|jS(N(Rt(RLtdt((s4/usr/local/lib/python2.7/site-packages/babel/util.pyt utcoffset scCs|jS(N(Ru(RLRz((s4/usr/local/lib/python2.7/site-packages/babel/util.pyttznamescCstS(N(tZERO(RLRz((s4/usr/local/lib/python2.7/site-packages/babel/util.pytdstsN( R9R:ReRRHRxRyR{R|R~(((s4/usr/local/lib/python2.7/site-packages/babel/util.pyRrüs     (t localtime('ReRtdatetimeRRR/R)ttextwrapt babel._compatRRtobjectR\R R;tVERBOSERR"R7R8RERGRFRhRqtAttributeErrorRrtpytzt_pytztbabelRtutctUTCtLOCALTZt get_localzonet STDOFFSETt DSTOFFSETtDSTDIFFR}(((s4/usr/local/lib/python2.7/site-packages/babel/util.pyt s:       / .D