-
Rg=c       s    d  Z  S U h  d d <d d <d d <d d <d	 d
 <d d <d d <d d <Z f y g e d i d  d Z Wn h i d Z n Xn d k Z o d k Z t d k Z u d k Z v d k Z x d k	 l
 Z
 z d k l Z  d h  d  Z  d e f d     YZ d S(   sy
  Extract information from a Python code parse tree.

    This module is based on the Demos/parser/example.py module
    distributed with the Python source distribution.


  File-specific Parser Configuration Values

    Parameters to the HappyDoc Parser can also be embedded within the
    first comment block of the module.  The parameter values
    recognized and their meanings are listed below.

    To provide file-specific parser configuration settings, any Python
    code can be embedded in the comments of the file.  For example::

      #!/usr/bin/env python
      #
      # HappyDoc:# These variables should be discovered.
      # HappyDoc:TestInt=1
      # HappyDoc:TestString="String"
      # HappyDoc:TestStringModule=string.strip(' this has spaces in front and back ')
      # HappyDoc:url=urlencode({'a':'A', 'b':'B'})
      # HappyDoc:docStringFormat='StructuredText'

    All lines beginning with the pattern "'# HappyDoc:'" will be
    concatenated (separated by newlines) and 'execed'.  The local
    namespace resulting from the execution of the code will be
    examined for variables of interest to the parser.  The incoming
    global namespace for the configuration code will have a few
    pre-populated names for convenience.

    Pre-defined Globals

      |------------------------------------------------------------------|
      | Name             | Description                                   |
      |==================================================================|
      | string           | The 'string' module.                          |
      |------------------------------------------------------------------|
      | urlquote         | Same as 'urllib.quote' function.              |
      |------------------------------------------------------------------|
      | urlencode        | Same as 'urllib.urlencode' function.          |
      |------------------------------------------------------------------|
    
    Recognized Parser Configuration Variables

      |------------------------------------------------------------------|
      | Parameter        | Description                                   |
      |==================================================================|
      | docStringFormat  | The name of the format for the '__doc__'      |
      |                  | strings in the module.  This value is used    |
      |                  | to determine the docstring converter which    |
      |                  | will know how to translate the docstrings in  |
      |                  | the module.                                   |
      |------------------------------------------------------------------|

s   $RCSfile: __init__.py,v $s   module_names=   $Id: __init__.py,v 1.8 2002/08/24 19:53:54 doughellmann Exp $s   rcs_ids    Doug Hellmann <doug@hellfly.net>s   creators   UNSPECIFIEDs   projects   Sun, 11-Nov-2001 10:44:25 ESTs   createds   $Author: doughellmann $s   authors   $Revision: 1.8 $s   versions   $Date: 2002/08/24 19:53:54 $s   dates    i   s   0.0N(   s
   ModuleInfo(   s   StreamFlushTestc    s     t  i i d d  d |   d |  d |  d |  t |  }  | i	   }  d i | i d   d }  | i    t  i i t  i i |  d	  }  y  t i |  } Wn_  t i j
 o$ }  t | | d
  }    n+  t j
 o }  t | |   n X t i |  }  | o  t  i i |  }
 n
  h  }
  t  i i d   t  d |   d |  d |  d |  d |
  d |  }	  t  i i" |	   |	 Sd S(   s;  Retrieve information from the parse tree of a source file.

    Parameters
    
      fileName --
        Name of the file to read Python source code from.

      includeComments=1 --
        Flag to indicate whether comments should be parsed for
        cases where __doc__ strings are not available.
        
    s	   parseinfos   getDocss   parents   fileNames   includeCommentss   defaultConfigValuess   
