1 \section{\module{pyclbr
} ---
2 Python class browser support
}
4 \declaremodule{standard
}{pyclbr
}
5 \modulesynopsis{Supports information extraction for a Python class
7 \sectionauthor{Fred L. Drake, Jr.
}{fdrake@acm.org
}
10 The
\module{pyclbr
} can be used to determine some limited information
11 about the classes, methods and top-level functions
12 defined in a module. The information
13 provided is sufficient to implement a traditional three-pane class
14 browser. The information is extracted from the source code rather
15 than by importing the module, so this module is safe to use with
16 untrusted source code. This restriction makes it impossible to use
17 this module with modules not implemented in Python, including many
18 standard and optional extension modules.
21 \begin{funcdesc
}{readmodule
}{module
\optional{, path
}}
22 % The 'inpackage' parameter appears to be for internal use only....
23 Read a module and return a dictionary mapping class names to class
24 descriptor objects. The parameter
\var{module
} should be the name
25 of a module as a string; it may be the name of a module within a
26 package. The
\var{path
} parameter should be a sequence, and is used
27 to augment the value of
\code{sys.path
}, which is used to locate
31 \begin{funcdesc
}{readmodule_ex
}{module
\optional{, path
}}
32 % The 'inpackage' parameter appears to be for internal use only....
33 Like
\function{readmodule()
}, but the returned dictionary, in addition
34 to mapping class names to class descriptor objects, also maps
35 top-level function names to function descriptor objects. Moreover, if
36 the module being read is a package, the key
\code{'__path__'
} in the
37 returned dictionary has as its value a list which contains the package
42 \subsection{Class Descriptor Objects
\label{pyclbr-class-objects
}}
44 The class descriptor objects used as values in the dictionary returned
45 by
\function{readmodule()
} and
\function{readmodule_ex()
}
46 provide the following data members:
49 \begin{memberdesc
}[class descriptor
]{module
}
50 The name of the module defining the class described by the class
54 \begin{memberdesc
}[class descriptor
]{name
}
55 The name of the class.
58 \begin{memberdesc
}[class descriptor
]{super
}
59 A list of class descriptors which describe the immediate base
60 classes of the class being described. Classes which are named as
61 superclasses but which are not discoverable by
62 \function{readmodule()
} are listed as a string with the class name
63 instead of class descriptors.
66 \begin{memberdesc
}[class descriptor
]{methods
}
67 A dictionary mapping method names to line numbers.
70 \begin{memberdesc
}[class descriptor
]{file
}
71 Name of the file containing the
\code{class
} statement defining the class.
74 \begin{memberdesc
}[class descriptor
]{lineno
}
75 The line number of the
\code{class
} statement within the file named by
79 \subsection{Function Descriptor Objects
\label{pyclbr-function-objects
}}
81 The function descriptor objects used as values in the dictionary returned
82 by
\function{readmodule_ex()
} provide the following data members:
85 \begin{memberdesc
}[function descriptor
]{module
}
86 The name of the module defining the function described by the function
90 \begin{memberdesc
}[function descriptor
]{name
}
91 The name of the function.
94 \begin{memberdesc
}[function descriptor
]{file
}
95 Name of the file containing the
\code{def
} statement defining the function.
98 \begin{memberdesc
}[function descriptor
]{lineno
}
99 The line number of the
\code{def
} statement within the file named by