
    %h9#                         d Z ddlZddlmZ  G d de      Z G d d      Z G d d	e      Z G d
 de      Z G d de      Z	 G d de	      Z
edk(  r e
       Zej                          yy)a  
  Copyright 2011 by the Massachusetts
  Institute of Technology.  All Rights Reserved.

  Export of this software from the United States of America may
  require a specific license from the United States Government.
  It is the responsibility of any person or organization contemplating
  export to obtain such a license before exporting.

  WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
  distribute this software and its documentation for any purpose and
  without fee is hereby granted, provided that the above copyright
  notice appear in all copies and that both that copyright notice and
  this permission notice appear in supporting documentation, and that
  the name of M.I.T. not be used in advertising or publicity pertaining
  to distribution of the software without specific, written prior
  permission.  Furthermore if you modify this software you must label
  your software as modified software and not distribute it in such a
  fashion that it might be confused with the original M.I.T. software.
  M.I.T. makes no representations about the suitability of
  this software for any purpose.  It is provided "as is" without express
  or implied warranty.
    N)Templatec                       e Zd Zd Zd Zy)	Attributec                 8   |j                  d      | _        |j                  d      | _        |j                  d      | _        |j                  d      | _        |j                  d      | _        |j                  d      | _        |j                  d      | _        y )N
definitionnametypetypeIdshort_descriptionlong_descriptionversion)getr   r   r	   r
   r   r   r   selfargkws     &/tmp/krb5-1.22.1/doc/tools/docmodel.py__init__zAttribute.__init__   sv    ))L1IIf%	IIf%	ii)!&+>!? %		*< =yy+    c                     t               }| j                  j                         D ]  \  }}|j                  |d|        ddj	                  |      z  S )N=zAttribute: %s,)list__dict__	iteritemsappendjoin)r   resultattrvalues       r   __repr__zAttribute.__repr__&   sN     MM335 	2LT%MMT%01	2&!111r   N__name__
__module____qualname__r   r     r   r   r   r      s    ,2r   r   c                   *    e Zd Zd Zd Zd Zd Zd Zy)CompositeTypec                 n   d| _         |j                  d      | _        |j                  d      | _        |j                  d      | _        |j                  d      | _        |j                  d      | _        |j                  dd      | _        |j                  d	      | _        |j                  d
      | _	        |j                  d      | _
        |j                  d      | _        |j                  d      | _        |j                  d      | _        | j                  |j                  d            | _        y )N	compositer   r   name_signatureIdinitializeractiveFr   return_typer   r   friendsr	   
attributes)categoryr   r   r   r*   r+   r,   r-   r   r.   r   r   r/   r	   _setAttributesr0   r   s     r   r   zCompositeType.__init__.   s    #))L1IIf%	#ii(89))D/ 99]3ii%0yy+ 99]3!&+>!? %		*< =yy+IIf%	--eii.EFr   c                    t               }| j                  j                         D ]H  \  }}|dk(  r(|&|D cg c]  }d|z  	 }}ddj                  |      z  }|j	                  |d|       J dj                  |      }|S c c}w )Nr0   z%sz
  %sz
  z: 
)r   r   r   r   r   )r   r   r   r   ar0   s         r   r    zCompositeType.__repr__>   s     MM335 	3LT%|#$49!:q$(!:J!:$v{{:'>>EMMd512	3 6" ";s   Bc                 d    d }|+t               }|D ]  }|j                  t        di |        |S Nr%   )r   r   r   )r   r0   r   r5   s       r   r2   zCompositeType._setAttributesK   <    !VF .in!n-. r   c                 >    t        j                  dd|      }d|z  }|S )N_-z
_%s-structresubr   r   r   s      r   struct_referencezCompositeType.struct_referenceT   s#    c4(&r   c                 >    t        j                  dd|      }d|z  }|S )Nr:   r;   z_%s-datar<   r?   s      r   macro_referencezCompositeType.macro_referenceZ   s#    c4(f$r   N)r"   r#   r$   r   r    r2   r@   rB   r%   r   r   r'   r'   -   s    G r   r'   c                       e Zd Zd Zd Zy)	Parameterc                 8   |j                  d      | _        |j                  d      | _        |j                  d      | _        |j                  d      | _        |j                  d      | _        |j                  d      | _        |j                  d      | _        y )Nseqnor   	directionr	   r
   descriptionr   )r   rF   r   rG   r	   r
   rH   r   r   s     r   r   zParameter.__init__a   ss    YYw'