s   
i    s   execs   Creating ModuleInfos   trees   names   commentInfoN(#   s   happydoclibs   TRACEs   intos   parents   fileNames   includeCommentss   defaultConfigValuess   opens   fs   reads   sources   joins   splits   closes   paths   basenames   splitexts   base_filenames   parsers   suites   asts   ParserErrors   msgs   compiles   codes	   TypeErrors	   ast2tuples   tups   parsecommentss   extractCommentss   comment_infos   writes
   ModuleInfos   mod_infos   outof(   s   parents   fileNames   includeCommentss   defaultConfigValuess   codes   fs   tups   asts   sources   mod_infos   comment_infos   msgs   base_filename(    (    s\   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_1/happydoclib/parseinfo/__init__.pys   getDocs s>   			%

					s   ParserUnitTestc      s"    d Z   h  d d <d d <d d <d d	 <d
 d <d d <d d <d d <d d <d d <Z  h  d d	 <Z  d   Z  d   Z  g  d  Z *d   Z Kd   Z Pd   Z pd   Z	 d   Z
 d   Z d   Z d    Z d!   Z *d"   Z RS(#   Ns   ./TestCases/test.pys'   ./TestCases/test_variable_extraction.pys   testExtractVariablesFromModules6   ./TestCases/test_variable_extraction_with_exception.pys+   testExtractVariablesFromModuleWithExceptions%   ./TestCases/test_import_statements.pys   testVariousImportStatementss!   TestCases/test_ignore_comments.pys   testIgnoreCommentss$   TestCases/test_decorated_comments.pys   testDecoratedCommentss   TestCases/test_bug434946.pys   testDOSFiless   TestCases/emptytest.pys   testEmptyModules!   TestCases/test_function_params.pys   testFunctionParameterss#   TestCases/test_nested_structures.pys   testNestedClassess   testNestedFunctionsi    c    st     |  i }  |  i i | |  i  }  |  i i | d  }  | |  _  t t	 | d | |  _
  d  Sd  S(   Ni   s   includeComments(   s   selfs   names   filename_maps   gets   default_filenames   filenames   include_commentss   comments_flags   getDocss   Nones   parsed_module(   s   selfs   names   comments_flags   filename(    (    s\   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_1/happydoclib/parseinfo/__init__.pys   setUp s   c    sJ     | o | o  d Sn  t | |  o  d Sn  d Sd  S(   Ni   i    (   s   ds1s   ds2s   cmp(   s   selfs   ds1s   ds2(    (    s\   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_1/happydoclib/parseinfo/__init__.pys   _docStringsAreEqual s
   c 
   s    | d  d j o  d  Sn  t | |  }  t |  t i j o  d  Sn t |  t i j o  | | i	 i
   j o  | | j o  d  Sn n  t o$ | | i	 i
   j p t d |   y  | | } Wn*  t j
 o  |  i d |  n Xt o6 |  i | i | i  p t d | | i | i f  nt |  t i j o t o$ | | i i
   j p t d |  | | }	 t o6 |  i |	 i | i  p t d | | i |	 i f  n t |  t i j o | | i i
   j o | | j o d  Sn n t o$ | | i i
   j p t d |   | | } !t o6 |  i | i | i  p t d	 | | i | i f  n& 't o | p t d
 | | f  (d  Sd  S(   Ni   s   __s   Did not find class docs for %ss   Did not find class info for %ss;   Docs for class %s do not match (imported "%s", parsed "%s")s   Did not find method info for %ss<   Docs for method %s do not match (imported "%s", parsed "%s")s   Did not find func info for %ss:   Docs for func %s do not match (imported "%s", parsed "%s")s   Got %s for %s(   s   names   getattrs   importedInfos   objs   types   typess   IntTypes	   ClassTypes
   parsedInfos   _class_infos   keyss   allowedFailuress	   __debug__s   AssertionErrors	   full_names   aClasss   KeyErrors   selfs   fails   _docStringsAreEquals
   _docstrings   __doc__s
   MethodTypes   _function_infos   aMethods   FunctionTypes   aFunc(
   s   selfs	   full_names   names   importedInfos
   parsedInfos   allowedFailuress   aClasss   objs   aFuncs   aMethod(    (    s\   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_1/happydoclib/parseinfo/__init__.pys   _testComparison s8   .D.D.D%c    s   *+d } ,h  } -t | t   |  } .t o | p t d t  /| i } 1xd t
 |  D1]S } 2d | | f } 3|  i | | | |  i 4d d d d d d	 d
 d g  qh W8d  Sd  S(   Ns   TestCases.tests   Could not import %ss   %s.%ss
   OuterClasss   OuterFunctions   TestApps
   ISTERMINALs   ISNONTERMINALs   ISEOFs   mains   appInit(   s   package_names   temp_localss
   __import__s   globalss   imported_modules	   __debug__s   AssertionErrors   filenames   tests   test_modules   dirs   names	   full_names   selfs   _testComparisons   parsed_module(   s   selfs   temp_localss   names   package_names   test_modules	   full_names   imported_module(    (    s\   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_1/happydoclib/parseinfo/__init__.pys   testBasicParser*s   		 	&c    s<   KL|  i i   } Mt o | p
 t d  Nd  Sd  S(   Ns   Did not find expected exception(   s   selfs   parsed_modules   getConfigurationValuess   module_valuess	   __debug__s   AssertionError(   s   selfs   module_values(    (    s\   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_1/happydoclib/parseinfo/__init__.pys+   testExtractVariablesFromModuleWithExceptionKs   c    s  PQd t  f d d d g f d t  f d d g f d t  f d d	 g f d
 d g f d d d g f d t  f d t  f d t  f d d g f d t  f d d g f d d g f d d g f d t  f d t  f g } e|  i i   } f| i   gt o | p
 t d  hxi t	 t  | |  Dh]R \ } } i| p | o jPn kt o! | | j p t d | | f  qWmt o! | | j p t d t |   nd  Sd  S(   Ns   CommandLineApps   TestApps   SubClassTestApps   Module1s   Module2s   Symbol1s   Package1.SubModule1s   Package2.SubModule2s   Symbol2s   Package3.SubModule3s   Symbol3s   a.bs   cs   ds   cgis   one.twos   oss	   prettyasts   astListFixNamess   strings   strips   syss   paths   tokens   *s   typess
   webbrowsers   No imports were found.s$   Import values do not match %s vs. %ss,   Did not find expected values, got %s instead(   s   Nones   expected_import_datas   selfs   parsed_modules   getImportDatas   import_datas   sorts	   __debug__s   AssertionErrors   maps   expecteds   actuals   str(   s   selfs   actuals   expected_import_datas   expecteds   import_data(    (    s\   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_1/happydoclib/parseinfo/__init__.pys   testVariousImportStatementsPs    /+c    s  pqt  o |  i i p t d |  i  st  o |  i i p t d |  i  v|  i d } wt  o | i p
 t d  yt  o | i p
 t d  || d } }t  o | i p
 t d  t  o | i p
 t d  |  i d	 } t  o | i p
 t d
  t  o | i p
 t d  | d } t  o | i p
 t d  t  o | i p
 t d  d  Sd  S(   Ns!   Did not ignore module comments %ss$   Did not find docstring for module %ss   WithCommentss-   Did not ignore comments in class WithCommentss1   Found unexepcted docstring for class WithCommentss   __init__s7   Did not ignore comments in method WithComments.__init__s;   Found unexpected docstring for method WithComments.__init__s   WithoutCommentss4   Found unexepected comments for class WithoutCommentss0   Did not find docstring for class WithoutCommentss=   Found unexpected comments for method WithoutComments.__init__s:   Did not find docstring for method WithoutComments.__init__(	   s	   __debug__s   selfs   parsed_modules	   _commentss   AssertionErrors   filenames
   _docstrings   cs   method(   s   selfs   cs   method(    (    s\   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_1/happydoclib/parseinfo/__init__.pys   testIgnoreCommentsps   )(c    s   |  i } t o | d i d j p
 t d  t o | d i d j p
 t d  t o | d i d j p
 t d	  t o | d
 i d j p
 t d  d } t o | d i | j p
 t d  d  Sd  S(   Ns   Hashess    
 
 Func with hash lines
 
 
s(   Did not find expected comment for Hashess   Dashess    
 Func with dash lines
 
s(   Did not find expected comment for Dashess   Equalss    
 Func with equal lines
 
s(   Did not find expected comment for Equalss   Mixeds'    
 Func with mixed dashes and equals
 
s'   Did not find expected comment for Mixeds   
 This function has, in the comments about it, a table.  That table
 should be rendered via STNG to an HTML table in the test output.
 
  |-------------------------------------------------|
  | Function  | Documentation                       |
  |=================================================|
  | '__str__' | This method converts the            |
  |           |  the object to a string.            |
  |           |                                     |
  |           | - Blah                              |
  |           |                                     |
  |           | - Blaf                              |
  |           |                                     |
  |           |       |--------------------------|  |
  |           |       |  Name   | Favorite       |  |
  |           |       |         | Color          |  |
  |           |       |==========================|  |
  |           |       | Jim     |  Red           |  |
  |           |       |--------------------------|  |
  |           |       | John    |  Blue          |  |
  |           |       |--------------------------|  |
  |-------------------------------------------------|
 
s   StructuredTextTables5   Did not find expected comment for StructuredTextTable(   s   selfs   parsed_modules   modules	   __debug__s	   _commentss   AssertionErrors   expected_for_stt(   s   selfs   expected_for_stts   module(    (    s\   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_1/happydoclib/parseinfo/__init__.pys   testDecoratedCommentss   ((((	(c    s   t  o |  i p t d |  i  t  o |  i d i p
 t d  t  o* |  i d i i d  d j  p
 t d  d  Sd  S(   Ns!   Did not retrieve any data from %ss   DefaultClassInsts+   Did not get docstring from DefaultClassInsts   i    sB   Did not strip carriage returns from docstring for DefaultClassInst(   s	   __debug__s   selfs   parsed_modules   AssertionErrors   filenames
   _docstrings   find(   s   self(    (    s\   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_1/happydoclib/parseinfo/__init__.pys   testDOSFiless   %%4c    s^   t  o |  i i i   p
 t d  t  o |  i i i   p
 t d  d  Sd  S(   Ns   Found unexpected classess   Found unexpected functions(   s	   __debug__s   selfs   parsed_modules   _class_infos   itemss   AssertionErrors   _function_info(   s   self(    (    s\   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_1/happydoclib/parseinfo/__init__.pys   testEmptyModules   ((c 	   s  |  i } | d } t o | p
 t d  d d d d d d d	 d
 d d d d d d d d d f } h  t t t f d <t t t f d <d d t f d <d d t f d <d d t f d <d d t f d <d d t f d	 <d d t f d
 <d d t f d <d d t f d <d d t f d <d d t f d <d d t f d <d d  t f d <d d! t f d <d d" t f d <d d# t f d <} | i	   } t o | p
 t d$  t o! | | j p t d% | | f  x | D] } | i |  } t o | p t d& |  y | | } Wn* t j
 o  |  i d' |  n Xt o- | | j p  t d( t |  t |  f  qWd  Sd  S()   Ns   example_function_with_argss?   Did not get function information for example_function_with_argss   arg1s   arg2s   arg3withDefaults   arg3aWithDefaults   arg3bWithDefaults   arg4DefaultInts   arg5DefaultTuples   arg6DefaultLists   arg7DefaultNones   arg8DefaultNames   arg9DefaultInstances   arg10DefaultInstanceWithParamss   negativeIntArgs   floatArgs   negativeFloatArgs   mathArgs   stringArgWithHTMLi   s
   'hi there's   "'hi again'"s   '"hi there again"'s   101s   ( 1, 2 )s   [ 3, 4 ]s   Nones   foos   DefaultClassInst()sL   DefaultClassInstWithParams(1, 2, ( 'tuple', 'param' ), [ 'list', 'param' ] )s   -1s   1.2s   -3.4s   1 + 2s   '<h1>Hi, Dick & Jane!</h1>'s    Did not get any parameter names.s6   Actual parameter names (%s) do not match expected (%s)s   Got no parameter info for %ss   Unexpected parameter %s founds7   Parameter info for %s does not match expected. %s vs %s(   s   selfs   parsed_modules   ms   fs	   __debug__s   AssertionErrors   expected_parameter_namess   Nones   expected_parameter_infos   getParameterNamess   actual_parameter_namess   ns   getParameterInfos   parameter_infos   expected_infos   KeyErrors   fails   str(	   s   selfs   expected_parameter_infos   actual_parameter_namess   fs   parameter_infos   ms   expected_infos   ns   expected_parameter_names(    (    s\   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_1/happydoclib/parseinfo/__init__.pys   testFunctionParameterss&   < <+
 	;c    s@  	|  i } 
y | d } Wn& t j
 o |  i d  n Xt o | i   d j p
 t d  y | d } Wn& t j
 o |  i d  n& Xt o | i
 d j p
 t d  y | d } Wn& t j
 o  |  i d	  n& X"t o | i
 d
 j p
 t d  (d  Sd  S(   Ns
   OuterClasss%   Could not retrieve class "OuterClass"s,   Name of class does not match expected value.s
   InnerClasss5   Could not retrieve class "InnerClass" from OuterClasssZ   This class is inside of OuterClass.

        This class is nested one level deep.
        s'   Docstring for InnerClass does not matchs   InnerClass2s6   Could not retrieve class "InnerClass2" from InnerClasssc   This class is inside of InnerClass.

            This class is nested two levels deep.
            s(   Docstring for InnerClass2 does not match(   s   selfs   parsed_modules   ms   cs   KeyErrors   fails	   __debug__s   getNames   AssertionErrors   ic1s
   _docstrings   ic2(   s   selfs   cs   ic2s   ic1s   m(    (    s\   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_1/happydoclib/parseinfo/__init__.pys   testNestedClassess"   '$$c    s  *+|  i } ,y -| d } Wn& .t j
 o /|  i d  n X1y 2| d } Wn& 3t j
 o 4|  i d  n& X6t o | i d j p
 t	 d  9y :| d } Wn& ;t j
 o <|  i d  n& X>t o | i d	 j p
 t	 d
  Ad  Sd  S(   Ns   OuterFunctions+   Could not retrieve function "OuterFunction"s   InnerFunctions1   Could not retrieve inner function "InnerFunction"s)   This function is inside of OuterFunction.s+   Docstring for InnerFunction does not match.s   InnerFunction2s2   Could not retrieve inner function "InnerFunction2"s)   This function is inside of InnerFunction.s,   Docstring for InnerFunction2 does not match.(   s   selfs   parsed_modules   ms   fs   KeyErrors   fails   if1s	   __debug__s
   _docstrings   AssertionErrors   if2(   s   selfs   if1s   if2s   fs   m(    (    s\   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_1/happydoclib/parseinfo/__init__.pys   testNestedFunctions*s    $$(   s   default_filenames   filename_maps   include_commentss   setUps   _docStringsAreEquals   _testComparisons   testBasicParsers+   testExtractVariablesFromModuleWithExceptions   testVariousImportStatementss   testIgnoreCommentss   testDecoratedCommentss   testDOSFiless   testEmptyModules   testFunctionParameterss   testNestedClassess   testNestedFunctions(    (    (    s\   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_1/happydoclib/parseinfo/__init__.pys   ParserUnitTest s    	cC!  ->"(   s   __doc__s   __rcs_info__s   splits   __version__s   parsers   typess   happydoclibs   happydoclib.parsecommentss   happydoclib.paths    happydoclib.parseinfo.moduleinfos
   ModuleInfos   happydoclib.StreamFlushTests   StreamFlushTests   getDocss   ParserUnitTest(	   s   parsers   StreamFlushTests   typess
   ModuleInfos   getDocss   ParserUnitTests   __version__s   happydoclibs   __rcs_info__(    (    s\   /home/dhellmann/Personal/Devel/HappyDoc/dist/HappyDoc-r2_1/happydoclib/parseinfo/__init__.pys   ?S s   QD