;
0sDc           @   s   d  Z  d k Z d k Z d k Z d k Z d Z d Z d Z d f  d     YZ e	 d j oX e
 e i  d j o	 d GHq e   Z e i e i d  Z d k Z e i e  n d S(	   s  
Parser for "Aaron's Markup Language" - a markup language
which is easier to type in than XML, yet gives us a
reasonable selection of formats.

The general rule is that if a line begins with a '.',
it requires special processing. Otherwise lines
are concatenated to paragraphs, and blank lines
separate paragraphs.

If the line ".foo bar bletch" is encountered,
it immediately ends and writes out any current
paragraph.

It then looks for a parser method called 'foo';
if found, it is called with arguments (bar, bletch).

If this is not found, it assumes that 'foo' is a
paragraph style, and the text for the first line
of the paragraph is 'bar bletch'.  It would be
up to the formatter to decide whether on not 'foo'
was a valid paragraph.

Special commands understood at present are:
.image filename
- adds the image to the document
.beginPre Code
- begins a Preformatted object in style 'Code'
.endPre
- ends a preformatted object.
Ni   i   s   s   Parserc           B   s   t  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d	   Z
 d
   Z d   Z e d  Z e d  Z d   Z RS(   Nc         C   s   |  i   d  S(   N(   s   selfs   reset(   s   self(    (    sD   /home/packages/reportlab/reportlab_2_0/reportlab/tools/docco/yaml.pys   __init__5   s    c         C   s1   d |  _ d |  _ g  |  _ g  |  _ t |  _ d  S(   Ni    s   Normal(   s   selfs   _lineNos   _styles   _resultss   _bufs   PLAINs   _mode(   s   self(    (    sD   /home/packages/reportlab/reportlab_2_0/reportlab/tools/docco/yaml.pys   reset8   s
    				c         C   sL   t  | d  i   } x | D] } |  i | d   q W|  i   |  i Sd  S(   Ns   ri(	   s   opens   filenames	   readliness   datas   lines   selfs   readLines   endParas   _results(   s   selfs   filenames   datas   line(    (    sD   /home/packages/reportlab/reportlab_2_0/reportlab/tools/docco/yaml.pys	   parseFile?   s     
c   
      C   s  |  i d |  _ t i |  } t |  d j o2 |  i t j o |  i	   q|  i
 i |  nU| d d j o3|  i	   t i | d  } | d | d f \ } } t |  i |  oo t d |  }	 y t |	 t |   Wqt j
 o5 } t i i d | t |  | |  i f    qXq|  i	   t i | d d  } t |  d j p t d | d |  i f  | \ } } | d |  _ |  i
 i |  n |  i
 i |  d  S(	   Ni   i    s   .s   self.s*   Parser method: apply(%s,%s) %s at line %d
s    i   s   Style %s but no data at line %d(   s   selfs   _lineNos   strings   lstrips   lines   strippeds   lens   _modes   PLAINs   endParas   _bufs   appends   splits   wordss   cmds   argss   hasattrs	   __class__s   evals   methods   applys   tuples	   TypeErrors   errs   syss   stderrs   writes   AssertionErrors   styletags   datas   _style(
   s   selfs   lines   styletags   argss   errs   strippeds   cmds   wordss   datas   method(    (    sD   /home/packages/reportlab/reportlab_2_0/reportlab/tools/docco/yaml.pys   readLineI   s0    
)
.c         C   s   t  i |  i d  } | o_ |  i t j o/ |  i i d |  i	 t  i |  i d  f  q{ |  i i d |  i	 | f  n g  |  _ d |  _	 d  S(   Ns    s   Preformatteds   
s	   Paragraphs   Normal(
   s   strings   joins   selfs   _bufs   texts   _modes   PREFORMATTEDs   _resultss   appends   _style(   s   selfs   text(    (    sD   /home/packages/reportlab/reportlab_2_0/reportlab/tools/docco/yaml.pys   endParao   s    / 	c         C   s   t  |  _ | |  _ d  S(   N(   s   PREFORMATTEDs   selfs   _modes	   stylenames   _style(   s   selfs	   stylename(    (    sD   /home/packages/reportlab/reportlab_2_0/reportlab/tools/docco/yaml.pys   beginPre}   s    	c         C   s   |  i   t |  _ d  S(   N(   s   selfs   endParas   PLAINs   _mode(   s   self(    (    sD   /home/packages/reportlab/reportlab_2_0/reportlab/tools/docco/yaml.pys   endPre   s    
c         C   s$   |  i   |  i i d | f  d  S(   Ns   Image(   s   selfs   endParas   _resultss   appends   filename(   s   selfs   filename(    (    sD   /home/packages/reportlab/reportlab_2_0/reportlab/tools/docco/yaml.pys   image   s    
c         C   s   |  i i d | f  d S(   s   Inserts a vertical spacers   VSpaceN(   s   selfs   _resultss   appends   points(   s   selfs   points(    (    sD   /home/packages/reportlab/reportlab_2_0/reportlab/tools/docco/yaml.pys   vSpace   s     c         C   s   |  i i d d f  d S(   s   Inserts a frame breaks	   PageBreaks   blahN(   s   selfs   _resultss   append(   s   self(    (    sD   /home/packages/reportlab/reportlab_2_0/reportlab/tools/docco/yaml.pys	   pageBreak   s     c         C   s'   |  i   |  i i d | | f  d S(   s8   Goes and gets the Python object and adds it to the storys   CustomN(   s   selfs   endParas   _resultss   appends
   moduleNames   funcName(   s   selfs
   moduleNames   funcName(    (    sD   /home/packages/reportlab/reportlab_2_0/reportlab/tools/docco/yaml.pys   custom   s     
c         C   s  t  i | |  } | i t j o  |  i i	 d d | i f  n t
 | i  d j od xa | i D]R } | i d j o< |  i i	 d d | i f  |  i i	 d d | i f  qb qb Wn t
 | i  d j o x | i D] } | i d j o |  i i	 d d d | i f  |  i i	 d d | i f  xa | i D]R } | i d j o< |  i i	 d d | i f  |  i i	 d d | i f  q8q8Wq q Wn d	 S(
   s_   Documents the entire module at this point by making
        paragraphs and preformatted objectss	   Paragraphs	   DocStringi    s   officials   Preformatteds   FunctionHeaders	   Class %s:s   DocStringIndentN(   s   codegrabs   getObjectsDefinedIns
   modulenames   pathnames   doccos   docs   Nones   selfs   _resultss   appends   lens	   functionss   fns   statuss   protos   classess   clss   names   methodss   mth(   s   selfs
   modulenames   pathnames   mths   doccos   fns   cls(    (    sD   /home/packages/reportlab/reportlab_2_0/reportlab/tools/docco/yaml.pys   getModuleDoc   s*      
 (
  
 c         C   s   t  i | |  } d } x | i D] } | i | j o d } |  i i d d d | i f  |  i i d d | i f  x] | i D]R } | i d j o< |  i i d d | i f  |  i i d d | i f  q q WPq" q" W| p t d	 |  d
 S(   s*   Documents the class and its public methodsi    i   s   Preformatteds   FunctionHeaders	   Class %s:s	   DocStrings   officials   DocStringIndents   No Classes Defined in N(   s   codegrabs   getObjectsDefinedIns
   modulenames   pathnames   doccos   founds   classess   clss   names	   classnames   selfs   _resultss   appends   docs   methodss   mths   statuss   protos   AssertionError(   s   selfs
   modulenames	   classnames   pathnames   mths   founds   doccos   cls(    (    sD   /home/packages/reportlab/reportlab_2_0/reportlab/tools/docco/yaml.pys   getClassDoc   s      
  
 $	c         C   s   |  i i d | f  d  S(   Ns   NextPageTemplate(   s   selfs   _resultss   appends   templateName(   s   selfs   templateName(    (    sD   /home/packages/reportlab/reportlab_2_0/reportlab/tools/docco/yaml.pys   nextPageTemplate   s    (   s   __name__s
   __module__s   __init__s   resets	   parseFiles   readLines   endParas   beginPres   endPres   images   vSpaces	   pageBreaks   customs   Nones   getModuleDocs   getClassDocs   nextPageTemplate(    (    (    sD   /home/packages/reportlab/reportlab_2_0/reportlab/tools/docco/yaml.pys   Parser4   s   			
	&							s   __main__s   usage: yaml.py source.txt(   s   __doc__s   syss   strings   imps   codegrabs   PLAINs   PREFORMATTEDs
   BULLETCHARs   Parsers   __name__s   lens   argvs   ps	   parseFiles   resultss   pprint(   s   pprints   ps   strings   PREFORMATTEDs   PLAINs   Parsers   codegrabs   resultss   syss   imps
   BULLETCHAR(    (    sD   /home/packages/reportlab/reportlab_2_0/reportlab/tools/docco/yaml.pys   ?&   s   							