• File: util.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/lib/python2.7/site-packages/babel/util.pyc
  • Date Modified: 10/27/2026 5:17 AM
  • File size: 13.17 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit

Mc@sdZddlZddlmZmZddlZddlZy
eZWn!ek
rmddl	m
ZnXddlZddlZddl
mZmZeZdddd	d
ddgZd
ZdZejdejZdZdZdejfdYZddddZd
efdYZyejjZWne k
rfddZnXyddl!m"Z"m#Z#Wne$k
rdZ#nXydj%dddZ%Wn e k
rdddZ%nXedZ'defd YZ(ydd!l)m*Z*Wn e$k
r3e(ddZ*nXed"ej+Z,ej-rfed"ej.Z/ne,Z/e/e,Z0d#efd$YZ1e1Z2dS(%s&Various utility classes and functions.iN(t	timedeltattzinfo(tSet(tiziptimaptdistinctt	pathmatchtrelpathtwraptexttodicttUTCtLOCALTZsrestructuredtext enccsEt}x5t|D]'}||kr|V|j|qqWdS(sYield 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}|jdz|j}|jtj}|rV|ttj}ntj|}|syddl	}|j
|Wnttfk
rqX|j}tj|}n|r|rtdndS|r|j
dSdSWd|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)
    iiNs\python refuses to compile code with both a UTF8 byte-order-mark and a magic encoding commenttutf_8i(ttelltseektreadlinet
startswithtcodecstBOM_UTF8tlentPYTHON_MAGIC_COMMENT_retmatchtparsertsuitetImportErrortSyntaxErrortgrouptNone(tfptpostline1thas_bomtmRtline2((s./usr/lib/python2.7/site-packages/babel/util.pytparse_encoding:s2

cCsidd6dd6dd6dd6d	d
6dd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
    :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
%
.tTextWrappercBseZejdZRS(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.pyRs
	cBseZdZddZdZdZdZeZdZ	dZ
dZdZd	Z
ed
ZdZddZd
ZdZdZRS(soOrdered dict implementation.
    
    :see: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/107747
    cCs,tj||pitj||_dS(N(tdictt__init__tkeyst_keys(tselftdata((s./usr/lib/python2.7/site-packages/babel/util.pyRKscCs$tj|||jj|dS(N(RJt__delitem__RMtremove(RNtkey((s./usr/lib/python2.7/site-packages/babel/util.pyRPscCs9tj|||||jkr5|jj|ndS(N(RJt__setitem__RMR1(RNRRR((s./usr/lib/python2.7/site-packages/babel/util.pyRSscCs
t|jS(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.pyRUs
cCst}|j||S(N(R	tupdate(RNtd((s./usr/lib/python2.7/site-packages/babel/util.pytcopys	
cCst|j|jS(N(tzipRMtvalues(RN((s./usr/lib/python2.7/site-packages/babel/util.pytitemsscCst|j|jS(N(RRMt
itervalues(RN((s./usr/lib/python2.7/site-packages/babel/util.pyt	iteritemsscCs|jS(N(RM(RN((s./usr/lib/python2.7/site-packages/babel/util.pyRLscCsO|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.pyRascCs9tj|||||jkr5|jj|ndS(N(RJt
setdefaultRMR1(RNRRtfailobj((s./usr/lib/python2.7/site-packages/babel/util.pyRbscCs+x$|jD]\}}|||<q
WdS(N(R[(RNRJRRtval((s./usr/lib/python2.7/site-packages/babel/util.pyRVscCst|j|jS(N(tmaptgetRM(RN((s./usr/lib/python2.7/site-packages/babel/util.pyRZscCst|j|jS(N(RRfRM(RN((s./usr/lib/python2.7/site-packages/babel/util.pyR\sN(R>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(sCompute 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.pyRs

%(t
attrgettert
itemgettercsfd}|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
itFixedOffsetTimezonecBsGeZdZddZdZdZdZdZdZ	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<FixedOffset "%s" %s>(RR(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!RKRRRRR(((s./usr/lib/python2.7/site-packages/babel/util.pyR)s				(R
tsecondst
LocalTimezonecBs,eZdZdZdZdZRS(cCs|j|rtStSdS(N(t_isdstt	DSTOFFSETt	STDOFFSET(RNR((s./usr/lib/python2.7/site-packages/babel/util.pyRVscCs|j|rtStSdS(N(RtDSTDIFFR(RNR((s./usr/lib/python2.7/site-packages/babel/util.pyR\scCstj|j|S(N(ttimeRR(RNR((s./usr/lib/python2.7/site-packages/babel/util.pyRbsc	Csd|j|j|j|j|j|j|jddf	}tj|}tj	|}|j
dkS(Nii(tyeartmonthtdaythourtminutetsecondtweekdayRtmktimet	localtimettm_isdst(RNRttttstamp((s./usr/lib/python2.7/site-packages/babel/util.pyRes(R>R?RRRR(((s./usr/lib/python2.7/site-packages/babel/util.pyRTs			(3RgRtdatetimeRRR5R/Rt	NameErrortsetsRttextwrapRt	itertoolsRRtobjectR^t__all__t
__docformat__RR@tVERBOSERR(RR=RRJR	RjRtAttributeErrortoperatorRsRtRRxR!RRtpytzR
ttimezoneRtdaylighttaltzoneRRRR(((s./usr/lib/python2.7/site-packages/babel/util.pyt<module>sf

				/	0D