| 2226 | self.showtopic(topic, xrefs) |
| 2227 | |
| 2228 | def listmodules(self, key=''): |
| 2229 | if key: |
| 2230 | self.output.write(''' |
| 2231 | Here is a list of modules whose name or summary contains '{}'. |
| 2232 | If there are any, enter a module name to get more help. |
| 2233 | |
| 2234 | '''.format(key)) |
| 2235 | apropos(key) |
| 2236 | else: |
| 2237 | self.output.write(''' |
| 2238 | Please wait a moment while I gather a list of all available modules... |
| 2239 | |
| 2240 | ''') |
| 2241 | modules = {} |
| 2242 | def callback(path, modname, desc, modules=modules): |
| 2243 | if modname and modname[-9:] == '.__init__': |
| 2244 | modname = modname[:-9] + ' (package)' |
| 2245 | if modname.find('.') < 0: |
| 2246 | modules[modname] = 1 |
| 2247 | def onerror(modname): |
| 2248 | callback(None, modname, None) |
| 2249 | ModuleScanner().run(callback, onerror=onerror) |
| 2250 | self.list(modules.keys()) |
| 2251 | self.output.write(''' |
| 2252 | Enter any module name to get more help. Or, type "modules spam" to search |
| 2253 | for modules whose name or summary contain the string "spam". |
| 2254 | ''') |
| 2255 | |
| 2256 | help = Helper() |
| 2257 | |