svn+ssh://pythondev@svn.python.org/python/trunk ........ r53954 | jeremy.hylton | 2007-02-26 10:41:18 -0800 (Mon, 26 Feb 2007) | 10 lines Do not copy free variables to locals in class namespaces. Fixes bug 1569356, but at the cost of a minor incompatibility in locals(). Add test that verifies that the class namespace is not polluted. Also clarify the behavior in the library docs. Along the way, cleaned up the dict_to_map and map_to_dict implementations and added some comments that explain what they do. ........ r53955 | jeremy.hylton | 2007-02-26 11:00:20 -0800 (Mon, 26 Feb 2007) | 2 lines Fix assertion. ........ r53969 | neal.norwitz | 2007-02-26 14:41:45 -0800 (Mon, 26 Feb 2007) | 3 lines When printing an unraisable error, don't print exceptions. before the name. This duplicates the behavior whening normally printing exceptions. ........ r53970 | andrew.kuchling | 2007-02-26 15:02:47 -0800 (Mon, 26 Feb 2007) | 1 line Markup fix ........ r53975 | neal.norwitz | 2007-02-26 15:48:27 -0800 (Mon, 26 Feb 2007) | 3 lines SF #1669182, 2.5 was already fixed. Just assert in 2.6 since string exceptions are gone. ........ r53976 | andrew.kuchling | 2007-02-26 15:54:17 -0800 (Mon, 26 Feb 2007) | 1 line Add some items ........ r53981 | jeremy.hylton | 2007-02-26 17:01:59 -0800 (Mon, 26 Feb 2007) | 4 lines Fix long-standing bug in name mangling for package imports Reported by Mike Verdone. ........ r53993 | jeremy.hylton | 2007-02-27 08:00:06 -0800 (Tue, 27 Feb 2007) | 2 lines tabify ........ r53994 | jeremy.hylton | 2007-02-27 08:13:23 -0800 (Tue, 27 Feb 2007) | 5 lines tabify Note that ast.c still has a mix of tabs and spaces, because it attempts to use four-space indents for more of the new code. ........ r53996 | jeremy.hylton | 2007-02-27 09:24:48 -0800 (Tue, 27 Feb 2007) | 2 lines whitespace normalization ........ r53997 | jeremy.hylton | 2007-02-27 10:29:45 -0800 (Tue, 27 Feb 2007) | 24 lines Add checking for a number of metaclass error conditions. We add some new rules that are required for preserving internal invariants of types. 1. If type (or a subclass of type) appears in bases, it must appear before any non-type bases. If a non-type base (like a regular new-style class) occurred first, it could trick type into allocating the new class an __dict__ which must be impossible. 2. There are several checks that are made of bases when creating a type. Those checks are now repeated when assigning to __bases__. We also add the restriction that assignment to __bases__ may not change the metaclass of the type. Add new tests for these cases and for a few other oddball errors that were no previously tested. Remove a crasher test that was fixed. Also some internal refactoring: Extract the code to find the most derived metaclass of a type and its bases. It is now needed in two places. Rewrite the TypeError checks in test_descr to use doctest. The tests now clearly show what exception they expect to see. ........ r53998 | jeremy.hylton | 2007-02-27 10:33:31 -0800 (Tue, 27 Feb 2007) | 2 lines Add news about changes to metaclasses and __bases__ error checking. ........ r54016 | armin.rigo | 2007-02-28 01:25:29 -0800 (Wed, 28 Feb 2007) | 3 lines Modify the segfaulting example to show why r53997 is not a solution to it. ........ r54022 | brett.cannon | 2007-02-28 10:15:00 -0800 (Wed, 28 Feb 2007) | 2 lines Add a test for instantiating SyntaxError with no arguments. ........ r54026 | raymond.hettinger | 2007-02-28 10:27:41 -0800 (Wed, 28 Feb 2007) | 1 line Docstring nit. ........ r54033 | raymond.hettinger | 2007-02-28 10:37:52 -0800 (Wed, 28 Feb 2007) | 1 line Prepare collections module for pure python code entries. ........ r54053 | raymond.hettinger | 2007-02-28 22:16:43 -0800 (Wed, 28 Feb 2007) | 1 line Add collections.NamedTuple ........ r54054 | neal.norwitz | 2007-02-28 23:04:41 -0800 (Wed, 28 Feb 2007) | 1 line Add Pat and Eric for work on PEP 3101 in the sandbox ........ r54061 | andrew.kuchling | 2007-03-01 06:36:12 -0800 (Thu, 01 Mar 2007) | 1 line Add NamedTuple ........ r54080 | georg.brandl | 2007-03-02 06:37:12 -0800 (Fri, 02 Mar 2007) | 2 lines Bug #1628895: some better tries to find HTML documentation in pydoc. ........ r54086 | raymond.hettinger | 2007-03-02 11:20:46 -0800 (Fri, 02 Mar 2007) | 1 line Fix embarrassing typo and fix constantification of None ........ r54088 | georg.brandl | 2007-03-02 12:30:14 -0800 (Fri, 02 Mar 2007) | 2 lines Bugs #1668032, #1668036, #1669304: clarify behavior of PyMem_Realloc and _Resize. ........ r54114 | georg.brandl | 2007-03-04 09:18:54 -0800 (Sun, 04 Mar 2007) | 2 lines Fix a bug in test_dict and test_userdict, found at the PyPy sprint. ........ r54124 | skip.montanaro | 2007-03-04 12:52:28 -0800 (Sun, 04 Mar 2007) | 2 lines Teach setup.py how to find Berkeley DB on Macs using MacPorts. ........ r54125 | skip.montanaro | 2007-03-04 12:54:12 -0800 (Sun, 04 Mar 2007) | 1 line note MacPorts/BerkDB change in setup.py ........ r54136 | neal.norwitz | 2007-03-04 23:52:01 -0800 (Sun, 04 Mar 2007) | 1 line Added Pete for 3101 too ........ r54138 | facundo.batista | 2007-03-05 08:31:54 -0800 (Mon, 05 Mar 2007) | 1 line Minor corrections to docs, and an explanation comentary ........ r54139 | georg.brandl | 2007-03-05 14:28:08 -0800 (Mon, 05 Mar 2007) | 3 lines Patch #1674228: when assigning a slice (old-style), check for the sq_ass_slice instead of the sq_slice slot. ........ r54149 | georg.brandl | 2007-03-06 01:33:01 -0800 (Tue, 06 Mar 2007) | 3 lines Nit: a struct field is set to GenericAlloc, not GenericAlloc(). ........ r54150 | georg.brandl | 2007-03-06 02:02:47 -0800 (Tue, 06 Mar 2007) | 3 lines Patch #1671450: add a section about subclassing builtin types to the "extending and embedding" tutorial. ........ r54152 | martin.v.loewis | 2007-03-06 02:41:24 -0800 (Tue, 06 Mar 2007) | 2 lines Patch #1121142: Implement ZipFile.open. ........ r54154 | georg.brandl | 2007-03-06 03:51:14 -0800 (Tue, 06 Mar 2007) | 2 lines A test case for the fix in #1674228. ........ r54156 | georg.brandl | 2007-03-06 03:52:24 -0800 (Tue, 06 Mar 2007) | 2 lines Patch #1672481: fix bug in idlelib.MultiCall. ........ r54159 | georg.brandl | 2007-03-06 04:17:50 -0800 (Tue, 06 Mar 2007) | 1 line Bug #1674503: close the file opened by execfile() in an error condition. ........ r54160 | georg.brandl | 2007-03-06 05:32:52 -0800 (Tue, 06 Mar 2007) | 3 lines Fix another reincarnation of bug #1576657 in defaultdict. ........ r54162 | georg.brandl | 2007-03-06 05:35:00 -0800 (Tue, 06 Mar 2007) | 2 lines A test case for the defaultdict KeyError bug. ........ r54164 | georg.brandl | 2007-03-06 05:37:45 -0800 (Tue, 06 Mar 2007) | 3 lines Patch #1663234: you can now run doctest on test files and modules using "python -m doctest [-v] filename ...". ........ r54165 | martin.v.loewis | 2007-03-06 06:43:00 -0800 (Tue, 06 Mar 2007) | 3 lines Patch #912410: Replace HTML entity references for attribute values in HTMLParser. ........ r54166 | skip.montanaro | 2007-03-06 07:41:38 -0800 (Tue, 06 Mar 2007) | 1 line patch 1673619 - identify extension modules which cannot be built ........ r54167 | guido.van.rossum | 2007-03-06 07:50:01 -0800 (Tue, 06 Mar 2007) | 5 lines Patch #1646728: datetime.fromtimestamp fails with negative fractional times. With unittest. Somebody please backport to 2.5. ........ r54169 | georg.brandl | 2007-03-06 09:49:14 -0800 (Tue, 06 Mar 2007) | 2 lines Fix cmp vs. key argument for list.sort. ........ r54170 | georg.brandl | 2007-03-06 10:21:32 -0800 (Tue, 06 Mar 2007) | 2 lines Small nit, found by Neal. ........ r54171 | georg.brandl | 2007-03-06 10:29:58 -0800 (Tue, 06 Mar 2007) | 3 lines Patch #1602128: clarify that richcmp methods can return NotImplemented and should return True or False otherwise. ........ r54173 | georg.brandl | 2007-03-06 10:41:12 -0800 (Tue, 06 Mar 2007) | 2 lines Patch #1638879: don't accept strings with embedded NUL bytes in long(). ........ r54175 | georg.brandl | 2007-03-06 10:47:31 -0800 (Tue, 06 Mar 2007) | 2 lines Patch #1673121: update README wrt. OSX default shell. ........ r54177 | georg.brandl | 2007-03-06 10:59:11 -0800 (Tue, 06 Mar 2007) | 3 lines Patch #1654417: make operator.{get,set,del}slice use the full range of Py_ssize_t. ........ r54180 | walter.doerwald | 2007-03-06 12:38:57 -0800 (Tue, 06 Mar 2007) | 4 lines Patch for bug #1633621: if curses.resizeterm() or curses.resize_term() is called, update _curses.LINES, _curses.COLS, curses.LINES and curses.COLS. ........ r54182 | walter.doerwald | 2007-03-06 13:15:24 -0800 (Tue, 06 Mar 2007) | 2 lines Document change to curses. ........ r54188 | georg.brandl | 2007-03-06 16:34:46 -0800 (Tue, 06 Mar 2007) | 5 lines Variant of patch #697613: don't exit the interpreter on a SystemExit exception if the -i command line option or PYTHONINSPECT environment variable is given, but break into the interactive interpreter just like on other exceptions or normal program exit. (backport) ........ r54189 | georg.brandl | 2007-03-06 16:40:28 -0800 (Tue, 06 Mar 2007) | 4 lines Patch #703779: unset __file__ in __main__ after running a file. This makes the filenames the warning module prints much more sensible when a PYTHONSTARTUP file is used. ........ r54192 | george.yoshida | 2007-03-06 20:21:18 -0800 (Tue, 06 Mar 2007) | 2 lines add versionadded info ........ r54195 | georg.brandl | 2007-03-06 23:39:06 -0800 (Tue, 06 Mar 2007) | 2 lines Patch #812285: allow multiple auth schemes in AbstractBasicAuthHandler. ........ r54197 | georg.brandl | 2007-03-07 00:31:51 -0800 (Wed, 07 Mar 2007) | 3 lines Patch #1001604: glob.glob() now returns unicode filenames if it was given a unicode argument and os.listdir() returns unicode filenames. ........ r54199 | georg.brandl | 2007-03-07 01:09:40 -0800 (Wed, 07 Mar 2007) | 3 lines Patches #1550273, #1550272: fix a few bugs in unittest and add a comprehensive test suite for the module. ........ r54201 | georg.brandl | 2007-03-07 01:21:06 -0800 (Wed, 07 Mar 2007) | 3 lines Patch #787789: allow to pass custom TestRunner instances to unittest's main() function. ........ r54202 | georg.brandl | 2007-03-07 01:34:45 -0800 (Wed, 07 Mar 2007) | 2 lines Patch #1669331: clarify shutil.copyfileobj() behavior wrt. file position. ........ r54204 | martin.v.loewis | 2007-03-07 03:04:33 -0800 (Wed, 07 Mar 2007) | 2 lines Bug #1115886: os.path.splitext('.cshrc') gives now ('.cshrc', ''). ........ r54206 | georg.brandl | 2007-03-07 03:37:42 -0800 (Wed, 07 Mar 2007) | 2 lines Patch #1675471: convert test_pty to unittest. ........ r54207 | georg.brandl | 2007-03-07 03:54:49 -0800 (Wed, 07 Mar 2007) | 4 lines Add some sanity checks to unittest.TestSuite's addTest(s) methods. Fixes #878275. ........ r54209 | guido.van.rossum | 2007-03-07 07:16:29 -0800 (Wed, 07 Mar 2007) | 3 lines Windows doesn't support negative timestamps. Skip the tests involving them if os.name == "nt". ........ r54219 | martin.v.loewis | 2007-03-08 05:42:43 -0800 (Thu, 08 Mar 2007) | 2 lines Add missing ) in parenthical remark. ........ r54220 | georg.brandl | 2007-03-08 09:49:06 -0800 (Thu, 08 Mar 2007) | 2 lines Fix #1676656: \em is different from \emph... ........ r54222 | georg.brandl | 2007-03-08 10:37:31 -0800 (Thu, 08 Mar 2007) | 2 lines Add a NEWS entry for rev. 54207,8. ........ r54225 | raymond.hettinger | 2007-03-08 11:24:27 -0800 (Thu, 08 Mar 2007) | 1 line SF 1676321: empty() returned wrong result ........ r54227 | collin.winter | 2007-03-08 11:58:14 -0800 (Thu, 08 Mar 2007) | 1 line Backported r54226 from p3yk: Move test_unittest, test_doctest and test_doctest2 higher up in the testing order. ........ r54230 | raymond.hettinger | 2007-03-08 13:33:47 -0800 (Thu, 08 Mar 2007) | 1 line SF #1637850: make_table in difflib did not work with unicode ........ r54232 | collin.winter | 2007-03-08 14:16:25 -0800 (Thu, 08 Mar 2007) | 1 line Patch #1668482: don't use '-' in mkstemp ........ r54233 | brett.cannon | 2007-03-08 15:58:11 -0800 (Thu, 08 Mar 2007) | 10 lines Introduce test.test_support.TransientResource. It's a context manager to surround calls to resources that may or may not be available. Specifying the expected exception and attributes to be raised if the resource is not available prevents overly broad catching of exceptions. This is meant to help suppress spurious failures by raising test.test_support.ResourceDenied if the exception matches. It would probably be good to go through the various network tests and surround the calls to catch connection timeouts (as done with test_socket_ssl in this commit). ........ r54234 | collin.winter | 2007-03-08 19:15:56 -0800 (Thu, 08 Mar 2007) | 1 line Patch #1481079: Support of HTTP_REFERER in CGIHTTPServer.py ........ r54235 | collin.winter | 2007-03-08 19:26:32 -0800 (Thu, 08 Mar 2007) | 1 line Add NEWS item for patch #1481079 (r54234). ........ r54237 | neal.norwitz | 2007-03-08 21:59:01 -0800 (Thu, 08 Mar 2007) | 1 line Fix SF #1676971, Complex OverflowError has a typo ........ r54239 | georg.brandl | 2007-03-09 04:58:41 -0800 (Fri, 09 Mar 2007) | 2 lines Typo. ........ r54240 | martin.v.loewis | 2007-03-09 07:35:55 -0800 (Fri, 09 Mar 2007) | 2 lines Patch #957003: Implement smtplib.LMTP. ........ r54243 | collin.winter | 2007-03-09 10:09:10 -0800 (Fri, 09 Mar 2007) | 2 lines Bug #1629566: clarify the docs on the return values of parsedate() and parsedate_tz() in email.utils and rfc822. ........ r54244 | thomas.heller | 2007-03-09 11:21:28 -0800 (Fri, 09 Mar 2007) | 3 lines Fix bug #1646630: ctypes.string_at(buf, 0) and ctypes.wstring_at(buf, 0) returned string up to the first NUL character. ........ r54245 | martin.v.loewis | 2007-03-09 11:36:01 -0800 (Fri, 09 Mar 2007) | 2 lines Add Ziga Seilnacht. ........ r54247 | collin.winter | 2007-03-09 12:33:07 -0800 (Fri, 09 Mar 2007) | 2 lines Patch #1491866: change the complex() constructor to allow parthensized forms. This means complex(repr(x)) now works instead of raising a ValueError. ........ r54248 | thomas.heller | 2007-03-09 12:39:22 -0800 (Fri, 09 Mar 2007) | 7 lines Bug #1651235: When a tuple was passed to a ctypes function call, Python would crash instead of raising an error. The crash was caused by a section of code that should have been removed long ago, at that time ctypes had other ways to pass parameters to function calls. ........ r54250 | collin.winter | 2007-03-09 15:30:39 -0800 (Fri, 09 Mar 2007) | 1 line Hashing simplification pointed out by Thomas Wouters. ........ r54252 | collin.winter | 2007-03-09 18:23:40 -0800 (Fri, 09 Mar 2007) | 5 lines * Unlink test files before and after each test; hopefully this will cut down on recent buildbot failures in test_islink. * Drop safe_remove() in favor of test_support.unlink(). * Fix the indentation of test_samefile so that it runs. ........ r54253 | collin.winter | 2007-03-09 18:51:26 -0800 (Fri, 09 Mar 2007) | 3 lines Bug #1531963: Make SocketServer.TCPServer's server_address always be equal to calling getsockname() on the server's socket. Will backport. ........ r54254 | neal.norwitz | 2007-03-09 19:19:18 -0800 (Fri, 09 Mar 2007) | 4 lines Simplify a little by handling the TCP case first. Update to use predominant style of spaces around = in args list and print to stderr if debugging. ........ r54256 | collin.winter | 2007-03-09 19:35:34 -0800 (Fri, 09 Mar 2007) | 1 line Add proper attribution for a bug fix. ........ r54257 | georg.brandl | 2007-03-09 23:38:14 -0800 (Fri, 09 Mar 2007) | 2 lines Typos. ........ r54260 | collin.winter | 2007-03-10 06:33:32 -0800 (Sat, 10 Mar 2007) | 1 line Convert an assert to a raise so it works even in the presence of -O. ........ r54262 | collin.winter | 2007-03-10 06:41:48 -0800 (Sat, 10 Mar 2007) | 2 lines Patch #1599845: Add an option to disable the implicit calls to server_bind() and server_activate() in the constructors for TCPServer, SimpleXMLRPCServer and DocXMLRPCServer. ........ r54268 | georg.brandl | 2007-03-11 00:28:46 -0800 (Sun, 11 Mar 2007) | 2 lines Add missing "return" statements in exception handler. ........ r54270 | ziga.seilnacht | 2007-03-11 08:54:54 -0700 (Sun, 11 Mar 2007) | 3 lines Patch #1675981: remove unreachable code from type.__new__() method. __dict__ and __weakref__ are removed from the slots tuple earlier in the code, in the loop that mangles slot names. Will backport. ........ r54271 | collin.winter | 2007-03-11 09:00:20 -0700 (Sun, 11 Mar 2007) | 3 lines Patch #1192590: Fix pdb's "ignore" and "condition" commands so they trap the IndexError caused by passing in an invalid breakpoint number. Will backport. ........ r54274 | vinay.sajip | 2007-03-11 11:32:07 -0700 (Sun, 11 Mar 2007) | 1 line Fix resource leak reported in SF #1516995. ........ r54278 | collin.winter | 2007-03-11 18:55:54 -0700 (Sun, 11 Mar 2007) | 4 lines Patch #1678662: ftp.python.org does not exist. So the testcode in urllib.py must use a more stable FTP. Will backport. ........ r54280 | barry.warsaw | 2007-03-11 20:20:01 -0700 (Sun, 11 Mar 2007) | 8 lines Tokio Kikuchi's fix for SF bug #1629369; folding whitespace allowed in the display name of an email address, e.g. Foo \tBar <foo@example.com> Test case added by Barry. ........ r54282 | skip.montanaro | 2007-03-11 20:30:50 -0700 (Sun, 11 Mar 2007) | 4 lines Sane humans would call these invalid tests, but Andrew McNamara pointed out that given the inputs in these tests Excel does indeed produce the output these tests expect. Document that for future confused folks. ........ r54283 | martin.v.loewis | 2007-03-12 03:50:39 -0700 (Mon, 12 Mar 2007) | 2 lines Bug #1675511: Use -Kpic instead of -xcode=pic32 on Solaris/x86. ........ r54285 | martin.v.loewis | 2007-03-12 04:01:10 -0700 (Mon, 12 Mar 2007) | 2 lines Patch #1677862: Require a space or tab after import in .pth files. ........ r54287 | georg.brandl | 2007-03-12 06:17:36 -0700 (Mon, 12 Mar 2007) | 8 lines Backport from Py3k branch: Patch #1591665: implement the __dir__() special function lookup in PyObject_Dir. Had to change a few bits of the patch because classobjs and __methods__ are still in Py2.6. ........ r54288 | georg.brandl | 2007-03-12 07:30:05 -0700 (Mon, 12 Mar 2007) | 3 lines Bug #1678647: write a newline after printing an exception in any case, even when converting the value to a string failed. ........ r54290 | collin.winter | 2007-03-12 08:57:19 -0700 (Mon, 12 Mar 2007) | 1 line Patch #1678088: convert test_operations to use unittest, fold the result into test_dict. ........ r54291 | collin.winter | 2007-03-12 09:11:39 -0700 (Mon, 12 Mar 2007) | 3 lines Bug #742342: make Python stop segfaulting on infinitely-recursive reload()s. Fixed by patch #922167. Will backport. ........ r54292 | georg.brandl | 2007-03-12 09:15:09 -0700 (Mon, 12 Mar 2007) | 2 lines Typo fix. ........ r54295 | collin.winter | 2007-03-12 10:24:07 -0700 (Mon, 12 Mar 2007) | 1 line Patch #1670993: Refactor test_threadedtempfile.py to use unittest. ........ r54296 | tim.peters | 2007-03-12 11:07:52 -0700 (Mon, 12 Mar 2007) | 2 lines Whitespace normalization. ........ r54297 | tim.peters | 2007-03-12 11:09:22 -0700 (Mon, 12 Mar 2007) | 2 lines Set missing svn:eol-style property on text files. ........ r54315 | brett.cannon | 2007-03-12 19:34:09 -0700 (Mon, 12 Mar 2007) | 8 lines Add test.test_support.transient_internet . Returns a context manager that nests test.test_support.TransientResource context managers that capture exceptions raised when the Internet connection is flaky. Initially using in test_socket_ssl but should probably be expanded to cover any test that should not raise the captured exceptions if the Internet connection works. ........ r54316 | brett.cannon | 2007-03-12 20:05:40 -0700 (Mon, 12 Mar 2007) | 2 lines Fix a typo where the variable name was not updated. ........ r54318 | neal.norwitz | 2007-03-12 21:59:58 -0700 (Mon, 12 Mar 2007) | 1 line Add Jerry Seutter for a bunch of his recent patches refactoring tests ........ r54319 | neal.norwitz | 2007-03-12 22:07:14 -0700 (Mon, 12 Mar 2007) | 7 lines Add some other acks for recent checkins: Brian Leair - 922167 Tomer Filiba - 1591665 Jeremy Jones - 1192590 ........ r54321 | neal.norwitz | 2007-03-12 22:31:38 -0700 (Mon, 12 Mar 2007) | 9 lines Fix some style nits: * lines too long * wrong indentation * space after a function name * wrong function name in error string * simplifying some logic Also add an error check to PyDict_SetItemString. ........ r54322 | georg.brandl | 2007-03-13 00:23:16 -0700 (Tue, 13 Mar 2007) | 2 lines Typo and grammar fixes. ........ r54323 | georg.brandl | 2007-03-13 00:50:57 -0700 (Tue, 13 Mar 2007) | 2 lines Patch #1679379: add documentation for fnmatch.translate(). ........ r54325 | georg.brandl | 2007-03-13 00:57:51 -0700 (Tue, 13 Mar 2007) | 2 lines Patch #1642844: comments to clarify the complexobject constructor. ........ r54326 | georg.brandl | 2007-03-13 01:14:27 -0700 (Tue, 13 Mar 2007) | 3 lines Patch #1668100: urllib2 now correctly raises URLError instead of OSError if accessing a local file via the file:// protocol fails. ........ r54327 | georg.brandl | 2007-03-13 02:32:11 -0700 (Tue, 13 Mar 2007) | 4 lines Patch #1635454: the csv.DictWriter class now includes the offending field names in its exception message if you try to write a record with a dictionary containing fields not in the CSV field names list. ........ r54328 | georg.brandl | 2007-03-13 02:41:31 -0700 (Tue, 13 Mar 2007) | 3 lines Patch #1555098: use str.join() instead of repeated string concatenation in robotparser. ........ r54329 | georg.brandl | 2007-03-13 03:06:48 -0700 (Tue, 13 Mar 2007) | 3 lines Patch #1542681: add entries for "with", "as" and "CONTEXTMANAGERS" to pydoc's help keywords. ........ r54331 | georg.brandl | 2007-03-13 03:19:22 -0700 (Tue, 13 Mar 2007) | 3 lines Patch #1569798: fix a bug in distutils when building Python from a directory within sys.exec_prefix. ........ r54333 | martin.v.loewis | 2007-03-13 03:24:00 -0700 (Tue, 13 Mar 2007) | 4 lines Patch #1449244: Support Unicode strings in email.message.Message.{set_charset,get_content_charset}. Will backport. ........ r54335 | lars.gustaebel | 2007-03-13 03:47:19 -0700 (Tue, 13 Mar 2007) | 34 lines This is the implementation of POSIX.1-2001 (pax) format read/write support. The TarInfo class now contains all necessary logic to process and create tar header data which has been moved there from the TarFile class. The fromtarfile() method was added. The new path and linkpath properties are aliases for the name and linkname attributes in correspondence to the pax naming scheme. The TarFile constructor and classmethods now accept a number of keyword arguments which could only be set as attributes before (e.g. dereference, ignore_zeros). The encoding and pax_headers arguments were added for pax support. There is a new tarinfo keyword argument that allows using subclassed TarInfo objects in TarFile. The boolean TarFile.posix attribute is deprecated, because now three tar formats are supported. Instead, the desired format for writing is specified using the constants USTAR_FORMAT, GNU_FORMAT and PAX_FORMAT as the format keyword argument. This change affects TarInfo.tobuf() as well. The test suite has been heavily reorganized and partially rewritten. A new testtar.tar was added that contains sample data in many formats from 4 different tar programs. Some bugs and quirks that also have been fixed: Directory names do no longer have a trailing slash in TarInfo.name or TarFile.getnames(). Adding the same file twice does not create a hardlink file member. The TarFile constructor does no longer need a name argument. The TarFile._mode attribute was renamed to mode and contains either 'r', 'w' or 'a'. ........ r54336 | georg.brandl | 2007-03-13 05:34:25 -0700 (Tue, 13 Mar 2007) | 3 lines Bug #1622896: fix a rare corner case where the bz2 module raised an error in spite of a succesful compression. ........ r54338 | lars.gustaebel | 2007-03-13 08:47:07 -0700 (Tue, 13 Mar 2007) | 3 lines Quick fix for tests that fail on systems with an encoding other than 'iso8859-1'. ........ r54339 | georg.brandl | 2007-03-13 10:43:32 -0700 (Tue, 13 Mar 2007) | 4 lines Patch #1603688: ConfigParser.SafeConfigParser now checks values that are set for invalid interpolation sequences that would lead to errors on reading back those values. ........ r54341 | georg.brandl | 2007-03-13 11:15:41 -0700 (Tue, 13 Mar 2007) | 3 lines Patch #1581073: add a flag to textwrap that prevents the dropping of whitespace while wrapping. ........ r54343 | georg.brandl | 2007-03-13 11:24:40 -0700 (Tue, 13 Mar 2007) | 2 lines Patch #1605192: list allowed states in error messages for imaplib. ........ r54344 | georg.brandl | 2007-03-13 11:31:49 -0700 (Tue, 13 Mar 2007) | 4 lines Patch #1537850: tempfile.NamedTemporaryFile now has a "delete" parameter which can be set to False to prevent the default delete-on-close behavior. ........ r54345 | collin.winter | 2007-03-13 11:53:04 -0700 (Tue, 13 Mar 2007) | 9 lines Add acks for recent patch checkins: Arvin Schnell - 1668482 S?\195?\169bastien Martini - 1481079 Heiko Wundram - 1491866 Damon Kohler - 1545011 Peter Parente - 1599845 Bjorn Lindqvist - 1678662 ........ r54346 | georg.brandl | 2007-03-13 12:00:36 -0700 (Tue, 13 Mar 2007) | 2 lines Acks for recent patches. ........ r54347 | georg.brandl | 2007-03-13 12:18:18 -0700 (Tue, 13 Mar 2007) | 3 lines Fix a tab. ........ r54348 | georg.brandl | 2007-03-13 12:32:21 -0700 (Tue, 13 Mar 2007) | 4 lines Patch #1533909: the timeit module now accepts callables in addition to strings for the code to time and the setup code. Also added two convenience functions for instantiating a Timer and calling its methods. ........ r54352 | georg.brandl | 2007-03-13 13:02:57 -0700 (Tue, 13 Mar 2007) | 3 lines Patch #1530482: add pydoc.render_doc() which returns the documentation for a thing instead of paging it to stdout, which pydoc.doc() does. ........ r54357 | thomas.heller | 2007-03-13 13:42:52 -0700 (Tue, 13 Mar 2007) | 1 line Patch #1649190: Adding support for _Bool to ctypes as c_bool, by David Remahl. ........ r54358 | georg.brandl | 2007-03-13 13:46:32 -0700 (Tue, 13 Mar 2007) | 2 lines Patch #1444529: the builtin compile() now accepts keyword arguments. (backport) ........ r54359 | thomas.heller | 2007-03-13 14:01:39 -0700 (Tue, 13 Mar 2007) | 1 line Add versionadded marker for ctypes.c_bool. ........ r54360 | georg.brandl | 2007-03-13 14:08:15 -0700 (Tue, 13 Mar 2007) | 3 lines Patch #1393667: pdb now has a "run" command which restarts the debugged Python program, optionally with different arguments. ........ r54361 | georg.brandl | 2007-03-13 14:32:01 -0700 (Tue, 13 Mar 2007) | 3 lines Deprecate commands.getstatus(). ........ r54362 | georg.brandl | 2007-03-13 14:32:56 -0700 (Tue, 13 Mar 2007) | 2 lines NEWS entry for getstatus() deprecation. ........ r54363 | georg.brandl | 2007-03-13 14:58:44 -0700 (Tue, 13 Mar 2007) | 4 lines Patch #1429539: pdb now correctly initializes the __main__ module for the debugged script, which means that imports from __main__ work correctly now. ........ r54364 | georg.brandl | 2007-03-13 15:07:36 -0700 (Tue, 13 Mar 2007) | 4 lines Patch #957650: "%var%" environment variable references are now properly expanded in ntpath.expandvars(), also "~user" home directory references are recognized and handled on Windows. ........ r54365 | georg.brandl | 2007-03-13 15:16:30 -0700 (Tue, 13 Mar 2007) | 2 lines Patch #1194449: correctly detect unbound methods in pydoc. ........ r54367 | georg.brandl | 2007-03-13 15:49:43 -0700 (Tue, 13 Mar 2007) | 5 lines Patch #1185447: binascii.b2a_qp() now correctly quotes binary characters with ASCII value less than 32. Also, it correctly quotes dots only if they occur on a single line, as opposed to the previous behavior of quoting dots if they are the second character of any line. ........ r54368 | collin.winter | 2007-03-13 16:02:15 -0700 (Tue, 13 Mar 2007) | 1 line Inline PyImport_GetModulesReloading(). ........ r54371 | barry.warsaw | 2007-03-13 21:59:50 -0700 (Tue, 13 Mar 2007) | 6 lines SF bug #1582282; decode_header() incorrectly splits not-conformant RFC 2047-like headers where there is no whitespace between encoded words. This fix changes the matching regexp to include a trailing lookahead assertion that the closing ?= must be followed by whitespace, newline, or end-of-string. This also changes the regexp to add the MULTILINE flag. ........ r54372 | gregory.p.smith | 2007-03-14 00:17:40 -0700 (Wed, 14 Mar 2007) | 2 lines correct order and names of the less often used keyword parameters. ........ r54373 | gregory.p.smith | 2007-03-14 00:19:50 -0700 (Wed, 14 Mar 2007) | 5 lines Its time to stop listing (Unix, Windows) when we really mean "everything but Mac OS 9" now that nobody is likely to use Python on Mac OS 9 and most of the (Mac) platform items are all OS X special API specific since OS X is unixy enough for these modules to be available out of the box. ........ r54376 | georg.brandl | 2007-03-14 01:27:52 -0700 (Wed, 14 Mar 2007) | 4 lines Bug #767111: fix long-standing bug in urllib which caused an AttributeError instead of an IOError when the server's response didn't contain a valid HTTP status line. ........ r54378 | ziga.seilnacht | 2007-03-14 05:24:09 -0700 (Wed, 14 Mar 2007) | 4 lines Patch #1680015: Don't modify __slots__ tuple if it contains an unicode name. Remove a reference leak that happened if the name could not be converted to string. Will backport. ........ r54386 | martin.v.loewis | 2007-03-14 13:02:31 -0700 (Wed, 14 Mar 2007) | 3 lines Patch #1559413: Fix test_cmd_line if sys.executable contains a space. Will backport. ........ r54389 | brett.cannon | 2007-03-14 14:40:13 -0700 (Wed, 14 Mar 2007) | 3 lines Note how test_socket_ssl has various exceptions that deal with a flaky Net connection are silenced. ........ r54390 | brett.cannon | 2007-03-14 14:44:15 -0700 (Wed, 14 Mar 2007) | 2 lines Raise ResourceDenied in test_urllib2net when the Net connection goes bad. ........ r54391 | neal.norwitz | 2007-03-14 21:41:20 -0700 (Wed, 14 Mar 2007) | 1 line Wrap a long line and fix a typo (is -> if) ........ r54392 | georg.brandl | 2007-03-15 00:38:14 -0700 (Thu, 15 Mar 2007) | 3 lines Patch #1680978: consistently use "alive" instead of "active" in the thread lib doc. ........ r54394 | georg.brandl | 2007-03-15 00:41:30 -0700 (Thu, 15 Mar 2007) | 3 lines Patch #1681153: the wave module now closes a file object it opened if initialization failed. ........ r54397 | ziga.seilnacht | 2007-03-15 04:44:55 -0700 (Thu, 15 Mar 2007) | 3 lines Patch #1462488: prevent a segfault in object_reduce_ex() by splitting the implementation for __reduce__ and __reduce_ex__ into two separate functions. Fixes bug #931877. Will backport. ........ r54404 | collin.winter | 2007-03-15 21:11:30 -0700 (Thu, 15 Mar 2007) | 3 lines Patch #1642547: Fix an error/crash when encountering syntax errors in complex if statements. Will backport. ........ r54406 | georg.brandl | 2007-03-16 00:55:09 -0700 (Fri, 16 Mar 2007) | 5 lines Bug #1681228: the webbrowser module now correctly uses the default GNOME or KDE browser, depending on whether there is a session of one of those present. Also, it tries the Windows default browser before trying Mozilla variants. (backport) ........ r54407 | georg.brandl | 2007-03-16 01:22:40 -0700 (Fri, 16 Mar 2007) | 4 lines Patch #1273829: os.walk() now has a "followlinks" parameter. If set to True (which is not the default), it visits symlinks pointing to directories. ........ r54408 | georg.brandl | 2007-03-16 01:24:21 -0700 (Fri, 16 Mar 2007) | 2 lines Add \versionadded tag. ........ r54409 | georg.brandl | 2007-03-16 01:33:47 -0700 (Fri, 16 Mar 2007) | 2 lines RFE #1670167: fix in isinstance() docs. ........ r54412 | ziga.seilnacht | 2007-03-16 04:59:38 -0700 (Fri, 16 Mar 2007) | 3 lines Patch #1623563: allow __class__ assignment for classes with __slots__. The old and the new class are still required to have the same slot names, but the order in which they are specified is not relevant. ........ r54413 | ziga.seilnacht | 2007-03-16 05:11:11 -0700 (Fri, 16 Mar 2007) | 2 lines Whitespace cleanup. Also remove the empty lines from the previous check in. ........ r54414 | jeremy.hylton | 2007-03-16 07:49:11 -0700 (Fri, 16 Mar 2007) | 2 lines Remove warning: funcion declaration isn't a prototype ........ r54415 | jeremy.hylton | 2007-03-16 08:59:47 -0700 (Fri, 16 Mar 2007) | 11 lines Clean up formatting of this file. The file should now follow PEP 7, except that it uses 4 space indents (in the style of Py3k). This particular code would be really hard to read with the regular tab idents. Other changes: - reflow long lines - change multi-line conditionals to have test at end of line ........ r54417 | collin.winter | 2007-03-16 14:13:35 -0700 (Fri, 16 Mar 2007) | 1 line Patch #1676994: Refactor test_popen2 to use unittest. ........ r54418 | collin.winter | 2007-03-16 14:15:35 -0700 (Fri, 16 Mar 2007) | 1 line Remove test/output/test_popen2 (missed in r54417). ........ r54419 | collin.winter | 2007-03-16 15:16:08 -0700 (Fri, 16 Mar 2007) | 1 line Patch 1339796: add a relpath() function to os.path. ........ r54421 | georg.brandl | 2007-03-17 09:08:45 -0700 (Sat, 17 Mar 2007) | 5 lines Patch #1675423: PyComplex_AsCComplex() now tries to convert an object to complex using its __complex__() method before falling back to the __float__() method. Therefore, the functions in the cmath module now can operate on objects that define a __complex__() method. (backport) ........ r54423 | gregory.p.smith | 2007-03-17 15:33:35 -0700 (Sat, 17 Mar 2007) | 2 lines move note to the correct section ........ r54426 | georg.brandl | 2007-03-18 01:25:00 -0700 (Sun, 18 Mar 2007) | 2 lines Patch #1682878: the new socket methods are recv_into and recvfrom_into, not *_buf. ........ r54432 | georg.brandl | 2007-03-18 11:28:25 -0700 (Sun, 18 Mar 2007) | 2 lines Patch #1678339: test case for bug in difflib. ........ r54439 | collin.winter | 2007-03-19 11:52:08 -0700 (Mon, 19 Mar 2007) | 1 line Patch #1630118: add a SpooledTemporaryFile class to tempfile. ........ r54441 | georg.brandl | 2007-03-19 12:02:48 -0700 (Mon, 19 Mar 2007) | 2 lines Patch #1683328: fixes and enhancements for "unparse" demo. ........ r54456 | neal.norwitz | 2007-03-19 22:07:28 -0700 (Mon, 19 Mar 2007) | 1 line Add some doc that was left out from some change to platform.py ........ r54457 | neal.norwitz | 2007-03-19 22:08:23 -0700 (Mon, 19 Mar 2007) | 1 line Add a comment about 3k migration ........ r54458 | neal.norwitz | 2007-03-19 22:21:21 -0700 (Mon, 19 Mar 2007) | 1 line Get rid of deprecation warning when testing commands.getstatus() ........ r54459 | neal.norwitz | 2007-03-19 22:23:09 -0700 (Mon, 19 Mar 2007) | 4 lines Try backing out 54407 to see if it corrects the problems on the Windows buildbots. This rev was backported, so we will need to keep both branches in sync, pending the outcome of the test after this checkin. ........ r54460 | neal.norwitz | 2007-03-19 23:13:25 -0700 (Mon, 19 Mar 2007) | 1 line Try to make this test more resistant to dropping from previous runs (ie, files that may exist but cause the test to fail). Should be backported (assuming it works :-) ........ r54461 | neal.norwitz | 2007-03-19 23:16:26 -0700 (Mon, 19 Mar 2007) | 1 line Try to make this test more resistant to dropping from previous runs (ie, files that may exist but cause the test to fail). Should be backported (assuming it works :-) ........ r54462 | neal.norwitz | 2007-03-19 23:53:17 -0700 (Mon, 19 Mar 2007) | 5 lines Try to be a little more resilient to errors. This might help the test pass, but my guess is that it won't. I'm guessing that some other test is leaving this file open which means it can't be removed under Windows AFAIK. ........ r54463 | neal.norwitz | 2007-03-20 01:14:57 -0700 (Tue, 20 Mar 2007) | 8 lines Try to get test_urllib to pass on Windows by closing the file. I'm guessing that's the problem. h.getfile() must be called *after* h.getreply() and the fp can be None. I'm not entirely convinced this is the best fix (or even correct). The buildbots will tell us if things improve or not. I don't know if this needs to be backported (assuming it actually works). ........ r54465 | raymond.hettinger | 2007-03-20 14:27:24 -0700 (Tue, 20 Mar 2007) | 1 line Extend work on rev 52962 and 53829 eliminating redundant PyObject_Hash() calls and fixing set/dict interoperability. ........ r54468 | georg.brandl | 2007-03-20 16:05:14 -0700 (Tue, 20 Mar 2007) | 2 lines Fix for glob.py if filesystem encoding is None. ........ r54479 | neal.norwitz | 2007-03-20 23:39:48 -0700 (Tue, 20 Mar 2007) | 1 line Remove unused file spotted by Paul Hankin ........ r54480 | georg.brandl | 2007-03-21 02:00:39 -0700 (Wed, 21 Mar 2007) | 3 lines Patch #1682205: a TypeError while unpacking an iterable is no longer masked by a generic one with the message "unpack non-sequence". ........ r54482 | georg.brandl | 2007-03-21 02:10:29 -0700 (Wed, 21 Mar 2007) | 2 lines New test for rev. 54407 which only uses directories under TESTFN. ........ r54483 | georg.brandl | 2007-03-21 02:16:53 -0700 (Wed, 21 Mar 2007) | 2 lines Patch #1684834: document some utility C API functions. ........ r54485 | georg.brandl | 2007-03-21 04:51:25 -0700 (Wed, 21 Mar 2007) | 2 lines Fix #1684254: split BROWSER contents with shlex to avoid displaying 'URL'. ........ r54487 | andrew.kuchling | 2007-03-21 07:32:43 -0700 (Wed, 21 Mar 2007) | 1 line Add comments on maintenance of this file ........ r54489 | andrew.kuchling | 2007-03-21 09:57:32 -0700 (Wed, 21 Mar 2007) | 1 line Fix sentence, and fix typo in example ........ r54490 | andrew.kuchling | 2007-03-21 09:59:20 -0700 (Wed, 21 Mar 2007) | 1 line Put code examples at left margin instead of indenting them ........ r54491 | facundo.batista | 2007-03-21 12:41:24 -0700 (Wed, 21 Mar 2007) | 1 line Minor clarification, saying that blocking means no timeout (from bug #882297) ........ r54492 | ziga.seilnacht | 2007-03-21 13:07:56 -0700 (Wed, 21 Mar 2007) | 2 lines Bug #1675967: re patterns pickled with older Python versions can now be unpickled. Will backport. ........ r54495 | raymond.hettinger | 2007-03-21 13:33:57 -0700 (Wed, 21 Mar 2007) | 1 line Add test and fix for fromkeys() optional argument. ........ r54524 | georg.brandl | 2007-03-22 01:05:45 -0700 (Thu, 22 Mar 2007) | 2 lines Bug #1685704: use -m switch in timeit docs. ........ r54533 | thomas.heller | 2007-03-22 12:44:31 -0700 (Thu, 22 Mar 2007) | 5 lines Back out "Patch #1643874: memory leak in ctypes fixed." The code in this patch leaves no way to give up the ownership of a BSTR instance. ........ r54538 | thomas.heller | 2007-03-22 13:34:37 -0700 (Thu, 22 Mar 2007) | 2 lines Explain the purpose of the b_needsfree flag (forward ported from release25-maint). ........ r54539 | guido.van.rossum | 2007-03-22 21:58:42 -0700 (Thu, 22 Mar 2007) | 12 lines - Bug #1683368: The object.__init__() and object.__new__() methods are now stricter in rejecting excess arguments. The only time when either allows excess arguments is when it is not overridden and the other one is. For backwards compatibility, when both are overridden, it is a deprecation warning (for now; maybe a Py3k warning later). When merging this into 3.0, the warnings should become errors. Note: without the change to string.py, lots of spurious warnings happen. What's going on there? ........ r54540 | neal.norwitz | 2007-03-22 22:17:23 -0700 (Thu, 22 Mar 2007) | 1 line Add Mark Dickinson for SF # 1675423. ........ r54541 | martin.v.loewis | 2007-03-23 03:35:49 -0700 (Fri, 23 Mar 2007) | 3 lines Patch #1686451: Fix return type for PySequence_{Count,Index,Fast_GET_SIZE}. Will backport. ........ r54543 | martin.v.loewis | 2007-03-23 06:27:15 -0700 (Fri, 23 Mar 2007) | 3 lines Bug #978833: Revert r50844, as it broke _socketobject.dup. Will backport. ........ r54545 | guido.van.rossum | 2007-03-23 11:53:03 -0700 (Fri, 23 Mar 2007) | 8 lines Add a type.__init__() method that enforces the same signature as type.__new__(), and then calls object.__init__(cls), just to be anal. This allows us to restore the code in string.py's _TemplateMetaclass that called super(...).__init__(name, bases, dct), which I commented out yesterday since it broke due to the stricter argument checking added to object.__init__(). ........ r54546 | facundo.batista | 2007-03-23 11:54:07 -0700 (Fri, 23 Mar 2007) | 4 lines Added a 'create_connect()' function to socket.py, which creates a connection with an optional timeout, and modified httplib.py to use this function in HTTPConnection. Applies patch 1676823. ........ r54547 | guido.van.rossum | 2007-03-23 12:39:01 -0700 (Fri, 23 Mar 2007) | 2 lines Add note about type.__init__(). ........ r54553 | thomas.heller | 2007-03-23 12:55:27 -0700 (Fri, 23 Mar 2007) | 5 lines Prevent creation (followed by a segfault) of array types when the size overflows the valid Py_ssize_t range. Check return values of PyMem_Malloc. Will backport to release25-maint. ........ r54555 | facundo.batista | 2007-03-23 13:23:08 -0700 (Fri, 23 Mar 2007) | 6 lines Surrounded with try/finally to socket's default timeout setting changes in the tests, so failing one test won't produce strange results in others. Also relaxed the timeout settings in the test (where actually the value didn't mean anything). ........ r54556 | collin.winter | 2007-03-23 15:24:39 -0700 (Fri, 23 Mar 2007) | 1 line Make test_relpath() pass on Windows. ........ r54559 | ziga.seilnacht | 2007-03-24 07:24:26 -0700 (Sat, 24 Mar 2007) | 6 lines Patch #1489771: update syntax rules in Python Reference Manual. Python 2.5 added support for explicit relative import statements and yield expressions, which were missing in the manual. Also fix grammar productions that used the names from the Grammar file, markup that broke the generated grammar.txt, and wrap some lines that broke the pdf output. Will backport. ........ r54565 | georg.brandl | 2007-03-24 15:20:34 -0700 (Sat, 24 Mar 2007) | 2 lines Remove typo accent. ........ r54566 | georg.brandl | 2007-03-24 15:27:56 -0700 (Sat, 24 Mar 2007) | 2 lines Revert accidental change. ........ r54567 | brett.cannon | 2007-03-24 18:32:36 -0700 (Sat, 24 Mar 2007) | 3 lines Change the docs to no longer claim that unittest is preferred over doctest for regression tests. ........ r54568 | facundo.batista | 2007-03-24 18:53:21 -0700 (Sat, 24 Mar 2007) | 4 lines Redone the tests, using the infrastructure already present for threading and socket serving. ........ r54570 | facundo.batista | 2007-03-24 20:20:05 -0700 (Sat, 24 Mar 2007) | 3 lines Closing the HTTP connection after each test, and listening more. ........ r54572 | georg.brandl | 2007-03-25 11:44:35 -0700 (Sun, 25 Mar 2007) | 2 lines Markup fix. ........ r54573 | georg.brandl | 2007-03-25 12:04:55 -0700 (Sun, 25 Mar 2007) | 2 lines Markup fix. ........ r54580 | facundo.batista | 2007-03-26 13:18:31 -0700 (Mon, 26 Mar 2007) | 5 lines Added an optional timeout to FTP class. Also I started a test_ftplib.py file to test the ftp lib (right now I included a basic test, the timeout one, and nothing else). ........ r54581 | georg.brandl | 2007-03-26 13:28:28 -0700 (Mon, 26 Mar 2007) | 2 lines Some nits. ........ r54582 | facundo.batista | 2007-03-26 13:56:09 -0700 (Mon, 26 Mar 2007) | 4 lines Forgot to add the file before the previous commit, here go the ftplib tests. ........ r54585 | facundo.batista | 2007-03-27 11:23:21 -0700 (Tue, 27 Mar 2007) | 5 lines Added an optional timeout to poplib.POP3. Also created a test_poplib.py file with a basic test and the timeout ones. Docs are also updated. ........ r54586 | facundo.batista | 2007-03-27 11:50:29 -0700 (Tue, 27 Mar 2007) | 3 lines The basic test cases of poplib.py. ........ r54594 | facundo.batista | 2007-03-27 20:45:20 -0700 (Tue, 27 Mar 2007) | 4 lines Bug 1688393. Adds a control of negative values in socket.recvfrom, which caused an ugly crash. ........ r54599 | facundo.batista | 2007-03-28 11:25:54 -0700 (Wed, 28 Mar 2007) | 5 lines Added timeout to smtplib (to SMTP and SMTP_SSL). Also created the test_smtplib.py file, with a basic test and the timeout ones. Docs are updated too. ........ r54603 | collin.winter | 2007-03-28 16:34:06 -0700 (Wed, 28 Mar 2007) | 3 lines Consolidate patches #1690164, 1683397, and 1690169, all of which refactor XML-related test suites. The patches are applied together because they use a common output/xmltests file. Thanks to Jerry Seutter for all three patches. ........ r54604 | collin.winter | 2007-03-28 19:28:16 -0700 (Wed, 28 Mar 2007) | 1 line Make test_zipfile clean up its temporary files properly. ........ r54605 | georg.brandl | 2007-03-29 00:41:32 -0700 (Thu, 29 Mar 2007) | 2 lines These are actually methods. ........ r54606 | georg.brandl | 2007-03-29 05:42:07 -0700 (Thu, 29 Mar 2007) | 4 lines In Windows' time.clock(), when QueryPerformanceFrequency() fails, the C lib's clock() is used, but it must be divided by CLOCKS_PER_SEC as for the POSIX implementation (thanks to #pypy). ........ r54608 | facundo.batista | 2007-03-29 11:22:35 -0700 (Thu, 29 Mar 2007) | 5 lines Added timout parameter to telnetlib.Telnet. Also created test_telnetlib.py with a basic test and timeout ones. Docs are also updated. ........ r54613 | facundo.batista | 2007-03-30 06:00:35 -0700 (Fri, 30 Mar 2007) | 4 lines Added the posibility to pass the timeout to FTP.connect, not only when instantiating the class. Docs and tests are updated. ........ r54614 | collin.winter | 2007-03-30 07:01:25 -0700 (Fri, 30 Mar 2007) | 1 line Bug #1688274: add documentation for C-level class objects. ........ r54615 | marc-andre.lemburg | 2007-03-30 08:01:42 -0700 (Fri, 30 Mar 2007) | 4 lines Bump the patch level version of distutils since there were a few bug fixes since the 2.5.0 release. ........ r54617 | georg.brandl | 2007-03-30 08:49:05 -0700 (Fri, 30 Mar 2007) | 2 lines Markup fix. ........ r54618 | georg.brandl | 2007-03-30 10:39:39 -0700 (Fri, 30 Mar 2007) | 2 lines Label name fix. ........ r54619 | georg.brandl | 2007-03-30 10:47:21 -0700 (Fri, 30 Mar 2007) | 2 lines Duplicate label fix. ........ r54620 | georg.brandl | 2007-03-30 10:48:39 -0700 (Fri, 30 Mar 2007) | 2 lines Markup fix. ........ r54623 | andrew.kuchling | 2007-03-30 11:00:15 -0700 (Fri, 30 Mar 2007) | 1 line Add item. (Oops, accidentally checked this in on my branch) ........ r54624 | georg.brandl | 2007-03-30 12:01:38 -0700 (Fri, 30 Mar 2007) | 2 lines Duplicate label fix. ........ r54625 | georg.brandl | 2007-03-30 12:14:02 -0700 (Fri, 30 Mar 2007) | 2 lines Markup fix. ........ r54629 | georg.brandl | 2007-03-31 03:17:31 -0700 (Sat, 31 Mar 2007) | 2 lines repair string literal. ........ r54630 | georg.brandl | 2007-03-31 04:54:58 -0700 (Sat, 31 Mar 2007) | 2 lines Markup fix. ........ r54631 | georg.brandl | 2007-03-31 04:58:36 -0700 (Sat, 31 Mar 2007) | 2 lines Duplicate label fix. ........ r54632 | georg.brandl | 2007-03-31 04:59:54 -0700 (Sat, 31 Mar 2007) | 2 lines Typo fix. ........ r54633 | neal.norwitz | 2007-03-31 11:54:18 -0700 (Sat, 31 Mar 2007) | 1 line Fix method names. Will backport. ........ r54634 | georg.brandl | 2007-03-31 11:56:11 -0700 (Sat, 31 Mar 2007) | 4 lines Bug #1655392: don't add -L/usr/lib/pythonX.Y/config to the LDFLAGS returned by python-config if Python was built with --enable-shared because that prevented the shared library from being used. ........ r54637 | collin.winter | 2007-03-31 12:31:34 -0700 (Sat, 31 Mar 2007) | 1 line Shut up an occaisonal buildbot error due to test files being left around. ........ r54644 | neal.norwitz | 2007-04-01 11:24:22 -0700 (Sun, 01 Apr 2007) | 11 lines SF #1685563, MSVCCompiler creates redundant and long PATH strings If MSVCCompiler.initialize() was called multiple times, the path would get duplicated. On Windows, this is a problem because the path is limited to 4k. There's no benefit in adding a path multiple times, so prevent that from occuring. We also normalize the path before checking for duplicates so things like /a and /a/ won't both be stored. Will backport. ........ r54646 | brett.cannon | 2007-04-01 11:47:27 -0700 (Sun, 01 Apr 2007) | 8 lines time.strptime's caching of its locale object was being recreated when the locale changed but not used during the function call it was recreated during. The test in this checkin is untested (OS X does not have the proper locale support for me to test), although the fix for the bug this deals with was tested by the OP (#1290505). Once the buildbots verify the test at least doesn't fail it becomes a backport candidate. ........ r54647 | brett.cannon | 2007-04-01 12:46:19 -0700 (Sun, 01 Apr 2007) | 3 lines Fix the test for recreating the locale cache object by not worrying about if one of the test locales cannot be set. ........ r54649 | georg.brandl | 2007-04-01 14:29:15 -0700 (Sun, 01 Apr 2007) | 2 lines Fix a lot of markup and meta-information glitches. ........ r54650 | georg.brandl | 2007-04-01 14:39:52 -0700 (Sun, 01 Apr 2007) | 2 lines Another fix. ........ r54651 | georg.brandl | 2007-04-01 15:39:10 -0700 (Sun, 01 Apr 2007) | 2 lines Lots of explicit class names for method and member descs. ........ r54652 | georg.brandl | 2007-04-01 15:40:12 -0700 (Sun, 01 Apr 2007) | 2 lines Explicit class names. ........ r54653 | georg.brandl | 2007-04-01 15:47:31 -0700 (Sun, 01 Apr 2007) | 2 lines Some semantic fixes. ........ r54654 | georg.brandl | 2007-04-01 16:29:10 -0700 (Sun, 01 Apr 2007) | 2 lines Remove bogus entry. ........ r54655 | georg.brandl | 2007-04-01 16:31:30 -0700 (Sun, 01 Apr 2007) | 2 lines Fix the class name of strings. ........ r54658 | raymond.hettinger | 2007-04-02 10:29:30 -0700 (Mon, 02 Apr 2007) | 1 line SF #1693079: Cannot save empty array in shelve ........ r54663 | raymond.hettinger | 2007-04-02 15:54:21 -0700 (Mon, 02 Apr 2007) | 3 lines Array module's buffer interface can now handle empty arrays. ........ r54664 | guido.van.rossum | 2007-04-02 16:55:37 -0700 (Mon, 02 Apr 2007) | 5 lines Fix warnings about object.__init__() signature. Two (test_array and test_descr) were bug IMO; the third (copy_reg) is a work-around which recognizes that object.__init__() doesn't do anything. ........ r54666 | raymond.hettinger | 2007-04-02 17:02:11 -0700 (Mon, 02 Apr 2007) | 1 line SF 1602378 Clarify docstrings for bisect ........ r54668 | raymond.hettinger | 2007-04-02 18:39:43 -0700 (Mon, 02 Apr 2007) | 3 lines SF #1382213: Tutorial section 9.5.1 ignores MRO for new-style classes ........ r54669 | matthias.klose | 2007-04-02 21:35:59 -0700 (Mon, 02 Apr 2007) | 4 lines - Fix an off-by-one bug in locale.strxfrm(). patch taken from http://bugs.debian.org/416934. ........ r54671 | georg.brandl | 2007-04-03 00:04:27 -0700 (Tue, 03 Apr 2007) | 9 lines Fix the strange case of \begin{methoddesc}[NNTP]{...} where \ifx#1\@undefined ended up comparing N and N, therefore executing the true part of the conditional, blowing up at \@undefined. ........ r54672 | facundo.batista | 2007-04-03 07:05:08 -0700 (Tue, 03 Apr 2007) | 4 lines Now using unittest for the tests infraestructure. Also split the tests in those who need the network, and that who doesn't. ........ r54673 | walter.doerwald | 2007-04-03 09:08:10 -0700 (Tue, 03 Apr 2007) | 4 lines Move the functionality for catching warnings in test_warnings.py into a separate class to that reusing the functionality in test_structmembers.py doesn't rerun the tests from test_warnings.py. ........ r54674 | walter.doerwald | 2007-04-03 09:16:24 -0700 (Tue, 03 Apr 2007) | 2 lines Document that CatchWarningTests is reused by test_structmembers.py. ........ r54675 | walter.doerwald | 2007-04-03 09:53:43 -0700 (Tue, 03 Apr 2007) | 4 lines Add tests for the filename. Test that the stacklevel is handled correctly. ........ r54676 | facundo.batista | 2007-04-03 10:29:48 -0700 (Tue, 03 Apr 2007) | 6 lines Added a SSL server to test_socket_ssl.py to be able to test locally. Now, it checks if have openssl available and run those specific tests (it starts openssl at the beggining of all the tests and then kills it at the end). ........ r54677 | walter.doerwald | 2007-04-03 11:33:29 -0700 (Tue, 03 Apr 2007) | 6 lines Implement a contextmanager test.test_support.catch_warning that can be used to catch the last warning issued by the warning framework. Change test_warnings.py and test_structmembers.py to use this new contextmanager. ........ r54678 | facundo.batista | 2007-04-03 14:15:34 -0700 (Tue, 03 Apr 2007) | 4 lines Changed the whole structure of startup and checking if the server is available. Hope to not get more false alarms. ........ r54681 | facundo.batista | 2007-04-04 07:10:40 -0700 (Wed, 04 Apr 2007) | 4 lines Fixed the way that the .pem files are looked for, and changed how to kill the process in win32 to use the _handle attribute. ........ r54682 | guido.van.rossum | 2007-04-04 10:43:02 -0700 (Wed, 04 Apr 2007) | 4 lines Fix a race condition in this test -- instead of assuming that it will take the test server thread at most 0.5 seconds to get ready, use an event variable. ........ r54683 | collin.winter | 2007-04-04 11:14:17 -0700 (Wed, 04 Apr 2007) | 1 line Clean up imports. ........ r54684 | collin.winter | 2007-04-04 11:16:24 -0700 (Wed, 04 Apr 2007) | 1 line Stop using test_support.verify(). ........ r54685 | martin.v.loewis | 2007-04-04 11:30:36 -0700 (Wed, 04 Apr 2007) | 2 lines Bug #1686475: Support stat'ing open files on Windows again. Will backport to 2.5. ........ r54687 | collin.winter | 2007-04-04 11:33:40 -0700 (Wed, 04 Apr 2007) | 1 line Make test_getopt use unittest. ........ r54688 | collin.winter | 2007-04-04 11:36:30 -0700 (Wed, 04 Apr 2007) | 1 line Make test_softspace use unittest. ........ r54689 | ziga.seilnacht | 2007-04-04 11:38:47 -0700 (Wed, 04 Apr 2007) | 2 lines Fix WalkTests.test_traversal() on Windows. The cleanup in MakedirTests.setUp() can now be removed. ........ r54695 | raymond.hettinger | 2007-04-05 11:00:03 -0700 (Thu, 05 Apr 2007) | 3 lines Bug #1563759: struct.unpack doens't support buffer protocol objects ........ r54697 | collin.winter | 2007-04-05 13:05:07 -0700 (Thu, 05 Apr 2007) | 1 line Convert test_long_future to use unittest. ........ r54698 | collin.winter | 2007-04-05 13:08:56 -0700 (Thu, 05 Apr 2007) | 1 line Convert test_normalization to use unittest. ........ r54699 | andrew.kuchling | 2007-04-05 18:11:58 -0700 (Thu, 05 Apr 2007) | 1 line Some grammar fixes ........ r54704 | collin.winter | 2007-04-06 12:27:40 -0700 (Fri, 06 Apr 2007) | 1 line Convert test_stringprep to use unittest. ........ r54705 | collin.winter | 2007-04-06 12:32:32 -0700 (Fri, 06 Apr 2007) | 1 line Import cleanup in test_crypt. ........ r54706 | collin.winter | 2007-04-06 13:00:05 -0700 (Fri, 06 Apr 2007) | 1 line Convert test_gc to use unittest. ........ r54707 | collin.winter | 2007-04-06 13:03:11 -0700 (Fri, 06 Apr 2007) | 1 line Convert test_module to use unittest. ........ r54711 | collin.winter | 2007-04-06 21:40:43 -0700 (Fri, 06 Apr 2007) | 1 line Convert test_fileinput to use unittest. ........ r54712 | brett.cannon | 2007-04-07 21:29:32 -0700 (Sat, 07 Apr 2007) | 5 lines Doc that file.next() has undefined behaviour when called on a file opened with 'w'. Closes bug #1569057. To be backported once 2.5 branch is unfrozen. ........ r54726 | vinay.sajip | 2007-04-09 09:16:10 -0700 (Mon, 09 Apr 2007) | 1 line Added optional timeout to SocketHandler.makeSocket (SF #1695948) ........ r54727 | ziga.seilnacht | 2007-04-09 12:10:29 -0700 (Mon, 09 Apr 2007) | 3 lines Patch #1695862: remove old test directory that causes test_urllib failures on Windows buildbots. The change is a one time fix and will be removed after a successful buildbot run. ........ r54729 | facundo.batista | 2007-04-09 20:00:37 -0700 (Mon, 09 Apr 2007) | 3 lines Minor fix to the tests pass ok even with -O. ........ r54730 | collin.winter | 2007-04-09 21:44:49 -0700 (Mon, 09 Apr 2007) | 1 line Typo fix. ........ r54732 | facundo.batista | 2007-04-10 05:58:45 -0700 (Tue, 10 Apr 2007) | 5 lines General clean-up. Lot of margin corrections, comments, some typos. Exceptions now are raised in the new style. And a mockup class is now also new style. Thanks Santiago Pereson. ........ r54741 | georg.brandl | 2007-04-10 14:39:38 -0700 (Tue, 10 Apr 2007) | 2 lines Repair a duplicate label and some obsolete uses of \setindexsubitem. ........ r54746 | andrew.kuchling | 2007-04-11 06:39:00 -0700 (Wed, 11 Apr 2007) | 1 line Add window.chgat() method, submitted via e-mail by Fabian Kreutz ........ r54747 | andrew.kuchling | 2007-04-11 06:42:25 -0700 (Wed, 11 Apr 2007) | 1 line Point readers at the patch submission instructions ........ r54748 | andrew.kuchling | 2007-04-11 06:47:13 -0700 (Wed, 11 Apr 2007) | 1 line Describe undocumented third argument to touchline() ........ r54757 | georg.brandl | 2007-04-11 10:16:24 -0700 (Wed, 11 Apr 2007) | 3 lines Add some missing NULL checks which trigger crashes on low-memory conditions. Found by Victor Stinner. Will backport when 2.5 branch is unfrozen. ........ r54760 | raymond.hettinger | 2007-04-11 11:40:58 -0700 (Wed, 11 Apr 2007) | 1 line SF 1191699: Make slices picklable ........ r54762 | georg.brandl | 2007-04-11 12:25:11 -0700 (Wed, 11 Apr 2007) | 2 lines Exceptions are no longer old-style instances. Fix accordingly. ........ r54763 | georg.brandl | 2007-04-11 16:28:44 -0700 (Wed, 11 Apr 2007) | 2 lines Repair missing spaces after \UNIX. ........ r54772 | raymond.hettinger | 2007-04-11 21:10:00 -0700 (Wed, 11 Apr 2007) | 1 line SF 1193128: Let str.translate(None) be an identity transformation ........ r54784 | georg.brandl | 2007-04-12 00:01:19 -0700 (Thu, 12 Apr 2007) | 2 lines Patch #1698951: clarify deprecation message in rexec and Bastion ........ r54785 | ziga.seilnacht | 2007-04-12 01:46:51 -0700 (Thu, 12 Apr 2007) | 2 lines Patch #1695862: remove the cleanup code, now that Windows buildbots are green again. ........ r54786 | walter.doerwald | 2007-04-12 03:35:00 -0700 (Thu, 12 Apr 2007) | 3 lines Fix utf-8-sig incremental decoder, which didn't recognise a BOM when the first chunk fed to the decoder started with a BOM, but was longer than 3 bytes. ........ r54807 | barry.warsaw | 2007-04-13 11:47:14 -0700 (Fri, 13 Apr 2007) | 8 lines Port r54805 from python25-maint branch: Add code to read from master_fd in the parent, breaking when we get an OSError (EIO can occur on Linux) or there's no more data to read. Without this, test_pty.py can hang on the waitpid() because the child is blocking on the stdout write. This will definitely happen on Mac OS X and could potentially happen on other platforms. See the comment for details. ........ r54812 | kristjan.jonsson | 2007-04-13 15:07:33 -0700 (Fri, 13 Apr 2007) | 1 line Fix a bug when using the __lltrace__ opcode tracer, and a problem sith signed chars in frameobject.c which can occur with opcodes > 127 ........ r54814 | kristjan.jonsson | 2007-04-13 15:20:13 -0700 (Fri, 13 Apr 2007) | 1 line Fix potential crash in path manipulation on windows ........ r54816 | trent.mick | 2007-04-13 16:22:05 -0700 (Fri, 13 Apr 2007) | 4 lines Add the necessary dependency for the Windows VC6 build to ensure 'pythoncore' is built before '_ctypes' is attempted. Will backport to 2.5 once it is unfrozen for 2.5.1. ........ r54825 | neal.norwitz | 2007-04-13 22:25:50 -0700 (Fri, 13 Apr 2007) | 3 lines When __slots__ are set to a unicode string, make it work the same as setting a plain string, ie don't expand to single letter identifiers. ........ r54841 | neal.norwitz | 2007-04-16 00:37:55 -0700 (Mon, 16 Apr 2007) | 1 line SF #1701207, Fix bogus assertion (and test it!) ........ r54844 | collin.winter | 2007-04-16 15:10:32 -0700 (Mon, 16 Apr 2007) | 1 line Check the availability of the urlfetch resource earlier than before. ........ r54849 | martin.v.loewis | 2007-04-16 22:02:01 -0700 (Mon, 16 Apr 2007) | 2 lines Add Travis Oliphant. ........ r54873 | brett.cannon | 2007-04-18 20:44:17 -0700 (Wed, 18 Apr 2007) | 2 lines Silence a compiler warning about incompatible pointer types. ........ r54874 | neal.norwitz | 2007-04-18 22:52:37 -0700 (Wed, 18 Apr 2007) | 2 lines SF #1703270, add missing declaration in readline.c to avoid compiler warning. ........ r54875 | armin.rigo | 2007-04-19 07:44:48 -0700 (Thu, 19 Apr 2007) | 8 lines Revert r53997 as per http://mail.python.org/pipermail/python-dev/2007-March/071796.html . I've kept a couple of still-valid extra tests in test_descr, but didn't bother to sort through the new comments and refactorings added in r53997 to see if some of them could be kept. If so, they could go in a follow-up check-in. ........ r54876 | armin.rigo | 2007-04-19 07:56:48 -0700 (Thu, 19 Apr 2007) | 2 lines Fix a usage of the dangerous pattern decref - modify field - incref. ........ r54884 | neal.norwitz | 2007-04-19 22:20:38 -0700 (Thu, 19 Apr 2007) | 9 lines Add an optional address to copy the failure mails to. Detect a conflict in the only file that should have outstanding changes when this script is run. This doesn't matter on the trunk, but does when run on a branch. Trunk always has the date set to today in boilerplate.tex. Each time a release is cut with a different date, a conflict occurs. (We could copy a known good version, but then we would lose changes to this file.) ........ r54918 | georg.brandl | 2007-04-21 13:35:38 -0700 (Sat, 21 Apr 2007) | 3 lines Bug #1704790: bind name "sys" locally in __del__ method so that it is not cleared before __del__ is run. ........ r54920 | facundo.batista | 2007-04-21 18:18:56 -0700 (Sat, 21 Apr 2007) | 5 lines Added tests for other methods of SSL object. Now we cover all the object methods. This is the final step to close the #451607 bug. ........ r54927 | facundo.batista | 2007-04-23 10:08:31 -0700 (Mon, 23 Apr 2007) | 5 lines As specified in RFC 2616, 2xx code indicates that the client's request was successfully received, understood, and accepted. Now in these cases no error is raised. Also fixed tests. ........ r54929 | collin.winter | 2007-04-23 20:43:46 -0700 (Mon, 23 Apr 2007) | 1 line Convert PyUnit -> unittest. ........ r54931 | collin.winter | 2007-04-23 21:09:52 -0700 (Mon, 23 Apr 2007) | 1 line Remove code that hasn't been called in years. ........ r54932 | neal.norwitz | 2007-04-23 21:53:12 -0700 (Mon, 23 Apr 2007) | 1 line Fix SF #1703110, Incorrect example for add_password() (use uri, not host) ........ r54934 | georg.brandl | 2007-04-24 03:36:42 -0700 (Tue, 24 Apr 2007) | 2 lines Some new year updates. ........ r54938 | facundo.batista | 2007-04-24 06:54:38 -0700 (Tue, 24 Apr 2007) | 4 lines Added a comment about last change in urllib2.py (all 2xx responses are ok now). ........ r54939 | georg.brandl | 2007-04-24 08:10:09 -0700 (Tue, 24 Apr 2007) | 2 lines Bug #1705717: error in sys.argv docs. ........ r54941 | georg.brandl | 2007-04-24 08:27:13 -0700 (Tue, 24 Apr 2007) | 4 lines Bug #1706381: Specifying the SWIG option "-c++" in the setup.py file (as opposed to the command line) will now write file names ending in ".cpp" too. ........ r54944 | raymond.hettinger | 2007-04-24 15:13:43 -0700 (Tue, 24 Apr 2007) | 1 line Fix markup ........ r54945 | kristjan.jonsson | 2007-04-24 17:10:50 -0700 (Tue, 24 Apr 2007) | 1 line Merge change 54909 from release25-maint: Fix several minor issues discovered using code analysis in VisualStudio 2005 Team Edition ........ r54947 | kristjan.jonsson | 2007-04-24 17:17:39 -0700 (Tue, 24 Apr 2007) | 1 line Make pythoncore compile cleanly with VisualStudio 2005. Used an explicit typecast to get a 64 bit integer, and undefined the Yield macro that conflicts with winbase.h ........ r54948 | kristjan.jonsson | 2007-04-24 17:19:26 -0700 (Tue, 24 Apr 2007) | 1 line Remove obsolete comment. Importing of .dll files has been discontinued, only .pyd files supported on windows now. ........ r54949 | georg.brandl | 2007-04-24 23:24:59 -0700 (Tue, 24 Apr 2007) | 2 lines Patch #1698768: updated the "using Python on the Mac" intro. ........ r54951 | georg.brandl | 2007-04-24 23:25:55 -0700 (Tue, 24 Apr 2007) | 2 lines Markup fix. ........ r54953 | neal.norwitz | 2007-04-24 23:30:05 -0700 (Tue, 24 Apr 2007) | 3 lines Whitespace normalization. Ugh, we really need to do this more often. You might want to review this change as it's my first time. Be gentle. :-) ........ r54956 | collin.winter | 2007-04-25 10:29:52 -0700 (Wed, 25 Apr 2007) | 1 line Standardize on test.test_support.run_unittest() (as opposed to a mix of run_unittest() and run_suite()). Also, add functionality to run_unittest() that admits usage of unittest.TestLoader.loadTestsFromModule(). ........ r54957 | collin.winter | 2007-04-25 10:37:35 -0700 (Wed, 25 Apr 2007) | 1 line Remove functionality from test_datetime.test_main() that does reference count checking; 'regrtest.py -R' is the way to do this kind of testing. ........ r54958 | collin.winter | 2007-04-25 10:57:53 -0700 (Wed, 25 Apr 2007) | 1 line Change test_support.have_unicode to use True/False instead of 1/0. ........ r54959 | tim.peters | 2007-04-25 11:47:18 -0700 (Wed, 25 Apr 2007) | 2 lines Whitespace normalization. ........ r54960 | tim.peters | 2007-04-25 11:48:35 -0700 (Wed, 25 Apr 2007) | 2 lines Set missing svn:eol-style property on text files. ........ r54961 | collin.winter | 2007-04-25 11:54:36 -0700 (Wed, 25 Apr 2007) | 1 line Import and raise statement cleanup. ........ r54969 | collin.winter | 2007-04-25 13:41:34 -0700 (Wed, 25 Apr 2007) | 1 line Convert test_ossaudiodev to use unittest. ........ r54974 | collin.winter | 2007-04-25 14:50:25 -0700 (Wed, 25 Apr 2007) | 1 line Fix an issue related to the unittest conversion. ........ r54979 | fred.drake | 2007-04-25 21:42:19 -0700 (Wed, 25 Apr 2007) | 1 line fix some markup errors ........ r54982 | kristjan.jonsson | 2007-04-26 02:15:08 -0700 (Thu, 26 Apr 2007) | 1 line Export function sanitize_the_mode from fileobject.c as _PyFile_SanitizeMode(). Use this function in posixmodule.c when implementing fdopen(). This fixes test_subprocess.py for a VisualStudio 2005 compile. ........ r54983 | kristjan.jonsson | 2007-04-26 06:44:16 -0700 (Thu, 26 Apr 2007) | 1 line The locale "En" appears not to be valid on windows underi VisualStudio.2005. Added "English" to the test_locale.py to make the testsuite pass for that build ........ r54984 | steve.holden | 2007-04-26 07:23:12 -0700 (Thu, 26 Apr 2007) | 1 line Minor wording change on slicing aide-memoire. ........ r54985 | kristjan.jonsson | 2007-04-26 08:24:54 -0700 (Thu, 26 Apr 2007) | 1 line Accomodate 64 bit time_t in the _bsddb module. ........
2299 lines
90 KiB
Python
Executable File
2299 lines
90 KiB
Python
Executable File
#!/usr/bin/env python
|
|
# -*- coding: Latin-1 -*-
|
|
"""Generate Python documentation in HTML or text for interactive use.
|
|
|
|
In the Python interpreter, do "from pydoc import help" to provide online
|
|
help. Calling help(thing) on a Python object documents the object.
|
|
|
|
Or, at the shell command line outside of Python:
|
|
|
|
Run "pydoc <name>" to show documentation on something. <name> may be
|
|
the name of a function, module, package, or a dotted reference to a
|
|
class or function within a module or module in a package. If the
|
|
argument contains a path segment delimiter (e.g. slash on Unix,
|
|
backslash on Windows) it is treated as the path to a Python source file.
|
|
|
|
Run "pydoc -k <keyword>" to search for a keyword in the synopsis lines
|
|
of all available modules.
|
|
|
|
Run "pydoc -p <port>" to start an HTTP server on a given port on the
|
|
local machine to generate documentation web pages.
|
|
|
|
For platforms without a command line, "pydoc -g" starts the HTTP server
|
|
and also pops up a little window for controlling it.
|
|
|
|
Run "pydoc -w <name>" to write out the HTML documentation for a module
|
|
to a file named "<name>.html".
|
|
|
|
Module docs for core modules are assumed to be in
|
|
|
|
http://www.python.org/doc/current/lib/
|
|
|
|
This can be overridden by setting the PYTHONDOCS environment variable
|
|
to a different URL or to a local directory containing the Library
|
|
Reference Manual pages.
|
|
"""
|
|
|
|
__author__ = "Ka-Ping Yee <ping@lfw.org>"
|
|
__date__ = "26 February 2001"
|
|
|
|
__version__ = "$Revision$"
|
|
__credits__ = """Guido van Rossum, for an excellent programming language.
|
|
Tommy Burnette, the original creator of manpy.
|
|
Paul Prescod, for all his work on onlinehelp.
|
|
Richard Chamberlain, for the first implementation of textdoc.
|
|
"""
|
|
|
|
# Known bugs that can't be fixed here:
|
|
# - imp.load_module() cannot be prevented from clobbering existing
|
|
# loaded modules, so calling synopsis() on a binary module file
|
|
# changes the contents of any existing module with the same name.
|
|
# - If the __file__ attribute on a module is a relative path and
|
|
# the current directory is changed with os.chdir(), an incorrect
|
|
# path will be displayed.
|
|
|
|
import sys, imp, os, re, types, inspect, __builtin__, pkgutil
|
|
from repr import Repr
|
|
try:
|
|
from collections import deque
|
|
except ImportError:
|
|
# Python 2.3 compatibility
|
|
class deque(list):
|
|
def popleft(self):
|
|
return self.pop(0)
|
|
|
|
# --------------------------------------------------------- common routines
|
|
|
|
def pathdirs():
|
|
"""Convert sys.path into a list of absolute, existing, unique paths."""
|
|
dirs = []
|
|
normdirs = []
|
|
for dir in sys.path:
|
|
dir = os.path.abspath(dir or '.')
|
|
normdir = os.path.normcase(dir)
|
|
if normdir not in normdirs and os.path.isdir(dir):
|
|
dirs.append(dir)
|
|
normdirs.append(normdir)
|
|
return dirs
|
|
|
|
def getdoc(object):
|
|
"""Get the doc string or comments for an object."""
|
|
result = inspect.getdoc(object) or inspect.getcomments(object)
|
|
return result and re.sub('^ *\n', '', result.rstrip()) or ''
|
|
|
|
def splitdoc(doc):
|
|
"""Split a doc string into a synopsis line (if any) and the rest."""
|
|
lines = doc.strip().split('\n')
|
|
if len(lines) == 1:
|
|
return lines[0], ''
|
|
elif len(lines) >= 2 and not lines[1].rstrip():
|
|
return lines[0], '\n'.join(lines[2:])
|
|
return '', '\n'.join(lines)
|
|
|
|
def classname(object, modname):
|
|
"""Get a class name and qualify it with a module name if necessary."""
|
|
name = object.__name__
|
|
if object.__module__ != modname:
|
|
name = object.__module__ + '.' + name
|
|
return name
|
|
|
|
def isdata(object):
|
|
"""Check if an object is of a type that probably means it's data."""
|
|
return not (inspect.ismodule(object) or inspect.isclass(object) or
|
|
inspect.isroutine(object) or inspect.isframe(object) or
|
|
inspect.istraceback(object) or inspect.iscode(object))
|
|
|
|
def replace(text, *pairs):
|
|
"""Do a series of global replacements on a string."""
|
|
while pairs:
|
|
text = pairs[1].join(text.split(pairs[0]))
|
|
pairs = pairs[2:]
|
|
return text
|
|
|
|
def cram(text, maxlen):
|
|
"""Omit part of a string if needed to make it fit in a maximum length."""
|
|
if len(text) > maxlen:
|
|
pre = max(0, (maxlen-3)//2)
|
|
post = max(0, maxlen-3-pre)
|
|
return text[:pre] + '...' + text[len(text)-post:]
|
|
return text
|
|
|
|
_re_stripid = re.compile(r' at 0x[0-9a-f]{6,16}(>+)$', re.IGNORECASE)
|
|
def stripid(text):
|
|
"""Remove the hexadecimal id from a Python object representation."""
|
|
# The behaviour of %p is implementation-dependent in terms of case.
|
|
if _re_stripid.search(repr(Exception)):
|
|
return _re_stripid.sub(r'\1', text)
|
|
return text
|
|
|
|
def _is_some_method(obj):
|
|
return inspect.ismethod(obj) or inspect.ismethoddescriptor(obj)
|
|
|
|
def allmethods(cl):
|
|
methods = {}
|
|
for key, value in inspect.getmembers(cl, _is_some_method):
|
|
methods[key] = 1
|
|
for base in cl.__bases__:
|
|
methods.update(allmethods(base)) # all your base are belong to us
|
|
for key in methods.keys():
|
|
methods[key] = getattr(cl, key)
|
|
return methods
|
|
|
|
def _split_list(s, predicate):
|
|
"""Split sequence s via predicate, and return pair ([true], [false]).
|
|
|
|
The return value is a 2-tuple of lists,
|
|
([x for x in s if predicate(x)],
|
|
[x for x in s if not predicate(x)])
|
|
"""
|
|
|
|
yes = []
|
|
no = []
|
|
for x in s:
|
|
if predicate(x):
|
|
yes.append(x)
|
|
else:
|
|
no.append(x)
|
|
return yes, no
|
|
|
|
def visiblename(name, all=None):
|
|
"""Decide whether to show documentation on a variable."""
|
|
# Certain special names are redundant.
|
|
if name in ('__builtins__', '__doc__', '__file__', '__path__',
|
|
'__module__', '__name__', '__slots__'): return 0
|
|
# Private names are hidden, but special names are displayed.
|
|
if name.startswith('__') and name.endswith('__'): return 1
|
|
if all is not None:
|
|
# only document that which the programmer exported in __all__
|
|
return name in all
|
|
else:
|
|
return not name.startswith('_')
|
|
|
|
def classify_class_attrs(object):
|
|
"""Wrap inspect.classify_class_attrs, with fixup for data descriptors."""
|
|
def fixup((name, kind, cls, value)):
|
|
if inspect.isdatadescriptor(value):
|
|
kind = 'data descriptor'
|
|
return name, kind, cls, value
|
|
return map(fixup, inspect.classify_class_attrs(object))
|
|
|
|
# ----------------------------------------------------- module manipulation
|
|
|
|
def ispackage(path):
|
|
"""Guess whether a path refers to a package directory."""
|
|
if os.path.isdir(path):
|
|
for ext in ('.py', '.pyc', '.pyo'):
|
|
if os.path.isfile(os.path.join(path, '__init__' + ext)):
|
|
return True
|
|
return False
|
|
|
|
def source_synopsis(file):
|
|
line = file.readline()
|
|
while line[:1] == '#' or not line.strip():
|
|
line = file.readline()
|
|
if not line: break
|
|
line = line.strip()
|
|
if line[:4] == 'r"""': line = line[1:]
|
|
if line[:3] == '"""':
|
|
line = line[3:]
|
|
if line[-1:] == '\\': line = line[:-1]
|
|
while not line.strip():
|
|
line = file.readline()
|
|
if not line: break
|
|
result = line.split('"""')[0].strip()
|
|
else: result = None
|
|
return result
|
|
|
|
def synopsis(filename, cache={}):
|
|
"""Get the one-line summary out of a module file."""
|
|
mtime = os.stat(filename).st_mtime
|
|
lastupdate, result = cache.get(filename, (0, None))
|
|
if lastupdate < mtime:
|
|
info = inspect.getmoduleinfo(filename)
|
|
try:
|
|
file = open(filename)
|
|
except IOError:
|
|
# module can't be opened, so skip it
|
|
return None
|
|
if info and 'b' in info[2]: # binary modules have to be imported
|
|
try: module = imp.load_module('__temp__', file, filename, info[1:])
|
|
except: return None
|
|
result = (module.__doc__ or '').splitlines()[0]
|
|
del sys.modules['__temp__']
|
|
else: # text modules can be directly examined
|
|
result = source_synopsis(file)
|
|
file.close()
|
|
cache[filename] = (mtime, result)
|
|
return result
|
|
|
|
class ErrorDuringImport(Exception):
|
|
"""Errors that occurred while trying to import something to document it."""
|
|
def __init__(self, filename, (exc, value, tb)):
|
|
self.filename = filename
|
|
self.exc = exc
|
|
self.value = value
|
|
self.tb = tb
|
|
|
|
def __str__(self):
|
|
exc = self.exc
|
|
if type(exc) is types.ClassType:
|
|
exc = exc.__name__
|
|
return 'problem in %s - %s: %s' % (self.filename, exc, self.value)
|
|
|
|
def importfile(path):
|
|
"""Import a Python source file or compiled file given its path."""
|
|
magic = imp.get_magic()
|
|
file = open(path, 'r')
|
|
if file.read(len(magic)) == magic:
|
|
kind = imp.PY_COMPILED
|
|
else:
|
|
kind = imp.PY_SOURCE
|
|
file.close()
|
|
filename = os.path.basename(path)
|
|
name, ext = os.path.splitext(filename)
|
|
file = open(path, 'r')
|
|
try:
|
|
module = imp.load_module(name, file, path, (ext, 'r', kind))
|
|
except:
|
|
raise ErrorDuringImport(path, sys.exc_info())
|
|
file.close()
|
|
return module
|
|
|
|
def safeimport(path, forceload=0, cache={}):
|
|
"""Import a module; handle errors; return None if the module isn't found.
|
|
|
|
If the module *is* found but an exception occurs, it's wrapped in an
|
|
ErrorDuringImport exception and reraised. Unlike __import__, if a
|
|
package path is specified, the module at the end of the path is returned,
|
|
not the package at the beginning. If the optional 'forceload' argument
|
|
is 1, we reload the module from disk (unless it's a dynamic extension)."""
|
|
try:
|
|
# If forceload is 1 and the module has been previously loaded from
|
|
# disk, we always have to reload the module. Checking the file's
|
|
# mtime isn't good enough (e.g. the module could contain a class
|
|
# that inherits from another module that has changed).
|
|
if forceload and path in sys.modules:
|
|
if path not in sys.builtin_module_names:
|
|
# Avoid simply calling reload() because it leaves names in
|
|
# the currently loaded module lying around if they're not
|
|
# defined in the new source file. Instead, remove the
|
|
# module from sys.modules and re-import. Also remove any
|
|
# submodules because they won't appear in the newly loaded
|
|
# module's namespace if they're already in sys.modules.
|
|
subs = [m for m in sys.modules if m.startswith(path + '.')]
|
|
for key in [path] + subs:
|
|
# Prevent garbage collection.
|
|
cache[key] = sys.modules[key]
|
|
del sys.modules[key]
|
|
module = __import__(path)
|
|
except:
|
|
# Did the error occur before or after the module was found?
|
|
(exc, value, tb) = info = sys.exc_info()
|
|
if path in sys.modules:
|
|
# An error occurred while executing the imported module.
|
|
raise ErrorDuringImport(sys.modules[path].__file__, info)
|
|
elif exc is SyntaxError:
|
|
# A SyntaxError occurred before we could execute the module.
|
|
raise ErrorDuringImport(value.filename, info)
|
|
elif exc is ImportError and \
|
|
str(value).lower().split()[:2] == ['no', 'module']:
|
|
# The module was not found.
|
|
return None
|
|
else:
|
|
# Some other error occurred during the importing process.
|
|
raise ErrorDuringImport(path, sys.exc_info())
|
|
for part in path.split('.')[1:]:
|
|
try: module = getattr(module, part)
|
|
except AttributeError: return None
|
|
return module
|
|
|
|
# ---------------------------------------------------- formatter base class
|
|
|
|
class Doc:
|
|
def document(self, object, name=None, *args):
|
|
"""Generate documentation for an object."""
|
|
args = (object, name) + args
|
|
# 'try' clause is to attempt to handle the possibility that inspect
|
|
# identifies something in a way that pydoc itself has issues handling;
|
|
# think 'super' and how it is a descriptor (which raises the exception
|
|
# by lacking a __name__ attribute) and an instance.
|
|
if inspect.isgetsetdescriptor(object): return self.docdata(*args)
|
|
if inspect.ismemberdescriptor(object): return self.docdata(*args)
|
|
try:
|
|
if inspect.ismodule(object): return self.docmodule(*args)
|
|
if inspect.isclass(object): return self.docclass(*args)
|
|
if inspect.isroutine(object): return self.docroutine(*args)
|
|
except AttributeError:
|
|
pass
|
|
if isinstance(object, property): return self.docproperty(*args)
|
|
return self.docother(*args)
|
|
|
|
def fail(self, object, name=None, *args):
|
|
"""Raise an exception for unimplemented types."""
|
|
message = "don't know how to document object%s of type %s" % (
|
|
name and ' ' + repr(name), type(object).__name__)
|
|
raise TypeError, message
|
|
|
|
docmodule = docclass = docroutine = docother = docproperty = docdata = fail
|
|
|
|
def getdocloc(self, object):
|
|
"""Return the location of module docs or None"""
|
|
|
|
try:
|
|
file = inspect.getabsfile(object)
|
|
except TypeError:
|
|
file = '(built-in)'
|
|
|
|
docloc = os.environ.get("PYTHONDOCS",
|
|
"http://www.python.org/doc/current/lib")
|
|
basedir = os.path.join(sys.exec_prefix, "lib",
|
|
"python"+sys.version[0:3])
|
|
if (isinstance(object, type(os)) and
|
|
(object.__name__ in ('errno', 'exceptions', 'gc', 'imp',
|
|
'marshal', 'posix', 'signal', 'sys',
|
|
'thread', 'zipimport') or
|
|
(file.startswith(basedir) and
|
|
not file.startswith(os.path.join(basedir, 'site-packages'))))):
|
|
htmlfile = "module-%s.html" % object.__name__
|
|
if docloc.startswith("http://"):
|
|
docloc = "%s/%s" % (docloc.rstrip("/"), htmlfile)
|
|
else:
|
|
docloc = os.path.join(docloc, htmlfile)
|
|
else:
|
|
docloc = None
|
|
return docloc
|
|
|
|
# -------------------------------------------- HTML documentation generator
|
|
|
|
class HTMLRepr(Repr):
|
|
"""Class for safely making an HTML representation of a Python object."""
|
|
def __init__(self):
|
|
Repr.__init__(self)
|
|
self.maxlist = self.maxtuple = 20
|
|
self.maxdict = 10
|
|
self.maxstring = self.maxother = 100
|
|
|
|
def escape(self, text):
|
|
return replace(text, '&', '&', '<', '<', '>', '>')
|
|
|
|
def repr(self, object):
|
|
return Repr.repr(self, object)
|
|
|
|
def repr1(self, x, level):
|
|
if hasattr(type(x), '__name__'):
|
|
methodname = 'repr_' + '_'.join(type(x).__name__.split())
|
|
if hasattr(self, methodname):
|
|
return getattr(self, methodname)(x, level)
|
|
return self.escape(cram(stripid(repr(x)), self.maxother))
|
|
|
|
def repr_string(self, x, level):
|
|
test = cram(x, self.maxstring)
|
|
testrepr = repr(test)
|
|
if '\\' in test and '\\' not in replace(testrepr, r'\\', ''):
|
|
# Backslashes are only literal in the string and are never
|
|
# needed to make any special characters, so show a raw string.
|
|
return 'r' + testrepr[0] + self.escape(test) + testrepr[0]
|
|
return re.sub(r'((\\[\\abfnrtv\'"]|\\[0-9]..|\\x..|\\u....)+)',
|
|
r'<font color="#c040c0">\1</font>',
|
|
self.escape(testrepr))
|
|
|
|
repr_str = repr_string
|
|
|
|
def repr_instance(self, x, level):
|
|
try:
|
|
return self.escape(cram(stripid(repr(x)), self.maxstring))
|
|
except:
|
|
return self.escape('<%s instance>' % x.__class__.__name__)
|
|
|
|
repr_unicode = repr_string
|
|
|
|
class HTMLDoc(Doc):
|
|
"""Formatter class for HTML documentation."""
|
|
|
|
# ------------------------------------------- HTML formatting utilities
|
|
|
|
_repr_instance = HTMLRepr()
|
|
repr = _repr_instance.repr
|
|
escape = _repr_instance.escape
|
|
|
|
def page(self, title, contents):
|
|
"""Format an HTML page."""
|
|
return '''
|
|
<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<html><head><title>Python: %s</title>
|
|
</head><body bgcolor="#f0f0f8">
|
|
%s
|
|
</body></html>''' % (title, contents)
|
|
|
|
def heading(self, title, fgcol, bgcol, extras=''):
|
|
"""Format a page heading."""
|
|
return '''
|
|
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
|
<tr bgcolor="%s">
|
|
<td valign=bottom> <br>
|
|
<font color="%s" face="helvetica, arial"> <br>%s</font></td
|
|
><td align=right valign=bottom
|
|
><font color="%s" face="helvetica, arial">%s</font></td></tr></table>
|
|
''' % (bgcol, fgcol, title, fgcol, extras or ' ')
|
|
|
|
def section(self, title, fgcol, bgcol, contents, width=6,
|
|
prelude='', marginalia=None, gap=' '):
|
|
"""Format a section with a heading."""
|
|
if marginalia is None:
|
|
marginalia = '<tt>' + ' ' * width + '</tt>'
|
|
result = '''<p>
|
|
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
|
<tr bgcolor="%s">
|
|
<td colspan=3 valign=bottom> <br>
|
|
<font color="%s" face="helvetica, arial">%s</font></td></tr>
|
|
''' % (bgcol, fgcol, title)
|
|
if prelude:
|
|
result = result + '''
|
|
<tr bgcolor="%s"><td rowspan=2>%s</td>
|
|
<td colspan=2>%s</td></tr>
|
|
<tr><td>%s</td>''' % (bgcol, marginalia, prelude, gap)
|
|
else:
|
|
result = result + '''
|
|
<tr><td bgcolor="%s">%s</td><td>%s</td>''' % (bgcol, marginalia, gap)
|
|
|
|
return result + '\n<td width="100%%">%s</td></tr></table>' % contents
|
|
|
|
def bigsection(self, title, *args):
|
|
"""Format a section with a big heading."""
|
|
title = '<big><strong>%s</strong></big>' % title
|
|
return self.section(title, *args)
|
|
|
|
def preformat(self, text):
|
|
"""Format literal preformatted text."""
|
|
text = self.escape(text.expandtabs())
|
|
return replace(text, '\n\n', '\n \n', '\n\n', '\n \n',
|
|
' ', ' ', '\n', '<br>\n')
|
|
|
|
def multicolumn(self, list, format, cols=4):
|
|
"""Format a list of items into a multi-column list."""
|
|
result = ''
|
|
rows = (len(list)+cols-1)/cols
|
|
for col in range(cols):
|
|
result = result + '<td width="%d%%" valign=top>' % (100/cols)
|
|
for i in range(rows*col, rows*col+rows):
|
|
if i < len(list):
|
|
result = result + format(list[i]) + '<br>\n'
|
|
result = result + '</td>'
|
|
return '<table width="100%%" summary="list"><tr>%s</tr></table>' % result
|
|
|
|
def grey(self, text): return '<font color="#909090">%s</font>' % text
|
|
|
|
def namelink(self, name, *dicts):
|
|
"""Make a link for an identifier, given name-to-URL mappings."""
|
|
for dict in dicts:
|
|
if name in dict:
|
|
return '<a href="%s">%s</a>' % (dict[name], name)
|
|
return name
|
|
|
|
def classlink(self, object, modname):
|
|
"""Make a link for a class."""
|
|
name, module = object.__name__, sys.modules.get(object.__module__)
|
|
if hasattr(module, name) and getattr(module, name) is object:
|
|
return '<a href="%s.html#%s">%s</a>' % (
|
|
module.__name__, name, classname(object, modname))
|
|
return classname(object, modname)
|
|
|
|
def modulelink(self, object):
|
|
"""Make a link for a module."""
|
|
return '<a href="%s.html">%s</a>' % (object.__name__, object.__name__)
|
|
|
|
def modpkglink(self, (name, path, ispackage, shadowed)):
|
|
"""Make a link for a module or package to display in an index."""
|
|
if shadowed:
|
|
return self.grey(name)
|
|
if path:
|
|
url = '%s.%s.html' % (path, name)
|
|
else:
|
|
url = '%s.html' % name
|
|
if ispackage:
|
|
text = '<strong>%s</strong> (package)' % name
|
|
else:
|
|
text = name
|
|
return '<a href="%s">%s</a>' % (url, text)
|
|
|
|
def markup(self, text, escape=None, funcs={}, classes={}, methods={}):
|
|
"""Mark up some plain text, given a context of symbols to look for.
|
|
Each context dictionary maps object names to anchor names."""
|
|
escape = escape or self.escape
|
|
results = []
|
|
here = 0
|
|
pattern = re.compile(r'\b((http|ftp)://\S+[\w/]|'
|
|
r'RFC[- ]?(\d+)|'
|
|
r'PEP[- ]?(\d+)|'
|
|
r'(self\.)?(\w+))')
|
|
while True:
|
|
match = pattern.search(text, here)
|
|
if not match: break
|
|
start, end = match.span()
|
|
results.append(escape(text[here:start]))
|
|
|
|
all, scheme, rfc, pep, selfdot, name = match.groups()
|
|
if scheme:
|
|
url = escape(all).replace('"', '"')
|
|
results.append('<a href="%s">%s</a>' % (url, url))
|
|
elif rfc:
|
|
url = 'http://www.rfc-editor.org/rfc/rfc%d.txt' % int(rfc)
|
|
results.append('<a href="%s">%s</a>' % (url, escape(all)))
|
|
elif pep:
|
|
url = 'http://www.python.org/peps/pep-%04d.html' % int(pep)
|
|
results.append('<a href="%s">%s</a>' % (url, escape(all)))
|
|
elif text[end:end+1] == '(':
|
|
results.append(self.namelink(name, methods, funcs, classes))
|
|
elif selfdot:
|
|
results.append('self.<strong>%s</strong>' % name)
|
|
else:
|
|
results.append(self.namelink(name, classes))
|
|
here = end
|
|
results.append(escape(text[here:]))
|
|
return ''.join(results)
|
|
|
|
# ---------------------------------------------- type-specific routines
|
|
|
|
def formattree(self, tree, modname, parent=None):
|
|
"""Produce HTML for a class tree as given by inspect.getclasstree()."""
|
|
result = ''
|
|
for entry in tree:
|
|
if type(entry) is type(()):
|
|
c, bases = entry
|
|
result = result + '<dt><font face="helvetica, arial">'
|
|
result = result + self.classlink(c, modname)
|
|
if bases and bases != (parent,):
|
|
parents = []
|
|
for base in bases:
|
|
parents.append(self.classlink(base, modname))
|
|
result = result + '(' + ', '.join(parents) + ')'
|
|
result = result + '\n</font></dt>'
|
|
elif type(entry) is type([]):
|
|
result = result + '<dd>\n%s</dd>\n' % self.formattree(
|
|
entry, modname, c)
|
|
return '<dl>\n%s</dl>\n' % result
|
|
|
|
def docmodule(self, object, name=None, mod=None, *ignored):
|
|
"""Produce HTML documentation for a module object."""
|
|
name = object.__name__ # ignore the passed-in name
|
|
try:
|
|
all = object.__all__
|
|
except AttributeError:
|
|
all = None
|
|
parts = name.split('.')
|
|
links = []
|
|
for i in range(len(parts)-1):
|
|
links.append(
|
|
'<a href="%s.html"><font color="#ffffff">%s</font></a>' %
|
|
('.'.join(parts[:i+1]), parts[i]))
|
|
linkedname = '.'.join(links + parts[-1:])
|
|
head = '<big><big><strong>%s</strong></big></big>' % linkedname
|
|
try:
|
|
path = inspect.getabsfile(object)
|
|
url = path
|
|
if sys.platform == 'win32':
|
|
import nturl2path
|
|
url = nturl2path.pathname2url(path)
|
|
filelink = '<a href="file:%s">%s</a>' % (url, path)
|
|
except TypeError:
|
|
filelink = '(built-in)'
|
|
info = []
|
|
if hasattr(object, '__version__'):
|
|
version = str(object.__version__)
|
|
if version[:11] == '$' + 'Revision: ' and version[-1:] == '$':
|
|
version = version[11:-1].strip()
|
|
info.append('version %s' % self.escape(version))
|
|
if hasattr(object, '__date__'):
|
|
info.append(self.escape(str(object.__date__)))
|
|
if info:
|
|
head = head + ' (%s)' % ', '.join(info)
|
|
docloc = self.getdocloc(object)
|
|
if docloc is not None:
|
|
docloc = '<br><a href="%(docloc)s">Module Docs</a>' % locals()
|
|
else:
|
|
docloc = ''
|
|
result = self.heading(
|
|
head, '#ffffff', '#7799ee',
|
|
'<a href=".">index</a><br>' + filelink + docloc)
|
|
|
|
modules = inspect.getmembers(object, inspect.ismodule)
|
|
|
|
classes, cdict = [], {}
|
|
for key, value in inspect.getmembers(object, inspect.isclass):
|
|
# if __all__ exists, believe it. Otherwise use old heuristic.
|
|
if (all is not None or
|
|
(inspect.getmodule(value) or object) is object):
|
|
if visiblename(key, all):
|
|
classes.append((key, value))
|
|
cdict[key] = cdict[value] = '#' + key
|
|
for key, value in classes:
|
|
for base in value.__bases__:
|
|
key, modname = base.__name__, base.__module__
|
|
module = sys.modules.get(modname)
|
|
if modname != name and module and hasattr(module, key):
|
|
if getattr(module, key) is base:
|
|
if not key in cdict:
|
|
cdict[key] = cdict[base] = modname + '.html#' + key
|
|
funcs, fdict = [], {}
|
|
for key, value in inspect.getmembers(object, inspect.isroutine):
|
|
# if __all__ exists, believe it. Otherwise use old heuristic.
|
|
if (all is not None or
|
|
inspect.isbuiltin(value) or inspect.getmodule(value) is object):
|
|
if visiblename(key, all):
|
|
funcs.append((key, value))
|
|
fdict[key] = '#-' + key
|
|
if inspect.isfunction(value): fdict[value] = fdict[key]
|
|
data = []
|
|
for key, value in inspect.getmembers(object, isdata):
|
|
if visiblename(key, all):
|
|
data.append((key, value))
|
|
|
|
doc = self.markup(getdoc(object), self.preformat, fdict, cdict)
|
|
doc = doc and '<tt>%s</tt>' % doc
|
|
result = result + '<p>%s</p>\n' % doc
|
|
|
|
if hasattr(object, '__path__'):
|
|
modpkgs = []
|
|
for importer, modname, ispkg in pkgutil.iter_modules(object.__path__):
|
|
modpkgs.append((modname, name, ispkg, 0))
|
|
modpkgs.sort()
|
|
contents = self.multicolumn(modpkgs, self.modpkglink)
|
|
result = result + self.bigsection(
|
|
'Package Contents', '#ffffff', '#aa55cc', contents)
|
|
elif modules:
|
|
contents = self.multicolumn(
|
|
modules, lambda (key, value), s=self: s.modulelink(value))
|
|
result = result + self.bigsection(
|
|
'Modules', '#fffff', '#aa55cc', contents)
|
|
|
|
if classes:
|
|
classlist = map(lambda (key, value): value, classes)
|
|
contents = [
|
|
self.formattree(inspect.getclasstree(classlist, 1), name)]
|
|
for key, value in classes:
|
|
contents.append(self.document(value, key, name, fdict, cdict))
|
|
result = result + self.bigsection(
|
|
'Classes', '#ffffff', '#ee77aa', ' '.join(contents))
|
|
if funcs:
|
|
contents = []
|
|
for key, value in funcs:
|
|
contents.append(self.document(value, key, name, fdict, cdict))
|
|
result = result + self.bigsection(
|
|
'Functions', '#ffffff', '#eeaa77', ' '.join(contents))
|
|
if data:
|
|
contents = []
|
|
for key, value in data:
|
|
contents.append(self.document(value, key))
|
|
result = result + self.bigsection(
|
|
'Data', '#ffffff', '#55aa55', '<br>\n'.join(contents))
|
|
if hasattr(object, '__author__'):
|
|
contents = self.markup(str(object.__author__), self.preformat)
|
|
result = result + self.bigsection(
|
|
'Author', '#ffffff', '#7799ee', contents)
|
|
if hasattr(object, '__credits__'):
|
|
contents = self.markup(str(object.__credits__), self.preformat)
|
|
result = result + self.bigsection(
|
|
'Credits', '#ffffff', '#7799ee', contents)
|
|
|
|
return result
|
|
|
|
def docclass(self, object, name=None, mod=None, funcs={}, classes={},
|
|
*ignored):
|
|
"""Produce HTML documentation for a class object."""
|
|
realname = object.__name__
|
|
name = name or realname
|
|
bases = object.__bases__
|
|
|
|
contents = []
|
|
push = contents.append
|
|
|
|
# Cute little class to pump out a horizontal rule between sections.
|
|
class HorizontalRule:
|
|
def __init__(self):
|
|
self.needone = 0
|
|
def maybe(self):
|
|
if self.needone:
|
|
push('<hr>\n')
|
|
self.needone = 1
|
|
hr = HorizontalRule()
|
|
|
|
# List the mro, if non-trivial.
|
|
mro = deque(inspect.getmro(object))
|
|
if len(mro) > 2:
|
|
hr.maybe()
|
|
push('<dl><dt>Method resolution order:</dt>\n')
|
|
for base in mro:
|
|
push('<dd>%s</dd>\n' % self.classlink(base,
|
|
object.__module__))
|
|
push('</dl>\n')
|
|
|
|
def spill(msg, attrs, predicate):
|
|
ok, attrs = _split_list(attrs, predicate)
|
|
if ok:
|
|
hr.maybe()
|
|
push(msg)
|
|
for name, kind, homecls, value in ok:
|
|
push(self.document(getattr(object, name), name, mod,
|
|
funcs, classes, mdict, object))
|
|
push('\n')
|
|
return attrs
|
|
|
|
def spilldescriptors(msg, attrs, predicate):
|
|
ok, attrs = _split_list(attrs, predicate)
|
|
if ok:
|
|
hr.maybe()
|
|
push(msg)
|
|
for name, kind, homecls, value in ok:
|
|
push(self._docdescriptor(name, value, mod))
|
|
return attrs
|
|
|
|
def spilldata(msg, attrs, predicate):
|
|
ok, attrs = _split_list(attrs, predicate)
|
|
if ok:
|
|
hr.maybe()
|
|
push(msg)
|
|
for name, kind, homecls, value in ok:
|
|
base = self.docother(getattr(object, name), name, mod)
|
|
if callable(value) or inspect.isdatadescriptor(value):
|
|
doc = getattr(value, "__doc__", None)
|
|
else:
|
|
doc = None
|
|
if doc is None:
|
|
push('<dl><dt>%s</dl>\n' % base)
|
|
else:
|
|
doc = self.markup(getdoc(value), self.preformat,
|
|
funcs, classes, mdict)
|
|
doc = '<dd><tt>%s</tt>' % doc
|
|
push('<dl><dt>%s%s</dl>\n' % (base, doc))
|
|
push('\n')
|
|
return attrs
|
|
|
|
attrs = filter(lambda (name, kind, cls, value): visiblename(name),
|
|
classify_class_attrs(object))
|
|
mdict = {}
|
|
for key, kind, homecls, value in attrs:
|
|
mdict[key] = anchor = '#' + name + '-' + key
|
|
value = getattr(object, key)
|
|
try:
|
|
# The value may not be hashable (e.g., a data attr with
|
|
# a dict or list value).
|
|
mdict[value] = anchor
|
|
except TypeError:
|
|
pass
|
|
|
|
while attrs:
|
|
if mro:
|
|
thisclass = mro.popleft()
|
|
else:
|
|
thisclass = attrs[0][2]
|
|
attrs, inherited = _split_list(attrs, lambda t: t[2] is thisclass)
|
|
|
|
if thisclass is __builtin__.object:
|
|
attrs = inherited
|
|
continue
|
|
elif thisclass is object:
|
|
tag = 'defined here'
|
|
else:
|
|
tag = 'inherited from %s' % self.classlink(thisclass,
|
|
object.__module__)
|
|
tag += ':<br>\n'
|
|
|
|
# Sort attrs by name.
|
|
try:
|
|
attrs.sort(key=lambda t: t[0])
|
|
except TypeError:
|
|
attrs.sort(lambda t1, t2: cmp(t1[0], t2[0])) # 2.3 compat
|
|
|
|
# Pump out the attrs, segregated by kind.
|
|
attrs = spill('Methods %s' % tag, attrs,
|
|
lambda t: t[1] == 'method')
|
|
attrs = spill('Class methods %s' % tag, attrs,
|
|
lambda t: t[1] == 'class method')
|
|
attrs = spill('Static methods %s' % tag, attrs,
|
|
lambda t: t[1] == 'static method')
|
|
attrs = spilldescriptors('Data descriptors %s' % tag, attrs,
|
|
lambda t: t[1] == 'data descriptor')
|
|
attrs = spilldata('Data and other attributes %s' % tag, attrs,
|
|
lambda t: t[1] == 'data')
|
|
assert attrs == []
|
|
attrs = inherited
|
|
|
|
contents = ''.join(contents)
|
|
|
|
if name == realname:
|
|
title = '<a name="%s">class <strong>%s</strong></a>' % (
|
|
name, realname)
|
|
else:
|
|
title = '<strong>%s</strong> = <a name="%s">class %s</a>' % (
|
|
name, name, realname)
|
|
if bases:
|
|
parents = []
|
|
for base in bases:
|
|
parents.append(self.classlink(base, object.__module__))
|
|
title = title + '(%s)' % ', '.join(parents)
|
|
doc = self.markup(getdoc(object), self.preformat, funcs, classes, mdict)
|
|
doc = doc and '<tt>%s<br> </tt>' % doc
|
|
|
|
return self.section(title, '#000000', '#ffc8d8', contents, 3, doc)
|
|
|
|
def formatvalue(self, object):
|
|
"""Format an argument default value as text."""
|
|
return self.grey('=' + self.repr(object))
|
|
|
|
def docroutine(self, object, name=None, mod=None,
|
|
funcs={}, classes={}, methods={}, cl=None):
|
|
"""Produce HTML documentation for a function or method object."""
|
|
realname = object.__name__
|
|
name = name or realname
|
|
anchor = (cl and cl.__name__ or '') + '-' + name
|
|
note = ''
|
|
skipdocs = 0
|
|
if inspect.ismethod(object):
|
|
imclass = object.im_class
|
|
if cl:
|
|
if imclass is not cl:
|
|
note = ' from ' + self.classlink(imclass, mod)
|
|
else:
|
|
if object.im_self is not None:
|
|
note = ' method of %s instance' % self.classlink(
|
|
object.im_self.__class__, mod)
|
|
else:
|
|
note = ' unbound %s method' % self.classlink(imclass,mod)
|
|
object = object.im_func
|
|
|
|
if name == realname:
|
|
title = '<a name="%s"><strong>%s</strong></a>' % (anchor, realname)
|
|
else:
|
|
if (cl and realname in cl.__dict__ and
|
|
cl.__dict__[realname] is object):
|
|
reallink = '<a href="#%s">%s</a>' % (
|
|
cl.__name__ + '-' + realname, realname)
|
|
skipdocs = 1
|
|
else:
|
|
reallink = realname
|
|
title = '<a name="%s"><strong>%s</strong></a> = %s' % (
|
|
anchor, name, reallink)
|
|
if inspect.isfunction(object):
|
|
args, varargs, kwonlyargs, kwdefaults, varkw, defaults, ann = \
|
|
inspect.getfullargspec(object)
|
|
argspec = inspect.formatargspec(
|
|
args, varargs, kwonlyargs, kwdefaults, varkw, defaults, ann,
|
|
formatvalue=self.formatvalue,
|
|
formatannotation=inspect.formatannotationrelativeto(object))
|
|
if realname == '<lambda>':
|
|
title = '<strong>%s</strong> <em>lambda</em> ' % name
|
|
# XXX lambda's won't usually have func_annotations['return']
|
|
# since the syntax doesn't support but it is possible.
|
|
# So removing parentheses isn't truly safe.
|
|
argspec = argspec[1:-1] # remove parentheses
|
|
else:
|
|
argspec = '(...)'
|
|
|
|
decl = title + argspec + (note and self.grey(
|
|
'<font face="helvetica, arial">%s</font>' % note))
|
|
|
|
if skipdocs:
|
|
return '<dl><dt>%s</dt></dl>\n' % decl
|
|
else:
|
|
doc = self.markup(
|
|
getdoc(object), self.preformat, funcs, classes, methods)
|
|
doc = doc and '<dd><tt>%s</tt></dd>' % doc
|
|
return '<dl><dt>%s</dt>%s</dl>\n' % (decl, doc)
|
|
|
|
def _docdescriptor(self, name, value, mod):
|
|
results = []
|
|
push = results.append
|
|
|
|
if name:
|
|
push('<dl><dt><strong>%s</strong></dt>\n' % name)
|
|
if value.__doc__ is not None:
|
|
doc = self.markup(getdoc(value), self.preformat)
|
|
push('<dd><tt>%s</tt></dd>\n' % doc)
|
|
push('</dl>\n')
|
|
|
|
return ''.join(results)
|
|
|
|
def docproperty(self, object, name=None, mod=None, cl=None):
|
|
"""Produce html documentation for a property."""
|
|
return self._docdescriptor(name, object, mod)
|
|
|
|
def docother(self, object, name=None, mod=None, *ignored):
|
|
"""Produce HTML documentation for a data object."""
|
|
lhs = name and '<strong>%s</strong> = ' % name or ''
|
|
return lhs + self.repr(object)
|
|
|
|
def docdata(self, object, name=None, mod=None, cl=None):
|
|
"""Produce html documentation for a data descriptor."""
|
|
return self._docdescriptor(name, object, mod)
|
|
|
|
def index(self, dir, shadowed=None):
|
|
"""Generate an HTML index for a directory of modules."""
|
|
modpkgs = []
|
|
if shadowed is None: shadowed = {}
|
|
for importer, name, ispkg in pkgutil.iter_modules([dir]):
|
|
modpkgs.append((name, '', ispkg, name in shadowed))
|
|
shadowed[name] = 1
|
|
|
|
modpkgs.sort()
|
|
contents = self.multicolumn(modpkgs, self.modpkglink)
|
|
return self.bigsection(dir, '#ffffff', '#ee77aa', contents)
|
|
|
|
# -------------------------------------------- text documentation generator
|
|
|
|
class TextRepr(Repr):
|
|
"""Class for safely making a text representation of a Python object."""
|
|
def __init__(self):
|
|
Repr.__init__(self)
|
|
self.maxlist = self.maxtuple = 20
|
|
self.maxdict = 10
|
|
self.maxstring = self.maxother = 100
|
|
|
|
def repr1(self, x, level):
|
|
if hasattr(type(x), '__name__'):
|
|
methodname = 'repr_' + '_'.join(type(x).__name__.split())
|
|
if hasattr(self, methodname):
|
|
return getattr(self, methodname)(x, level)
|
|
return cram(stripid(repr(x)), self.maxother)
|
|
|
|
def repr_string(self, x, level):
|
|
test = cram(x, self.maxstring)
|
|
testrepr = repr(test)
|
|
if '\\' in test and '\\' not in replace(testrepr, r'\\', ''):
|
|
# Backslashes are only literal in the string and are never
|
|
# needed to make any special characters, so show a raw string.
|
|
return 'r' + testrepr[0] + test + testrepr[0]
|
|
return testrepr
|
|
|
|
repr_str = repr_string
|
|
|
|
def repr_instance(self, x, level):
|
|
try:
|
|
return cram(stripid(repr(x)), self.maxstring)
|
|
except:
|
|
return '<%s instance>' % x.__class__.__name__
|
|
|
|
class TextDoc(Doc):
|
|
"""Formatter class for text documentation."""
|
|
|
|
# ------------------------------------------- text formatting utilities
|
|
|
|
_repr_instance = TextRepr()
|
|
repr = _repr_instance.repr
|
|
|
|
def bold(self, text):
|
|
"""Format a string in bold by overstriking."""
|
|
return ''.join(map(lambda ch: ch + '\b' + ch, text))
|
|
|
|
def indent(self, text, prefix=' '):
|
|
"""Indent text by prepending a given prefix to each line."""
|
|
if not text: return ''
|
|
lines = text.split('\n')
|
|
lines = map(lambda line, prefix=prefix: prefix + line, lines)
|
|
if lines: lines[-1] = lines[-1].rstrip()
|
|
return '\n'.join(lines)
|
|
|
|
def section(self, title, contents):
|
|
"""Format a section with a given heading."""
|
|
clean_contents = self.indent(contents).rstrip()
|
|
return self.bold(title) + '\n' + clean_contents + '\n\n'
|
|
|
|
# ---------------------------------------------- type-specific routines
|
|
|
|
def formattree(self, tree, modname, parent=None, prefix=''):
|
|
"""Render in text a class tree as returned by inspect.getclasstree()."""
|
|
result = ''
|
|
for entry in tree:
|
|
if type(entry) is type(()):
|
|
c, bases = entry
|
|
result = result + prefix + classname(c, modname)
|
|
if bases and bases != (parent,):
|
|
parents = map(lambda c, m=modname: classname(c, m), bases)
|
|
result = result + '(%s)' % ', '.join(parents)
|
|
result = result + '\n'
|
|
elif type(entry) is type([]):
|
|
result = result + self.formattree(
|
|
entry, modname, c, prefix + ' ')
|
|
return result
|
|
|
|
def docmodule(self, object, name=None, mod=None):
|
|
"""Produce text documentation for a given module object."""
|
|
name = object.__name__ # ignore the passed-in name
|
|
synop, desc = splitdoc(getdoc(object))
|
|
result = self.section('NAME', name + (synop and ' - ' + synop))
|
|
|
|
try:
|
|
all = object.__all__
|
|
except AttributeError:
|
|
all = None
|
|
|
|
try:
|
|
file = inspect.getabsfile(object)
|
|
except TypeError:
|
|
file = '(built-in)'
|
|
result = result + self.section('FILE', file)
|
|
|
|
docloc = self.getdocloc(object)
|
|
if docloc is not None:
|
|
result = result + self.section('MODULE DOCS', docloc)
|
|
|
|
if desc:
|
|
result = result + self.section('DESCRIPTION', desc)
|
|
|
|
classes = []
|
|
for key, value in inspect.getmembers(object, inspect.isclass):
|
|
# if __all__ exists, believe it. Otherwise use old heuristic.
|
|
if (all is not None
|
|
or (inspect.getmodule(value) or object) is object):
|
|
if visiblename(key, all):
|
|
classes.append((key, value))
|
|
funcs = []
|
|
for key, value in inspect.getmembers(object, inspect.isroutine):
|
|
# if __all__ exists, believe it. Otherwise use old heuristic.
|
|
if (all is not None or
|
|
inspect.isbuiltin(value) or inspect.getmodule(value) is object):
|
|
if visiblename(key, all):
|
|
funcs.append((key, value))
|
|
data = []
|
|
for key, value in inspect.getmembers(object, isdata):
|
|
if visiblename(key, all):
|
|
data.append((key, value))
|
|
|
|
if hasattr(object, '__path__'):
|
|
modpkgs = []
|
|
for importer, modname, ispkg in pkgutil.iter_modules(object.__path__):
|
|
if ispkg:
|
|
modpkgs.append(modname + ' (package)')
|
|
else:
|
|
modpkgs.append(modname)
|
|
|
|
modpkgs.sort()
|
|
result = result + self.section(
|
|
'PACKAGE CONTENTS', '\n'.join(modpkgs))
|
|
|
|
if classes:
|
|
classlist = map(lambda (key, value): value, classes)
|
|
contents = [self.formattree(
|
|
inspect.getclasstree(classlist, 1), name)]
|
|
for key, value in classes:
|
|
contents.append(self.document(value, key, name))
|
|
result = result + self.section('CLASSES', '\n'.join(contents))
|
|
|
|
if funcs:
|
|
contents = []
|
|
for key, value in funcs:
|
|
contents.append(self.document(value, key, name))
|
|
result = result + self.section('FUNCTIONS', '\n'.join(contents))
|
|
|
|
if data:
|
|
contents = []
|
|
for key, value in data:
|
|
contents.append(self.docother(value, key, name, maxlen=70))
|
|
result = result + self.section('DATA', '\n'.join(contents))
|
|
|
|
if hasattr(object, '__version__'):
|
|
version = str(object.__version__)
|
|
if version[:11] == '$' + 'Revision: ' and version[-1:] == '$':
|
|
version = version[11:-1].strip()
|
|
result = result + self.section('VERSION', version)
|
|
if hasattr(object, '__date__'):
|
|
result = result + self.section('DATE', str(object.__date__))
|
|
if hasattr(object, '__author__'):
|
|
result = result + self.section('AUTHOR', str(object.__author__))
|
|
if hasattr(object, '__credits__'):
|
|
result = result + self.section('CREDITS', str(object.__credits__))
|
|
return result
|
|
|
|
def docclass(self, object, name=None, mod=None):
|
|
"""Produce text documentation for a given class object."""
|
|
realname = object.__name__
|
|
name = name or realname
|
|
bases = object.__bases__
|
|
|
|
def makename(c, m=object.__module__):
|
|
return classname(c, m)
|
|
|
|
if name == realname:
|
|
title = 'class ' + self.bold(realname)
|
|
else:
|
|
title = self.bold(name) + ' = class ' + realname
|
|
if bases:
|
|
parents = map(makename, bases)
|
|
title = title + '(%s)' % ', '.join(parents)
|
|
|
|
doc = getdoc(object)
|
|
contents = doc and [doc + '\n'] or []
|
|
push = contents.append
|
|
|
|
# List the mro, if non-trivial.
|
|
mro = deque(inspect.getmro(object))
|
|
if len(mro) > 2:
|
|
push("Method resolution order:")
|
|
for base in mro:
|
|
push(' ' + makename(base))
|
|
push('')
|
|
|
|
# Cute little class to pump out a horizontal rule between sections.
|
|
class HorizontalRule:
|
|
def __init__(self):
|
|
self.needone = 0
|
|
def maybe(self):
|
|
if self.needone:
|
|
push('-' * 70)
|
|
self.needone = 1
|
|
hr = HorizontalRule()
|
|
|
|
def spill(msg, attrs, predicate):
|
|
ok, attrs = _split_list(attrs, predicate)
|
|
if ok:
|
|
hr.maybe()
|
|
push(msg)
|
|
for name, kind, homecls, value in ok:
|
|
push(self.document(getattr(object, name),
|
|
name, mod, object))
|
|
return attrs
|
|
|
|
def spilldescriptors(msg, attrs, predicate):
|
|
ok, attrs = _split_list(attrs, predicate)
|
|
if ok:
|
|
hr.maybe()
|
|
push(msg)
|
|
for name, kind, homecls, value in ok:
|
|
push(self._docdescriptor(name, value, mod))
|
|
return attrs
|
|
|
|
def spilldata(msg, attrs, predicate):
|
|
ok, attrs = _split_list(attrs, predicate)
|
|
if ok:
|
|
hr.maybe()
|
|
push(msg)
|
|
for name, kind, homecls, value in ok:
|
|
if callable(value) or inspect.isdatadescriptor(value):
|
|
doc = getdoc(value)
|
|
else:
|
|
doc = None
|
|
push(self.docother(getattr(object, name),
|
|
name, mod, maxlen=70, doc=doc) + '\n')
|
|
return attrs
|
|
|
|
attrs = filter(lambda (name, kind, cls, value): visiblename(name),
|
|
classify_class_attrs(object))
|
|
while attrs:
|
|
if mro:
|
|
thisclass = mro.popleft()
|
|
else:
|
|
thisclass = attrs[0][2]
|
|
attrs, inherited = _split_list(attrs, lambda t: t[2] is thisclass)
|
|
|
|
if thisclass is __builtin__.object:
|
|
attrs = inherited
|
|
continue
|
|
elif thisclass is object:
|
|
tag = "defined here"
|
|
else:
|
|
tag = "inherited from %s" % classname(thisclass,
|
|
object.__module__)
|
|
filter(lambda t: not t[0].startswith('_'), attrs)
|
|
|
|
# Sort attrs by name.
|
|
attrs.sort()
|
|
|
|
# Pump out the attrs, segregated by kind.
|
|
attrs = spill("Methods %s:\n" % tag, attrs,
|
|
lambda t: t[1] == 'method')
|
|
attrs = spill("Class methods %s:\n" % tag, attrs,
|
|
lambda t: t[1] == 'class method')
|
|
attrs = spill("Static methods %s:\n" % tag, attrs,
|
|
lambda t: t[1] == 'static method')
|
|
attrs = spilldescriptors("Data descriptors %s:\n" % tag, attrs,
|
|
lambda t: t[1] == 'data descriptor')
|
|
attrs = spilldata("Data and other attributes %s:\n" % tag, attrs,
|
|
lambda t: t[1] == 'data')
|
|
assert attrs == []
|
|
attrs = inherited
|
|
|
|
contents = '\n'.join(contents)
|
|
if not contents:
|
|
return title + '\n'
|
|
return title + '\n' + self.indent(contents.rstrip(), ' | ') + '\n'
|
|
|
|
def formatvalue(self, object):
|
|
"""Format an argument default value as text."""
|
|
return '=' + self.repr(object)
|
|
|
|
def docroutine(self, object, name=None, mod=None, cl=None):
|
|
"""Produce text documentation for a function or method object."""
|
|
realname = object.__name__
|
|
name = name or realname
|
|
note = ''
|
|
skipdocs = 0
|
|
if inspect.ismethod(object):
|
|
imclass = object.im_class
|
|
if cl:
|
|
if imclass is not cl:
|
|
note = ' from ' + classname(imclass, mod)
|
|
else:
|
|
if object.im_self is not None:
|
|
note = ' method of %s instance' % classname(
|
|
object.im_self.__class__, mod)
|
|
else:
|
|
note = ' unbound %s method' % classname(imclass,mod)
|
|
object = object.im_func
|
|
|
|
if name == realname:
|
|
title = self.bold(realname)
|
|
else:
|
|
if (cl and realname in cl.__dict__ and
|
|
cl.__dict__[realname] is object):
|
|
skipdocs = 1
|
|
title = self.bold(name) + ' = ' + realname
|
|
if inspect.isfunction(object):
|
|
args, varargs, varkw, defaults, kwonlyargs, kwdefaults, ann = \
|
|
inspect.getfullargspec(object)
|
|
argspec = inspect.formatargspec(
|
|
args, varargs, varkw, defaults, kwonlyargs, kwdefaults, ann,
|
|
formatvalue=self.formatvalue,
|
|
formatannotation=inspect.formatannotationrelativeto(object))
|
|
if realname == '<lambda>':
|
|
title = self.bold(name) + ' lambda '
|
|
# XXX lambda's won't usually have func_annotations['return']
|
|
# since the syntax doesn't support but it is possible.
|
|
# So removing parentheses isn't truly safe.
|
|
argspec = argspec[1:-1] # remove parentheses
|
|
else:
|
|
argspec = '(...)'
|
|
decl = title + argspec + note
|
|
|
|
if skipdocs:
|
|
return decl + '\n'
|
|
else:
|
|
doc = getdoc(object) or ''
|
|
return decl + '\n' + (doc and self.indent(doc).rstrip() + '\n')
|
|
|
|
def _docdescriptor(self, name, value, mod):
|
|
results = []
|
|
push = results.append
|
|
|
|
if name:
|
|
push(self.bold(name))
|
|
push('\n')
|
|
doc = getdoc(value) or ''
|
|
if doc:
|
|
push(self.indent(doc))
|
|
push('\n')
|
|
return ''.join(results)
|
|
|
|
def docproperty(self, object, name=None, mod=None, cl=None):
|
|
"""Produce text documentation for a property."""
|
|
return self._docdescriptor(name, object, mod)
|
|
|
|
def docdata(self, object, name=None, mod=None, cl=None):
|
|
"""Produce text documentation for a data descriptor."""
|
|
return self._docdescriptor(name, object, mod)
|
|
|
|
def docother(self, object, name=None, mod=None, parent=None, maxlen=None, doc=None):
|
|
"""Produce text documentation for a data object."""
|
|
repr = self.repr(object)
|
|
if maxlen:
|
|
line = (name and name + ' = ' or '') + repr
|
|
chop = maxlen - len(line)
|
|
if chop < 0: repr = repr[:chop] + '...'
|
|
line = (name and self.bold(name) + ' = ' or '') + repr
|
|
if doc is not None:
|
|
line += '\n' + self.indent(str(doc))
|
|
return line
|
|
|
|
# --------------------------------------------------------- user interfaces
|
|
|
|
def pager(text):
|
|
"""The first time this is called, determine what kind of pager to use."""
|
|
global pager
|
|
pager = getpager()
|
|
pager(text)
|
|
|
|
def getpager():
|
|
"""Decide what method to use for paging through text."""
|
|
if type(sys.stdout) is not types.FileType:
|
|
return plainpager
|
|
if not sys.stdin.isatty() or not sys.stdout.isatty():
|
|
return plainpager
|
|
if 'PAGER' in os.environ:
|
|
if sys.platform == 'win32': # pipes completely broken in Windows
|
|
return lambda text: tempfilepager(plain(text), os.environ['PAGER'])
|
|
elif os.environ.get('TERM') in ('dumb', 'emacs'):
|
|
return lambda text: pipepager(plain(text), os.environ['PAGER'])
|
|
else:
|
|
return lambda text: pipepager(text, os.environ['PAGER'])
|
|
if os.environ.get('TERM') in ('dumb', 'emacs'):
|
|
return plainpager
|
|
if sys.platform == 'win32' or sys.platform.startswith('os2'):
|
|
return lambda text: tempfilepager(plain(text), 'more <')
|
|
if hasattr(os, 'system') and os.system('(less) 2>/dev/null') == 0:
|
|
return lambda text: pipepager(text, 'less')
|
|
|
|
import tempfile
|
|
(fd, filename) = tempfile.mkstemp()
|
|
os.close(fd)
|
|
try:
|
|
if hasattr(os, 'system') and os.system('more %s' % filename) == 0:
|
|
return lambda text: pipepager(text, 'more')
|
|
else:
|
|
return ttypager
|
|
finally:
|
|
os.unlink(filename)
|
|
|
|
def plain(text):
|
|
"""Remove boldface formatting from text."""
|
|
return re.sub('.\b', '', text)
|
|
|
|
def pipepager(text, cmd):
|
|
"""Page through text by feeding it to another program."""
|
|
pipe = os.popen(cmd, 'w')
|
|
try:
|
|
pipe.write(text)
|
|
pipe.close()
|
|
except IOError:
|
|
pass # Ignore broken pipes caused by quitting the pager program.
|
|
|
|
def tempfilepager(text, cmd):
|
|
"""Page through text by invoking a program on a temporary file."""
|
|
import tempfile
|
|
filename = tempfile.mktemp()
|
|
file = open(filename, 'w')
|
|
file.write(text)
|
|
file.close()
|
|
try:
|
|
os.system(cmd + ' ' + filename)
|
|
finally:
|
|
os.unlink(filename)
|
|
|
|
def ttypager(text):
|
|
"""Page through text on a text terminal."""
|
|
lines = plain(text).split('\n')
|
|
try:
|
|
import tty
|
|
fd = sys.stdin.fileno()
|
|
old = tty.tcgetattr(fd)
|
|
tty.setcbreak(fd)
|
|
getchar = lambda: sys.stdin.read(1)
|
|
except (ImportError, AttributeError):
|
|
tty = None
|
|
getchar = lambda: sys.stdin.readline()[:-1][:1]
|
|
|
|
try:
|
|
r = inc = os.environ.get('LINES', 25) - 1
|
|
sys.stdout.write('\n'.join(lines[:inc]) + '\n')
|
|
while lines[r:]:
|
|
sys.stdout.write('-- more --')
|
|
sys.stdout.flush()
|
|
c = getchar()
|
|
|
|
if c in ('q', 'Q'):
|
|
sys.stdout.write('\r \r')
|
|
break
|
|
elif c in ('\r', '\n'):
|
|
sys.stdout.write('\r \r' + lines[r] + '\n')
|
|
r = r + 1
|
|
continue
|
|
if c in ('b', 'B', '\x1b'):
|
|
r = r - inc - inc
|
|
if r < 0: r = 0
|
|
sys.stdout.write('\n' + '\n'.join(lines[r:r+inc]) + '\n')
|
|
r = r + inc
|
|
|
|
finally:
|
|
if tty:
|
|
tty.tcsetattr(fd, tty.TCSAFLUSH, old)
|
|
|
|
def plainpager(text):
|
|
"""Simply print unformatted text. This is the ultimate fallback."""
|
|
sys.stdout.write(plain(text))
|
|
|
|
def describe(thing):
|
|
"""Produce a short description of the given thing."""
|
|
if inspect.ismodule(thing):
|
|
if thing.__name__ in sys.builtin_module_names:
|
|
return 'built-in module ' + thing.__name__
|
|
if hasattr(thing, '__path__'):
|
|
return 'package ' + thing.__name__
|
|
else:
|
|
return 'module ' + thing.__name__
|
|
if inspect.isbuiltin(thing):
|
|
return 'built-in function ' + thing.__name__
|
|
if inspect.isgetsetdescriptor(thing):
|
|
return 'getset descriptor %s.%s.%s' % (
|
|
thing.__objclass__.__module__, thing.__objclass__.__name__,
|
|
thing.__name__)
|
|
if inspect.ismemberdescriptor(thing):
|
|
return 'member descriptor %s.%s.%s' % (
|
|
thing.__objclass__.__module__, thing.__objclass__.__name__,
|
|
thing.__name__)
|
|
if inspect.isclass(thing):
|
|
return 'class ' + thing.__name__
|
|
if inspect.isfunction(thing):
|
|
return 'function ' + thing.__name__
|
|
if inspect.ismethod(thing):
|
|
return 'method ' + thing.__name__
|
|
return type(thing).__name__
|
|
|
|
def locate(path, forceload=0):
|
|
"""Locate an object by name or dotted path, importing as necessary."""
|
|
parts = [part for part in path.split('.') if part]
|
|
module, n = None, 0
|
|
while n < len(parts):
|
|
nextmodule = safeimport('.'.join(parts[:n+1]), forceload)
|
|
if nextmodule: module, n = nextmodule, n + 1
|
|
else: break
|
|
if module:
|
|
object = module
|
|
for part in parts[n:]:
|
|
try: object = getattr(object, part)
|
|
except AttributeError: return None
|
|
return object
|
|
else:
|
|
if hasattr(__builtin__, path):
|
|
return getattr(__builtin__, path)
|
|
|
|
# --------------------------------------- interactive interpreter interface
|
|
|
|
text = TextDoc()
|
|
html = HTMLDoc()
|
|
|
|
def resolve(thing, forceload=0):
|
|
"""Given an object or a path to an object, get the object and its name."""
|
|
if isinstance(thing, str):
|
|
object = locate(thing, forceload)
|
|
if not object:
|
|
raise ImportError, 'no Python documentation found for %r' % thing
|
|
return object, thing
|
|
else:
|
|
return thing, getattr(thing, '__name__', None)
|
|
|
|
def render_doc(thing, title='Python Library Documentation: %s', forceload=0):
|
|
"""Render text documentation, given an object or a path to an object."""
|
|
object, name = resolve(thing, forceload)
|
|
desc = describe(object)
|
|
module = inspect.getmodule(object)
|
|
if name and '.' in name:
|
|
desc += ' in ' + name[:name.rfind('.')]
|
|
elif module and module is not object:
|
|
desc += ' in module ' + module.__name__
|
|
elif not (inspect.ismodule(object) or
|
|
inspect.isclass(object) or
|
|
inspect.isroutine(object) or
|
|
inspect.isgetsetdescriptor(object) or
|
|
inspect.ismemberdescriptor(object) or
|
|
isinstance(object, property)):
|
|
# If the passed object is a piece of data or an instance,
|
|
# document its available methods instead of its value.
|
|
object = type(object)
|
|
desc += ' object'
|
|
return title % desc + '\n\n' + text.document(object, name)
|
|
|
|
def doc(thing, title='Python Library Documentation: %s', forceload=0):
|
|
"""Display text documentation, given an object or a path to an object."""
|
|
try:
|
|
object, name = resolve(thing, forceload)
|
|
desc = describe(object)
|
|
module = inspect.getmodule(object)
|
|
if name and '.' in name:
|
|
desc += ' in ' + name[:name.rfind('.')]
|
|
elif module and module is not object:
|
|
desc += ' in module ' + module.__name__
|
|
elif not (inspect.ismodule(object) or
|
|
inspect.isclass(object) or
|
|
inspect.isroutine(object) or
|
|
inspect.isgetsetdescriptor(object) or
|
|
inspect.ismemberdescriptor(object) or
|
|
isinstance(object, property)):
|
|
# If the passed object is a piece of data or an instance,
|
|
# document its available methods instead of its value.
|
|
object = type(object)
|
|
desc += ' object'
|
|
pager(render_doc(thing, title, forceload))
|
|
except (ImportError, ErrorDuringImport) as value:
|
|
print(value)
|
|
|
|
def writedoc(thing, forceload=0):
|
|
"""Write HTML documentation to a file in the current directory."""
|
|
try:
|
|
object, name = resolve(thing, forceload)
|
|
page = html.page(describe(object), html.document(object, name))
|
|
file = open(name + '.html', 'w')
|
|
file.write(page)
|
|
file.close()
|
|
print('wrote', name + '.html')
|
|
except (ImportError, ErrorDuringImport) as value:
|
|
print(value)
|
|
|
|
def writedocs(dir, pkgpath='', done=None):
|
|
"""Write out HTML documentation for all modules in a directory tree."""
|
|
if done is None: done = {}
|
|
for importer, modname, ispkg in pkgutil.walk_packages([dir], pkgpath):
|
|
writedoc(modname)
|
|
return
|
|
|
|
def raw_input(prompt):
|
|
sys.stdout.write(prompt)
|
|
sys.stdout.flush()
|
|
return sys.stdin.readline()
|
|
|
|
class Helper:
|
|
keywords = {
|
|
'and': 'BOOLEAN',
|
|
'as': 'with',
|
|
'assert': ('ref/assert', ''),
|
|
'break': ('ref/break', 'while for'),
|
|
'class': ('ref/class', 'CLASSES SPECIALMETHODS'),
|
|
'continue': ('ref/continue', 'while for'),
|
|
'def': ('ref/function', ''),
|
|
'del': ('ref/del', 'BASICMETHODS'),
|
|
'elif': 'if',
|
|
'else': ('ref/if', 'while for'),
|
|
'except': 'try',
|
|
'exec': ('ref/exec', ''),
|
|
'finally': 'try',
|
|
'for': ('ref/for', 'break continue while'),
|
|
'from': 'import',
|
|
'global': ('ref/global', 'NAMESPACES'),
|
|
'if': ('ref/if', 'TRUTHVALUE'),
|
|
'import': ('ref/import', 'MODULES'),
|
|
'in': ('ref/comparisons', 'SEQUENCEMETHODS2'),
|
|
'is': 'COMPARISON',
|
|
'lambda': ('ref/lambdas', 'FUNCTIONS'),
|
|
'not': 'BOOLEAN',
|
|
'or': 'BOOLEAN',
|
|
'pass': ('ref/pass', ''),
|
|
'print': ('ref/print', ''),
|
|
'raise': ('ref/raise', 'EXCEPTIONS'),
|
|
'return': ('ref/return', 'FUNCTIONS'),
|
|
'try': ('ref/try', 'EXCEPTIONS'),
|
|
'while': ('ref/while', 'break continue if TRUTHVALUE'),
|
|
'with': ('ref/with', 'CONTEXTMANAGERS EXCEPTIONS yield'),
|
|
'yield': ('ref/yield', ''),
|
|
}
|
|
|
|
topics = {
|
|
'TYPES': ('ref/types', 'STRINGS UNICODE NUMBERS SEQUENCES MAPPINGS FUNCTIONS CLASSES MODULES FILES inspect'),
|
|
'STRINGS': ('ref/strings', 'str UNICODE SEQUENCES STRINGMETHODS FORMATTING TYPES'),
|
|
'STRINGMETHODS': ('lib/string-methods', 'STRINGS FORMATTING'),
|
|
'FORMATTING': ('lib/typesseq-strings', 'OPERATORS'),
|
|
'UNICODE': ('ref/strings', 'encodings unicode SEQUENCES STRINGMETHODS FORMATTING TYPES'),
|
|
'NUMBERS': ('ref/numbers', 'INTEGER FLOAT COMPLEX TYPES'),
|
|
'INTEGER': ('ref/integers', 'int range'),
|
|
'FLOAT': ('ref/floating', 'float math'),
|
|
'COMPLEX': ('ref/imaginary', 'complex cmath'),
|
|
'SEQUENCES': ('lib/typesseq', 'STRINGMETHODS FORMATTING xrange LISTS'),
|
|
'MAPPINGS': 'DICTIONARIES',
|
|
'FUNCTIONS': ('lib/typesfunctions', 'def TYPES'),
|
|
'METHODS': ('lib/typesmethods', 'class def CLASSES TYPES'),
|
|
'CODEOBJECTS': ('lib/bltin-code-objects', 'compile FUNCTIONS TYPES'),
|
|
'TYPEOBJECTS': ('lib/bltin-type-objects', 'types TYPES'),
|
|
'FRAMEOBJECTS': 'TYPES',
|
|
'TRACEBACKS': 'TYPES',
|
|
'NONE': ('lib/bltin-null-object', ''),
|
|
'ELLIPSIS': ('lib/bltin-ellipsis-object', 'SLICINGS'),
|
|
'FILES': ('lib/bltin-file-objects', ''),
|
|
'SPECIALATTRIBUTES': ('lib/specialattrs', ''),
|
|
'CLASSES': ('ref/types', 'class SPECIALMETHODS PRIVATENAMES'),
|
|
'MODULES': ('lib/typesmodules', 'import'),
|
|
'PACKAGES': 'import',
|
|
'EXPRESSIONS': ('ref/summary', 'lambda or and not in is BOOLEAN COMPARISON BITWISE SHIFTING BINARY FORMATTING POWER UNARY ATTRIBUTES SUBSCRIPTS SLICINGS CALLS TUPLES LISTS DICTIONARIES'),
|
|
'OPERATORS': 'EXPRESSIONS',
|
|
'PRECEDENCE': 'EXPRESSIONS',
|
|
'OBJECTS': ('ref/objects', 'TYPES'),
|
|
'SPECIALMETHODS': ('ref/specialnames', 'BASICMETHODS ATTRIBUTEMETHODS CALLABLEMETHODS SEQUENCEMETHODS1 MAPPINGMETHODS SEQUENCEMETHODS2 NUMBERMETHODS CLASSES'),
|
|
'BASICMETHODS': ('ref/customization', 'cmp hash repr str SPECIALMETHODS'),
|
|
'ATTRIBUTEMETHODS': ('ref/attribute-access', 'ATTRIBUTES SPECIALMETHODS'),
|
|
'CALLABLEMETHODS': ('ref/callable-types', 'CALLS SPECIALMETHODS'),
|
|
'SEQUENCEMETHODS1': ('ref/sequence-types', 'SEQUENCES SEQUENCEMETHODS2 SPECIALMETHODS'),
|
|
'SEQUENCEMETHODS2': ('ref/sequence-methods', 'SEQUENCES SEQUENCEMETHODS1 SPECIALMETHODS'),
|
|
'MAPPINGMETHODS': ('ref/sequence-types', 'MAPPINGS SPECIALMETHODS'),
|
|
'NUMBERMETHODS': ('ref/numeric-types', 'NUMBERS AUGMENTEDASSIGNMENT SPECIALMETHODS'),
|
|
'EXECUTION': ('ref/execmodel', 'NAMESPACES DYNAMICFEATURES EXCEPTIONS'),
|
|
'NAMESPACES': ('ref/naming', 'global ASSIGNMENT DELETION DYNAMICFEATURES'),
|
|
'DYNAMICFEATURES': ('ref/dynamic-features', ''),
|
|
'SCOPING': 'NAMESPACES',
|
|
'FRAMES': 'NAMESPACES',
|
|
'EXCEPTIONS': ('ref/exceptions', 'try except finally raise'),
|
|
'COERCIONS': ('ref/coercion-rules','CONVERSIONS'),
|
|
'CONVERSIONS': ('ref/conversions', 'COERCIONS'),
|
|
'IDENTIFIERS': ('ref/identifiers', 'keywords SPECIALIDENTIFIERS'),
|
|
'SPECIALIDENTIFIERS': ('ref/id-classes', ''),
|
|
'PRIVATENAMES': ('ref/atom-identifiers', ''),
|
|
'LITERALS': ('ref/atom-literals', 'STRINGS NUMBERS TUPLELITERALS LISTLITERALS DICTIONARYLITERALS'),
|
|
'TUPLES': 'SEQUENCES',
|
|
'TUPLELITERALS': ('ref/exprlists', 'TUPLES LITERALS'),
|
|
'LISTS': ('lib/typesseq-mutable', 'LISTLITERALS'),
|
|
'LISTLITERALS': ('ref/lists', 'LISTS LITERALS'),
|
|
'DICTIONARIES': ('lib/typesmapping', 'DICTIONARYLITERALS'),
|
|
'DICTIONARYLITERALS': ('ref/dict', 'DICTIONARIES LITERALS'),
|
|
'ATTRIBUTES': ('ref/attribute-references', 'getattr hasattr setattr ATTRIBUTEMETHODS'),
|
|
'SUBSCRIPTS': ('ref/subscriptions', 'SEQUENCEMETHODS1'),
|
|
'SLICINGS': ('ref/slicings', 'SEQUENCEMETHODS2'),
|
|
'CALLS': ('ref/calls', 'EXPRESSIONS'),
|
|
'POWER': ('ref/power', 'EXPRESSIONS'),
|
|
'UNARY': ('ref/unary', 'EXPRESSIONS'),
|
|
'BINARY': ('ref/binary', 'EXPRESSIONS'),
|
|
'SHIFTING': ('ref/shifting', 'EXPRESSIONS'),
|
|
'BITWISE': ('ref/bitwise', 'EXPRESSIONS'),
|
|
'COMPARISON': ('ref/comparisons', 'EXPRESSIONS BASICMETHODS'),
|
|
'BOOLEAN': ('ref/Booleans', 'EXPRESSIONS TRUTHVALUE'),
|
|
'ASSERTION': 'assert',
|
|
'ASSIGNMENT': ('ref/assignment', 'AUGMENTEDASSIGNMENT'),
|
|
'AUGMENTEDASSIGNMENT': ('ref/augassign', 'NUMBERMETHODS'),
|
|
'DELETION': 'del',
|
|
'PRINTING': 'print',
|
|
'RETURNING': 'return',
|
|
'IMPORTING': 'import',
|
|
'CONDITIONAL': 'if',
|
|
'LOOPING': ('ref/compound', 'for while break continue'),
|
|
'TRUTHVALUE': ('lib/truth', 'if while and or not BASICMETHODS'),
|
|
'DEBUGGING': ('lib/module-pdb', 'pdb'),
|
|
'CONTEXTMANAGERS': ('ref/context-managers', 'with'),
|
|
}
|
|
|
|
def __init__(self, input, output):
|
|
self.input = input
|
|
self.output = output
|
|
self.docdir = None
|
|
execdir = os.path.dirname(sys.executable)
|
|
homedir = os.environ.get('PYTHONHOME')
|
|
join = os.path.join
|
|
for dir in [os.environ.get('PYTHONDOCS'),
|
|
homedir and os.path.join(homedir, 'doc'),
|
|
join(execdir, 'doc'), # for Windows
|
|
join(sys.prefix, 'doc/python-docs-' + sys.version.split()[0]),
|
|
join(sys.prefix, 'doc/python-' + sys.version.split()[0]),
|
|
join(sys.prefix, 'doc/python-docs-' + sys.version[:3]),
|
|
join(sys.prefix, 'doc/python-' + sys.version[:3]),
|
|
join(sys.prefix, 'Resources/English.lproj/Documentation')]:
|
|
if dir and os.path.isdir(join(dir, 'lib')):
|
|
self.docdir = dir
|
|
break
|
|
if dir and os.path.isdir(join(dir, 'html', 'lib')):
|
|
self.docdir = join(dir, 'html')
|
|
break
|
|
|
|
def __repr__(self):
|
|
if inspect.stack()[1][3] == '?':
|
|
self()
|
|
return ''
|
|
return '<pydoc.Helper instance>'
|
|
|
|
def __call__(self, request=None):
|
|
if request is not None:
|
|
self.help(request)
|
|
else:
|
|
self.intro()
|
|
self.interact()
|
|
self.output.write('''
|
|
You are now leaving help and returning to the Python interpreter.
|
|
If you want to ask for help on a particular object directly from the
|
|
interpreter, you can type "help(object)". Executing "help('string')"
|
|
has the same effect as typing a particular string at the help> prompt.
|
|
''')
|
|
|
|
def interact(self):
|
|
self.output.write('\n')
|
|
while True:
|
|
try:
|
|
request = self.getline('help> ')
|
|
if not request: break
|
|
except (KeyboardInterrupt, EOFError):
|
|
break
|
|
request = replace(request, '"', '', "'", '').strip()
|
|
if request.lower() in ('q', 'quit'): break
|
|
self.help(request)
|
|
|
|
def getline(self, prompt):
|
|
"""Read one line, using raw_input when available."""
|
|
if self.input is sys.stdin:
|
|
return raw_input(prompt)
|
|
else:
|
|
self.output.write(prompt)
|
|
self.output.flush()
|
|
return self.input.readline()
|
|
|
|
def help(self, request):
|
|
if type(request) is type(''):
|
|
if request == 'help': self.intro()
|
|
elif request == 'keywords': self.listkeywords()
|
|
elif request == 'topics': self.listtopics()
|
|
elif request == 'modules': self.listmodules()
|
|
elif request[:8] == 'modules ':
|
|
self.listmodules(request.split()[1])
|
|
elif request in self.keywords: self.showtopic(request)
|
|
elif request in self.topics: self.showtopic(request)
|
|
elif request: doc(request, 'Help on %s:')
|
|
elif isinstance(request, Helper): self()
|
|
else: doc(request, 'Help on %s:')
|
|
self.output.write('\n')
|
|
|
|
def intro(self):
|
|
self.output.write('''
|
|
Welcome to Python %s! This is the online help utility.
|
|
|
|
If this is your first time using Python, you should definitely check out
|
|
the tutorial on the Internet at http://www.python.org/doc/tut/.
|
|
|
|
Enter the name of any module, keyword, or topic to get help on writing
|
|
Python programs and using Python modules. To quit this help utility and
|
|
return to the interpreter, just type "quit".
|
|
|
|
To get a list of available modules, keywords, or topics, type "modules",
|
|
"keywords", or "topics". Each module also comes with a one-line summary
|
|
of what it does; to list the modules whose summaries contain a given word
|
|
such as "spam", type "modules spam".
|
|
''' % sys.version[:3])
|
|
|
|
def list(self, items, columns=4, width=80):
|
|
items = items[:]
|
|
items.sort()
|
|
colw = width / columns
|
|
rows = (len(items) + columns - 1) / columns
|
|
for row in range(rows):
|
|
for col in range(columns):
|
|
i = col * rows + row
|
|
if i < len(items):
|
|
self.output.write(items[i])
|
|
if col < columns - 1:
|
|
self.output.write(' ' + ' ' * (colw-1 - len(items[i])))
|
|
self.output.write('\n')
|
|
|
|
def listkeywords(self):
|
|
self.output.write('''
|
|
Here is a list of the Python keywords. Enter any keyword to get more help.
|
|
|
|
''')
|
|
self.list(self.keywords.keys())
|
|
|
|
def listtopics(self):
|
|
self.output.write('''
|
|
Here is a list of available topics. Enter any topic name to get more help.
|
|
|
|
''')
|
|
self.list(self.topics.keys())
|
|
|
|
def showtopic(self, topic):
|
|
if not self.docdir:
|
|
self.output.write('''
|
|
Sorry, topic and keyword documentation is not available because the Python
|
|
HTML documentation files could not be found. If you have installed them,
|
|
please set the environment variable PYTHONDOCS to indicate their location.
|
|
|
|
On the Microsoft Windows operating system, the files can be built by
|
|
running "hh -decompile . PythonNN.chm" in the C:\PythonNN\Doc> directory.
|
|
''')
|
|
return
|
|
target = self.topics.get(topic, self.keywords.get(topic))
|
|
if not target:
|
|
self.output.write('no documentation found for %s\n' % repr(topic))
|
|
return
|
|
if type(target) is type(''):
|
|
return self.showtopic(target)
|
|
|
|
filename, xrefs = target
|
|
filename = self.docdir + '/' + filename + '.html'
|
|
try:
|
|
file = open(filename)
|
|
except:
|
|
self.output.write('could not read docs from %s\n' % filename)
|
|
return
|
|
|
|
divpat = re.compile('<div[^>]*navigat.*?</div.*?>', re.I | re.S)
|
|
addrpat = re.compile('<address.*?>.*?</address.*?>', re.I | re.S)
|
|
document = re.sub(addrpat, '', re.sub(divpat, '', file.read()))
|
|
file.close()
|
|
|
|
import htmllib, formatter, StringIO
|
|
buffer = StringIO.StringIO()
|
|
parser = htmllib.HTMLParser(
|
|
formatter.AbstractFormatter(formatter.DumbWriter(buffer)))
|
|
parser.start_table = parser.do_p
|
|
parser.end_table = lambda parser=parser: parser.do_p({})
|
|
parser.start_tr = parser.do_br
|
|
parser.start_td = parser.start_th = lambda a, b=buffer: b.write('\t')
|
|
parser.feed(document)
|
|
buffer = replace(buffer.getvalue(), '\xa0', ' ', '\n', '\n ')
|
|
pager(' ' + buffer.strip() + '\n')
|
|
if xrefs:
|
|
buffer = StringIO.StringIO()
|
|
formatter.DumbWriter(buffer).send_flowing_data(
|
|
'Related help topics: ' + ', '.join(xrefs.split()) + '\n')
|
|
self.output.write('\n%s\n' % buffer.getvalue())
|
|
|
|
def listmodules(self, key=''):
|
|
if key:
|
|
self.output.write('''
|
|
Here is a list of matching modules. Enter any module name to get more help.
|
|
|
|
''')
|
|
apropos(key)
|
|
else:
|
|
self.output.write('''
|
|
Please wait a moment while I gather a list of all available modules...
|
|
|
|
''')
|
|
modules = {}
|
|
def callback(path, modname, desc, modules=modules):
|
|
if modname and modname[-9:] == '.__init__':
|
|
modname = modname[:-9] + ' (package)'
|
|
if modname.find('.') < 0:
|
|
modules[modname] = 1
|
|
ModuleScanner().run(callback)
|
|
self.list(modules.keys())
|
|
self.output.write('''
|
|
Enter any module name to get more help. Or, type "modules spam" to search
|
|
for modules whose descriptions contain the word "spam".
|
|
''')
|
|
|
|
help = Helper(sys.stdin, sys.stdout)
|
|
|
|
class Scanner:
|
|
"""A generic tree iterator."""
|
|
def __init__(self, roots, children, descendp):
|
|
self.roots = roots[:]
|
|
self.state = []
|
|
self.children = children
|
|
self.descendp = descendp
|
|
|
|
def next(self):
|
|
if not self.state:
|
|
if not self.roots:
|
|
return None
|
|
root = self.roots.pop(0)
|
|
self.state = [(root, self.children(root))]
|
|
node, children = self.state[-1]
|
|
if not children:
|
|
self.state.pop()
|
|
return self.next()
|
|
child = children.pop(0)
|
|
if self.descendp(child):
|
|
self.state.append((child, self.children(child)))
|
|
return child
|
|
|
|
|
|
class ModuleScanner:
|
|
"""An interruptible scanner that searches module synopses."""
|
|
|
|
def run(self, callback, key=None, completer=None):
|
|
if key: key = key.lower()
|
|
self.quit = False
|
|
seen = {}
|
|
|
|
for modname in sys.builtin_module_names:
|
|
if modname != '__main__':
|
|
seen[modname] = 1
|
|
if key is None:
|
|
callback(None, modname, '')
|
|
else:
|
|
name = __import__(modname).__doc__ or ''
|
|
desc = name.split('\n')[0]
|
|
name = modname + ' - ' + desc
|
|
if name.lower().find(key) >= 0:
|
|
callback(None, modname, desc)
|
|
|
|
for importer, modname, ispkg in pkgutil.walk_packages():
|
|
if self.quit:
|
|
break
|
|
if key is None:
|
|
callback(None, modname, '')
|
|
else:
|
|
loader = importer.find_module(modname)
|
|
if hasattr(loader,'get_source'):
|
|
import StringIO
|
|
desc = source_synopsis(
|
|
StringIO.StringIO(loader.get_source(modname))
|
|
) or ''
|
|
if hasattr(loader,'get_filename'):
|
|
path = loader.get_filename(modname)
|
|
else:
|
|
path = None
|
|
else:
|
|
module = loader.load_module(modname)
|
|
desc = (module.__doc__ or '').splitlines()[0]
|
|
path = getattr(module,'__file__',None)
|
|
name = modname + ' - ' + desc
|
|
if name.lower().find(key) >= 0:
|
|
callback(path, modname, desc)
|
|
|
|
if completer:
|
|
completer()
|
|
|
|
def apropos(key):
|
|
"""Print all the one-line module summaries that contain a substring."""
|
|
def callback(path, modname, desc):
|
|
if modname[-9:] == '.__init__':
|
|
modname = modname[:-9] + ' (package)'
|
|
print(modname, desc and '- ' + desc)
|
|
try: import warnings
|
|
except ImportError: pass
|
|
else: warnings.filterwarnings('ignore') # ignore problems during import
|
|
ModuleScanner().run(callback, key)
|
|
|
|
# --------------------------------------------------- web browser interface
|
|
|
|
def serve(port, callback=None, completer=None):
|
|
import BaseHTTPServer, mimetools, select
|
|
|
|
# Patch up mimetools.Message so it doesn't break if rfc822 is reloaded.
|
|
class Message(mimetools.Message):
|
|
def __init__(self, fp, seekable=1):
|
|
Message = self.__class__
|
|
Message.__bases__[0].__bases__[0].__init__(self, fp, seekable)
|
|
self.encodingheader = self.getheader('content-transfer-encoding')
|
|
self.typeheader = self.getheader('content-type')
|
|
self.parsetype()
|
|
self.parseplist()
|
|
|
|
class DocHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
|
def send_document(self, title, contents):
|
|
try:
|
|
self.send_response(200)
|
|
self.send_header('Content-Type', 'text/html')
|
|
self.end_headers()
|
|
self.wfile.write(html.page(title, contents))
|
|
except IOError: pass
|
|
|
|
def do_GET(self):
|
|
path = self.path
|
|
if path[-5:] == '.html': path = path[:-5]
|
|
if path[:1] == '/': path = path[1:]
|
|
if path and path != '.':
|
|
try:
|
|
obj = locate(path, forceload=1)
|
|
except ErrorDuringImport as value:
|
|
self.send_document(path, html.escape(str(value)))
|
|
return
|
|
if obj:
|
|
self.send_document(describe(obj), html.document(obj, path))
|
|
else:
|
|
self.send_document(path,
|
|
'no Python documentation found for %s' % repr(path))
|
|
else:
|
|
heading = html.heading(
|
|
'<big><big><strong>Python: Index of Modules</strong></big></big>',
|
|
'#ffffff', '#7799ee')
|
|
def bltinlink(name):
|
|
return '<a href="%s.html">%s</a>' % (name, name)
|
|
names = filter(lambda x: x != '__main__',
|
|
sys.builtin_module_names)
|
|
contents = html.multicolumn(names, bltinlink)
|
|
indices = ['<p>' + html.bigsection(
|
|
'Built-in Modules', '#ffffff', '#ee77aa', contents)]
|
|
|
|
seen = {}
|
|
for dir in sys.path:
|
|
indices.append(html.index(dir, seen))
|
|
contents = heading + ' '.join(indices) + '''<p align=right>
|
|
<font color="#909090" face="helvetica, arial"><strong>
|
|
pydoc</strong> by Ka-Ping Yee <ping@lfw.org></font>'''
|
|
self.send_document('Index of Modules', contents)
|
|
|
|
def log_message(self, *args): pass
|
|
|
|
class DocServer(BaseHTTPServer.HTTPServer):
|
|
def __init__(self, port, callback):
|
|
host = (sys.platform == 'mac') and '127.0.0.1' or 'localhost'
|
|
self.address = ('', port)
|
|
self.url = 'http://%s:%d/' % (host, port)
|
|
self.callback = callback
|
|
self.base.__init__(self, self.address, self.handler)
|
|
|
|
def serve_until_quit(self):
|
|
import select
|
|
self.quit = False
|
|
while not self.quit:
|
|
rd, wr, ex = select.select([self.socket.fileno()], [], [], 1)
|
|
if rd: self.handle_request()
|
|
|
|
def server_activate(self):
|
|
self.base.server_activate(self)
|
|
if self.callback: self.callback(self)
|
|
|
|
DocServer.base = BaseHTTPServer.HTTPServer
|
|
DocServer.handler = DocHandler
|
|
DocHandler.MessageClass = Message
|
|
try:
|
|
try:
|
|
DocServer(port, callback).serve_until_quit()
|
|
except (KeyboardInterrupt, select.error):
|
|
pass
|
|
finally:
|
|
if completer: completer()
|
|
|
|
# ----------------------------------------------------- graphical interface
|
|
|
|
def gui():
|
|
"""Graphical interface (starts web server and pops up a control window)."""
|
|
class GUI:
|
|
def __init__(self, window, port=7464):
|
|
self.window = window
|
|
self.server = None
|
|
self.scanner = None
|
|
|
|
import Tkinter
|
|
self.server_frm = Tkinter.Frame(window)
|
|
self.title_lbl = Tkinter.Label(self.server_frm,
|
|
text='Starting server...\n ')
|
|
self.open_btn = Tkinter.Button(self.server_frm,
|
|
text='open browser', command=self.open, state='disabled')
|
|
self.quit_btn = Tkinter.Button(self.server_frm,
|
|
text='quit serving', command=self.quit, state='disabled')
|
|
|
|
self.search_frm = Tkinter.Frame(window)
|
|
self.search_lbl = Tkinter.Label(self.search_frm, text='Search for')
|
|
self.search_ent = Tkinter.Entry(self.search_frm)
|
|
self.search_ent.bind('<Return>', self.search)
|
|
self.stop_btn = Tkinter.Button(self.search_frm,
|
|
text='stop', pady=0, command=self.stop, state='disabled')
|
|
if sys.platform == 'win32':
|
|
# Trying to hide and show this button crashes under Windows.
|
|
self.stop_btn.pack(side='right')
|
|
|
|
self.window.title('pydoc')
|
|
self.window.protocol('WM_DELETE_WINDOW', self.quit)
|
|
self.title_lbl.pack(side='top', fill='x')
|
|
self.open_btn.pack(side='left', fill='x', expand=1)
|
|
self.quit_btn.pack(side='right', fill='x', expand=1)
|
|
self.server_frm.pack(side='top', fill='x')
|
|
|
|
self.search_lbl.pack(side='left')
|
|
self.search_ent.pack(side='right', fill='x', expand=1)
|
|
self.search_frm.pack(side='top', fill='x')
|
|
self.search_ent.focus_set()
|
|
|
|
font = ('helvetica', sys.platform == 'win32' and 8 or 10)
|
|
self.result_lst = Tkinter.Listbox(window, font=font, height=6)
|
|
self.result_lst.bind('<Button-1>', self.select)
|
|
self.result_lst.bind('<Double-Button-1>', self.goto)
|
|
self.result_scr = Tkinter.Scrollbar(window,
|
|
orient='vertical', command=self.result_lst.yview)
|
|
self.result_lst.config(yscrollcommand=self.result_scr.set)
|
|
|
|
self.result_frm = Tkinter.Frame(window)
|
|
self.goto_btn = Tkinter.Button(self.result_frm,
|
|
text='go to selected', command=self.goto)
|
|
self.hide_btn = Tkinter.Button(self.result_frm,
|
|
text='hide results', command=self.hide)
|
|
self.goto_btn.pack(side='left', fill='x', expand=1)
|
|
self.hide_btn.pack(side='right', fill='x', expand=1)
|
|
|
|
self.window.update()
|
|
self.minwidth = self.window.winfo_width()
|
|
self.minheight = self.window.winfo_height()
|
|
self.bigminheight = (self.server_frm.winfo_reqheight() +
|
|
self.search_frm.winfo_reqheight() +
|
|
self.result_lst.winfo_reqheight() +
|
|
self.result_frm.winfo_reqheight())
|
|
self.bigwidth, self.bigheight = self.minwidth, self.bigminheight
|
|
self.expanded = 0
|
|
self.window.wm_geometry('%dx%d' % (self.minwidth, self.minheight))
|
|
self.window.wm_minsize(self.minwidth, self.minheight)
|
|
self.window.tk.willdispatch()
|
|
|
|
import threading
|
|
threading.Thread(
|
|
target=serve, args=(port, self.ready, self.quit)).start()
|
|
|
|
def ready(self, server):
|
|
self.server = server
|
|
self.title_lbl.config(
|
|
text='Python documentation server at\n' + server.url)
|
|
self.open_btn.config(state='normal')
|
|
self.quit_btn.config(state='normal')
|
|
|
|
def open(self, event=None, url=None):
|
|
url = url or self.server.url
|
|
try:
|
|
import webbrowser
|
|
webbrowser.open(url)
|
|
except ImportError: # pre-webbrowser.py compatibility
|
|
if sys.platform == 'win32':
|
|
os.system('start "%s"' % url)
|
|
elif sys.platform == 'mac':
|
|
try: import ic
|
|
except ImportError: pass
|
|
else: ic.launchurl(url)
|
|
else:
|
|
rc = os.system('netscape -remote "openURL(%s)" &' % url)
|
|
if rc: os.system('netscape "%s" &' % url)
|
|
|
|
def quit(self, event=None):
|
|
if self.server:
|
|
self.server.quit = 1
|
|
self.window.quit()
|
|
|
|
def search(self, event=None):
|
|
key = self.search_ent.get()
|
|
self.stop_btn.pack(side='right')
|
|
self.stop_btn.config(state='normal')
|
|
self.search_lbl.config(text='Searching for "%s"...' % key)
|
|
self.search_ent.forget()
|
|
self.search_lbl.pack(side='left')
|
|
self.result_lst.delete(0, 'end')
|
|
self.goto_btn.config(state='disabled')
|
|
self.expand()
|
|
|
|
import threading
|
|
if self.scanner:
|
|
self.scanner.quit = 1
|
|
self.scanner = ModuleScanner()
|
|
threading.Thread(target=self.scanner.run,
|
|
args=(self.update, key, self.done)).start()
|
|
|
|
def update(self, path, modname, desc):
|
|
if modname[-9:] == '.__init__':
|
|
modname = modname[:-9] + ' (package)'
|
|
self.result_lst.insert('end',
|
|
modname + ' - ' + (desc or '(no description)'))
|
|
|
|
def stop(self, event=None):
|
|
if self.scanner:
|
|
self.scanner.quit = 1
|
|
self.scanner = None
|
|
|
|
def done(self):
|
|
self.scanner = None
|
|
self.search_lbl.config(text='Search for')
|
|
self.search_lbl.pack(side='left')
|
|
self.search_ent.pack(side='right', fill='x', expand=1)
|
|
if sys.platform != 'win32': self.stop_btn.forget()
|
|
self.stop_btn.config(state='disabled')
|
|
|
|
def select(self, event=None):
|
|
self.goto_btn.config(state='normal')
|
|
|
|
def goto(self, event=None):
|
|
selection = self.result_lst.curselection()
|
|
if selection:
|
|
modname = self.result_lst.get(selection[0]).split()[0]
|
|
self.open(url=self.server.url + modname + '.html')
|
|
|
|
def collapse(self):
|
|
if not self.expanded: return
|
|
self.result_frm.forget()
|
|
self.result_scr.forget()
|
|
self.result_lst.forget()
|
|
self.bigwidth = self.window.winfo_width()
|
|
self.bigheight = self.window.winfo_height()
|
|
self.window.wm_geometry('%dx%d' % (self.minwidth, self.minheight))
|
|
self.window.wm_minsize(self.minwidth, self.minheight)
|
|
self.expanded = 0
|
|
|
|
def expand(self):
|
|
if self.expanded: return
|
|
self.result_frm.pack(side='bottom', fill='x')
|
|
self.result_scr.pack(side='right', fill='y')
|
|
self.result_lst.pack(side='top', fill='both', expand=1)
|
|
self.window.wm_geometry('%dx%d' % (self.bigwidth, self.bigheight))
|
|
self.window.wm_minsize(self.minwidth, self.bigminheight)
|
|
self.expanded = 1
|
|
|
|
def hide(self, event=None):
|
|
self.stop()
|
|
self.collapse()
|
|
|
|
import Tkinter
|
|
try:
|
|
root = Tkinter.Tk()
|
|
# Tk will crash if pythonw.exe has an XP .manifest
|
|
# file and the root has is not destroyed explicitly.
|
|
# If the problem is ever fixed in Tk, the explicit
|
|
# destroy can go.
|
|
try:
|
|
gui = GUI(root)
|
|
root.mainloop()
|
|
finally:
|
|
root.destroy()
|
|
except KeyboardInterrupt:
|
|
pass
|
|
|
|
# -------------------------------------------------- command-line interface
|
|
|
|
def ispath(x):
|
|
return isinstance(x, str) and x.find(os.sep) >= 0
|
|
|
|
def cli():
|
|
"""Command-line interface (looks at sys.argv to decide what to do)."""
|
|
import getopt
|
|
class BadUsage(Exception): pass
|
|
|
|
# Scripts don't get the current directory in their path by default.
|
|
scriptdir = os.path.dirname(sys.argv[0])
|
|
if scriptdir in sys.path:
|
|
sys.path.remove(scriptdir)
|
|
sys.path.insert(0, '.')
|
|
|
|
try:
|
|
opts, args = getopt.getopt(sys.argv[1:], 'gk:p:w')
|
|
writing = 0
|
|
|
|
for opt, val in opts:
|
|
if opt == '-g':
|
|
gui()
|
|
return
|
|
if opt == '-k':
|
|
apropos(val)
|
|
return
|
|
if opt == '-p':
|
|
try:
|
|
port = int(val)
|
|
except ValueError:
|
|
raise BadUsage
|
|
def ready(server):
|
|
print('pydoc server ready at %s' % server.url)
|
|
def stopped():
|
|
print('pydoc server stopped')
|
|
serve(port, ready, stopped)
|
|
return
|
|
if opt == '-w':
|
|
writing = 1
|
|
|
|
if not args: raise BadUsage
|
|
for arg in args:
|
|
if ispath(arg) and not os.path.exists(arg):
|
|
print('file %r does not exist' % arg)
|
|
break
|
|
try:
|
|
if ispath(arg) and os.path.isfile(arg):
|
|
arg = importfile(arg)
|
|
if writing:
|
|
if ispath(arg) and os.path.isdir(arg):
|
|
writedocs(arg)
|
|
else:
|
|
writedoc(arg)
|
|
else:
|
|
help.help(arg)
|
|
except ErrorDuringImport as value:
|
|
print(value)
|
|
|
|
except (getopt.error, BadUsage):
|
|
cmd = os.path.basename(sys.argv[0])
|
|
print("""pydoc - the Python documentation tool
|
|
|
|
%s <name> ...
|
|
Show text documentation on something. <name> may be the name of a
|
|
Python keyword, topic, function, module, or package, or a dotted
|
|
reference to a class or function within a module or module in a
|
|
package. If <name> contains a '%s', it is used as the path to a
|
|
Python source file to document. If name is 'keywords', 'topics',
|
|
or 'modules', a listing of these things is displayed.
|
|
|
|
%s -k <keyword>
|
|
Search for a keyword in the synopsis lines of all available modules.
|
|
|
|
%s -p <port>
|
|
Start an HTTP server on the given port on the local machine.
|
|
|
|
%s -g
|
|
Pop up a graphical interface for finding and serving documentation.
|
|
|
|
%s -w <name> ...
|
|
Write out the HTML documentation for a module to a file in the current
|
|
directory. If <name> contains a '%s', it is treated as a filename; if
|
|
it names a directory, documentation is written for all the contents.
|
|
""" % (cmd, os.sep, cmd, cmd, cmd, cmd, os.sep))
|
|
|
|
if __name__ == '__main__': cli()
|