-í
H<c    
   sB  d  Z  d k Z d k Z d k Td k l Z d k Td k Te i d „ Z d d „ Z	 d „  Z
 d d	 „ Z d e i d
 „ Z e i d „ Z d d „ Z d „  Z d e e e e e e i e e i d „	 Z d e e e e e i e d „ Z e i e e i d „ Z e e e e e i d „ Z d e e e d „ Z d e e d „ Z d e e d „ Z d e e e d „ Z d „  Z  d „  Z! d „  Z" d e e# e$ d „ Z% d e e& e' e( e) ƒ d „ Z* e e+ d d f e e+ d d f d e, e- e' d  d ƒ d d! f e e. e/ d e0 f d" e1 e- d d d# f f Z2 e e2 d$ „ Z3 e3 Z4 e e+ d d f e e+ d d f d e, e5 e' d  d ƒ d d! f e e. e/ d e0 f d" e1 e5 d d d# f f Z6 e6 d% „ Z7 e e, e8 d f d& e, e- e# d d f e e. e/ d e0 f f Z9 e& e8 d' „ Z: d k; Z; d( f  d) „  ƒ  YZ< d* d+ „ Z= e> d, j o e= ƒ  n d S(-   s<   mxTextTools - A tools package for fast text processing.

    Copyright (c) 2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
    Copyright (c) 2000-2001, eGenix.com Software GmbH; mailto:info@egenix.com
    See the documentation for further information on copyrights,
    or contact the author. All Rights Reserved.
