Update of /cvsroot/python/python/dist/src/Lib In directory usw-pr-cvs1:/tmp/cvs-serv20557 Modified Files: Tag: release22-maint pydoc.py Log Message: Backport 1.68: Extend stripid() to handle strings ending in more than one '>'. Add resolve() to handle looking up objects and names (fix SF bug 586931). Add a nicer error message when given a filename that doesn't exist. Index: pydoc.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v retrieving revision 1.56.8.5 retrieving revision 1.56.8.6 diff -C2 -d -r1.56.8.5 -r1.56.8.6 *** pydoc.py 7 Oct 2002 13:24:02 -0000 1.56.8.5 --- pydoc.py 7 Oct 2002 17:09:25 -0000 1.56.8.6 *************** *** 107,113 **** """Remove the hexadecimal id from a Python object representation.""" # The behaviour of %p is implementation-dependent; we check two cases. ! for pattern in [' at 0x[0-9a-f]{6,}>$', ' at [0-9A-F]{8,}>$']: if re.search(pattern, repr(Exception)): ! return re.sub(pattern, '>', text) return text --- 107,113 ---- """Remove the hexadecimal id from a Python object representation.""" # The behaviour of %p is implementation-dependent; we check two cases. ! for pattern in [' at 0x[0-9a-f]{6,}(>+)$', ' at [0-9A-F]{8,}(>+)$']: if re.search(pattern, repr(Exception)): ! return re.sub(pattern, '\\1', text) return text *************** *** 1324,1366 **** html = HTMLDoc() ! def doc(thing, title='Python Library Documentation: %s', forceload=0): ! """Display text documentation, given an object or a path to an object.""" ! suffix, name = '', None ! if type(thing) is type(''): ! try: ! object = locate(thing, forceload) ! except ErrorDuringImport, value: ! print value ! return if not object: ! print 'no Python documentation found for %s' % repr(thing) ! return ! parts = split(thing, '.') ! if len(parts) > 1: suffix = ' in ' + join(parts[:-1], '.') ! name = parts[-1] ! thing = object ! desc = describe(thing) ! module = inspect.getmodule(thing) ! if not suffix and module and module is not thing: ! suffix = ' in module ' + module.__name__ ! pager(title % (desc + suffix) + '\n\n' + text.document(thing, name)) ! def writedoc(key, forceload=0): """Write HTML documentation to a file in the current directory.""" try: ! object = locate(key, forceload) ! except ErrorDuringImport, value: print value - else: - if object: - page = html.page(describe(object), - html.document(object, object.__name__)) - file = open(key + '.html', 'w') - file.write(page) - file.close() - print 'wrote', key + '.html' - else: - print 'no Python documentation found for %s' % repr(key) def writedocs(dir, pkgpath='', done=None): --- 1324,1362 ---- 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 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__ ! pager(title % desc + '\n\n' + text.document(object, name)) ! except (ImportError, ErrorDuringImport), 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), value: print value def writedocs(dir, pkgpath='', done=None): *************** *** 2032,2036 **** def ispath(x): ! return type(x) is types.StringType and find(x, os.sep) >= 0 def cli(): --- 2028,2032 ---- def ispath(x): ! return isinstance(x, str) and find(x, os.sep) >= 0 def cli(): *************** *** 2072,2075 **** --- 2068,2074 ---- 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):
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4