ó ™‚Mc@s™dZddlZddlmZmZddlZddlZy eZWn!ek rmddl m ZnXddl Z ddl Z ddl mZmZeƒZdddd d d d gZd Zd„ZejdejƒZd„Zd„Zde jfd„ƒYZdddd„Zd efd„ƒYZyejjZWne k rfdd„ZnXyddl!m"Z"m#Z#Wne$k rd„Z#nXydj%ddd„Z%Wn e k rÚddd„Z%nXedƒZ'defd „ƒYZ(ydd!l)m*Z*Wn e$k r3e(dd ƒZ*nXed"e j+ ƒZ,e j-rfed"e j. ƒZ/ne,Z/e/e,Z0d#efd$„ƒYZ1e1ƒZ2dS(%s&Various utility classes and functions.iÿÿÿÿN(t timedeltattzinfo(tSet(tiziptimaptdistinctt pathmatchtrelpathtwraptexttodicttUTCtLOCALTZsrestructuredtext enccsEtƒ}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 :return: the distinct items in the collection :rtype: ``iterator`` N(tsettitertadd(titerabletseentitem((s./usr/lib/python2.7/site-packages/babel/util.pyR"s   s([ \t\f]* \# .* coding[=:][ \t]*([-\w.]+)cCs |jƒ}|jdƒzÞ|jƒ}|jtjƒ}|rV|ttjƒ}ntj|ƒ}|sÀyddl }|j |ƒWnt t fk r¡qÀX|jƒ}tj|ƒ}n|rß|rÛt dƒ‚ndS|rò|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ÿÿÿÿNs\python refuses to compile code with both a UTF8 byte-order-mark and a magic encoding commenttutf_8i(ttelltseektreadlinet startswithtcodecstBOM_UTF8tlentPYTHON_MAGIC_COMMENT_retmatchtparsertsuitet ImportErrort SyntaxErrortgrouptNone(tfptpostline1thas_bomtmRtline2((s./usr/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(s…Extended 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 :return: `True` if the path name matches the pattern, `False` otherwise :rtype: `bool` s[^/]t?s[^/]/s?/s[^/]+t*s[^/]+/s*/s (?:.+/)*?s**/s(?:.+/)*?[^/]+s**s ([?*]+/?)itt$t/N( t enumeratetretsplittappendtescapeRtjointreplacetostsepR!(tpatterntfilenametsymbolstbuftidxtpartR((s./usr/lib/python2.7/site-packages/babel/util.pyRis % .t TextWrappercBseZejdƒZRS(s((\s+|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))(t__name__t __module__R/tcompilet wordsep_re(((s./usr/lib/python2.7/site-packages/babel/util.pyR=™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 :return: a list of lines :rtype: `list` twidthtinitial_indenttsubsequent_indenttbreak_long_words(R=tFalsetwrap(ttextRBRCRDtwrapper((s./usr/lib/python2.7/site-packages/babel/util.pyR s  cBs¤eZdZdd„Zd„Zd„Zd„ZeZd„Z d„Z d„Z d„Z d „Z ed „Zd „Zdd „Zd „Zd„Zd„ZRS(soOrdered dict implementation. :see: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/107747 cCs,tj||piƒtj|ƒ|_dS(N(tdictt__init__tkeyst_keys(tselftdata((s./usr/lib/python2.7/site-packages/babel/util.pyRK¸scCs$tj||ƒ|jj|ƒdS(N(RJt __delitem__RMtremove(RNtkey((s./usr/lib/python2.7/site-packages/babel/util.pyRP¼scCs9tj|||ƒ||jkr5|jj|ƒndS(N(RJt __setitem__RMR1(RNRRR((s./usr/lib/python2.7/site-packages/babel/util.pyRSÀscCs t|jƒS(N(R RM(RN((s./usr/lib/python2.7/site-packages/babel/util.pyt__iter__ÅscCstj|ƒg|_dS(N(RJtclearRM(RN((s./usr/lib/python2.7/site-packages/babel/util.pyRUÉs cCstƒ}|j|ƒ|S(N(R tupdate(RNtd((s./usr/lib/python2.7/site-packages/babel/util.pytcopyÍs  cCst|j|jƒƒS(N(tzipRMtvalues(RN((s./usr/lib/python2.7/site-packages/babel/util.pytitemsÒscCst|j|jƒƒS(N(RRMt itervalues(RN((s./usr/lib/python2.7/site-packages/babel/util.pyt iteritemsÕscCs|jS(N(RM(RN((s./usr/lib/python2.7/site-packages/babel/util.pyRLØscCsO|tkrtj||ƒS||kr,|S|jj|ƒtj|||ƒS(N(tmissingRJtpopRMRQ(RNRRtdefault((s./usr/lib/python2.7/site-packages/babel/util.pyR_Ûs   cCs|jj|ƒtj|ƒS(N(RMRQRJtpopitem(RNRR((s./usr/lib/python2.7/site-packages/babel/util.pyRaãscCs9tj|||ƒ||jkr5|jj|ƒndS(N(RJt setdefaultRMR1(RNRRtfailobj((s./usr/lib/python2.7/site-packages/babel/util.pyRbçscCs+x$|jƒD]\}}|||R?t__doc__R!RKRPRSRTtiterkeysRURXR[R]RLR^R_RaRbRVRZR\(((s./usr/lib/python2.7/site-packages/babel/util.pyR ³s"              t.cCstjj|ƒjtjƒ}tjj|ƒjtjƒ}ttjj||gƒƒ}tjjgt|ƒ|||}tjj|ŒS(s‰Compute the relative path to one path from another. >>> 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' :return: the relative path :rtype: `basestring` ( R5tpathtabspathR0R6Rt commonprefixtpardirR3(Rjtstartt start_listt path_listtitrel_list((s./usr/lib/python2.7/site-packages/babel/util.pyRús %(t attrgettert itemgettercs‡fd†}|S(Ncs|ˆS(N((tobj(tname(s./usr/lib/python2.7/site-packages/babel/util.pyt_getitems((RvRw((Rvs./usr/lib/python2.7/site-packages/babel/util.pyRtscCs|j||ƒS(N(trsplit(ta_stringR6tmaxsplit((s./usr/lib/python2.7/site-packages/babel/util.pyRxscCsi|j|ƒ}|dks-t|ƒ|kr1|St|ƒ|}|j|| ƒ}||}|g|S(N(R0R!RR3(RyR6Rztpartstmaxsplit_indextnon_splitted_parttsplitted((s./usr/lib/python2.7/site-packages/babel/util.pyRxs itFixedOffsetTimezonecBsGeZdZdd„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_offsetR!tzone(RNtoffsetRv((s./usr/lib/python2.7/site-packages/babel/util.pyRK,s  cCs|jS(N(R‚(RN((s./usr/lib/python2.7/site-packages/babel/util.pyt__str__2scCsd|j|jfS(Ns(R‚R(RN((s./usr/lib/python2.7/site-packages/babel/util.pyt__repr__5scCs|jS(N(R(RNtdt((s./usr/lib/python2.7/site-packages/babel/util.pyt utcoffset8scCs|jS(N(R‚(RNR†((s./usr/lib/python2.7/site-packages/babel/util.pyttzname;scCstS(N(tZERO(RNR†((s./usr/lib/python2.7/site-packages/babel/util.pytdst>sN( R>R?RgR!RKR„R…R‡RˆRŠ(((s./usr/lib/python2.7/site-packages/babel/util.pyR)s     (R tsecondst LocalTimezonecBs,eZd„Zd„Zd„Zd„ZRS(cCs|j|ƒrtStSdS(N(t_isdstt DSTOFFSETt STDOFFSET(RNR†((s./usr/lib/python2.7/site-packages/babel/util.pyR‡VscCs|j|ƒrtStSdS(N(RtDSTDIFFR‰(RNR†((s./usr/lib/python2.7/site-packages/babel/util.pyRŠ\scCstj|j|ƒS(N(ttimeRˆR(RNR†((s./usr/lib/python2.7/site-packages/babel/util.pyRˆbsc Csd|j|j|j|j|j|j|jƒddf }tj|ƒ}tj |ƒ}|j dkS(Niiÿÿÿÿ( tyeartmonthtdaythourtminutetsecondtweekdayR‘tmktimet localtimettm_isdst(RNR†ttttstamp((s./usr/lib/python2.7/site-packages/babel/util.pyRes (R>R?R‡RŠRˆR(((s./usr/lib/python2.7/site-packages/babel/util.pyRŒTs   (3RgRtdatetimeRRR5R/R t NameErrortsetsRttextwrapR‘t itertoolsRRtobjectR^t__all__t __docformat__RR@tVERBOSERR(RR=RRJR RjRtAttributeErrortoperatorRsRtRRxR!R‰RtpytzR ttimezoneRtdaylighttaltzoneRŽRRŒR (((s./usr/lib/python2.7/site-packages/babel/util.pytsf           / 0D