N(   s   *(   s   __version__c    s*  |  | } d }	 d }
 | d  \ } } } t | ƒ d j o | d }	 n t | ƒ d j o | d }
 n t	 | d ƒ \ } } t | } t | ƒ | j o | d d f j o
 d } nI | t j o
 d	 } n2 t | ƒ } t | ƒ d
 j o | d
  d } n d t | ƒ d | | f |	 |
 f Sd S(   s7    Returns a pp-formatted tag table entry as string 
    i    i   i   i   i   s   Tables   SubTables   <table>s   Here/Toi   s   ...s#   %-15.15s : %-30s : jne=%+i : je=%+is   %-.15s : %sN(   s   tables   is   es   jnes   jes   ts   cs   ms   lens   divmods   flagss   cmds   id2cmds   types	   TupleTypes   Nones   repr(   s   tables   is	   TupleTypes   cs   es   cmds   ms   flagss   ts   jnes   je(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   format_entry s&     
  
&

iÿÿÿÿc    s€   g  } x_ t t |  ƒ ƒ D]K } | | j o | i d t |  | ƒ ƒ n | i d t |  | ƒ ƒ q Wt i	 | d ƒ d Sd S(   s;    Returns a pp-formatted version of the tag table as string s   --> s       s   
N(
   s   ls   ranges   lens   tables   js   is   appends   format_entrys   strings   join(   s   tables   is   js   l(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   format_table6 s      c    s   t  |  ƒ GHd S(   s    Print the tag table 
    N(   s   format_tables   table(   s   table(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   print_tagtableB s     i    c 	   sõ   xî | D]æ \ } } } } t | ƒ } t | ƒ d j o | d  d } n t |  | | !ƒ } t | ƒ d j o | d  d } n | t
 j o' d | d G| Gd G| G| | f GHn8 d | d G| Gd G| G| | f GHt |  | | d ƒ q Wd S(	   sC    Print the taglist tags for text using the given indent level 
    i   s   ...i<   s    s    |s   : i   N(   s   tagss   tags   ls   rs   subtagss   reprs   tagnames   lens   texts   targets   Nones   indents
   print_tags(	   s   texts   tagss   indents   targets   tags   ls   rs   subtagss   tagname(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys
   print_tagsH s      '#c    sø   xñ |  D]é } t | ƒ | j oT t | ƒ } t | ƒ d j o | d  d } n d | d G| Gd t | ƒ GHn} | d } | d d !\ } } t | | | !ƒ } t | ƒ d j o | d  d } n d | d G| Gd | | G| | f GHq Wd	 S(
   s<    Print the joinlist joins using the given indent level 
    i(   s   ...s    s    |s    (len = %i)i    i   i   N(
   s   joinss   js   types
   StringTypes   reprs   texts   lens   indents   ls   r(   s   joinss   indents
   StringTypes   rs   texts   js   l(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   print_joinlistY s      #
c    s€   d g t  |  ƒ } xb t t  |  ƒ ƒ D]N } |  | } t | ƒ | j o | | | <n | d | d | d !| | <q& W| Sd S(   sÓ    Return a normalized joinlist.

        All tuples in the joinlist are turned into real strings.  The
        resulting list is a equivalent copy of the joinlist only
        consisting of strings.
        
    s    i    i   i   N(   s   lens   jlists   ls   ranges   is   entrys   types
   StringType(   s   jlists
   StringTypes   is   entrys   l(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   normlistm s    
  
!c    s[   h  } xJ |  D]B } | | } | i | ƒ o | | i | ƒ n | g | | <q W| Sd  S(   N(   s   ds   ls   ws   indexs   cs   has_keys   append(   s   ls   indexs   cs   ws   d(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   _lookup_dict„ s     
c    s8  g  } t |  ƒ } | i ƒ  } t | ƒ d j  oB | i t t t	 i
 | i ƒ  d ƒ f ƒ | i t t d f ƒ n xž | i ƒ  D] \ } } | i t ƒ t | ƒ d } x. | D]& } | i t t | d d t f ƒ q° W| i t t t f ƒ t t | t | ƒ | f | | <q€ W| i t t t f ƒ t | ƒ Sd S(   s9    Creates a lookup table that matches the words in l 
    i   s    iÿÿÿÿi   N(   s   ts   _lookup_dicts   ls   ds   keyss   lens   appends   Nones   IsIns   strings   joins   Skips   itemss   cs   groups   is   ws   Words   MatchOks   Fails   Heres   Iss   tuple(   s   ls   groups   ds   keyss   cs   is   ts   w(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   word_in_list s$     (  $$c    sü   |
 | ƒ | j o | | ƒ } n | } | i } | t j oD | d j o t	 | ƒ d j  o |	 |  | | ƒ Sn t	 |  ƒ } n |  t | d f | t t t	 | ƒ d d f |  t t f f } | |  | | | ƒ \ } } } | o |  Sn | | ƒ Sd S(   sì   A fast replacement for string.replace.
    
       what can be given as string or search object.

       This function is a good example for the AppendTagobj-flag usage
       (the taglist can be used directly as joinlist).
       
    i    i   iÿÿÿÿN(   s   types   whats
   StringTypes   SearchObjects   sos   matchs   stops   Nones   starts   lens   string_replaces   texts   withs
   sWordStarts   Skips   AppendTagobjs   Moves   ToEOFs   ts   tags   founds   taglists   lasts   join(   s   texts   whats   withs   starts   stops   SearchObjects   joins   joinlists   tags   string_replaces   types
   StringTypes   lasts   sos   ts   founds   taglist(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   replaceª s     	 =c
    s   | t j o t |  ƒ } n t | ƒ | j o |	 | ƒ } n | t	 | d d f f } | |  | | | ƒ \ } } }
 | o |  Sn | | |  | ƒ ƒ Sd S(   s  Analogon to string.replace; returns a string with all occurences
       of what in text[start:stop] replaced by with
       - uses a one entry tag-table and a Boyer-Moore-Search-object
       - what can be a string or a BMS/FS search object
       - it's faster than string.replace in those cases, where
         the what-string gets long and/or many replacements are found;
         faster meaning from a few percent up to many times as fast
       - start and stop define the slice of text to work in
       - stop defaults to len(text)
    i   i    N(   s   stops   Nones   lens   texts   types   whats
   StringTypes   BMSs   withs	   sFindWords   ts   tags   starts   founds   taglists   lasts   joins   joinlist(   s   texts   whats   withs   starts   stops   joins   joinlists   tags
   StringTypes   BMSs   lasts   ts   founds   taglist(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys	   _replace2Î s     c    s¥   t  | ƒ | j o | | ƒ } n | i |  ƒ } | o |  Sn g  } d }	 x2 | D]* \ }
 } | i |  |	 |
 !| ƒ | }	 qU W| i |  |	 ƒ | | d ƒ Sd  S(   Ni    s    (   s   types   whats
   StringTypes   FSs   findalls   texts   slicess   ls   xs   lefts   rights   appends   withs   join(   s   texts   whats   withs   joins   FSs
   StringTypes   slicess   ls   rights   xs   left(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys	   _replace3ç s     
c    sž   t  | ƒ | j o | | ƒ } n | i |  ƒ } | o |  Sn t g t | ƒ }
 x/ t
 t | ƒ ƒ D] }	 | f | |	 |
 |	 <qh W| | |  |
 ƒ ƒ Sd  S(   N(   s   types   whats
   StringTypes   FSs   findalls   texts   slicess   Nones   lens   repls   ranges   is   withs   joins   joinlist(   s   texts   whats   withs   joins   joinlists   tags   FSs
   StringTypes   slicess   is   repl(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys	   _replace4ù s     c    sD   | t j	 o | | |  | | | ƒ ƒ Sn | | |  | | ƒ ƒ Sd S(   s¨   Apply multiple replacement to a text at once.

        replacements must be list of tuples (replacement, left,
        right).  It is used to replace the slice text[left:right] with
        the string replacement.

        Note that the replacements do not affect one another.  Indices
        always refer to the original text string.

        Replacements must not overlap. Otherwise a ValueError is
        raised.

    N(   s   stops   Nones   joins   joinlists   texts   replacementss   start(   s   texts   replacementss   starts   stops   joins   joinlist(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   multireplaces     c    sD   | t j	 o | | ƒ i |  | | ƒ Sn | | ƒ i |  | ƒ Sd S(   s   A faster replacement for string.find().

        Uses a search object for the task. Returns the position of the
        first occurance of what in text[start:stop]. stop defaults to
        len(text).  Returns -1 in case no occurance was found.
        
    N(   s   stops   Nones   SearchObjects   whats   finds   texts   start(   s   texts   whats   starts   stops   SearchObject(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   finds    
 c    sD   | t j	 o | | ƒ i |  | | ƒ Sn | | ƒ i |  | ƒ Sd S(   s   Find all occurances of what in text.

        Uses a search object for the task. Returns a list of slice
        tuples (l,r) marking the all occurances in
        text[start:stop]. stop defaults to len(text).  Returns an
        empty list in case no occurance was found.
        
    N(   s   stops   Nones   SearchObjects   whats   findalls   texts   start(   s   texts   whats   starts   stops   SearchObject(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   findall.s     c    s±   | o | | | ƒ }	 n | | ƒ }	 | o |	 i |  | | ƒ }
 n |	 i |  | ƒ }
 d } g  } | i } x+ |
 D]# \ } } | |  | | !ƒ | } qt W| |  | ƒ | Sd S(   s”   A faster replacement for string.split().

        Uses a search object for the task. Returns the result of
        cutting the text[start:stop] string into snippets at every sep
        occurance in form of a list of substrings. translate is passed
        to the search object as translation string.

        XXX convert to a C function... or even better, add as method
        to search objects.

    i    N(   s	   translates   SearchObjects   seps   sos   stops   findalls   texts   starts   cutss   ls   lists   appends   lefts   right(   s   texts   seps   starts   stops	   translates   SearchObjects   rights   lists   ls   sos   cutss   appends   left(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   split?s      	 
c 	   sd   x] | D]U \ } } } } | t | ƒ } |  | | !| | <| o t
 |  | | d | ƒ n q Wd  S(   Ns   .(   s   taglists   os   ls   rs   ss   prefixs   strs   pfxs   texts   dicts   _tagdict(	   s   texts   dicts   prefixs   taglists   os   ls   ss   rs   pfx(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   _tagdict`s     c    s±   t  t |  f | ƒ \ } } } | o | t | f Sn h  } t	 } xY | D]Q \ } } }	 } t | ƒ }
 |  | |	 !| |
 <| o | |  t |
 d | ƒ n qK W| | | f Sd S(   sÝ   Tag a text just like the function tag() and then convert
        its output into a dictionary where the tagobjects reference
        their respective strings
        - this function emulates the interface of tag()
        - in contrast to tag() this funtion *does* make copies
          of the found stings
        - returns a tuple (rc,tagdict,next) with the same meaning
          of rc and next as tag(); tagdict is the new dictionary - 
          None in case rc is 0
    s   .N(   s   applys   tags   texts   argss   rcs   taglists   nexts   Nones   ds   _tagdicts   tagdicts   os   ls   rs   ss   strs   pfxs   dict(   s   texts   argss   ds   tagdicts   ls   os   nexts   ss   rcs   rs   pfxs   taglist(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   tagdicths      c    s   t  |  d ƒ Sd S(   sB    Return a set with all characters *except* the ones in chars.
    i    N(   s   sets   chars(   s   chars(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   invset€s     c    s@   | t j o t |  ƒ } n | |  | | | ƒ } | d j  Sd S(   s    Return 1 iff text[start:stop] only contains whitespace
        characters (as defined in Constants/Sets.py), 0 otherwise.
    i    N(   s   stops   Nones   lens   texts   setfinds   nonwhitespaces   starts   i(   s   texts   starts   stops   nonwhitespaces   setfinds   i(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   is_whitespace†s
     s    c    s   | | |  | ƒ | ƒ Sd S(   sá    Eliminates newline characters and compresses whitespace
        characters into one space.

        The result is a one line text string. Tim Peters will like
        this function called with '-' separator ;-)
        
    N(   s   joins   setsplits   texts   collapse_sets	   separator(   s   texts	   separators   joins   setsplits   collapse_set(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   collapse’s    
 s   i   s   
s   lines   
iþÿÿÿs
   empty lineiüÿÿÿc    s   | |  | ƒ d Sd S(   s   Split text into a list of single lines.

        The following combinations are considered to be line-ends:
        '', '
', '
'; they may be used in any combination.  The
        line-end indicators are removed from the strings prior to
        adding them to the list.

        This function allows dealing with text files from Macs, PCs
        and Unix origins in a portable way.
        
    i   N(   s   tags   texts   linesplit_table(   s   texts   tags   linesplit_table(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys
   splitlines§s     c    s   t  t |  | ƒ d ƒ Sd S(   s    Returns the number of lines in text.

        Line ends are treated just like for splitlines() in a
        portable way.
    i   N(   s   lens   tags   texts   linecount_table(   s   texts   linecount_table(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys
   countlinesÃs     s   wordc    s   | |  | ƒ Sd S(   sª    Split text into a list of single words.

        Words are separated by whitespace. The whitespace is stripped
        before adding the words to the list.
        
    N(   s   setsplits   texts   whitespace_set(   s   texts   setsplits   whitespace_set(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys
   splitwordsÔs    	 s   _timerc      sw   t  Z d  Z d Z d Z e i e i d „ Z e i e i d „ Z e i e i d „ Z	 e i e i d „ Z
 d „  Z RS(   s   timer class with a quite obvious interface
        - .start() starts a fairly accurate CPU-time timer plus an
          absolute timer
        - .stop() stops the timer and returns a tuple: the CPU-time in seconds
          and the absolute time elapsed since .start() was called
    i    c    s   | ƒ  |  _ | ƒ  |  _ d  S(   N(   s   times   selfs   atimes   clocks   utime(   s   selfs   clocks   time(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   startòs    c    s:   | ƒ  |  i |  _ | ƒ  |  i |  _ |  i |  i f Sd  S(   N(   s   clocks   selfs   utimes   times   atime(   s   selfs   clocks   time(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   stop÷s    c    s1   | ƒ  |  i |  _ | ƒ  |  i |  _ |  i Sd  S(   N(   s   clocks   selfs   utimes   times   atime(   s   selfs   clocks   time(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   usertimeýs    c    s1   | ƒ  |  i |  _ | ƒ  |  i |  _ |  i Sd  S(   N(   s   clocks   selfs   utimes   times   atime(   s   selfs   clocks   time(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   abstimes    c    s   d |  i |  i f Sd  S(   Ns   %0.2fu %0.2fa sec.(   s   selfs   utimes   atime(   s   self(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   __str__	s    (   s   __name__s
   __module__s   __doc__s   utimes   atimes   times   clocks   starts   stops   usertimes   abstimes   __str__(    (    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   _timeræs    s   mxTextTools/mxTextTools.cc    s@   d „  } t |  ƒ i ƒ  } d  k } t ƒ  } d t | ƒ GHd  S(   Nc    sú   Hx£ t  t |  ƒ ƒ D]  } |  | | | j o Pn q Wd t |  ƒ t | ƒ f GHt |  ƒ t | ƒ j o d t |  t | ƒ ƒ GHn d t | t |  ƒ ƒ GHHd  Sd | GH|  | d | !d t |  | ƒ t | | ƒ f |  | d | d !GHHd  S(   Ns   Length mismatch: orig=%i new=%is   Missing chars:s   Excess chars:s   Mismatch at offset %i:id   s   <- %s != %s ->i   (   s   ranges   lens   origs   is   news   repr(   s   origs   news   i(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   mismatchs     		Es   Working on a %i byte string(	   s   mismatchs   opens   files   reads   texts   strings   _timers   ts   len(   s   files   strings   mismatchs   texts   t(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   _benchs    			 . ) $ s   __main__(?   s   __doc__s   strings   typess   mxTextToolss   __version__s   Constants.TagTabless   Constants.Setss	   TupleTypes   format_entrys   format_tables   print_tagtables
   print_tagss
   StringTypes   print_joinlists   normlists   _lookup_dicts   word_in_lists   Nones   BMSs   joins   joinlists   tags   replaces   types	   _replace2s   FSs	   _replace3s	   _replace4s   multireplaces   finds   findalls   splits   _tagdicts   tagdicts   invsets   nonwhitespace_sets   setfinds   is_whitespaces   setsplits   sets   newlines
   whitespaces   collapses   Iss   AllInSets   AppendMatchs   EOFs   Heres   MatchOks   Skips   _linesplit_tables
   splitliness	   linesplits   AppendTagobjs   _linecount_tables
   countliness   whitespace_sets   _wordsplit_tables
   splitwordss   times   _timers   _benchs   __name__("   s   _lookup_dicts   _tagdicts   format_tables   finds   replaces   _linesplit_tables   _linecount_tables   findalls   collapses   tagdicts   _timers   print_tagtables   word_in_lists   _benchs   splits
   splitwordss   __version__s
   print_tagss   format_entrys   strings   normlists   _wordsplit_tables   is_whitespaces
   countliness	   linesplits   typess   invsets   multireplaces	   _replace2s	   _replace3s
   splitliness   print_joinlists	   _replace4s   time(    (    s@   /mit/seven/lib/python2.2/site-packages/mx/TextTools/TextTools.pys   ? sN   		*$!!			kk=	'ÿ 	