rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
stats = os.stat(localfile)
def open_local_file(self, req): host = req.get_host() file = req.get_selector() localfile = url2pathname(file) stats = os.stat(localfile) size = stats[stat.ST_SIZE] modified = rfc822.formatdate(stats[stat.ST_MTIME]) mtype = mimetypes.guess_type(file)[0] stats = os.stat(localfile) headers = mimetools.Message(StringIO( '...
def index(dir): """Return a list of (module-name, synopsis) pairs for a directory tree.""" results = [] for entry in os.listdir(dir): path = os.path.join(dir, entry) if ispackage(path): results.extend(map( lambda (m, s), pkg=entry: (pkg + '.' + m, s), index(path))) elif os.path.isfile(path) and entry[-3:] == '.py': res...
def index(dir): """Return a list of (module-name, synopsis) pairs for a directory tree.""" results = [] for entry in os.listdir(dir): path = os.path.join(dir, entry) if ispackage(path): results.extend(map( lambda (m, s), pkg=entry: (pkg + '.' + m, s), index(path))) elif os.path.isfile(path) and entry[-3:] == '.py': res...
elif lower(filename[-4:]) == '.pyc':
elif lower(filename[-4:]) in ['.pyc', '.pyd', '.pyo']:
def modulename(path): """Return the Python module name for a given path, or None.""" filename = os.path.basename(path) if lower(filename[-3:]) == '.py': return filename[:-3] elif lower(filename[-4:]) == '.pyc': return filename[:-4] elif lower(filename[-11:]) == 'module.so': return filename[:-11] elif lower(filename[-13...
if inspect.ismethod(object): return apply(self.docmethod, args) if inspect.isbuiltin(object): return apply(self.docbuiltin, args) if inspect.isfunction(object): return apply(self.docfunction, args)
if inspect.isroutine(object): return apply(self.docroutine, args)
def document(self, object, *args): """Generate documentation for an object.""" args = (object,) + args if inspect.ismodule(object): return apply(self.docmodule, args) if inspect.isclass(object): return apply(self.docclass, args) if inspect.ismethod(object): return apply(self.docmethod, args) if inspect.isbuiltin(object...
<tr bgcolor="%s"><td colspan=3 valign=bottom><small><small><br></small></small ><font color="%s" face="helvetica, arial">&nbsp;%s</font></td
<tr bgcolor="%s"><td>&nbsp;</td> <td valign=bottom><small><small><br></small></small ><font color="%s" face="helvetica"><br>&nbsp;%s</font></td
def heading(self, title, fgcol, bgcol, extras=''): """Format a page heading.""" return """
><font color="%s" face="helvetica, arial">&nbsp;%s</font></td></tr></table> """ % (bgcol, fgcol, title, fgcol, extras)
><font color="%s" face="helvetica">%s</font></td><td>&nbsp;</td></tr></table> """ % (bgcol, fgcol, title, fgcol, extras or '&nbsp;')
def heading(self, title, fgcol, bgcol, extras=''): """Format a page heading.""" return """
<tr bgcolor="%s"><td colspan=3 valign=bottom><small><small><br></small></small
<tr bgcolor="%s"><td rowspan=2>&nbsp;</td> <td colspan=3 valign=bottom><small><small><br></small></small
def section(self, title, fgcol, bgcol, contents, width=20, prelude='', marginalia=None, gap='&nbsp;&nbsp;&nbsp;'): """Format a section with a heading.""" if marginalia is None: marginalia = '&nbsp;' * width result = """
def footer(self): return """ <table width="100%"><tr><td align=right> <font face="helvetica, arial"><small><small>generated with <strong>htmldoc</strong> by Ka-Ping Yee</a></small></small></font> </td></tr></table> """
def bigsection(self, title, *args): """Format a section with a big heading.""" title = '<big><strong>%s</strong></big>' % title return apply(self.section, (title,) + args)
result = '' head = '<br><big><big><strong>&nbsp;%s</strong></big></big>' % name
parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color=" (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.') head = '<big><big><strong>%s</strong></big></big>' % linkedname
def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ result = '' head = '<br><big><big><strong>&nbsp;%s</strong></big></big>' % name try: path = os.path.abspath(inspect.getfile(object)) filelink = '<a href="file:%s">%s</a>' % (path, path) except TypeError: filelink =...
result = result + self.heading(
result = self.heading(
def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ result = '' head = '<br><big><big><strong>&nbsp;%s</strong></big></big>' % name try: path = os.path.abspath(inspect.getfile(object)) filelink = '<a href="file:%s">%s</a>' % (path, path) except TypeError: filelink =...
if doc: doc = '<small><tt>' + doc + '<br>&nbsp;</tt></small>'
if doc: doc = '<small><tt>' + doc + '</tt></small>'
def docclass(self, object, funcs={}, classes={}): """Produce HTML documentation for a class object.""" name = object.__name__ bases = object.__bases__ contents = ''
def docmethod(self, object, funcs={}, classes={}, methods={}, clname=''): """Produce HTML documentation for a method object.""" return self.document( object.im_func, funcs, classes, methods, clname)
def docclass(self, object, funcs={}, classes={}): """Produce HTML documentation for a class object.""" name = object.__name__ bases = object.__bases__ contents = ''
def docfunction(self, object, funcs={}, classes={}, methods={}, clname=''): """Produce HTML documentation for a function object.""" args, varargs, varkw, defaults = inspect.getargspec(object) argspec = inspect.formatargspec( args, varargs, varkw, defaults, formatvalue=self.formatvalue) if object.__name__ == '<lambda>'...
def docroutine(self, object, funcs={}, classes={}, methods={}, clname=''): """Produce HTML documentation for a function or method object.""" if inspect.ismethod(object): object = object.im_func if inspect.isbuiltin(object): decl = '<a name="%s"><strong>%s</strong>(...)</a>\n' % ( clname + '-' + object.__name__, object....
def docfunction(self, object, funcs={}, classes={}, methods={}, clname=''): """Produce HTML documentation for a function object.""" args, varargs, varkw, defaults = inspect.getargspec(object) argspec = inspect.formatargspec( args, varargs, varkw, defaults, formatvalue=self.formatvalue)
anchor = clname + '-' + object.__name__ decl = '<a name="%s"\n><strong>%s</strong>%s</a>\n' % ( anchor, object.__name__, argspec)
args, varargs, varkw, defaults = inspect.getargspec(object) argspec = inspect.formatargspec( args, varargs, varkw, defaults, formatvalue=self.formatvalue) if object.__name__ == '<lambda>': decl = '<em>lambda</em> ' + argspec[1:-1] else: anchor = clname + '-' + object.__name__ decl = '<a name="%s"\n><strong>%s</strong>...
def docfunction(self, object, funcs={}, classes={}, methods={}, clname=''): """Produce HTML documentation for a function object.""" args, varargs, varkw, defaults = inspect.getargspec(object) argspec = inspect.formatargspec( args, varargs, varkw, defaults, formatvalue=self.formatvalue)
def docbuiltin(self, object, *extras): """Produce HTML documentation for a built-in function.""" return '<dl><dt><strong>%s</strong>(...)</dl>' % object.__name__
def docbuiltin(self, object, *extras): """Produce HTML documentation for a built-in function.""" return '<dl><dt><strong>%s</strong>(...)</dl>' % object.__name__
def docmethod(self, object): """Produce text documentation for a method object.""" return self.document(object.im_func)
def docmethod(self, object): """Produce text documentation for a method object.""" return self.document(object.im_func)
def docfunction(self, object): """Produce text documentation for a function object.""" try:
def docroutine(self, object): """Produce text documentation for a function or method object.""" if inspect.ismethod(object): object = object.im_func if inspect.isbuiltin(object): decl = self.bold(object.__name__) + '(...)' else:
def docfunction(self, object): """Produce text documentation for a function object.""" try: args, varargs, varkw, defaults = inspect.getargspec(object) argspec = inspect.formatargspec( args, varargs, varkw, defaults, formatvalue=self.formatvalue) except TypeError: argspec = '(...)'
except TypeError: argspec = '(...)' if object.__name__ == '<lambda>': decl = '<lambda> ' + argspec[1:-1] else: decl = self.bold(object.__name__) + argspec
if object.__name__ == '<lambda>': decl = '<lambda> ' + argspec[1:-1] else: decl = self.bold(object.__name__) + argspec
def docfunction(self, object): """Produce text documentation for a function object.""" try: args, varargs, varkw, defaults = inspect.getargspec(object) argspec = inspect.formatargspec( args, varargs, varkw, defaults, formatvalue=self.formatvalue) except TypeError: argspec = '(...)'
def docbuiltin(self, object): """Produce text documentation for a built-in function object.""" return (self.bold(object.__name__) + '(...)\n' + rstrip(self.indent(object.__doc__)) + '\n')
def docfunction(self, object): """Produce text documentation for a function object.""" try: args, varargs, varkw, defaults = inspect.getargspec(object) argspec = inspect.formatargspec( args, varargs, varkw, defaults, formatvalue=self.formatvalue) except TypeError: argspec = '(...)'
if hasattr(__builtins__, path): return None, getattr(__builtins__, path)
def locate(path): """Locate an object by name (or dotted path), importing as necessary.""" if not path: # special case: imp.find_module('') strangely succeeds return None, None if type(path) is not types.StringType: return None, path if hasattr(__builtins__, path): return None, getattr(__builtins__, path) parts = split...
print 'problem in %s - %s' % (value.filename, value.args)
print 'Problem in %s - %s' % (value.filename, value.args)
def doc(thing): """Display documentation on an object (for interactive use).""" if type(thing) is type(""): try: path, x = locate(thing) except DocImportError, value: print 'problem in %s - %s' % (value.filename, value.args) return if x: thing = x else: print 'could not find or import %s' % repr(thing) return desc = d...
print 'could not find or import %s' % repr(thing)
print 'No Python documentation found for %s.' % repr(thing)
def doc(thing): """Display documentation on an object (for interactive use).""" if type(thing) is type(""): try: path, x = locate(thing) except DocImportError, value: print 'problem in %s - %s' % (value.filename, value.args) return if x: thing = x else: print 'could not find or import %s' % repr(thing) return desc = d...
def writedocs(path, pkgpath=''): if os.path.isdir(path): dir = path for file in os.listdir(dir): path = os.path.join(dir, file) if os.path.isdir(path): writedocs(path, file + '.' + pkgpath) if os.path.isfile(path): writedocs(path, pkgpath) if os.path.isfile(path): modname = modulename(path) if modname: writedoc(pkgpath...
def doc(thing): """Display documentation on an object (for interactive use).""" if type(thing) is type(""): try: path, x = locate(thing) except DocImportError, value: print 'problem in %s - %s' % (value.filename, value.args) return if x: thing = x else: print 'could not find or import %s' % repr(thing) return desc = d...
print 'could not find or import %s' % repr(key)
print 'No Python documentation found for %s.' % repr(key) class Scanner: """A generic tree iterator.""" def __init__(self, roots, children, recurse): self.roots = roots[:] self.state = [] self.children = children self.recurse = recurse def next(self): if not self.state: if not self.roots: return None root = self.root...
def man(key): """Display documentation on an object in a form similar to man(1).""" path, object = locate(key) if object: title = 'Python Library Documentation: ' + describe(object) if path: title = title + ' in ' + path pager('\n' + title + '\n\n' + text.document(object)) found = 1 else: print 'could not find or impor...
key = lower(key) for module in sys.builtin_module_names: desc = __import__(module).__doc__ or '' desc = split(desc, '\n')[0] if find(lower(module + ' ' + desc), key) >= 0: print module, '-', desc or '(no description)' modules = [] for dir in pathdirs(): for module, desc in index(dir): desc = desc or '' if module not in...
def callback(path, modname, desc): if modname[-9:] == '.__init__': modname = modname[:-9] + ' (package)' print modname, '-', desc or '(no description)' ModuleScanner().run(key, callback)
def apropos(key): """Print all the one-line module summaries that contain a substring.""" key = lower(key) for module in sys.builtin_module_names: desc = __import__(module).__doc__ or '' desc = split(desc, '\n')[0] if find(lower(module + ' ' + desc), key) >= 0: print module, '-', desc or '(no description)' modules = []...
def serve(address, callback=None): import BaseHTTPServer, mimetools
def serve(port, callback=None): import BaseHTTPServer, mimetools, select
def serve(address, callback=None): import BaseHTTPServer, mimetools # 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.send_response(200) self.send_header('Content-Type', 'text/html') self.end_headers() self.wfile.write( '''<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><title>Python: %s</title><body bgcolor=" self.wfile.write(contents) self.wfile.write('</body></html>')
try: self.send_response(200) self.send_header('Content-Type', 'text/html') self.end_headers() self.wfile.write(''' <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><title>Python: %s</title><body bgcolor=" %s </body></html>''' % (title, contents)) except IOError: pass
def send_document(self, title, contents): self.send_response(200) self.send_header('Content-Type', 'text/html') self.end_headers() self.wfile.write(
'problem with %s - %s' % (value.filename, value.args)))
'Problem in %s - %s' % (value.filename, value.args)))
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: p, x = locate(path) except DocImportError, value: self.send_document(path, html.escape( 'problem with %s - %s' % (value.filename, value.args))) return if x: self.send_document(d...
'There is no Python module or object named "%s".' % path)
'No Python documentation found for %s.' % repr(path))
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: p, x = locate(path) except DocImportError, value: self.send_document(path, html.escape( 'problem with %s - %s' % (value.filename, value.args))) return if x: self.send_document(d...
'<br><big><big><strong>&nbsp;' 'Python: Index of Modules' '</strong></big></big>', '
'<big><big><strong>Python: Index of Modules</strong></big></big>', '
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: p, x = locate(path) except DocImportError, value: self.send_document(path, html.escape( 'problem with %s - %s' % (value.filename, value.args))) return if x: self.send_document(d...
self.send_document('Index of Modules', heading + join(indices))
contents = heading + join(indices) + """<p align=right> <small><small><font color=" pydoc</strong> by Ka-Ping Yee &lt;ping@lfw.org&gt;</font></small></small>""" self.send_document('Index of Modules', contents)
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: p, x = locate(path) except DocImportError, value: self.send_document(path, html.escape( 'problem with %s - %s' % (value.filename, value.args))) return if x: self.send_document(d...
def __init__(self, address, callback):
def __init__(self, port, callback): self.address = ('127.0.0.1', port) self.url = 'http://127.0.0.1:%d/' % port
def __init__(self, address, callback): self.callback = callback self.base.__init__(self, address, self.handler)
self.base.__init__(self, address, self.handler)
self.base.__init__(self, self.address, self.handler) def serve_until_quit(self): import select self.quit = 0 while not self.quit: rd, wr, ex = select.select([self.socket.fileno()], [], [], 1) if rd: self.handle_request()
def __init__(self, address, callback): self.callback = callback self.base.__init__(self, address, self.handler)
if self.callback: self.callback()
if self.callback: self.callback(self)
def server_activate(self): self.base.server_activate(self) if self.callback: self.callback()
DocServer(address, callback).serve_forever()
DocServer(port, callback).serve_until_quit() except (KeyboardInterrupt, select.error): pass print 'server stopped' 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 impo...
def server_activate(self): self.base.server_activate(self) if self.callback: self.callback()
print 'server stopped'
pass
def server_activate(self): self.base.server_activate(self) if self.callback: self.callback()
opts, args = getopt.getopt(sys.argv[1:], 'k:p:w')
if sys.platform in ['mac', 'win', 'win32', 'nt'] and not sys.argv[1:]: gui() return opts, args = getopt.getopt(sys.argv[1:], 'gk:p:w')
def cli(): import getopt class BadUsage: pass try: opts, args = getopt.getopt(sys.argv[1:], 'k:p:w') writing = 0 for opt, val in opts: if opt == '-k': apropos(lower(val)) break if opt == '-p': try: port = int(val) except ValueError: raise BadUsage def ready(port=port): print 'server ready at http://127.0.0.1:%d/' % p...
apropos(lower(val)) break
apropos(val) return
def cli(): import getopt class BadUsage: pass try: opts, args = getopt.getopt(sys.argv[1:], 'k:p:w') writing = 0 for opt, val in opts: if opt == '-k': apropos(lower(val)) break if opt == '-p': try: port = int(val) except ValueError: raise BadUsage def ready(port=port): print 'server ready at http://127.0.0.1:%d/' % p...
def ready(port=port): print 'server ready at http://127.0.0.1:%d/' % port serve(('127.0.0.1', port), ready) break
def ready(server): print 'server ready at %s' % server.url serve(port, ready) return
def ready(port=port): print 'server ready at http://127.0.0.1:%d/' % port
if not args: raise BadUsage
def ready(port=port): print 'server ready at http://127.0.0.1:%d/' % port
else: if args: for arg in args: try: if os.path.isfile(arg): arg = importfile(arg) if writing: if os.path.isdir(arg): writedocs(arg) else: writedoc(arg) else: man(arg) except DocImportError, value: print 'problem in %s - %s' % ( value.filename, value.args) else: if sys.platform in ['mac', 'win', 'win32', 'nt']: import...
if not args: raise BadUsage for arg in args: try: if find(arg, os.sep) >= 0 and os.path.isfile(arg): arg = importfile(arg) if writing: writedoc(arg) else: man(arg) except DocImportError, value: print 'Problem in %s - %s' % (value.filename, value.args)
def ready(port=port): print 'server ready at http://127.0.0.1:%d/' % port
print """%s <name> ... Show documentation on something. <name> may be the name of a Python function, module, or package, or a dotted reference to a class or function within a module or module in a package, or the filename of a Python module to import.
cmd = sys.argv[0] print """pydoc - the Python documentation tool %s <name> ... Show text documentation on something. <name> may be the name of a 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 Py...
def ready(port=port): print 'server ready at http://127.0.0.1:%d/' % port
Search for a keyword in the synopsis lines of all modules.
Search for a keyword in the synopsis lines of all available modules.
def ready(port=port): print 'server ready at http://127.0.0.1:%d/' % port
%s -w <module> ... Write out the HTML documentation for a module to a file. %s -w <moduledir> Write out the HTML documentation for all modules in the tree under a given directory to files in the current directory. """ % ((sys.argv[0],) * 5) if __name__ == '__main__': cli()
%s -g Pop up a graphical interface for serving and finding 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. """ % (cmd, os.sep, cmd, cmd, cmd, cmd, os.sep) if __name__ == '__main__': cli()
def ready(port=port): print 'server ready at http://127.0.0.1:%d/' % port
sys.stderr.write("*** %s\n" % s)
ewrite("*** %s\n" % s)
def para_msg(s): sys.stderr.write("*** %s\n" % s)
def find_all_elements_from_set(doc, gi_set, nodes=None): if nodes is None: nodes = []
def find_all_child_elements(doc, gi): nodes = [] for child in doc.childNodes: if child.nodeType == ELEMENT: if child.tagName == gi: nodes.append(child) return nodes def find_all_elements_from_set(doc, gi_set): return __find_all_elements_from_set(doc, gi_set, []) def __find_all_elements_from_set(doc, gi_set, nodes):
def find_all_elements_from_set(doc, gi_set, nodes=None): if nodes is None: nodes = [] if doc.nodeType == ELEMENT and doc.tagName in gi_set: nodes.append(doc) for child in doc.childNodes: if child.nodeType == ELEMENT: find_all_elements_from_set(child, gi_set, nodes) return nodes
find_all_elements_from_set(child, gi_set, nodes)
__find_all_elements_from_set(child, gi_set, nodes)
def find_all_elements_from_set(doc, gi_set, nodes=None): if nodes is None: nodes = [] if doc.nodeType == ELEMENT and doc.tagName in gi_set: nodes.append(doc) for child in doc.childNodes: if child.nodeType == ELEMENT: find_all_elements_from_set(child, gi_set, nodes) return nodes
descriptor.setAttribute("index", "noindex")
descriptor.setAttribute("index", "no")
def rewrite_descriptor(doc, descriptor): # # Do these things: # 1. Add an "index=noindex" attribute to the element if the tagName # ends in 'ni', removing the 'ni' from the name. # 2. Create a <signature> from the name attribute and <args>. # 3. Create additional <signature>s from <*line{,ni}> elements, # ...
sys.stderr.write( "module name in title doesn't match" " <declaremodule>; no <short-synopsis>\n")
ewrite("module name in title doesn't match" " <declaremodule/>; no <short-synopsis/>\n")
def create_module_info(doc, section): # Heavy. node = extract_first_element(section, "modulesynopsis") if node is None: return node._node.name = "synopsis" lastchild = node.childNodes[-1] if lastchild.nodeType == TEXT \ and lastchild.data[-1:] == ".": lastchild.data = lastchild.data[:-1] modauthor = extract_first_eleme...
sys.stderr.write( "Unexpected condition: <section> without <title>\n")
ewrite("Unexpected condition: <section/> without <title/>\n")
def create_module_info(doc, section): # Heavy. node = extract_first_element(section, "modulesynopsis") if node is None: return node._node.name = "synopsis" lastchild = node.childNodes[-1] if lastchild.nodeType == TEXT \ and lastchild.data[-1:] == ".": lastchild.data = lastchild.data[:-1] modauthor = extract_first_eleme...
def cleanup_synopses(doc): for node in find_all_elements(doc, "section"):
def cleanup_synopses(doc, fragment): for node in find_all_elements(fragment, "section"):
def cleanup_synopses(doc): for node in find_all_elements(doc, "section"): create_module_info(doc, node)
"moduleauthor",
"moduleauthor", "indexterm",
def move_elements_by_name(doc, source, dest, name, sep=None): nodes = [] for child in source.childNodes: if child.nodeType == ELEMENT and child.tagName == name: nodes.append(child) for node in nodes: source.removeChild(node) dest.appendChild(node) if sep: dest.appendChild(doc.createTextNode(sep))
parent.insertBefore(para, parent.childNodes[start])
nextnode = parent.childNodes[start] if nextnode.nodeType == TEXT: if nextnode.data and nextnode.data[0] != "\n": nextnode.data = "\n" + nextnode.data else: newnode = doc.createTextNode("\n") parent.insertBefore(newnode, nextnode) nextnode = newnode start = start + 1 parent.insertBefore(para, nextnode)
def build_para(doc, parent, start, i): children = parent.childNodes after = start + 1 have_last = 0 BREAK_ELEMENTS = PARA_LEVEL_ELEMENTS + RECURSE_INTO_PARA_CONTAINERS # Collect all children until \n\n+ is found in a text node or a # member of BREAK_ELEMENTS is found. for j in range(start, i): after = j + 1 child = chi...
sys.stderr.write("--- fixup_refmodindexes_chunk(%s)\n" % container)
bwrite("--- fixup_refmodindexes_chunk(%s)\n" % container)
def fixup_refmodindexes_chunk(container): # node is probably a <para>; let's see how often it isn't: if container.tagName != PARA_ELEMENT: sys.stderr.write("--- fixup_refmodindexes_chunk(%s)\n" % container) module_entries = find_all_elements(container, "module") if not module_entries: return index_entries = find_all_el...
sys.stderr.write( "--- unexpected number of children for %s node:\n" % entry.tagName) sys.stderr.write(entry.toxml() + "\n")
bwrite("--- unexpected number of children for %s node:\n" % entry.tagName) ewrite(entry.toxml() + "\n")
def fixup_refmodindexes_chunk(container): # node is probably a <para>; let's see how often it isn't: if container.tagName != PARA_ELEMENT: sys.stderr.write("--- fixup_refmodindexes_chunk(%s)\n" % container) module_entries = find_all_elements(container, "module") if not module_entries: return index_entries = find_all_el...
node.setAttribute("index", "index")
node.setAttribute("index", "yes")
def fixup_refmodindexes_chunk(container): # node is probably a <para>; let's see how often it isn't: if container.tagName != PARA_ELEMENT: sys.stderr.write("--- fixup_refmodindexes_chunk(%s)\n" % container) module_entries = find_all_elements(container, "module") if not module_entries: return index_entries = find_all_el...
entries = find_all_elements(container, "bifuncindex") function_entries = find_all_elements(container, "function")
entries = find_all_child_elements(container, "bifuncindex") function_entries = find_all_child_elements(container, "function")
def fixup_bifuncindexes_chunk(container): removes = [] entries = find_all_elements(container, "bifuncindex") function_entries = find_all_elements(container, "function") for entry in entries: function_name = entry.getAttribute("name") found = 0 for func_entry in function_entries: t2 = func_entry.childNodes[0].data if t2...
func_entry.setAttribute("index", "index")
func_entry.setAttribute("index", "yes")
def fixup_bifuncindexes_chunk(container): removes = [] entries = find_all_elements(container, "bifuncindex") function_entries = find_all_elements(container, "function") for entry in entries: function_name = entry.getAttribute("name") found = 0 for func_entry in function_entries: t2 = func_entry.childNodes[0].data if t2...
found = 1
def fixup_bifuncindexes_chunk(container): removes = [] entries = find_all_elements(container, "bifuncindex") function_entries = find_all_elements(container, "function") for entry in entries: function_name = entry.getAttribute("name") found = 0 for func_entry in function_entries: t2 = func_entry.childNodes[0].data if t2...
cleanup_trailing_parens(doc, ["function", "method", "cfunction"]) cleanup_synopses(doc)
cleanup_trailing_parens(fragment, ["function", "method", "cfunction"]) cleanup_synopses(doc, fragment)
def convert(ifp, ofp): p = esistools.ExtendedEsisBuilder() p.feed(ifp.read()) doc = p.document fragment = p.fragment normalize(fragment) simplify(doc, fragment) handle_labels(doc, fragment) handle_appendix(doc, fragment) fixup_trailing_whitespace(doc, { "abstract": "\n", "title": "", "chapter": "\n\n", "section": "\n\n...
self.check_extension_list()
def get_source_files (self):
if len (words) != 2:
if len (words) < 2:
def read_template (self): """Read and parse the manifest template file named by 'self.template' (usually "MANIFEST.in"). Process all file specifications (include and exclude) in the manifest template and add the resulting filenames to 'self.files'."""
"'%s' expects a single <pattern>" %
"'%s' expects <pattern1> <pattern2> ..." %
def read_template (self): """Read and parse the manifest template file named by 'self.template' (usually "MANIFEST.in"). Process all file specifications (include and exclude) in the manifest template and add the resulting filenames to 'self.files'."""
pattern = native_path (words[1])
pattern_list = map(native_path, words[1:])
def read_template (self): """Read and parse the manifest template file named by 'self.template' (usually "MANIFEST.in"). Process all file specifications (include and exclude) in the manifest template and add the resulting filenames to 'self.files'."""
if len (words) != 3:
if len (words) < 3:
def read_template (self): """Read and parse the manifest template file named by 'self.template' (usually "MANIFEST.in"). Process all file specifications (include and exclude) in the manifest template and add the resulting filenames to 'self.files'."""
"'%s' expects <dir> <pattern>" %
"'%s' expects <dir> <pattern1> <pattern2> ..." %
def read_template (self): """Read and parse the manifest template file named by 'self.template' (usually "MANIFEST.in"). Process all file specifications (include and exclude) in the manifest template and add the resulting filenames to 'self.files'."""
(dir, pattern) = map (native_path, words[1:3])
dir = native_path(words[1]) pattern_list = map (native_path, words[2:])
def read_template (self): """Read and parse the manifest template file named by 'self.template' (usually "MANIFEST.in"). Process all file specifications (include and exclude) in the manifest template and add the resulting filenames to 'self.files'."""
print "include", pattern files = select_pattern (all_files, pattern, anchor=1) if not files: template.warn ("no files found matching '%s'" % pattern) else: self.files.extend (files)
print "include", string.join(pattern_list) for pattern in pattern_list: files = select_pattern (all_files, pattern, anchor=1) if not files: template.warn ("no files found matching '%s'" % pattern) else: self.files.extend (files)
def read_template (self): """Read and parse the manifest template file named by 'self.template' (usually "MANIFEST.in"). Process all file specifications (include and exclude) in the manifest template and add the resulting filenames to 'self.files'."""
print "exclude", pattern num = exclude_pattern (self.files, pattern, anchor=1) if num == 0: template.warn \ ("no previously-included files found matching '%s'" % pattern)
print "exclude", string.join(pattern_list) for pattern in pattern_list: num = exclude_pattern (self.files, pattern, anchor=1) if num == 0: template.warn ( "no previously-included files found matching '%s'"% pattern)
def read_template (self): """Read and parse the manifest template file named by 'self.template' (usually "MANIFEST.in"). Process all file specifications (include and exclude) in the manifest template and add the resulting filenames to 'self.files'."""
print "global-include", pattern files = select_pattern (all_files, pattern, anchor=0) if not files: template.warn (("no files found matching '%s' " + "anywhere in distribution") % pattern) else: self.files.extend (files)
print "global-include", string.join(pattern_list) for pattern in pattern_list: files = select_pattern (all_files, pattern, anchor=0) if not files: template.warn (("no files found matching '%s' " + "anywhere in distribution") % pattern) else: self.files.extend (files)
def read_template (self): """Read and parse the manifest template file named by 'self.template' (usually "MANIFEST.in"). Process all file specifications (include and exclude) in the manifest template and add the resulting filenames to 'self.files'."""
print "global-exclude", pattern num = exclude_pattern (self.files, pattern, anchor=0) if num == 0: template.warn \ (("no previously-included files matching '%s' " + "found anywhere in distribution") % pattern)
print "global-exclude", string.join(pattern_list) for pattern in pattern_list: num = exclude_pattern (self.files, pattern, anchor=0) if num == 0: template.warn \ (("no previously-included files matching '%s' " + "found anywhere in distribution") % pattern)
def read_template (self): """Read and parse the manifest template file named by 'self.template' (usually "MANIFEST.in"). Process all file specifications (include and exclude) in the manifest template and add the resulting filenames to 'self.files'."""
print "recursive-include", dir, pattern files = select_pattern (all_files, pattern, prefix=dir) if not files: template.warn (("no files found matching '%s' " + "under directory '%s'") % (pattern, dir)) else: self.files.extend (files)
print "recursive-include", dir, string.join(pattern_list) for pattern in pattern_list: files = select_pattern (all_files, pattern, prefix=dir) if not files: template.warn (("no files found matching '%s' " + "under directory '%s'") % (pattern, dir)) else: self.files.extend (files)
def read_template (self): """Read and parse the manifest template file named by 'self.template' (usually "MANIFEST.in"). Process all file specifications (include and exclude) in the manifest template and add the resulting filenames to 'self.files'."""
print "recursive-exclude", dir, pattern num = exclude_pattern (self.files, pattern, prefix=dir) if num == 0: template.warn \ (("no previously-included files matching '%s' " + "found under directory '%s'") % (pattern, dir))
print "recursive-exclude", dir, string.join(pattern_list) for pattern in pattern_list: num = exclude_pattern (self.files, pattern, prefix=dir) if num == 0: template.warn \ (("no previously-included files matching '%s' " + "found under directory '%s'") % (pattern, dir))
def read_template (self): """Read and parse the manifest template file named by 'self.template' (usually "MANIFEST.in"). Process all file specifications (include and exclude) in the manifest template and add the resulting filenames to 'self.files'."""
file(foo_path, 'w').close() file(bar_path, 'w').close()
f = open(foo_path, 'w') f.write("@") f.close() f = open(bar_path, 'w') f.write("@") f.close()
def test_clean(self): # Remove old files from 'tmp' foo_path = os.path.join(self._path, 'tmp', 'foo') bar_path = os.path.join(self._path, 'tmp', 'bar') file(foo_path, 'w').close() file(bar_path, 'w').close() self._box.clean() self.assert_(os.path.exists(foo_path)) self.assert_(os.path.exists(bar_path)) foo_stat = os.st...
os.utime(os.path.join(foo_path), (time.time() - 129600 - 2, foo_stat.st_mtime))
os.utime(foo_path, (time.time() - 129600 - 2, foo_stat.st_mtime))
def test_clean(self): # Remove old files from 'tmp' foo_path = os.path.join(self._path, 'tmp', 'foo') bar_path = os.path.join(self._path, 'tmp', 'bar') file(foo_path, 'w').close() file(bar_path, 'w').close() self._box.clean() self.assert_(os.path.exists(foo_path)) self.assert_(os.path.exists(bar_path)) foo_stat = os.st...
st = os.lstat(name)
try: st = os.lstat(name) except os.error: continue
def walk(top, func, arg): """walk(top,func,arg) calls func(arg, d, files) for each directory "d" in the tree rooted at "top" (including "top" itself). "files" is a list of all the files and subdirs in directory "d". """ try: names = os.listdir(top) except os.error: return func(arg, top, names) for name in names: name...
s = "Module(%r" % % (self.__name__,)
s = "Module(%r" % (self.__name__,)
def __repr__(self): s = "Module(%r" % % (self.__name__,) if self.__file__ is not None: s = s + ", %r" % (self.__file__,) if self.__path__ is not None: s = s + ", %r" % (self.__path__,) s = s + ")" return s
(run, run == 1 and "" or "s", timeTaken))
(run, run != 1 and "s" or "", timeTaken))
def run(self, test): "Run the given test case or test suite." result = self._makeResult() startTime = time.time() test(result) stopTime = time.time() timeTaken = float(stopTime - startTime) result.printErrors() self.stream.writeln(result.separator2) run = result.testsRun self.stream.writeln("Ran %d test%s in %.3fs" % (...
def IN_CLASSA(a): return ((((in_addr_t)(a)) & 0x80000000) == 0) IN_CLASSA_NET = 0xff000000
def IN_CLASSA(a): return ((((in_addr_t)(a)) & (-2147483648)) == 0) IN_CLASSA_NET = (-16777216)
def IN_CLASSA(a): return ((((in_addr_t)(a)) & 0x80000000) == 0)
IN_CLASSA_HOST = (0xffffffff & ~IN_CLASSA_NET)
IN_CLASSA_HOST = ((-1) & ~IN_CLASSA_NET)
def IN_CLASSA(a): return ((((in_addr_t)(a)) & 0x80000000) == 0)
def IN_CLASSB(a): return ((((in_addr_t)(a)) & 0xc0000000) == 0x80000000) IN_CLASSB_NET = 0xffff0000
def IN_CLASSB(a): return ((((in_addr_t)(a)) & (-1073741824)) == (-2147483648)) IN_CLASSB_NET = (-65536)
def IN_CLASSB(a): return ((((in_addr_t)(a)) & 0xc0000000) == 0x80000000)
IN_CLASSB_HOST = (0xffffffff & ~IN_CLASSB_NET)
IN_CLASSB_HOST = ((-1) & ~IN_CLASSB_NET)
def IN_CLASSB(a): return ((((in_addr_t)(a)) & 0xc0000000) == 0x80000000)
def IN_CLASSC(a): return ((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000) IN_CLASSC_NET = 0xffffff00
def IN_CLASSC(a): return ((((in_addr_t)(a)) & (-536870912)) == (-1073741824)) IN_CLASSC_NET = (-256)
def IN_CLASSC(a): return ((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000)
IN_CLASSC_HOST = (0xffffffff & ~IN_CLASSC_NET) def IN_CLASSD(a): return ((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000)
IN_CLASSC_HOST = ((-1) & ~IN_CLASSC_NET) def IN_CLASSD(a): return ((((in_addr_t)(a)) & (-268435456)) == (-536870912))
def IN_CLASSC(a): return ((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000)
def IN_EXPERIMENTAL(a): return ((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000) def IN_BADCLASS(a): return ((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000)
def IN_EXPERIMENTAL(a): return ((((in_addr_t)(a)) & (-536870912)) == (-536870912)) def IN_BADCLASS(a): return ((((in_addr_t)(a)) & (-268435456)) == (-268435456))
def IN_EXPERIMENTAL(a): return ((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000)
PATH_MAX = 4095
PATH_MAX = 4096
def IN_BADCLASS(a): return ((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000)
SSIZE_MAX = INT_MAX
SSIZE_MAX = LONG_MAX
def IN_BADCLASS(a): return ((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000)
FILENAME_MAX = 4095
FILENAME_MAX = 4096
def IN_BADCLASS(a): return ((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000)
fp = open(pathname)
fp = open(pathname, "U")
def run_script(self, pathname): self.msg(2, "run_script", pathname) fp = open(pathname) stuff = ("", "r", imp.PY_SOURCE) self.load_module('__main__', fp, pathname, stuff)
fp = open(pathname)
fp = open(pathname, "U")
def load_file(self, pathname): dir, name = os.path.split(pathname) name, ext = os.path.splitext(name) fp = open(pathname) stuff = (ext, "r", imp.PY_SOURCE) self.load_module(name, fp, pathname, stuff)
args['linker_so'] = linker_so + ' -shared'
if platform == 'darwin1': args['linker_so'] = linker_so else: args['linker_so'] = linker_so + ' -shared'
def build_extensions(self):
self.read_multi()
self.read_multi(environ, keep_blank_values, strict_parsing)
def __init__(self, fp=None, headers=None, outerboundary="", environ=os.environ, keep_blank_values=0, strict_parsing=0): """Constructor. Read multipart/* until last part.
def read_multi(self):
def read_multi(self, environ, keep_blank_values, strict_parsing):
def read_multi(self): """Internal: read a part that is itself multipart.""" self.list = [] part = self.__class__(self.fp, {}, self.innerboundary) # Throw first part away while not part.done: headers = rfc822.Message(self.fp) part = self.__class__(self.fp, headers, self.innerboundary) self.list.append(part) self.skip_li...
part = self.__class__(self.fp, {}, self.innerboundary)
part = self.__class__(self.fp, {}, self.innerboundary, environ, keep_blank_values, strict_parsing)
def read_multi(self): """Internal: read a part that is itself multipart.""" self.list = [] part = self.__class__(self.fp, {}, self.innerboundary) # Throw first part away while not part.done: headers = rfc822.Message(self.fp) part = self.__class__(self.fp, headers, self.innerboundary) self.list.append(part) self.skip_li...
part = self.__class__(self.fp, headers, self.innerboundary)
part = self.__class__(self.fp, headers, self.innerboundary, environ, keep_blank_values, strict_parsing)
def read_multi(self): """Internal: read a part that is itself multipart.""" self.list = [] part = self.__class__(self.fp, {}, self.innerboundary) # Throw first part away while not part.done: headers = rfc822.Message(self.fp) part = self.__class__(self.fp, headers, self.innerboundary) self.list.append(part) self.skip_li...
tests = [ GeneralModuleTests, BasicTCPTest ]
tests = [GeneralModuleTests, BasicTCPTest, TCPTimeoutTest, TestExceptions]
def test_main(): tests = [ GeneralModuleTests, BasicTCPTest ] if sys.platform != 'mac': tests.append(BasicUDPTest) tests.extend([ NonBlockingTCPTests, FileObjectClassTestCase, UnbufferedFileObjectClassTestCase, LineBufferedFileObjectClassTestCase, SmallBufferedFileObjectClassTestCase ]) test_support.run_unittest(*test...
tests.append(BasicUDPTest)
tests.extend([ BasicUDPTest, UDPTimeoutTest ])
def test_main(): tests = [ GeneralModuleTests, BasicTCPTest ] if sys.platform != 'mac': tests.append(BasicUDPTest) tests.extend([ NonBlockingTCPTests, FileObjectClassTestCase, UnbufferedFileObjectClassTestCase, LineBufferedFileObjectClassTestCase, SmallBufferedFileObjectClassTestCase ]) test_support.run_unittest(*test...
user_pass = base64.encodestring(unquote(user_pass)).strip() req.add_header('Proxy-Authorization', 'Basic '+user_pass)
if ':' in user_pass: user, password = user_pass.split(':', 1) user_pass = base64.encodestring('%s:%s' % (unquote(user), unquote(password))) req.add_header('Proxy-Authorization', 'Basic ' + user_pass)
def proxy_open(self, req, proxy, type): orig_type = req.get_type() type, r_type = splittype(proxy) host, XXX = splithost(r_type) if '@' in host: user_pass, host = host.split('@', 1) user_pass = base64.encodestring(unquote(user_pass)).strip() req.add_header('Proxy-Authorization', 'Basic '+user_pass) host = unquote(host)...
h.putheader('Host', host)
scheme, sel = splittype(req.get_selector()) sel_host, sel_path = splithost(sel) h.putheader('Host', sel_host or host)
def do_open(self, http_class, req): host = req.get_host() if not host: raise URLError('no host given')
print "open", askopenfilename(filetypes=[("all filez", "*")]).encode(enc)
print "open", askopenfilename(filetypes=[("all files", "*")]).encode(enc)
def askdirectory (**options): "Ask for a directory, and return the file name" return Directory(**options).show()