IIf%	;/IIf%	ii) 99]3yy+r   c                     | j                   | j                  | j                  | j                  | j                  | j
                  f}d|z  S )NzCParameter: name=%s,direction=%s,seqno=%s,type=%s,typeId=%s,descr=%s)r   rG   rF   r	   r
   rH   )r   contents     r   r    zParameter.__repr__j   s:    99T^^DJJtyyTM]M]^TW^^^r   Nr!   r%   r   r   rD   rD   `   s    ,_r   rD   c                   0    e Zd Zd Zd Zd Zd Zd Zd Zy)Functionc                    d| _         |j                  d      | _        |j                  d      | _        |j                  dd      | _        |j                  d      | _        | j                  |j                  d            | _        |j                  d      | _        |j                  d	      | _	        |j                  d
      | _
        |j                  d      | _        |j                  d      | _        |j                  d      | _        |j                  d      | _        |j                  d      | _        |j                  d      | _        |j                  d      | _        |j                  d      | _        y )Nfunctionr   r+   r-   Fr   
parametersr.   return_descriptionretval_descriptionwarn_descriptionsa_descriptionnotes_descriptionversion_numr   r   deprecated_descriptionr/   )r1   r   r   r+   r-   r   _setParametersrO   r.   rP   rQ   rR   rS   rT   rU   r   r   rV   r/   r   s     r   r   zFunction.__init__o   s'   "IIf%	))D/ii%0yy+--eii.EF 99]3"')),@"A"')),@"A %		*< =#ii(89!&+>!? 99]3!&+>!? %		*< =&+ii0H&I#yy+r   c                 d    d }|+t               }|D ]  }|j                  t        di |        |S r7   )r   r   rD   )r   rO   r   ps       r   rW   zFunction._setParameters   r8   r   c                 |    t        | j                        | j                  | j                  g}dj	                  |      S Nr   )strr+   r   r1   r   r   r   s     r   getObjectRowzFunction.getObjectRow   s3    dgg,))--! xxr   c                     | j                   | j                  | j                  | j                  | j                  g}dj                  |      S r[   )r+   r-   r   r   r   r   r]   s     r   getObjectDescriptionRowz Function.getObjectDescriptionRow   sA    ''++,,((''	) xxr   c                 8   t               }| j                  D ]q  }| j                  |j                  |j                  |j
                  |j                  |j                  |j                  g}|j                  dj                  |             s dj                  |      S )Nr   r4   )r   rO   r+   r   rF   r	   r
   rH   r   r   r   )r   r   rY   p_rows       r   getParameterRowszFunction.getParameterRows   s{     	+AWWVVWWVVXX]]YY E MM#((5/*	+ yy  r   c                    t               }|j                  d| j                  z         |j                  d| j                  z         |j                  d| j                  z         | j
                  D cg c]  }d|z  	 }}|j                  ddj                  |      z         |j                  d| j                  z         |j                  d| j                  z         |j                  d	| j                  z         |j                  d
| j                  z         |j                  d| j                  z         |j                  d| j                  z         |j                  d| j                  z         |j                  d| j                  z         |j                  d| j                  z         |j                  d| j                   z         dj                  |      }|S c c}w )NzCategory: %szFunction name: %szFunction Id: %sz  %szParameters:
%sr4   zFunction return type: %sz$Function return type description:
%szFunction retval description:
%szFunction short description:
%szFunction long description:
%szWarning description:
%szSee also description:
%szNOTE description:
%szVersion introduced:
%szDeprecated description:
%s)r   r   r1   r   r+   rO   r   r.   rP   rQ   r   r   rR   rS   rT   rU   rV   )r   linesrY   rO   r   s        r   r    zFunction.__repr__   s   ^dmm34(49945&01*.//:Qfqj:
:&:)>>?/$2B2BBC<t?V?VVW7$:Q:QQR69O9OOP58M8MMN/$2G2GGH043F3FFG,t/E/EEF.1A1AAB2T5P5PPQ5! ;s   3G#N)	r"   r#   r$   r   rW   r^   r`   rc   r    r%   r   r   rL   rL   n   s     ,&  !r   rL   c                   $    e Zd Zd Zd Zd Zd Zy)DocModelc                     t        |      rK|d   | _        |d   dk(  rd| _        t        di || _        y |d   dk(  rd| _        t        di || _        y y y )Nr   r1   rN   r)   r%   )lenr   r1   rL   rN   r'   r)   r   s     r   r   zDocModel.__init__   sd    u:fDIZ J. * ( 15 1z"k1 +!.!7!7 2 r   c                 D    t        | | j                        }t        |      S N)getattrr1   r\   )r   objs     r   r    zDocModel.__repr__   s    d4==)3xr   c                    t               }| j                  j                  D ][  }|j                  du r!|j	                  |j                  dd       2|j	                  |j                  d|j
                         ] dj                  |      }| j                  j                  d| j                  j
                  d|d}|S )Nz...  z, ())r   rN   rO   r	   r   r   r   r.   )r   
param_listrY   r   s       r   	signaturezDocModel.signature   s    V
)) 	>Avv!!QVVC"89!!QVVQVV"<=		>
 YYz*
 $ 9 9 $ 2 2J@ r   c                     t        |d      }t        |j                         |       }t        |d      }|j                  t	        |             |j                          |j                          y )Nrw)openr   readwriter\   close)r   pathtemplate_pathftouts         r   savezDocModel.save   sM    $QVVXd#4o		#a&				r   N)r"   r#   r$   r   r    rs   r   r%   r   r   rg   rg      s    8r   rg   c                   0     e Zd Z fdZd Zd Zd Z xZS )DocModelTestc                 n    d}t         j                  t        |d            }t        t        |   di | y )Nz../docutil/example.ymlru   r%   )yamlloadrw   superr   r   )r   doc_pathr   	__class__s      r   r   zDocModelTest.__init__   s/    +		$x,-l4)2E2r   c                 $    | j                          y rk   )	test_saver   s    r   	run_testszDocModelTest.run_tests   s    r   c                 0    t        d       t        |        y )Ntesting)printr   s    r   
test_printzDocModelTest.test_print   s    idr   c                 0    d}d}| j                  ||       y )Nz../docutil/function2edit.htmlz;/var/tsitkova/Sources/v10/trunk/documentation/test_doc.html)r   )r   r|   r{   s      r   r   zDocModelTest.test_save   s    7L		$&r   )r"   r#   r$   r   r   r   r   __classcell__)r   s   @r   r   r      s    3

'r   r   __main__)__doc__r=   Cheetah.Templater   objectr   r'   rD   rL   rg   r   r"   testerr   r%   r   r   <module>r      s   . 
 %2 2"1 1f_ _Nv Nb"v "J'8 '* z^F
 r   