³ò
°b|Mc           @   s+  d  Z  d d k Z d d k l Z l Z d d k Z d d k Z y e Wn# e j
 o d d k	 l
 Z n Xd d k Z d d k Z d d k l Z l Z e ƒ  Z d d d d	 d
 d d g Z d Z d „  Z e i d e i ƒ Z d „  Z d „  Z d e i f d „  ƒ  YZ d d d d „ Z d
 e f d „  ƒ  YZ y e i i Z Wn e  j
 o d d „ Z n Xe d ƒ Z! d e f d „  ƒ  YZ" y d d k# l$ Z$ Wn" e% j
 o e" d d ƒ Z$ n Xe d e i& ƒ Z' e i( o e d e i) ƒ Z* n e' Z* e* e' Z+ d e f d  „  ƒ  YZ, e, ƒ  Z- d S(!   s&   Various utility classes and functions.iÿÿÿÿN(   t	   timedeltat   tzinfo(   t   Set(   t   izipt   imapt   distinctt	   pathmatcht   relpatht   wraptextt   odictt   UTCt   LOCALTZs   restructuredtext enc         c   sG   t  ƒ  } x7 t |  ƒ D]) } | | j o | V| i | ƒ q q Wd S(   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(   t   sett   itert   add(   t   iterablet   seent   item(    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyR   "   s    	 s(   [ \t\f]* \# .* coding[=:][ \t]*([-\w.]+)c         C   s  |  i  ƒ  } |  i d ƒ zð |  i ƒ  } | i t i ƒ } | o | t t i ƒ } n t i | ƒ } | pX y d d k	 } | i
 | ƒ Wn t t f j
 o qÆ X|  i ƒ  } t i | ƒ } n | o | o t d ƒ ‚ n d Sn | o | i d ƒ Sn d SWd |  i | ƒ Xd S(   s  Deduce 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)
    i    iÿÿÿÿNs\   python refuses to compile code with both a UTF8 byte-order-mark and a magic encoding commentt   utf_8i   (   t   tellt   seekt   readlinet
   startswitht   codecst   BOM_UTF8t   lent   PYTHON_MAGIC_COMMENT_ret   matcht   parsert   suitet   ImportErrort   SyntaxErrort   groupt   None(   t   fpt   post   line1t   has_bomt   mR   t   line2(    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyt   parse_encoding:   s2    c         C   sä   h  d d <d d <d d <d d <d	 d
 <d d <} g  } xg t  t i d |  ƒ ƒ D]M \ } } | d o | i | | ƒ q[ | o | i t i | ƒ ƒ q[ q[ Wt i d i | ƒ d | i t i	 d ƒ ƒ } | d j	 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	   ([?*]+/?)i   t    t   $t   /N(   t	   enumeratet   ret   splitt   appendt   escapeR   t   joint   replacet   ost   sepR!   (   t   patternt   filenamet   symbolst   buft   idxt   partR   (    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyR   i   s     					 .t   TextWrapperc           B   s   e  Z e i d  ƒ Z RS(   s(   (\s+|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))(   t   __name__t
   __module__R/   t   compilet
   wordsep_re(    (    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyR=   ™   s   iF   R+   c      	   C   s.   t  d | d | d | d t ƒ } | i |  ƒ 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`
    t   widtht   initial_indentt   subsequent_indentt   break_long_words(   R=   t   Falset   wrap(   t   textRB   RC   RD   t   wrapper(    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyR       s    	c           B   s¤   e  Z d  Z d d „ Z d „  Z d „  Z d „  Z e Z d „  Z	 d „  Z
 d „  Z d „  Z d	 „  Z e d
 „ Z d „  Z d d „ Z d „  Z d „  Z d „  Z RS(   so   Ordered dict implementation.
    
    :see: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/107747
    c         C   s-   t  i |  | p h  ƒ t  i |  ƒ |  _ d  S(   N(   t   dictt   __init__t   keyst   _keys(   t   selft   data(    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyRK   ¸   s    c         C   s$   t  i |  | ƒ |  i i | ƒ d  S(   N(   RJ   t   __delitem__RM   t   remove(   RN   t   key(    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyRP   ¼   s    c         C   s;   t  i |  | | ƒ | |  i j o |  i i | ƒ n d  S(   N(   RJ   t   __setitem__RM   R1   (   RN   RR   R   (    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyRS   À   s    c         C   s   t  |  i ƒ S(   N(   R   RM   (   RN   (    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyt   __iter__Å   s    c         C   s   t  i |  ƒ g  |  _ d  S(   N(   RJ   t   clearRM   (   RN   (    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyRU   É   s    c         C   s   t  ƒ  } | i |  ƒ | S(   N(   R	   t   update(   RN   t   d(    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyt   copyÍ   s    	c         C   s   t  |  i |  i ƒ  ƒ S(   N(   t   zipRM   t   values(   RN   (    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyt   itemsÒ   s    c         C   s   t  |  i |  i ƒ  ƒ S(   N(   R   RM   t
   itervalues(   RN   (    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyt	   iteritemsÕ   s    c         C   s   |  i  S(   N(   RM   (   RN   (    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyRL   Ø   s    c         C   sY   | t  j o t i |  | ƒ Sn | |  j o | Sn |  i i | ƒ t i |  | | ƒ S(   N(   t   missingRJ   t   popRM   RQ   (   RN   RR   t   default(    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyR_   Û   s    c         C   s   |  i  i | ƒ t i | ƒ S(   N(   RM   RQ   RJ   t   popitem(   RN   RR   (    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyRa   ã   s    c         C   s;   t  i |  | | ƒ | |  i j o |  i i | ƒ n d  S(   N(   RJ   t
   setdefaultRM   R1   (   RN   RR   t   failobj(    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyRb   ç   s    c         C   s+   x$ | i  ƒ  D] \ } } | |  | <q Wd  S(   N(   R[   (   RN   RJ   RR   t   val(    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyRV   ì   s     c         C   s   t  |  i |  i ƒ S(   N(   t   mapt   getRM   (   RN   (    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyRZ   ð   s    c         C   s   t  |  i |  i ƒ S(   N(   R   Rf   RM   (   RN   (    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyR\   ó   s    N(   R>   R?   t   __doc__R!   RK   RP   RS   RT   t   iterkeysRU   RX   R[   R]   RL   R^   R_   Ra   Rb   RV   RZ   R\   (    (    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyR	   ³   s"   											t   .c         C   s   t  i i | ƒ i t  i ƒ } t  i i |  ƒ i t  i ƒ } t t  i i | | g ƒ ƒ } t  i i g t | ƒ | | | } t  i i | Œ  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`
        (	   R5   t   patht   abspathR0   R6   R   t   commonprefixt   pardirR3   (   Rj   t   startt
   start_listt	   path_listt   it   rel_list(    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyR   ú   s
    %i    t   FixedOffsetTimezonec           B   sG   e  Z d  Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   s&   Fixed offset in minutes east from UTC.c         C   s:   t  d | ƒ |  _ | d  j o d | } n | |  _ d  S(   Nt   minutess
   Etc/GMT+%d(   R    t   _offsetR!   t   zone(   RN   t   offsett   name(    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyRK     s    c         C   s   |  i  S(   N(   Rv   (   RN   (    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyt   __str__  s    c         C   s   d |  i  |  i f S(   Ns   <FixedOffset "%s" %s>(   Rv   Ru   (   RN   (    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyt   __repr__  s    c         C   s   |  i  S(   N(   Ru   (   RN   t   dt(    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyt	   utcoffset"  s    c         C   s   |  i  S(   N(   Rv   (   RN   R{   (    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyt   tzname%  s    c         C   s   t  S(   N(   t   ZERO(   RN   R{   (    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyt   dst(  s    N(
   R>   R?   Rg   R!   RK   Ry   Rz   R|   R}   R   (    (    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyRs     s   				(   R
   t   secondst   LocalTimezonec           B   s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C   s    |  i  | ƒ o t Sn t Sd  S(   N(   t   _isdstt	   DSTOFFSETt	   STDOFFSET(   RN   R{   (    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyR|   @  s    c         C   s    |  i  | ƒ o t Sn t Sd  S(   N(   R‚   t   DSTDIFFR~   (   RN   R{   (    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyR   F  s    c         C   s   t  i |  i | ƒ S(   N(   t   timeR}   R‚   (   RN   R{   (    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyR}   L  s    c      	   C   sd   | i  | i | i | i | i | i | i ƒ  d d f	 } t i | ƒ } t i	 | ƒ } | i
 d j S(   Ni    iÿÿÿÿ(   t   yeart   montht   dayt   hourt   minutet   secondt   weekdayR†   t   mktimet	   localtimet   tm_isdst(   RN   R{   t   ttt   stamp(    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyR‚   O  s    (   R>   R?   R|   R   R}   R‚   (    (    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pyR   >  s   			(.   Rg   R   t   datetimeR    R   R5   R/   R   t	   NameErrort   setsR   t   textwrapR†   t	   itertoolsR   R   t   objectR^   t   __all__t   __docformat__R   R@   t   VERBOSER   R(   R   R=   R   RJ   R	   Rj   R   t   AttributeErrorR~   Rs   t   pytzR
   R   t   timezoneR„   t   daylightt   altzoneRƒ   R…   R   R   (    (    (    sW   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Babel-0.9.5-py2.5.egg/babel/util.pys   <module>   sT   				/	0D

	