bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def find_library_file (self, dirs, lib):
def find_library_file (self, dirs, lib):
12,900
def __init__(self,stream,errors='strict',mapping=None):
def __init__(self,stream,errors='strict',mapping=None):
12,901
def splituser(host): """splituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.""" global _userprog if _userprog is None: import re _userprog = re.compile('^([^@]*)@(.*)$') match = _userprog.match(host) if match: return map(unquote, match.group(1, 2)) return None, host
def splituser(host): """splituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'.""" global _userprog if _userprog is None: import re _userprog = re.compile('^(.*)@(.*)$') match = _userprog.match(host) if match: return map(unquote, match.group(1, 2)) return None, host
12,902
#ifdef USE_TOOLBOX_OBJECT_GLUE
#ifdef""" finalstuff = finalstuff + """ /* Routines to convert any CF type to/from the corresponding CFxxxObj */ PyObject *CFObj_New(CFTypeRef itself) { if (itself == NULL) { PyErr_SetString(PyExc_RuntimeError, "cannot wrap NULL"); return NULL; } if (CFGetTypeID(itself) == CFArrayGetTypeID()) return CFArrayRefObj_New((CFArrayRef)itself); if (CFGetTypeID(itself) == CFDictionaryGetTypeID()) return CFDictionaryRefObj_New((CFDictionaryRef)itself); if (CFGetTypeID(itself) == CFDataGetTypeID()) return CFDataRefObj_New((CFDataRef)itself); if (CFGetTypeID(itself) == CFStringGetTypeID()) return CFStringRefObj_New((CFStringRef)itself); if (CFGetTypeID(itself) == CFURLGetTypeID()) return CFURLRefObj_New((CFURLRef)itself); /* XXXX Or should we use PyCF_CF2Python here?? */ return CFTypeRefObj_New(itself); } int CFObj_Convert(PyObject *v, CFTypeRef *p_itself) { if (v == Py_None) { *p_itself = NULL; return 1; } /* Check for other CF objects here */ if (!CFTypeRefObj_Check(v) && !CFArrayRefObj_Check(v) && !CFMutableArrayRefObj_Check(v) && !CFDictionaryRefObj_Check(v) && !CFMutableDictionaryRefObj_Check(v) && !CFDataRefObj_Check(v) && !CFMutableDataRefObj_Check(v) && !CFStringRefObj_Check(v) && !CFMutableStringRefObj_Check(v) && !CFURLRefObj_Check(v) ) { /* XXXX Or should we use PyCF_Python2CF here?? */ PyErr_SetString(PyExc_TypeError, "CF object required"); return 0; } *p_itself = ((CFTypeRefObject *)v)->ob_itself; return 1; } USE_TOOLBOX_OBJECT_GLUE
12,903
def startElement(self, name, attrs): self._out.write('<' + name) for (name, value) in attrs.items(): self._out.write(' %s="%s"' % (name, escape(value))) self._out.write('>')
def startElement(self, name, attrs): self._out.write('<' + name) for (name, value) in attrs.items(): self._out.write(' %s=%s' % (name, quoteattr(value))) self._out.write('>')
12,904
def startElementNS(self, name, qname, attrs): if name[0] is None: # if the name was not namespace-scoped, use the unqualified part name = name[1] else: # else try to restore the original prefix from the namespace name = self._current_context[name[0]] + ":" + name[1] self._out.write('<' + name)
def startElementNS(self, name, qname, attrs): if name[0] is None: # if the name was not namespace-scoped, use the unqualified part name = name[1] else: # else try to restore the original prefix from the namespace name = self._current_context[name[0]] + ":" + name[1] self._out.write('<' + name)
12,905
def demo2(): # exercises some new and improved features speed('fast') width(3) # draw a segmented half-circle setheading(towards(0,0)) x,y = position() r = (x**2+y**2)**.5/2.0 right(90) pendown = True for i in range(18): if pendown: up() pendown = False else: down() pendown = True circle(r,10) sleep(2) reset() left(90) # draw a series of triangles l = 10 color("green") width(3) left(180) sp = 5 for i in range(-2,16): if i > 0: color(1.0-0.05*i,0,0.05*i) fill(1) color("green") for j in range(3): forward(l) left(120) l += 10 left(15) if sp > 0: sp = sp-1 speed(speeds[sp]) color(0.25,0,0.75) fill(0) # draw and fill a concave shape left(120) up() forward(70) right(30) down() color("red") speed("fastest") fill(1) for i in range(4): circle(50,90) right(90) forward(30) right(90) color("yellow") fill(0) left(90) up() forward(30) down(); color("red") # create a second turtle and make the original pursue and catch it turtle=Turtle() turtle.reset() turtle.left(90) turtle.speed('normal') turtle.up() turtle.goto(280,40) turtle.left(24) turtle.down() turtle.speed('fast') turtle.color("blue") turtle.width(2) speed('fastest') # turn default turtle towards new turtle object setheading(towards(turtle)) while ( abs(position()[0]-turtle.position()[0])>4 or abs(position()[1]-turtle.position()[1])>4): turtle.forward(3.5) turtle.left(0.6) # turn default turtle towards new turtle object setheading(towards(turtle)) forward(4) write("CAUGHT! ", move=True)
def demo2(): # exercises some new and improved features speed('fast') width(3) # draw a segmented half-circle setheading(towards(0,0)) x,y = position() r = (x**2+y**2)**.5/2.0 right(90) pendown = True for i in range(18): if pendown: up() pendown = False else: down() pendown = True circle(r,10) sleep(2) reset() left(90) # draw a series of triangles l = 10 color("green") width(3) left(180) sp = 5 for i in range(-2,16): if i > 0: color(1.0-0.05*i,0,0.05*i) fill(1) color("green") for j in range(3): forward(l) left(120) l += 10 left(15) if sp > 0: sp = sp-1 speed(speeds[sp]) color(0.25,0,0.75) fill(0) # draw and fill a concave shape left(120) up() forward(70) right(30) down() color("red") speed("fastest") fill(1) for i in range(4): circle(50,90) right(90) forward(30) right(90) color("yellow") fill(0) left(90) up() forward(30) down(); color("red") # create a second turtle and make the original pursue and catch it turtle=Turtle() turtle.reset() turtle.left(90) turtle.speed('normal') turtle.up() turtle.goto(280,40) turtle.left(24) turtle.down() turtle.speed('fast') turtle.color("blue") turtle.width(2) speed('fastest') # turn default turtle towards new turtle object setheading(towards(turtle)) while ( abs(position()[0]-turtle.position()[0])>4 or abs(position()[1]-turtle.position()[1])>4): turtle.forward(3.5) turtle.left(0.6) # turn default turtle towards new turtle object setheading(towards(turtle)) forward(4) write("CAUGHT! ", move=True)
12,906
def getdefaultlocale(envvars=('LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LANG')): """ Tries to determine the default locale settings and returns them as tuple (language code, encoding). According to POSIX, a program which has not called setlocale(LC_ALL, "") runs using the portable 'C' locale. Calling setlocale(LC_ALL, "") lets it use the default locale as defined by the LANG variable. Since we don't want to interfere with the current locale setting we thus emulate the behavior in the way described above. To maintain compatibility with other platforms, not only the LANG variable is tested, but a list of variables given as envvars parameter. The first found to be defined will be used. envvars defaults to the search path used in GNU gettext; it must always contain the variable name 'LANG'. Except for the code 'C', the language code corresponds to RFC 1766. code and encoding can be None in case the values cannot be determined. """ try: # check if it's supported by the _locale module import _locale code, encoding = _locale._getdefaultlocale() except (ImportError, AttributeError): pass else: # make sure the code/encoding values are valid if sys.platform == "win32" and code and code[:2] == "0x": # map windows language identifier to language name code = windows_locale.get(int(code, 0)) # ...add other platform-specific processing here, if # necessary... return code, encoding # fall back on POSIX behaviour import os lookup = os.environ.get for variable in envvars: localename = lookup(variable,None) if localename is not None: break else: localename = 'C' return _parse_localename(localename)
def getdefaultlocale(envvars=('LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LANG')): """ Tries to determine the default locale settings and returns them as tuple (language code, encoding). According to POSIX, a program which has not called setlocale(LC_ALL, "") runs using the portable 'C' locale. Calling setlocale(LC_ALL, "") lets it use the default locale as defined by the LANG variable. Since we don't want to interfere with the current locale setting we thus emulate the behavior in the way described above. To maintain compatibility with other platforms, not only the LANG variable is tested, but a list of variables given as envvars parameter. The first found to be defined will be used. envvars defaults to the search path used in GNU gettext; it must always contain the variable name 'LANG'. Except for the code 'C', the language code corresponds to RFC 1766. code and encoding can be None in case the values cannot be determined. """ try: # check if it's supported by the _locale module import _locale code, encoding = _locale._getdefaultlocale() except (ImportError, AttributeError): pass else: # make sure the code/encoding values are valid if sys.platform == "win32" and code and code[:2] == "0x": # map windows language identifier to language name code = windows_locale.get(int(code, 0)) # ...add other platform-specific processing here, if # necessary... return code, encoding # fall back on POSIX behaviour import os lookup = os.environ.get for variable in envvars: localename = lookup(variable,None) if localename: break else: localename = 'C' return _parse_localename(localename)
12,907
def _prepareInstall(self, package, force=0, recursive=1): """Internal routine, recursive engine for prepareInstall. Test whether the package is installed and (if not installed or if force==1) prepend it to the temporary todo list and call ourselves recursively on all prerequisites.""" if not force: status, message = package.installed() if status == "yes": return if package in self._todo or package in self._curtodo: return self._curtodo.insert(0, package) if not recursive: return prereqs = package.prerequisites() for pkg, descr in prereqs: if pkg: self._prepareInstall(pkg, force, recursive) else: self._curmessages.append("Problem with dependency: %s" % descr)
def _prepareInstall(self, package, force=0, recursive=1): """Internal routine, recursive engine for prepareInstall. Test whether the package is installed and (if not installed or if force==1) prepend it to the temporary todo list and call ourselves recursively on all prerequisites.""" if not force: status, message = package.installed() if status == "yes": return if package in self._todo or package in self._curtodo: return self._curtodo.insert(0, package) if not recursive: return prereqs = package.prerequisites() for pkg, descr in prereqs: if pkg: self._prepareInstall(pkg, False, recursive) else: self._curmessages.append("Problem with dependency: %s" % descr)
12,908
def addpackage(sitedir, name): global _dirs_in_sys_path if _dirs_in_sys_path is None: _init_pathinfo() reset = 1 else: reset = 0 fullname = os.path.join(sitedir, name) try: f = open(fullname) except IOError: return while 1: dir = f.readline() if not dir: break if dir[0] == '#': continue if dir.startswith("import"): exec dir continue if dir[-1] == '\n': dir = dir[:-1] dir, dircase = makepath(sitedir, dir) if not dircase in _dirs_in_sys_path and os.path.exists(dir): sys.path.append(dir) _dirs_in_sys_path[dircase] = 1 if reset: _dirs_in_sys_path = None
def addpackage(sitedir, name): global _dirs_in_sys_path if _dirs_in_sys_path is None: _init_pathinfo() reset = 1 else: reset = 0 fullname = os.path.join(sitedir, name) try: f = open(fullname) except IOError: return while 1: dir = f.readline() if not dir: break if dir[0] == '#': continue if dir.startswith("import"): exec dir continue dir = dir.rstrip() dir, dircase = makepath(sitedir, dir) if not dircase in _dirs_in_sys_path and os.path.exists(dir): sys.path.append(dir) _dirs_in_sys_path[dircase] = 1 if reset: _dirs_in_sys_path = None
12,909
def __init__(self, link, str, seqno): self.links = [link] self.seqno = seqno # remove <#\d+#> left in by moving the data out of LaTeX2HTML str = self.__rmjunk.sub('', str) # build up the text self.text = split_entry_text(str) self.key = split_entry_key(str)
def __init__(self, link, str, seqno): self.links = [link] self.seqno = seqno # remove <#\d+#> left in by moving the data out of LaTeX2HTMLfor pattern, replacement in REPLACEMENTS: str = pattern.sub(replacement, str) # build up the text self.text = split_entry_text(str) self.key = split_entry_key(str)
12,910
def getMessage(self): """ Return the message for this LogRecord.
def getMessage(self): """ Return the message for this LogRecord.
12,911
def is_cgi(self): """test whether PATH corresponds to a CGI script.
def is_cgi(self): """test whether PATH corresponds to a CGI script.
12,912
def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = string.rfind(rest, '?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = string.find(rest, '/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `scriptname`) return if not executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return nobody = nobody_uid() self.send_response(200, "Script output follows") self.wfile.flush() # Always flush before forking pid = os.fork() if pid != 0: # Parent pid, sts = os.waitpid(pid, 0) if sts: self.log_error("CGI script exit status x%x" % sts) return # Child try: # Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html # XXX Much of the following could be prepared ahead of time! env = {} env['SERVER_SOFTWARE'] = self.version_string() env['SERVER_NAME'] = self.server.server_name env['GATEWAY_INTERFACE'] = 'CGI/1.1' env['SERVER_PROTOCOL'] = self.protocol_version env['SERVER_PORT'] = str(self.server.server_port) env['REQUEST_METHOD'] = self.command uqrest = urllib.unquote(rest) env['PATH_INFO'] = uqrest env['PATH_TRANSLATED'] = self.translate_path(uqrest) env['SCRIPT_NAME'] = scriptname if query: env['QUERY_STRING'] = query host = self.address_string() if host != self.client_address[0]: env['REMOTE_HOST'] = host env['REMOTE_ADDR'] = self.client_address[0] # AUTH_TYPE # REMOTE_USER # REMOTE_IDENT if self.headers.typeheader is None: env['CONTENT_TYPE'] = self.headers.type else: env['CONTENT_TYPE'] = self.headers.typeheader length = self.headers.getheader('content-length') if length: env['CONTENT_LENGTH'] = length accept = [] for line in self.headers.getallmatchingheaders('accept'): if line[:1] in string.whitespace: accept.append(string.strip(line)) else: accept = accept + string.split(line[7:], ',') env['HTTP_ACCEPT'] = string.joinfields(accept, ',') ua = self.headers.getheader('user-agent') if ua: env['HTTP_USER_AGENT'] = ua co = filter(None, self.headers.getheaders('cookie')) if co: env['HTTP_COOKIE'] = string.join(co, ', ') # XXX Other HTTP_* headers decoded_query = string.replace(query, '+', ' ') try: os.setuid(nobody) except os.error: pass os.dup2(self.rfile.fileno(), 0) os.dup2(self.wfile.fileno(), 1) print scriptfile, script, decoded_query os.execve(scriptfile, [script, decoded_query], env) except: self.server.handle_error(self.request, self.client_address) os._exit(127)
def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = string.rfind(rest, '?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = string.find(rest, '/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `scriptname`) return ispy = self.is_python(scriptname) if not ispy: if not (self.have_fork or self.have_popen2): self.send_error(403, "CGI script is not a Python script (%s)" % `scriptname`) return if not self.is_executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return env = {} env['SERVER_SOFTWARE'] = self.version_string() env['SERVER_NAME'] = self.server.server_name env['GATEWAY_INTERFACE'] = 'CGI/1.1' env['SERVER_PROTOCOL'] = self.protocol_version env['SERVER_PORT'] = str(self.server.server_port) env['REQUEST_METHOD'] = self.command uqrest = urllib.unquote(rest) env['PATH_INFO'] = uqrest env['PATH_TRANSLATED'] = self.translate_path(uqrest) env['SCRIPT_NAME'] = scriptname if query: env['QUERY_STRING'] = query host = self.address_string() if host != self.client_address[0]: env['REMOTE_HOST'] = host env['REMOTE_ADDR'] = self.client_address[0] if self.headers.typeheader is None: env['CONTENT_TYPE'] = self.headers.type else: env['CONTENT_TYPE'] = self.headers.typeheader length = self.headers.getheader('content-length') if length: env['CONTENT_LENGTH'] = length accept = [] for line in self.headers.getallmatchingheaders('accept'): if line[:1] in string.whitespace: accept.append(string.strip(line)) else: accept = accept + string.split(line[7:], ',') env['HTTP_ACCEPT'] = string.joinfields(accept, ',') ua = self.headers.getheader('user-agent') if ua: env['HTTP_USER_AGENT'] = ua co = filter(None, self.headers.getheaders('cookie')) if co: env['HTTP_COOKIE'] = string.join(co, ', ') if not self.have_fork: for k in ('QUERY_STRING', 'REMOTE_HOST', 'CONTENT_LENGTH', 'HTTP_USER_AGENT', 'HTTP_COOKIE'): env.setdefault(k, "") self.send_response(200, "Script output follows") self.wfile.flush() # Always flush before forking pid = os.fork() if pid != 0: # Parent pid, sts = os.waitpid(pid, 0) if sts: self.log_error("CGI script exit status x%x" % sts) return # Child try: # Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html # XXX Much of the following could be prepared ahead of time! env = {} env['SERVER_SOFTWARE'] = self.version_string() env['SERVER_NAME'] = self.server.server_name env['GATEWAY_INTERFACE'] = 'CGI/1.1' env['SERVER_PROTOCOL'] = self.protocol_version env['SERVER_PORT'] = str(self.server.server_port) env['REQUEST_METHOD'] = self.command uqrest = urllib.unquote(rest) env['PATH_INFO'] = uqrest env['PATH_TRANSLATED'] = self.translate_path(uqrest) env['SCRIPT_NAME'] = scriptname if query: env['QUERY_STRING'] = query host = self.address_string() if host != self.client_address[0]: env['REMOTE_HOST'] = host env['REMOTE_ADDR'] = self.client_address[0] # AUTH_TYPE # REMOTE_USER # REMOTE_IDENT if self.headers.typeheader is None: env['CONTENT_TYPE'] = self.headers.type else: env['CONTENT_TYPE'] = self.headers.typeheader length = self.headers.getheader('content-length') if length: env['CONTENT_LENGTH'] = length accept = [] for line in self.headers.getallmatchingheaders('accept'): if line[:1] in string.whitespace: accept.append(string.strip(line)) else: accept = accept + string.split(line[7:], ',') env['HTTP_ACCEPT'] = string.joinfields(accept, ',') ua = self.headers.getheader('user-agent') if ua: env['HTTP_USER_AGENT'] = ua co = filter(None, self.headers.getheaders('cookie')) if co: env['HTTP_COOKIE'] = string.join(co, ', ') # XXX Other HTTP_* headers decoded_query = string.replace(query, '+', ' ') try: os.setuid(nobody) except os.error: pass os.dup2(self.rfile.fileno(), 0) os.dup2(self.wfile.fileno(), 1) print scriptfile, script, decoded_query os.execve(scriptfile, [script, decoded_query], env) except: self.server.handle_error(self.request, self.client_address) os._exit(127)
12,913
def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = string.rfind(rest, '?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = string.find(rest, '/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `scriptname`) return if not executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return nobody = nobody_uid() self.send_response(200, "Script output follows") self.wfile.flush() # Always flush before forking pid = os.fork() if pid != 0: # Parent pid, sts = os.waitpid(pid, 0) if sts: self.log_error("CGI script exit status x%x" % sts) return # Child try: # Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html # XXX Much of the following could be prepared ahead of time! env = {} env['SERVER_SOFTWARE'] = self.version_string() env['SERVER_NAME'] = self.server.server_name env['GATEWAY_INTERFACE'] = 'CGI/1.1' env['SERVER_PROTOCOL'] = self.protocol_version env['SERVER_PORT'] = str(self.server.server_port) env['REQUEST_METHOD'] = self.command uqrest = urllib.unquote(rest) env['PATH_INFO'] = uqrest env['PATH_TRANSLATED'] = self.translate_path(uqrest) env['SCRIPT_NAME'] = scriptname if query: env['QUERY_STRING'] = query host = self.address_string() if host != self.client_address[0]: env['REMOTE_HOST'] = host env['REMOTE_ADDR'] = self.client_address[0] # AUTH_TYPE # REMOTE_USER # REMOTE_IDENT if self.headers.typeheader is None: env['CONTENT_TYPE'] = self.headers.type else: env['CONTENT_TYPE'] = self.headers.typeheader length = self.headers.getheader('content-length') if length: env['CONTENT_LENGTH'] = length accept = [] for line in self.headers.getallmatchingheaders('accept'): if line[:1] in string.whitespace: accept.append(string.strip(line)) else: accept = accept + string.split(line[7:], ',') env['HTTP_ACCEPT'] = string.joinfields(accept, ',') ua = self.headers.getheader('user-agent') if ua: env['HTTP_USER_AGENT'] = ua co = filter(None, self.headers.getheaders('cookie')) if co: env['HTTP_COOKIE'] = string.join(co, ', ') # XXX Other HTTP_* headers decoded_query = string.replace(query, '+', ' ') try: os.setuid(nobody) except os.error: pass os.dup2(self.rfile.fileno(), 0) os.dup2(self.wfile.fileno(), 1) print scriptfile, script, decoded_query os.execve(scriptfile, [script, decoded_query], env) except: self.server.handle_error(self.request, self.client_address) os._exit(127)
def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = string.rfind(rest, '?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = string.find(rest, '/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `scriptname`) return if not executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return nobody = nobody_uid() self.send_response(200, "Script output follows") self.wfile.flush() # Always flush before forking pid = os.fork() if pid != 0: # Parent pid, sts = os.waitpid(pid, 0) if sts: self.log_error("CGI script exit status x%x" % sts) return # Child try: # Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html # XXX Much of the following could be prepared ahead of time! env = {} env['SERVER_SOFTWARE'] = self.version_string() env['SERVER_NAME'] = self.server.server_name env['GATEWAY_INTERFACE'] = 'CGI/1.1' env['SERVER_PROTOCOL'] = self.protocol_version env['SERVER_PORT'] = str(self.server.server_port) env['REQUEST_METHOD'] = self.command uqrest = urllib.unquote(rest) env['PATH_INFO'] = uqrest env['PATH_TRANSLATED'] = self.translate_path(uqrest) env['SCRIPT_NAME'] = scriptname if query: env['QUERY_STRING'] = query host = self.address_string() if host != self.client_address[0]: env['REMOTE_HOST'] = host env['REMOTE_ADDR'] = self.client_address[0] # AUTH_TYPE # REMOTE_USER # REMOTE_IDENT if self.headers.typeheader is None: env['CONTENT_TYPE'] = self.headers.type else: env['CONTENT_TYPE'] = self.headers.typeheader length = self.headers.getheader('content-length') if length: env['CONTENT_LENGTH'] = length accept = [] for line in self.headers.getallmatchingheaders('accept'): if line[:1] in string.whitespace: accept.append(string.strip(line)) else: accept = accept + string.split(line[7:], ',') env['HTTP_ACCEPT'] = string.joinfields(accept, ',') ua = self.headers.getheader('user-agent') if ua: env['HTTP_USER_AGENT'] = ua co = filter(None, self.headers.getheaders('cookie')) if co: env['HTTP_COOKIE'] = string.join(co, ', ') # XXX Other HTTP_* headers decoded_query = string.replace(query, '+', ' ') try: os.setuid(nobody) except os.error: pass os.dup2(self.rfile.fileno(), 0) os.dup2(self.wfile.fileno(), 1) print scriptfile, script, decoded_query os.execve(scriptfile, [script, decoded_query], env) except: self.server.handle_error(self.request, self.client_address) os._exit(127)
12,914
def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = string.rfind(rest, '?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = string.find(rest, '/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `scriptname`) return if not executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return nobody = nobody_uid() self.send_response(200, "Script output follows") self.wfile.flush() # Always flush before forking pid = os.fork() if pid != 0: # Parent pid, sts = os.waitpid(pid, 0) if sts: self.log_error("CGI script exit status x%x" % sts) return # Child try: # Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html # XXX Much of the following could be prepared ahead of time! env = {} env['SERVER_SOFTWARE'] = self.version_string() env['SERVER_NAME'] = self.server.server_name env['GATEWAY_INTERFACE'] = 'CGI/1.1' env['SERVER_PROTOCOL'] = self.protocol_version env['SERVER_PORT'] = str(self.server.server_port) env['REQUEST_METHOD'] = self.command uqrest = urllib.unquote(rest) env['PATH_INFO'] = uqrest env['PATH_TRANSLATED'] = self.translate_path(uqrest) env['SCRIPT_NAME'] = scriptname if query: env['QUERY_STRING'] = query host = self.address_string() if host != self.client_address[0]: env['REMOTE_HOST'] = host env['REMOTE_ADDR'] = self.client_address[0] # AUTH_TYPE # REMOTE_USER # REMOTE_IDENT if self.headers.typeheader is None: env['CONTENT_TYPE'] = self.headers.type else: env['CONTENT_TYPE'] = self.headers.typeheader length = self.headers.getheader('content-length') if length: env['CONTENT_LENGTH'] = length accept = [] for line in self.headers.getallmatchingheaders('accept'): if line[:1] in string.whitespace: accept.append(string.strip(line)) else: accept = accept + string.split(line[7:], ',') env['HTTP_ACCEPT'] = string.joinfields(accept, ',') ua = self.headers.getheader('user-agent') if ua: env['HTTP_USER_AGENT'] = ua co = filter(None, self.headers.getheaders('cookie')) if co: env['HTTP_COOKIE'] = string.join(co, ', ') # XXX Other HTTP_* headers decoded_query = string.replace(query, '+', ' ') try: os.setuid(nobody) except os.error: pass os.dup2(self.rfile.fileno(), 0) os.dup2(self.wfile.fileno(), 1) print scriptfile, script, decoded_query os.execve(scriptfile, [script, decoded_query], env) except: self.server.handle_error(self.request, self.client_address) os._exit(127)
def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = string.rfind(rest, '?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = string.find(rest, '/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `scriptname`) return if not executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return nobody = nobody_uid() self.send_response(200, "Script output follows") self.wfile.flush() # Always flush before forking pid = os.fork() if pid != 0: # Parent pid, sts = os.waitpid(pid, 0) if sts: self.log_error("CGI script exit status x%x" % sts) return # Child try: # Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html # XXX Much of the following could be prepared ahead of time! env = {} env['SERVER_SOFTWARE'] = self.version_string() env['SERVER_NAME'] = self.server.server_name env['GATEWAY_INTERFACE'] = 'CGI/1.1' env['SERVER_PROTOCOL'] = self.protocol_version env['SERVER_PORT'] = str(self.server.server_port) env['REQUEST_METHOD'] = self.command uqrest = urllib.unquote(rest) env['PATH_INFO'] = uqrest env['PATH_TRANSLATED'] = self.translate_path(uqrest) env['SCRIPT_NAME'] = scriptname if query: env['QUERY_STRING'] = query host = self.address_string() if host != self.client_address[0]: env['REMOTE_HOST'] = host env['REMOTE_ADDR'] = self.client_address[0] # AUTH_TYPE # REMOTE_USER # REMOTE_IDENT if self.headers.typeheader is None: env['CONTENT_TYPE'] = self.headers.type else: env['CONTENT_TYPE'] = self.headers.typeheader length = self.headers.getheader('content-length') if length: env['CONTENT_LENGTH'] = length accept = [] for line in self.headers.getallmatchingheaders('accept'): if line[:1] in string.whitespace: accept.append(string.strip(line)) else: accept = accept + string.split(line[7:], ',') env['HTTP_ACCEPT'] = string.joinfields(accept, ',') ua = self.headers.getheader('user-agent') if ua: env['HTTP_USER_AGENT'] = ua co = filter(None, self.headers.getheaders('cookie')) if co: env['HTTP_COOKIE'] = string.join(co, ', ') # XXX Other HTTP_* headers decoded_query = string.replace(query, '+', ' ') try: os.setuid(nobody) except os.error: pass os.dup2(self.rfile.fileno(), 0) os.dup2(self.wfile.fileno(), 1) print scriptfile, script, decoded_query os.execve(scriptfile, [script, decoded_query], env) except: self.server.handle_error(self.request, self.client_address) os._exit(127)
12,915
def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = string.rfind(rest, '?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = string.find(rest, '/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `scriptname`) return if not executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return nobody = nobody_uid() self.send_response(200, "Script output follows") self.wfile.flush() # Always flush before forking pid = os.fork() if pid != 0: # Parent pid, sts = os.waitpid(pid, 0) if sts: self.log_error("CGI script exit status x%x" % sts) return # Child try: # Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html # XXX Much of the following could be prepared ahead of time! env = {} env['SERVER_SOFTWARE'] = self.version_string() env['SERVER_NAME'] = self.server.server_name env['GATEWAY_INTERFACE'] = 'CGI/1.1' env['SERVER_PROTOCOL'] = self.protocol_version env['SERVER_PORT'] = str(self.server.server_port) env['REQUEST_METHOD'] = self.command uqrest = urllib.unquote(rest) env['PATH_INFO'] = uqrest env['PATH_TRANSLATED'] = self.translate_path(uqrest) env['SCRIPT_NAME'] = scriptname if query: env['QUERY_STRING'] = query host = self.address_string() if host != self.client_address[0]: env['REMOTE_HOST'] = host env['REMOTE_ADDR'] = self.client_address[0] # AUTH_TYPE # REMOTE_USER # REMOTE_IDENT if self.headers.typeheader is None: env['CONTENT_TYPE'] = self.headers.type else: env['CONTENT_TYPE'] = self.headers.typeheader length = self.headers.getheader('content-length') if length: env['CONTENT_LENGTH'] = length accept = [] for line in self.headers.getallmatchingheaders('accept'): if line[:1] in string.whitespace: accept.append(string.strip(line)) else: accept = accept + string.split(line[7:], ',') env['HTTP_ACCEPT'] = string.joinfields(accept, ',') ua = self.headers.getheader('user-agent') if ua: env['HTTP_USER_AGENT'] = ua co = filter(None, self.headers.getheaders('cookie')) if co: env['HTTP_COOKIE'] = string.join(co, ', ') # XXX Other HTTP_* headers decoded_query = string.replace(query, '+', ' ') try: os.setuid(nobody) except os.error: pass os.dup2(self.rfile.fileno(), 0) os.dup2(self.wfile.fileno(), 1) print scriptfile, script, decoded_query os.execve(scriptfile, [script, decoded_query], env) except: self.server.handle_error(self.request, self.client_address) os._exit(127)
def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = string.rfind(rest, '?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = string.find(rest, '/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `scriptname`) return if not executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return nobody = nobody_uid() self.send_response(200, "Script output follows") self.wfile.flush() # Always flush before forking pid = os.fork() if pid != 0: # Parent pid, sts = os.waitpid(pid, 0) if sts: self.log_error("CGI script exit status x%x" % sts) return # Child try: # Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html # XXX Much of the following could be prepared ahead of time! env = {} env['SERVER_SOFTWARE'] = self.version_string() env['SERVER_NAME'] = self.server.server_name env['GATEWAY_INTERFACE'] = 'CGI/1.1' env['SERVER_PROTOCOL'] = self.protocol_version env['SERVER_PORT'] = str(self.server.server_port) env['REQUEST_METHOD'] = self.command uqrest = urllib.unquote(rest) env['PATH_INFO'] = uqrest env['PATH_TRANSLATED'] = self.translate_path(uqrest) env['SCRIPT_NAME'] = scriptname if query: env['QUERY_STRING'] = query host = self.address_string() if host != self.client_address[0]: env['REMOTE_HOST'] = host env['REMOTE_ADDR'] = self.client_address[0] # AUTH_TYPE # REMOTE_USER # REMOTE_IDENT if self.headers.typeheader is None: env['CONTENT_TYPE'] = self.headers.type else: env['CONTENT_TYPE'] = self.headers.typeheader length = self.headers.getheader('content-length') if length: env['CONTENT_LENGTH'] = length accept = [] for line in self.headers.getallmatchingheaders('accept'): if line[:1] in string.whitespace: accept.append(string.strip(line)) else: accept = accept + string.split(line[7:], ',') env['HTTP_ACCEPT'] = string.joinfields(accept, ',') ua = self.headers.getheader('user-agent') if ua: env['HTTP_USER_AGENT'] = ua co = filter(None, self.headers.getheaders('cookie')) if co: env['HTTP_COOKIE'] = string.join(co, ', ') # XXX Other HTTP_* headers decoded_query = string.replace(query, '+', ' ') try: os.setuid(nobody) except os.error: pass os.dup2(self.rfile.fileno(), 0) os.dup2(self.wfile.fileno(), 1) print scriptfile, script, decoded_query os.execve(scriptfile, [script, decoded_query], env) except: self.server.handle_error(self.request, self.client_address) os._exit(127)
12,916
def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = string.rfind(rest, '?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = string.find(rest, '/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `scriptname`) return if not executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return nobody = nobody_uid() self.send_response(200, "Script output follows") self.wfile.flush() # Always flush before forking pid = os.fork() if pid != 0: # Parent pid, sts = os.waitpid(pid, 0) if sts: self.log_error("CGI script exit status x%x" % sts) return # Child try: # Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html # XXX Much of the following could be prepared ahead of time! env = {} env['SERVER_SOFTWARE'] = self.version_string() env['SERVER_NAME'] = self.server.server_name env['GATEWAY_INTERFACE'] = 'CGI/1.1' env['SERVER_PROTOCOL'] = self.protocol_version env['SERVER_PORT'] = str(self.server.server_port) env['REQUEST_METHOD'] = self.command uqrest = urllib.unquote(rest) env['PATH_INFO'] = uqrest env['PATH_TRANSLATED'] = self.translate_path(uqrest) env['SCRIPT_NAME'] = scriptname if query: env['QUERY_STRING'] = query host = self.address_string() if host != self.client_address[0]: env['REMOTE_HOST'] = host env['REMOTE_ADDR'] = self.client_address[0] # AUTH_TYPE # REMOTE_USER # REMOTE_IDENT if self.headers.typeheader is None: env['CONTENT_TYPE'] = self.headers.type else: env['CONTENT_TYPE'] = self.headers.typeheader length = self.headers.getheader('content-length') if length: env['CONTENT_LENGTH'] = length accept = [] for line in self.headers.getallmatchingheaders('accept'): if line[:1] in string.whitespace: accept.append(string.strip(line)) else: accept = accept + string.split(line[7:], ',') env['HTTP_ACCEPT'] = string.joinfields(accept, ',') ua = self.headers.getheader('user-agent') if ua: env['HTTP_USER_AGENT'] = ua co = filter(None, self.headers.getheaders('cookie')) if co: env['HTTP_COOKIE'] = string.join(co, ', ') # XXX Other HTTP_* headers decoded_query = string.replace(query, '+', ' ') try: os.setuid(nobody) except os.error: pass os.dup2(self.rfile.fileno(), 0) os.dup2(self.wfile.fileno(), 1) print scriptfile, script, decoded_query os.execve(scriptfile, [script, decoded_query], env) except: self.server.handle_error(self.request, self.client_address) os._exit(127)
def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = string.rfind(rest, '?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = string.find(rest, '/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `scriptname`) return if not executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return nobody = nobody_uid() self.send_response(200, "Script output follows") self.wfile.flush() # Always flush before forking pid = os.fork() if pid != 0: # Parent pid, sts = os.waitpid(pid, 0) if sts: self.log_error("CGI script exit status x%x" % sts) return # Child try: # Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html # XXX Much of the following could be prepared ahead of time! env = {} env['SERVER_SOFTWARE'] = self.version_string() env['SERVER_NAME'] = self.server.server_name env['GATEWAY_INTERFACE'] = 'CGI/1.1' env['SERVER_PROTOCOL'] = self.protocol_version env['SERVER_PORT'] = str(self.server.server_port) env['REQUEST_METHOD'] = self.command uqrest = urllib.unquote(rest) env['PATH_INFO'] = uqrest env['PATH_TRANSLATED'] = self.translate_path(uqrest) env['SCRIPT_NAME'] = scriptname if query: env['QUERY_STRING'] = query host = self.address_string() if host != self.client_address[0]: env['REMOTE_HOST'] = host env['REMOTE_ADDR'] = self.client_address[0] # AUTH_TYPE # REMOTE_USER # REMOTE_IDENT if self.headers.typeheader is None: env['CONTENT_TYPE'] = self.headers.type else: env['CONTENT_TYPE'] = self.headers.typeheader length = self.headers.getheader('content-length') if length: env['CONTENT_LENGTH'] = length accept = [] for line in self.headers.getallmatchingheaders('accept'): if line[:1] in string.whitespace: accept.append(string.strip(line)) else: accept = accept + string.split(line[7:], ',') env['HTTP_ACCEPT'] = string.joinfields(accept, ',') ua = self.headers.getheader('user-agent') if ua: env['HTTP_USER_AGENT'] = ua co = filter(None, self.headers.getheaders('cookie')) if co: env['HTTP_COOKIE'] = string.join(co, ', ') # XXX Other HTTP_* headers decoded_query = string.replace(query, '+', ' ') try: os.setuid(nobody) except os.error: pass os.dup2(self.rfile.fileno(), 0) os.dup2(self.wfile.fileno(), 1) print scriptfile, script, decoded_query os.execve(scriptfile, [script, decoded_query], env) except: self.server.handle_error(self.request, self.client_address) os._exit(127)
12,917
def nobody_uid(): """Internal routine to get nobody's uid""" global nobody if nobody: return nobody import pwd try: nobody = pwd.getpwnam('nobody')[2] except KeyError: nobody = 1 + max(map(lambda x: x[2], pwd.getpwall())) return nobody
def nobody_uid(): """Internal routine to get nobody's uid""" global nobody if nobody: return nobody try: import pwd except ImportError: return -1 try: nobody = pwd.getpwnam('nobody')[2] except KeyError: nobody = 1 + max(map(lambda x: x[2], pwd.getpwall())) return nobody
12,918
def test_filter_subclasses(self): # test, that filter() never returns tuple, str or unicode subclasses funcs = (None, lambda x: True) class tuple2(tuple): pass class str2(str): pass inputs = { tuple2: [(), (1,2,3)], str2: ["", "123"] } if have_unicode: class unicode2(unicode): pass inputs[unicode2] = [unicode(), unicode("123")]
def test_filter_subclasses(self): # test, that filter() never returns tuple, str or unicode subclasses funcs = (None, lambda x: True) class tuple2(tuple): def __getitem__(self, index): return 2*tuple.__getitem__(self, index) class str2(str): def __getitem__(self, index): return 2*tuple.__getitem__(self, index) inputs = { tuple2: [(), (1,2,3)], str2: ["", "123"] } if have_unicode: class unicode2(unicode): def __getitem__(self, index): return 2*tuple.__getitem__(self, index) inputs[unicode2] = [unicode(), unicode("123")]
12,919
def test_filter_subclasses(self): # test, that filter() never returns tuple, str or unicode subclasses funcs = (None, lambda x: True) class tuple2(tuple): pass class str2(str): pass inputs = { tuple2: [(), (1,2,3)], str2: ["", "123"] } if have_unicode: class unicode2(unicode): pass inputs[unicode2] = [unicode(), unicode("123")]
def test_filter_subclasses(self): # test, that filter() never returns tuple, str or unicode subclasses funcs = (None, lambda x: True) class tuple2(tuple): def __getitem__(self, index): return 2*str.__getitem__(self, index) class str2(str): def __getitem__(self, index): return 2*str.__getitem__(self, index) inputs = { tuple2: [(), (1,2,3)], str2: ["", "123"] } if have_unicode: class unicode2(unicode): def __getitem__(self, index): return 2*str.__getitem__(self, index) inputs[unicode2] = [unicode(), unicode("123")]
12,920
def test_filter_subclasses(self): # test, that filter() never returns tuple, str or unicode subclasses funcs = (None, lambda x: True) class tuple2(tuple): pass class str2(str): pass inputs = { tuple2: [(), (1,2,3)], str2: ["", "123"] } if have_unicode: class unicode2(unicode): pass inputs[unicode2] = [unicode(), unicode("123")]
def test_filter_subclasses(self): # test, that filter() never returns tuple, str or unicode subclasses funcs = (None, lambda x: True) class tuple2(tuple): pass class str2(str): pass inputs = { tuple2: {(): (), (1, 2, 3): (1, 2, 3)}, str2: {"": "", "123": "112233"} } if have_unicode: class unicode2(unicode): pass inputs[unicode2] = [unicode(), unicode("123")]
12,921
def test_filter_subclasses(self): # test, that filter() never returns tuple, str or unicode subclasses funcs = (None, lambda x: True) class tuple2(tuple): pass class str2(str): pass inputs = { tuple2: [(), (1,2,3)], str2: ["", "123"] } if have_unicode: class unicode2(unicode): pass inputs[unicode2] = [unicode(), unicode("123")]
def test_filter_subclasses(self): # test, that filter() never returns tuple, str or unicode subclasses funcs = (None, lambda x: True) class tuple2(tuple): pass class str2(str): pass inputs = { tuple2: [(), (1,2,3)], str2: ["", "123"] } if have_unicode: class unicode2(unicode): pass inputs[unicode2] = [unicode(), unicode("123")]
12,922
def visit (z, dirname, names): for name in names: path = os.path.normpath(os.path.join(dirname, name)) if os.path.isfile(path): z.write(path, path)
def visit (z, dirname, names): for name in names: path = os.path.normpath(os.path.join(dirname, name)) if os.path.isfile(path): z.write(path, path)
12,923
def testfile(filename, module_relative=True, name=None, package=None, globs=None, verbose=None, report=True, optionflags=0, extraglobs=None, raise_on_error=False): """ Test examples in the given file. Return (#failures, #tests). Optional keyword arg "module_relative" specifies how filenames should be interpreted: - If "module_relative" is True (the default), then "filename" specifies a module-relative path. By default, this path is relative to the calling module's directory; but if the "package" argument is specified, then it is relative to that package. To ensure os-independence, "filename" should use "/" characters to separate path segments, and should not be an absolute path (i.e., it may not begin with "/"). - If "module_relative" is False, then "filename" specifies an os-specific path. The path may be absolute or relative (to the current working directory). Optional keyword arg "name" gives the name of the file; by default use the file's name. Optional keyword argument "package" is a Python package or the name of a Python package whose directory should be used as the base directory for a module relative filename. If no package is specified, then the calling module's directory is used as the base directory for module relative filenames. It is an error to specify "package" if "module_relative" is False. Optional keyword arg "globs" gives a dict to be used as the globals when executing examples; by default, use {}. A copy of this dict is actually used for each docstring, so that each docstring's examples start with a clean slate. Optional keyword arg "extraglobs" gives a dictionary that should be merged into the globals that are used to execute examples. By default, no extra globals are used. Optional keyword arg "verbose" prints lots of stuff if true, prints only failures if false; by default, it's true iff "-v" is in sys.argv. Optional keyword arg "report" prints a summary at the end when true, else prints nothing at the end. In verbose mode, the summary is detailed, else very brief (in fact, empty if all tests passed). Optional keyword arg "optionflags" or's together module constants, and defaults to 0. Possible values (see the docs for details): DONT_ACCEPT_TRUE_FOR_1 DONT_ACCEPT_BLANKLINE NORMALIZE_WHITESPACE ELLIPSIS IGNORE_EXCEPTION_DETAIL REPORT_UDIFF REPORT_CDIFF REPORT_NDIFF REPORT_ONLY_FIRST_FAILURE Optional keyword arg "raise_on_error" raises an exception on the first unexpected exception or failure. This allows failures to be post-mortem debugged. Advanced tomfoolery: testmod runs methods of a local instance of class doctest.Tester, then merges the results into (or creates) global Tester instance doctest.master. Methods of doctest.master can be called directly too, if you want to do something unusual. Passing report=0 to testmod is especially useful then, to delay displaying a summary. Invoke doctest.master.summarize(verbose) when you're done fiddling. """ global master if package and not module_relative: raise ValueError("Package may only be specified for module-" "relative paths.") # Relativize the path if module_relative: package = _normalize_module(package) filename = _module_relative_path(package, filename) # If no name was given, then use the file's name. if name is None: name = os.path.split(filename)[-1] # Assemble the globals. if globs is None: globs = {} else: globs = globs.copy() if extraglobs is not None: globs.update(extraglobs) if raise_on_error: runner = DebugRunner(verbose=verbose, optionflags=optionflags) else: runner = DocTestRunner(verbose=verbose, optionflags=optionflags) # Read the file, convert it to a test, and run it. s = open(filename).read() test = DocTestParser().get_doctest(s, globs, name, filename, 0) runner.run(test) if report: runner.summarize() if master is None: master = runner else: master.merge(runner) return runner.failures, runner.tries
def testfile(filename, module_relative=True, name=None, package=None, globs=None, verbose=None, report=True, optionflags=0, extraglobs=None, raise_on_error=False): """ Test examples in the given file. Return (#failures, #tests). Optional keyword arg "module_relative" specifies how filenames should be interpreted: - If "module_relative" is True (the default), then "filename" specifies a module-relative path. By default, this path is relative to the calling module's directory; but if the "package" argument is specified, then it is relative to that package. To ensure os-independence, "filename" should use "/" characters to separate path segments, and should not be an absolute path (i.e., it may not begin with "/"). - If "module_relative" is False, then "filename" specifies an os-specific path. The path may be absolute or relative (to the current working directory). Optional keyword arg "name" gives the name of the test; by default use the file's basename. Optional keyword argument "package" is a Python package or the name of a Python package whose directory should be used as the base directory for a module relative filename. If no package is specified, then the calling module's directory is used as the base directory for module relative filenames. It is an error to specify "package" if "module_relative" is False. Optional keyword arg "globs" gives a dict to be used as the globals when executing examples; by default, use {}. A copy of this dict is actually used for each docstring, so that each docstring's examples start with a clean slate. Optional keyword arg "extraglobs" gives a dictionary that should be merged into the globals that are used to execute examples. By default, no extra globals are used. Optional keyword arg "verbose" prints lots of stuff if true, prints only failures if false; by default, it's true iff "-v" is in sys.argv. Optional keyword arg "report" prints a summary at the end when true, else prints nothing at the end. In verbose mode, the summary is detailed, else very brief (in fact, empty if all tests passed). Optional keyword arg "optionflags" or's together module constants, and defaults to 0. Possible values (see the docs for details): DONT_ACCEPT_TRUE_FOR_1 DONT_ACCEPT_BLANKLINE NORMALIZE_WHITESPACE ELLIPSIS IGNORE_EXCEPTION_DETAIL REPORT_UDIFF REPORT_CDIFF REPORT_NDIFF REPORT_ONLY_FIRST_FAILURE Optional keyword arg "raise_on_error" raises an exception on the first unexpected exception or failure. This allows failures to be post-mortem debugged. Advanced tomfoolery: testmod runs methods of a local instance of class doctest.Tester, then merges the results into (or creates) global Tester instance doctest.master. Methods of doctest.master can be called directly too, if you want to do something unusual. Passing report=0 to testmod is especially useful then, to delay displaying a summary. Invoke doctest.master.summarize(verbose) when you're done fiddling. """ global master if package and not module_relative: raise ValueError("Package may only be specified for module-" "relative paths.") # Relativize the path if module_relative: package = _normalize_module(package) filename = _module_relative_path(package, filename) # If no name was given, then use the file's name. if name is None: name = os.path.split(filename)[-1] # Assemble the globals. if globs is None: globs = {} else: globs = globs.copy() if extraglobs is not None: globs.update(extraglobs) if raise_on_error: runner = DebugRunner(verbose=verbose, optionflags=optionflags) else: runner = DocTestRunner(verbose=verbose, optionflags=optionflags) # Read the file, convert it to a test, and run it. s = open(filename).read() test = DocTestParser().get_doctest(s, globs, name, filename, 0) runner.run(test) if report: runner.summarize() if master is None: master = runner else: master.merge(runner) return runner.failures, runner.tries
12,924
def testfile(filename, module_relative=True, name=None, package=None, globs=None, verbose=None, report=True, optionflags=0, extraglobs=None, raise_on_error=False): """ Test examples in the given file. Return (#failures, #tests). Optional keyword arg "module_relative" specifies how filenames should be interpreted: - If "module_relative" is True (the default), then "filename" specifies a module-relative path. By default, this path is relative to the calling module's directory; but if the "package" argument is specified, then it is relative to that package. To ensure os-independence, "filename" should use "/" characters to separate path segments, and should not be an absolute path (i.e., it may not begin with "/"). - If "module_relative" is False, then "filename" specifies an os-specific path. The path may be absolute or relative (to the current working directory). Optional keyword arg "name" gives the name of the file; by default use the file's name. Optional keyword argument "package" is a Python package or the name of a Python package whose directory should be used as the base directory for a module relative filename. If no package is specified, then the calling module's directory is used as the base directory for module relative filenames. It is an error to specify "package" if "module_relative" is False. Optional keyword arg "globs" gives a dict to be used as the globals when executing examples; by default, use {}. A copy of this dict is actually used for each docstring, so that each docstring's examples start with a clean slate. Optional keyword arg "extraglobs" gives a dictionary that should be merged into the globals that are used to execute examples. By default, no extra globals are used. Optional keyword arg "verbose" prints lots of stuff if true, prints only failures if false; by default, it's true iff "-v" is in sys.argv. Optional keyword arg "report" prints a summary at the end when true, else prints nothing at the end. In verbose mode, the summary is detailed, else very brief (in fact, empty if all tests passed). Optional keyword arg "optionflags" or's together module constants, and defaults to 0. Possible values (see the docs for details): DONT_ACCEPT_TRUE_FOR_1 DONT_ACCEPT_BLANKLINE NORMALIZE_WHITESPACE ELLIPSIS IGNORE_EXCEPTION_DETAIL REPORT_UDIFF REPORT_CDIFF REPORT_NDIFF REPORT_ONLY_FIRST_FAILURE Optional keyword arg "raise_on_error" raises an exception on the first unexpected exception or failure. This allows failures to be post-mortem debugged. Advanced tomfoolery: testmod runs methods of a local instance of class doctest.Tester, then merges the results into (or creates) global Tester instance doctest.master. Methods of doctest.master can be called directly too, if you want to do something unusual. Passing report=0 to testmod is especially useful then, to delay displaying a summary. Invoke doctest.master.summarize(verbose) when you're done fiddling. """ global master if package and not module_relative: raise ValueError("Package may only be specified for module-" "relative paths.") # Relativize the path if module_relative: package = _normalize_module(package) filename = _module_relative_path(package, filename) # If no name was given, then use the file's name. if name is None: name = os.path.split(filename)[-1] # Assemble the globals. if globs is None: globs = {} else: globs = globs.copy() if extraglobs is not None: globs.update(extraglobs) if raise_on_error: runner = DebugRunner(verbose=verbose, optionflags=optionflags) else: runner = DocTestRunner(verbose=verbose, optionflags=optionflags) # Read the file, convert it to a test, and run it. s = open(filename).read() test = DocTestParser().get_doctest(s, globs, name, filename, 0) runner.run(test) if report: runner.summarize() if master is None: master = runner else: master.merge(runner) return runner.failures, runner.tries
def testfile(filename, module_relative=True, name=None, package=None, globs=None, verbose=None, report=True, optionflags=0, extraglobs=None, raise_on_error=False): """ Test examples in the given file. Return (#failures, #tests). Optional keyword arg "module_relative" specifies how filenames should be interpreted: - If "module_relative" is True (the default), then "filename" specifies a module-relative path. By default, this path is relative to the calling module's directory; but if the "package" argument is specified, then it is relative to that package. To ensure os-independence, "filename" should use "/" characters to separate path segments, and should not be an absolute path (i.e., it may not begin with "/"). - If "module_relative" is False, then "filename" specifies an os-specific path. The path may be absolute or relative (to the current working directory). Optional keyword arg "name" gives the name of the file; by default use the file's name. Optional keyword argument "package" is a Python package or the name of a Python package whose directory should be used as the base directory for a module relative filename. If no package is specified, then the calling module's directory is used as the base directory for module relative filenames. It is an error to specify "package" if "module_relative" is False. Optional keyword arg "globs" gives a dict to be used as the globals when executing examples; by default, use {}. A copy of this dict is actually used for each docstring, so that each docstring's examples start with a clean slate. Optional keyword arg "extraglobs" gives a dictionary that should be merged into the globals that are used to execute examples. By default, no extra globals are used. Optional keyword arg "verbose" prints lots of stuff if true, prints only failures if false; by default, it's true iff "-v" is in sys.argv. Optional keyword arg "report" prints a summary at the end when true, else prints nothing at the end. In verbose mode, the summary is detailed, else very brief (in fact, empty if all tests passed). Optional keyword arg "optionflags" or's together module constants, and defaults to 0. Possible values (see the docs for details): DONT_ACCEPT_TRUE_FOR_1 DONT_ACCEPT_BLANKLINE NORMALIZE_WHITESPACE ELLIPSIS IGNORE_EXCEPTION_DETAIL REPORT_UDIFF REPORT_CDIFF REPORT_NDIFF REPORT_ONLY_FIRST_FAILURE Optional keyword arg "raise_on_error" raises an exception on the first unexpected exception or failure. This allows failures to be post-mortem debugged. Advanced tomfoolery: testmod runs methods of a local instance of class doctest.Tester, then merges the results into (or creates) global Tester instance doctest.master. Methods of doctest.master can be called directly too, if you want to do something unusual. Passing report=0 to testmod is especially useful then, to delay displaying a summary. Invoke doctest.master.summarize(verbose) when you're done fiddling. """ global master if package and not module_relative: raise ValueError("Package may only be specified for module-" "relative paths.") # Relativize the path if module_relative: package = _normalize_module(package) filename = _module_relative_path(package, filename) # If no name was given, then use the file's name. if name is None: name = os.path.basename(filename) # Assemble the globals. if globs is None: globs = {} else: globs = globs.copy() if extraglobs is not None: globs.update(extraglobs) if raise_on_error: runner = DebugRunner(verbose=verbose, optionflags=optionflags) else: runner = DocTestRunner(verbose=verbose, optionflags=optionflags) # Read the file, convert it to a test, and run it. s = open(filename).read() test = DocTestParser().get_doctest(s, globs, name, filename, 0) runner.run(test) if report: runner.summarize() if master is None: master = runner else: master.merge(runner) return runner.failures, runner.tries
12,925
def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None, **options): """ Convert doctest tests for a module to a unittest test suite. This converts each documentation string in a module that contains doctest tests to a unittest test case. If any of the tests in a doc string fail, then the test case fails. An exception is raised showing the name of the file containing the test and a (sometimes approximate) line number. The `module` argument provides the module to be tested. The argument can be either a module or a module name. If no argument is given, the calling module is used. A number of options may be provided as keyword arguments: package The name of a Python package. Text-file paths will be interpreted relative to the directory containing this package. The package may be supplied as a package object or as a dotted package name. setUp The name of a set-up function. This is called before running the tests in each file. The setUp function will be passed a DocTest object. The setUp function can access the test globals as the globs attribute of the test passed. tearDown The name of a tear-down function. This is called after running the tests in each file. The tearDown function will be passed a DocTest object. The tearDown function can access the test globals as the globs attribute of the test passed. globs A dictionary containing initial global variables for the tests. optionflags A set of doctest option flags expressed as an integer. """ if test_finder is None: test_finder = DocTestFinder() module = _normalize_module(module) tests = test_finder.find(module, globs=globs, extraglobs=extraglobs) if globs is None: globs = module.__dict__ if not tests: # Why do we want to do this? Because it reveals a bug that might # otherwise be hidden. raise ValueError(module, "has no tests") tests.sort() suite = unittest.TestSuite() for test in tests: if len(test.examples) == 0: continue if not test.filename: filename = module.__file__ if filename[-4:] in (".pyc", ".pyo"): filename = filename[:-1] test.filename = filename suite.addTest(DocTestCase(test, **options)) return suite
def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None, **options): """ Convert doctest tests for a module to a unittest test suite. This converts each documentation string in a module that contains doctest tests to a unittest test case. If any of the tests in a doc string fail, then the test case fails. An exception is raised showing the name of the file containing the test and a (sometimes approximate) line number. The `module` argument provides the module to be tested. The argument can be either a module or a module name. If no argument is given, the calling module is used. A number of options may be provided as keyword arguments: setUp The name of a set-up function. This is called before running the tests in each file. The setUp function will be passed a DocTest object. The setUp function can access the test globals as the globs attribute of the test passed. tearDown The name of a tear-down function. This is called after running the tests in each file. The tearDown function will be passed a DocTest object. The tearDown function can access the test globals as the globs attribute of the test passed. globs A dictionary containing initial global variables for the tests. optionflags A set of doctest option flags expressed as an integer. """ if test_finder is None: test_finder = DocTestFinder() module = _normalize_module(module) tests = test_finder.find(module, globs=globs, extraglobs=extraglobs) if globs is None: globs = module.__dict__ if not tests: # Why do we want to do this? Because it reveals a bug that might # otherwise be hidden. raise ValueError(module, "has no tests") tests.sort() suite = unittest.TestSuite() for test in tests: if len(test.examples) == 0: continue if not test.filename: filename = module.__file__ if filename[-4:] in (".pyc", ".pyo"): filename = filename[:-1] test.filename = filename suite.addTest(DocTestCase(test, **options)) return suite
12,926
def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None, **options): """ Convert doctest tests for a module to a unittest test suite. This converts each documentation string in a module that contains doctest tests to a unittest test case. If any of the tests in a doc string fail, then the test case fails. An exception is raised showing the name of the file containing the test and a (sometimes approximate) line number. The `module` argument provides the module to be tested. The argument can be either a module or a module name. If no argument is given, the calling module is used. A number of options may be provided as keyword arguments: package The name of a Python package. Text-file paths will be interpreted relative to the directory containing this package. The package may be supplied as a package object or as a dotted package name. setUp The name of a set-up function. This is called before running the tests in each file. The setUp function will be passed a DocTest object. The setUp function can access the test globals as the globs attribute of the test passed. tearDown The name of a tear-down function. This is called after running the tests in each file. The tearDown function will be passed a DocTest object. The tearDown function can access the test globals as the globs attribute of the test passed. globs A dictionary containing initial global variables for the tests. optionflags A set of doctest option flags expressed as an integer. """ if test_finder is None: test_finder = DocTestFinder() module = _normalize_module(module) tests = test_finder.find(module, globs=globs, extraglobs=extraglobs) if globs is None: globs = module.__dict__ if not tests: # Why do we want to do this? Because it reveals a bug that might # otherwise be hidden. raise ValueError(module, "has no tests") tests.sort() suite = unittest.TestSuite() for test in tests: if len(test.examples) == 0: continue if not test.filename: filename = module.__file__ if filename[-4:] in (".pyc", ".pyo"): filename = filename[:-1] test.filename = filename suite.addTest(DocTestCase(test, **options)) return suite
def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None, **options): """ Convert doctest tests for a module to a unittest test suite. This converts each documentation string in a module that contains doctest tests to a unittest test case. If any of the tests in a doc string fail, then the test case fails. An exception is raised showing the name of the file containing the test and a (sometimes approximate) line number. The `module` argument provides the module to be tested. The argument can be either a module or a module name. If no argument is given, the calling module is used. A number of options may be provided as keyword arguments: package The name of a Python package. Text-file paths will be interpreted relative to the directory containing this package. The package may be supplied as a package object or as a dotted package name. setUp A set-up function. This is called before running the tests in each file. The setUp function will be passed a DocTest object. The setUp function can access the test globals as the globs attribute of the test passed. tearDown The name of a tear-down function. This is called after running the tests in each file. The tearDown function will be passed a DocTest object. The tearDown function can access the test globals as the globs attribute of the test passed. globs A dictionary containing initial global variables for the tests. optionflags A set of doctest option flags expressed as an integer. """ if test_finder is None: test_finder = DocTestFinder() module = _normalize_module(module) tests = test_finder.find(module, globs=globs, extraglobs=extraglobs) if globs is None: globs = module.__dict__ if not tests: # Why do we want to do this? Because it reveals a bug that might # otherwise be hidden. raise ValueError(module, "has no tests") tests.sort() suite = unittest.TestSuite() for test in tests: if len(test.examples) == 0: continue if not test.filename: filename = module.__file__ if filename[-4:] in (".pyc", ".pyo"): filename = filename[:-1] test.filename = filename suite.addTest(DocTestCase(test, **options)) return suite
12,927
def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None, **options): """ Convert doctest tests for a module to a unittest test suite. This converts each documentation string in a module that contains doctest tests to a unittest test case. If any of the tests in a doc string fail, then the test case fails. An exception is raised showing the name of the file containing the test and a (sometimes approximate) line number. The `module` argument provides the module to be tested. The argument can be either a module or a module name. If no argument is given, the calling module is used. A number of options may be provided as keyword arguments: package The name of a Python package. Text-file paths will be interpreted relative to the directory containing this package. The package may be supplied as a package object or as a dotted package name. setUp The name of a set-up function. This is called before running the tests in each file. The setUp function will be passed a DocTest object. The setUp function can access the test globals as the globs attribute of the test passed. tearDown The name of a tear-down function. This is called after running the tests in each file. The tearDown function will be passed a DocTest object. The tearDown function can access the test globals as the globs attribute of the test passed. globs A dictionary containing initial global variables for the tests. optionflags A set of doctest option flags expressed as an integer. """ if test_finder is None: test_finder = DocTestFinder() module = _normalize_module(module) tests = test_finder.find(module, globs=globs, extraglobs=extraglobs) if globs is None: globs = module.__dict__ if not tests: # Why do we want to do this? Because it reveals a bug that might # otherwise be hidden. raise ValueError(module, "has no tests") tests.sort() suite = unittest.TestSuite() for test in tests: if len(test.examples) == 0: continue if not test.filename: filename = module.__file__ if filename[-4:] in (".pyc", ".pyo"): filename = filename[:-1] test.filename = filename suite.addTest(DocTestCase(test, **options)) return suite
def DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None, **options): """ Convert doctest tests for a module to a unittest test suite. This converts each documentation string in a module that contains doctest tests to a unittest test case. If any of the tests in a doc string fail, then the test case fails. An exception is raised showing the name of the file containing the test and a (sometimes approximate) line number. The `module` argument provides the module to be tested. The argument can be either a module or a module name. If no argument is given, the calling module is used. A number of options may be provided as keyword arguments: package The name of a Python package. Text-file paths will be interpreted relative to the directory containing this package. The package may be supplied as a package object or as a dotted package name. setUp The name of a set-up function. This is called before running the tests in each file. The setUp function will be passed a DocTest object. The setUp function can access the test globals as the globs attribute of the test passed. tearDown A tear-down function. This is called after running the tests in each file. The tearDown function will be passed a DocTest object. The tearDown function can access the test globals as the globs attribute of the test passed. globs A dictionary containing initial global variables for the tests. optionflags A set of doctest option flags expressed as an integer. """ if test_finder is None: test_finder = DocTestFinder() module = _normalize_module(module) tests = test_finder.find(module, globs=globs, extraglobs=extraglobs) if globs is None: globs = module.__dict__ if not tests: # Why do we want to do this? Because it reveals a bug that might # otherwise be hidden. raise ValueError(module, "has no tests") tests.sort() suite = unittest.TestSuite() for test in tests: if len(test.examples) == 0: continue if not test.filename: filename = module.__file__ if filename[-4:] in (".pyc", ".pyo"): filename = filename[:-1] test.filename = filename suite.addTest(DocTestCase(test, **options)) return suite
12,928
def DocFileTest(path, module_relative=True, package=None, globs=None, **options): if globs is None: globs = {} if package and not module_relative: raise ValueError("Package may only be specified for module-" "relative paths.") # Relativize the path. if module_relative: package = _normalize_module(package) path = _module_relative_path(package, path) # Find the file and read it. name = os.path.split(path)[-1] doc = open(path).read() # Convert it to a test, and wrap it in a DocFileCase. test = DocTestParser().get_doctest(doc, globs, name, path, 0) return DocFileCase(test, **options)
def DocFileTest(path, module_relative=True, package=None, globs=None, **options): if globs is None: globs = {} if package and not module_relative: raise ValueError("Package may only be specified for module-" "relative paths.") # Relativize the path. if module_relative: package = _normalize_module(package) path = _module_relative_path(package, path) # Find the file and read it. name = os.path.basename(path) doc = open(path).read() # Convert it to a test, and wrap it in a DocFileCase. test = DocTestParser().get_doctest(doc, globs, name, path, 0) return DocFileCase(test, **options)
12,929
def DocFileSuite(*paths, **kw): """A unittest suite for one or more doctest files. The path to each doctest file is given as a string; the interpretation of that string depends on the keyword argument "module_relative". A number of options may be provided as keyword arguments: module_relative If "module_relative" is True, then the given file paths are interpreted as os-independent module-relative paths. By default, these paths are relative to the calling module's directory; but if the "package" argument is specified, then they are relative to that package. To ensure os-independence, "filename" should use "/" characters to separate path segments, and may not be an absolute path (i.e., it may not begin with "/"). If "module_relative" is False, then the given file paths are interpreted as os-specific paths. These paths may be absolute or relative (to the current working directory). package A Python package or the name of a Python package whose directory should be used as the base directory for module relative paths. If "package" is not specified, then the calling module's directory is used as the base directory for module relative filenames. It is an error to specify "package" if "module_relative" is False. setUp The name of a set-up function. This is called before running the tests in each file. The setUp function will be passed a DocTest object. The setUp function can access the test globals as the globs attribute of the test passed. tearDown The name of a tear-down function. This is called after running the tests in each file. The tearDown function will be passed a DocTest object. The tearDown function can access the test globals as the globs attribute of the test passed. globs A dictionary containing initial global variables for the tests. optionflags A set of doctest option flags expressed as an integer. """ suite = unittest.TestSuite() # We do this here so that _normalize_module is called at the right # level. If it were called in DocFileTest, then this function # would be the caller and we might guess the package incorrectly. if kw.get('module_relative', True): kw['package'] = _normalize_module(kw.get('package')) for path in paths: suite.addTest(DocFileTest(path, **kw)) return suite
def DocFileSuite(*paths, **kw): """A unittest suite for one or more doctest files. The path to each doctest file is given as a string; the interpretation of that string depends on the keyword argument "module_relative". A number of options may be provided as keyword arguments: module_relative If "module_relative" is True, then the given file paths are interpreted as os-independent module-relative paths. By default, these paths are relative to the calling module's directory; but if the "package" argument is specified, then they are relative to that package. To ensure os-independence, "filename" should use "/" characters to separate path segments, and may not be an absolute path (i.e., it may not begin with "/"). If "module_relative" is False, then the given file paths are interpreted as os-specific paths. These paths may be absolute or relative (to the current working directory). package A Python package or the name of a Python package whose directory should be used as the base directory for module relative paths. If "package" is not specified, then the calling module's directory is used as the base directory for module relative filenames. It is an error to specify "package" if "module_relative" is False. setUp A set-up function. This is called before running the tests in each file. The setUp function will be passed a DocTest object. The setUp function can access the test globals as the globs attribute of the test passed. tearDown The name of a tear-down function. This is called after running the tests in each file. The tearDown function will be passed a DocTest object. The tearDown function can access the test globals as the globs attribute of the test passed. globs A dictionary containing initial global variables for the tests. optionflags A set of doctest option flags expressed as an integer. """ suite = unittest.TestSuite() # We do this here so that _normalize_module is called at the right # level. If it were called in DocFileTest, then this function # would be the caller and we might guess the package incorrectly. if kw.get('module_relative', True): kw['package'] = _normalize_module(kw.get('package')) for path in paths: suite.addTest(DocFileTest(path, **kw)) return suite
12,930
def DocFileSuite(*paths, **kw): """A unittest suite for one or more doctest files. The path to each doctest file is given as a string; the interpretation of that string depends on the keyword argument "module_relative". A number of options may be provided as keyword arguments: module_relative If "module_relative" is True, then the given file paths are interpreted as os-independent module-relative paths. By default, these paths are relative to the calling module's directory; but if the "package" argument is specified, then they are relative to that package. To ensure os-independence, "filename" should use "/" characters to separate path segments, and may not be an absolute path (i.e., it may not begin with "/"). If "module_relative" is False, then the given file paths are interpreted as os-specific paths. These paths may be absolute or relative (to the current working directory). package A Python package or the name of a Python package whose directory should be used as the base directory for module relative paths. If "package" is not specified, then the calling module's directory is used as the base directory for module relative filenames. It is an error to specify "package" if "module_relative" is False. setUp The name of a set-up function. This is called before running the tests in each file. The setUp function will be passed a DocTest object. The setUp function can access the test globals as the globs attribute of the test passed. tearDown The name of a tear-down function. This is called after running the tests in each file. The tearDown function will be passed a DocTest object. The tearDown function can access the test globals as the globs attribute of the test passed. globs A dictionary containing initial global variables for the tests. optionflags A set of doctest option flags expressed as an integer. """ suite = unittest.TestSuite() # We do this here so that _normalize_module is called at the right # level. If it were called in DocFileTest, then this function # would be the caller and we might guess the package incorrectly. if kw.get('module_relative', True): kw['package'] = _normalize_module(kw.get('package')) for path in paths: suite.addTest(DocFileTest(path, **kw)) return suite
def DocFileSuite(*paths, **kw): """A unittest suite for one or more doctest files. The path to each doctest file is given as a string; the interpretation of that string depends on the keyword argument "module_relative". A number of options may be provided as keyword arguments: module_relative If "module_relative" is True, then the given file paths are interpreted as os-independent module-relative paths. By default, these paths are relative to the calling module's directory; but if the "package" argument is specified, then they are relative to that package. To ensure os-independence, "filename" should use "/" characters to separate path segments, and may not be an absolute path (i.e., it may not begin with "/"). If "module_relative" is False, then the given file paths are interpreted as os-specific paths. These paths may be absolute or relative (to the current working directory). package A Python package or the name of a Python package whose directory should be used as the base directory for module relative paths. If "package" is not specified, then the calling module's directory is used as the base directory for module relative filenames. It is an error to specify "package" if "module_relative" is False. setUp The name of a set-up function. This is called before running the tests in each file. The setUp function will be passed a DocTest object. The setUp function can access the test globals as the globs attribute of the test passed. tearDown A tear-down function. This is called after running the tests in each file. The tearDown function will be passed a DocTest object. The tearDown function can access the test globals as the globs attribute of the test passed. globs A dictionary containing initial global variables for the tests. optionflags A set of doctest option flags expressed as an integer. """ suite = unittest.TestSuite() # We do this here so that _normalize_module is called at the right # level. If it were called in DocFileTest, then this function # would be the caller and we might guess the package incorrectly. if kw.get('module_relative', True): kw['package'] = _normalize_module(kw.get('package')) for path in paths: suite.addTest(DocFileTest(path, **kw)) return suite
12,931
def __call__(self): self.__setup() prompt = 'Hit Return for more, or q (and Return) to quit: ' lineno = 0 while 1: try: for i in range(lineno, lineno + self.MAXLINES): print self.__lines[i] except IndexError: break else: lineno += self.MAXLINES key = None while key is None: key = raw_input(prompt) if key not in ('', 'q'): key = None if key == 'q': break
def __call__(self): self.__setup() prompt = 'Hit Return for more, or q (and Return) to quit: ' lineno = 0 while 1: try: for i in range(lineno, lineno + self.MAXLINES): print self.__lines[i] except IndexError: break else: lineno += self.MAXLINES key = None while key is None: key = raw_input(prompt) if key not in ('', 'q'): key = None if key == 'q': break
12,932
def __call__(self): self.__setup() prompt = 'Hit Return for more, or q (and Return) to quit: ' lineno = 0 while 1: try: for i in range(lineno, lineno + self.MAXLINES): print self.__lines[i] except IndexError: break else: lineno += self.MAXLINES key = None while key is None: key = raw_input(prompt) if key not in ('', 'q'): key = None if key == 'q': break
def __call__(self): self.__setup() prompt = 'Hit Return for more, or q (and Return) to quit: ' lineno = 0 while 1: try: for i in range(lineno, lineno + self.MAXLINES): print self.__lines[i] except IndexError: break else: lineno += self.MAXLINES key = None while key is None: key = raw_input(prompt) if key not in ('', 'q'): key = None if key == 'q': break
12,933
def _dispatch(self, msg): # Get the Content-Type: for the message, then try to dispatch to # self._handle_<maintype>_<subtype>(). If there's no handler for the # full MIME type, then dispatch to self._handle_<maintype>(). If # that's missing too, then dispatch to self._writeBody(). ctype = msg.get_content_type() # We do have a Content-Type: header. main, sub = ctype.split('/') specific = UNDERSCORE.join((main, sub)).replace('-', '_') meth = getattr(self, '_handle_' + specific, None) if meth is None: generic = main.replace('-', '_') meth = getattr(self, '_handle_' + generic, None) if meth is None: meth = self._writeBody meth(msg)
def _dispatch(self, msg): # Get the Content-Type: for the message, then try to dispatch to # self._handle_<maintype>_<subtype>(). If there's no handler for the # full MIME type, then dispatch to self._handle_<maintype>(). If # that's missing too, then dispatch to self._writeBody(). ctype = msg.get_content_type() # We do have a Content-Type: header. main, sub = ctype.split('/') specific = UNDERSCORE.join((main, sub)).replace('-', '_') meth = getattr(self, '_handle_' + specific, None) if meth is None: generic = main.replace('-', '_') meth = getattr(self, '_handle_' + generic, None) if meth is None: meth = self._writeBody meth(msg)
12,934
def readmodule(module, path=[]): '''Backwards compatible interface. Call readmodule_ex() and then only keep Class objects from the resulting dictionary.''' dict = readmodule_ex(module, path) res = {} for key, value in dict.items(): if isinstance(value, Class): res[key] = value return res
def readmodule(module, path=[]): '''Backwards compatible interface. Call readmodule_ex() and then only keep Class objects from the resulting dictionary.''' dict = _readmodule(module, path) res = {} for key, value in dict.items(): if isinstance(value, Class): res[key] = value return res
12,935
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
def readmodule_ex(module, path=[]): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
12,936
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
defreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' readmodule_ex(module,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' path=[],return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inpackage=None):return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' '''Readreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' areturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' filereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' returnreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' areturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dictionaryreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ofreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classes.return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Searchreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' MODULEreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' PATHreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' sys.path,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' readreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' parsereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' returnreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' areturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dictionaryreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' withreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' onereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' entryreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' eachreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' foundreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' module.return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' INPACKAGEreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' isreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' true,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' itreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mustreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' bereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dottedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' namereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ofreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' packagereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' whichreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' wereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' arereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' searchingreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' areturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' submodule,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' PATHreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mustreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' bereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' packagereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' searchreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' path;return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' otherwise,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' wereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' arereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' searchingreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' areturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' top-levelreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' module,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' PATHreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' isreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' combinedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' withreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' sys.path.return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' '''return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Computereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' fullreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' namereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' (prependingreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inpackagereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' set)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inpackage:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' fullmodulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' "%s.%s"return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' %return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' (inpackage,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' module)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' else:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' fullmodulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Checkreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' cachereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' fullmodulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' _modules:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' returnreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' _modules[fullmodule]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Initializereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dictreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thisreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' module'sreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' contentsreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dictreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' {}return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Checkreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' itreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' isreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' areturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' built-inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' module;return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' wereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' don'treturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' doreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' muchreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thesereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' sys.builtin_module_namesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' notreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inpackage:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' _modules[module]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dictreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' returnreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dictreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Checkreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' areturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dottedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' namereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ireturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' module.rfind('.')return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ireturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' >=return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 0:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' packagereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' module[:i]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' submodulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' module[i+1:]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' parentreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' readmodule_ex(package,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' path,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inpackage)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inpackage:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' packagereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' "%s.%s"return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' %return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' (inpackage,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' package)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' returnreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' readmodule_ex(submodule,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' parent['__path__'],return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' package)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Searchreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' pathreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' freturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Nonereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inpackage:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' f,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' file,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' (suff,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mode,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' type)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' imp.find_module(module,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' path)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' else:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' f,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' file,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' (suff,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mode,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' type)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' imp.find_module(module,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' pathreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' +return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' sys.path)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' typereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' imp.PKG_DIRECTORY:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dict['__path__']return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' [file]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' pathreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' [file]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' +return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' pathreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' f,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' file,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' (suff,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mode,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' type)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' imp.find_module('__init__',return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' [file])return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' _modules[fullmodule]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dictreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' typereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' !=return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' imp.PY_SOURCE:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' notreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Pythonreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' source,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' can'treturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' doreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' anythingreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' withreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thisreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' f.close()return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' returnreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dictreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classstackreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' []return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' stackreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ofreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' (class,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' indent)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' pairsreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' greturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenize.generate_tokens(f.readline)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' try:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokentype,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' token,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' start,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' end,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' linereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' g:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 'def':return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' lineno,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thisindentreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' startreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokentype,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' meth_name,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' start,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' end,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' linereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' g.next()return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokentypereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' !=return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' NAME:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' continuereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Syntaxreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' errorreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' closereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' allreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' indentedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' atreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' leastreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' asreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' muchreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' whilereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classstackreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' \return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classstack[-1][1]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' >=return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thisindent:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' delreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classstack[-1]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classstack:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' it'sreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' areturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' methodreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' cur_classreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classstack[-1][0]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' cur_class._addmethod(meth_name,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' lineno)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' else:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' it'sreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' areturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' functionreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dict[meth_name]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Function(module,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' meth_name,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' file,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' lineno)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' elifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 'class':return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' lineno,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thisindentreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' startreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokentype,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' class_name,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' start,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' end,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' linereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' g.next()return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokentypereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' !=return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' NAME:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' continuereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Syntaxreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' errorreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' closereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' allreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' indentedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' atreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' leastreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' asreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' muchreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' whilereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classstackreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' \return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classstack[-1][1]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' >=return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thisindent:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' delreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classstack[-1]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' parsereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' whatreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' followsreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' namereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokentype,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' token,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' start,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' end,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' linereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' g.next()return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inheritreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Nonereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' '(':return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' namesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' []return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Listreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ofreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' superclassesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' there'sreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' areturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' listreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ofreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' superclassesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' levelreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 1return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' superreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' []return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Tokensreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' makingreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' upreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' currentreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' superclassreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' whilereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' True:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokentype,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' token,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' start,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' end,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' linereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' g.next()return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' (')',return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ',')return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' levelreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 1:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' nreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' "".join(super)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' nreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dict:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' wereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' knowreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thisreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' superreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' nreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dict[n]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' else:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' creturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' n.split('.')return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' len(c)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' >return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 1:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' superreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' isreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ofreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' formreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' module.class:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' lookreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' c[-2]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' creturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' c[-1]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' _modules:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' _modules[m]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' creturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' d:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' nreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' d[c]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' names.append(n)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' '(':return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' levelreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' +=return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 1return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' elifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ')':return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' levelreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' -=return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 1return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' levelreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 0:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' breakreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' elifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ','return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' levelreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 1:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' passreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' else:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' super.append(token)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inheritreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' namesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' cur_classreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Class(module,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' class_name,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inherit,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' file,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' lineno)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dict[class_name]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' cur_classreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classstack.append((cur_class,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thisindent))return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' elifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 'import'return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' start[1]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 0:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' _getnamelist(g)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mod,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mod2return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modules:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' try:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Recursivelyreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' readreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' importedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' notreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inpackage:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' readmodule_ex(mod,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' path)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' else:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' try:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' readmodule_ex(mod,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' path,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inpackage)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' exceptreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ImportError:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' readmodule_ex(mod)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' except:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' wereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' can'treturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' findreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' orreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' parsereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' importedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' module,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tooreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' badreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' --return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' don'treturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' diereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' here.return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' passreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' elifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 'from'return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' start[1]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' 0:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mod,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' _getname(g)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' notreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' orreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tokenreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' !=return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' "import":return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' continuereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' namesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' _getnamelist(g)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' try:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Recursivelyreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' readreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' importedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' readmodule_ex(mod,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' path,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inpackage)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' except:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' wereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' can'treturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' findreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' orreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' parsereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' importedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' module,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' tooreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' badreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' --return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' don'treturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' diereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' here.return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' continuereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' addreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' anyreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' classesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thatreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' werereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' definedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' importedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' modulereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' toreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ourreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' namereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' spacereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' theyreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' werereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mentionedreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' listreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' n,return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' n2return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' names:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' nreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' d:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dict[n2return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' orreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' n]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' d[n]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' elifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' nreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ==return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' '*':return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' onlyreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' addreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' areturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' namereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' notreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' alreadyreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' therereturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' (toreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' mimicreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' whatreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' Pythonreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' doesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' internally)return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' alsoreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' don'treturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' addreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' #return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' namesreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' thatreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' startreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' withreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' _return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' forreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' nreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' d:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' ifreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' n[0]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' !=return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' '_'return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' andreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' notreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' nreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' inreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dict:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dict[n]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' =return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' d[n]return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' exceptreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' StopIteration:return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' passreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' f.close()return _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' returnreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].''' dictreturn _readmodule(module, path) def _readmodule(module, path, inpackage=None): '''Do the hard work for readmodule[_ex].'''
12,937
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = _readmodule(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
12,938
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return _readmodule(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
12,939
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict stack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
12,940
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if tokentype == DEDENT: lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
12,941
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
12,942
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as muchif classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much# parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
12,943
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) if not stack: dict[class_name] = cur_class stack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
12,944
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: _readmodule(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
12,945
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: _readmodule(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = _readmodule(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
12,946
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: _readmodule(mod, []) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
12,947
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = _readmodule(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
12,948
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
12,949
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_' and not n in dict: dict[n] = d[n] except StopIteration: pass f.close() return dict
def readmodule_ex(module, path=[], inpackage=None): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module. If INPACKAGE is true, it must be the dotted name of the package in which we are searching for a submodule, and then PATH must be the package search path; otherwise, we are searching for a top-level module, and PATH is combined with sys.path. ''' # Compute the full module name (prepending inpackage if set) if inpackage: fullmodule = "%s.%s" % (inpackage, module) else: fullmodule = module # Check in the cache if fullmodule in _modules: return _modules[fullmodule] # Initialize the dict for this module's contents dict = {} # Check if it is a built-in module; we don't do much for these if module in sys.builtin_module_names and not inpackage: _modules[module] = dict return dict # Check for a dotted module name i = module.rfind('.') if i >= 0: package = module[:i] submodule = module[i+1:] parent = readmodule_ex(package, path, inpackage) if inpackage: package = "%s.%s" % (inpackage, package) return readmodule_ex(submodule, parent['__path__'], package) # Search the path for the module f = None if inpackage: f, file, (suff, mode, type) = imp.find_module(module, path) else: f, file, (suff, mode, type) = imp.find_module(module, path + sys.path) if type == imp.PKG_DIRECTORY: dict['__path__'] = [file] path = [file] + path f, file, (suff, mode, type) = imp.find_module('__init__', [file]) _modules[fullmodule] = dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() return dict classstack = [] # stack of (class, indent) pairs g = tokenize.generate_tokens(f.readline) try: for tokentype, token, start, end, line in g: if token == 'def': lineno, thisindent = start tokentype, meth_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # it's a class method cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) else: # it's a function dict[meth_name] = Function(module, meth_name, file, lineno) elif token == 'class': lineno, thisindent = start tokentype, class_name, start, end, line = g.next() if tokentype != NAME: continue # Syntax error # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] # parse what follows the class name tokentype, token, start, end, line = g.next() inherit = None if token == '(': names = [] # List of superclasses # there's a list of superclasses level = 1 super = [] # Tokens making up current superclass while True: tokentype, token, start, end, line = g.next() if token in (')', ',') and level == 1: n = "".join(super) if n in dict: # we know this super class n = dict[n] else: c = n.split('.') if len(c) > 1: # super class is of the form # module.class: look in module for # class m = c[-2] c = c[-1] if m in _modules: d = _modules[m] if c in d: n = d[c] names.append(n) if token == '(': level += 1 elif token == ')': level -= 1 if level == 0: break elif token == ',' and level == 1: pass else: super.append(token) inherit = names cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif token == 'import' and start[1] == 0: modules = _getnamelist(g) for mod, mod2 in modules: try: # Recursively read the imported module if not inpackage: readmodule_ex(mod, path) else: try: readmodule_ex(mod, path, inpackage) except ImportError: readmodule_ex(mod) except: # If we can't find or parse the imported module, # too bad -- don't die here. pass elif token == 'from' and start[1] == 0: mod, token = _getname(g) if not mod or token != "import": continue names = _getnamelist(g) try: # Recursively read the imported module d = readmodule_ex(mod, path, inpackage) except: # If we can't find or parse the imported module, # too bad -- don't die here. continue # add any classes that were defined in the imported module # to our name space if they were mentioned in the list for n, n2 in names: if n in d: dict[n2 or n] = d[n] elif n == '*': # only add a name if not already there (to mimic # what Python does internally) also don't add # names that start with _ for n in d: if n[0] != '_': dict[n] = d[n] except StopIteration: pass f.close() return dict
12,950
def hide(self, event=None): self.stop() self.collapse()
def hide(self, event=None): self.stop() self.collapse()
12,951
def __init__(self, verbose=0): self.verbose = verbose self.reset()
def__init__(self,verbose=0):self.verbose=verboseself.reset()
12,952
def reset(self): self.rawdata = '' self.stack = [] self.lasttag = '???' self.nomoretags = 0 self.literal = 0
defreset(self):self.rawdata=''self.stack=[]self.lasttag='???'self.nomoretags=0self.literal=0
12,953
def setnomoretags(self): self.nomoretags = self.literal = 1
defsetnomoretags(self):self.nomoretags=self.literal=1
12,954
def setliteral(self, *args): self.literal = 1
def setliteral(self, *args): self.literal = 1
12,955
def feed(self, data): self.rawdata = self.rawdata + data self.goahead(0)
deffeed(self,data):self.rawdata=self.rawdata+dataself.goahead(0)
12,956
def report_unbalanced(self, tag): if self.verbose: print '*** Unbalanced </' + tag + '>' print '*** Stack:', self.stack
defreport_unbalanced(self,tag):ifself.verbose:print'***Unbalanced</'+tag+'>'print'***Stack:',self.stack
12,957
def handle_charref(self, name): try: n = int(name) except ValueError: self.unknown_charref(name) return if not 0 <= n <= 255: self.unknown_charref(name) return self.handle_data(chr(n))
defhandle_charref(self,name):try:n=int(name)exceptValueError:self.unknown_charref(name)returnifnot0<=n<=255:self.unknown_charref(name)returnself.handle_data(chr(n))
12,958
def module_funcs(stdscr): "Test module-level functions" for func in [curses.baudrate, curses.beep, curses.can_change_color, curses.cbreak, curses.def_prog_mode, curses.doupdate, curses.filter, curses.flash, curses.flushinp, curses.has_colors, curses.has_ic, curses.has_il, curses.isendwin, curses.killchar, curses.longname, curses.nocbreak, curses.noecho, curses.nonl, curses.noqiflush, curses.noraw, curses.reset_prog_mode, curses.termattrs, curses.termname, curses.erasechar, curses.getsyx]: func() # Functions that actually need arguments if curses.tigetstr("cnorm"): curses.curs_set(1) curses.delay_output(1) curses.echo() ; curses.echo(1) f = tempfile.TemporaryFile() stdscr.putwin(f) f.seek(0) curses.getwin(f) f.close() curses.halfdelay(1) curses.intrflush(1) curses.meta(1) curses.napms(100) curses.newpad(50,50) win = curses.newwin(5,5) win = curses.newwin(5,5, 1,1) curses.nl() ; curses.nl(1) curses.putp('abc') curses.qiflush() curses.raw() ; curses.raw(1) curses.setsyx(5,5) curses.setupterm(fd=sys.__stdout__.fileno()) curses.tigetflag('hc') curses.tigetnum('co') curses.tigetstr('cr') curses.tparm('cr') curses.typeahead(sys.__stdin__.fileno()) curses.unctrl('a') curses.ungetch('a') curses.use_env(1) # Functions only available on a few platforms if curses.has_colors(): curses.start_color() curses.init_pair(2, 1,1) curses.color_content(1) curses.color_pair(2) curses.pair_content(curses.COLOR_PAIRS) curses.pair_number(0) if hasattr(curses, 'use_default_colors'): curses.use_default_colors() if hasattr(curses, 'keyname'): curses.keyname(13) if hasattr(curses, 'has_key'): curses.has_key(13) if hasattr(curses, 'getmouse'): curses.mousemask(curses.BUTTON1_PRESSED) curses.mouseinterval(10)
def module_funcs(stdscr): "Test module-level functions" for func in [curses.baudrate, curses.beep, curses.can_change_color, curses.cbreak, curses.def_prog_mode, curses.doupdate, curses.filter, curses.flash, curses.flushinp, curses.has_colors, curses.has_ic, curses.has_il, curses.isendwin, curses.killchar, curses.longname, curses.nocbreak, curses.noecho, curses.nonl, curses.noqiflush, curses.noraw, curses.reset_prog_mode, curses.termattrs, curses.termname, curses.erasechar, curses.getsyx]: func() # Functions that actually need arguments if curses.tigetstr("cnorm"): curses.curs_set(1) curses.delay_output(1) curses.echo() ; curses.echo(1) f = tempfile.TemporaryFile() stdscr.putwin(f) f.seek(0) curses.getwin(f) f.close() curses.halfdelay(1) curses.intrflush(1) curses.meta(1) curses.napms(100) curses.newpad(50,50) win = curses.newwin(5,5) win = curses.newwin(5,5, 1,1) curses.nl() ; curses.nl(1) curses.putp('abc') curses.qiflush() curses.raw() ; curses.raw(1) curses.setsyx(5,5) curses.setupterm(fd=sys.__stdout__.fileno()) curses.tigetflag('hc') curses.tigetnum('co') curses.tigetstr('cr') curses.tparm('cr') curses.typeahead(sys.__stdin__.fileno()) curses.unctrl('a') curses.ungetch('a') curses.use_env(1) # Functions only available on a few platforms if curses.has_colors(): curses.start_color() curses.init_pair(2, 1,1) curses.color_content(1) curses.color_pair(2) curses.pair_content(curses.COLOR_PAIRS - 1) curses.pair_number(0) if hasattr(curses, 'use_default_colors'): curses.use_default_colors() if hasattr(curses, 'keyname'): curses.keyname(13) if hasattr(curses, 'has_key'): curses.has_key(13) if hasattr(curses, 'getmouse'): curses.mousemask(curses.BUTTON1_PRESSED) curses.mouseinterval(10)
12,959
def compile (self, sources, macros=None, includes=None):
def compile (self, sources, macros=None, includes=None):
12,960
def compile (self, sources, macros=None, includes=None):
def compile (self, sources, macros=None, includes=None):
12,961
def compile (self, sources, macros=None, includes=None):
defreturn self.object_filenames (sources) compilereturn self.object_filenames (sources) (self,return self.object_filenames (sources) sources,return self.object_filenames (sources) macros=None,return self.object_filenames (sources) includes=None):
12,962
def link_shared_object (self, objects, output_filename, libraries=None, library_dirs=None, build_info=None):
def link_shared_object (self, objects, output_filename, libraries=None, library_dirs=None, build_info=None):
12,963
def link_shared_object (self, objects, output_filename, libraries=None, library_dirs=None, build_info=None):
deflink_shared_object(self,objects,output_filename,libraries=None,library_dirs=None,build_info=None):
12,964
def shared_library_filename (self, libname): return "lib%s%s" % (libname, self._shared_lib_ext )
def shared_library_filename (self, libname): return "lib%s%s" % (libname, self._shared_lib_ext )
12,965
def _split_command (cmd): """Split a command string up into the progam to run (a string) and the list of arguments; return them as (cmd, arglist).""" args = string.split (cmd) return (args[0], args[1:])
def _split_command (cmd): """Split a command string up into the progam to run (a string) and the list of arguments; return them as (cmd, arglist).""" args = string.split (cmd) return (args[0], args[1:])
12,966
def stopped(): print 'pydoc server stopped'
def stopped(): print 'pydoc server stopped'
12,967
def _init_mac(): """Initialize the module as appropriate for Macintosh systems""" g = {} # set basic install directories g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1) g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1) # XXX hmmm.. a normal install puts include files here g['INCLUDEPY'] = get_python_inc(plat_specific=0) import MacOS if not hasattr(MacOS, 'runtimemodel'): g['SO'] = '.ppc.slb' else: g['SO'] = '.%s.slb' % MacOS.runtimemodel # XXX are these used anywhere? g['install_lib'] = os.path.join(EXEC_PREFIX, "Lib") g['install_platlib'] = os.path.join(EXEC_PREFIX, "Mac", "Lib") global _config_vars _config_vars = g
def _init_mac(): """Initialize the module as appropriate for Macintosh systems""" g = {} # set basic install directories g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1) g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1) # XXX hmmm.. a normal install puts include files here g['INCLUDEPY'] = get_python_inc(plat_specific=0) import MacOS if not hasattr(MacOS, 'runtimemodel'): g['SO'] = '.ppc.slb' else: g['SO'] = '.%s.slb' % MacOS.runtimemodel # XXX are these used anywhere? g['install_lib'] = os.path.join(EXEC_PREFIX, "Lib") g['install_platlib'] = os.path.join(EXEC_PREFIX, "Mac", "Lib") global _config_vars _config_vars = g
12,968
def connect(self, host = '', port = 0): '''Connect to host. Arguments are: - host: hostname to connect to (string, default previous host) - port: port to connect to (integer, default previous port)''' if host: self.host = host if port: self.port = port self.passiveserver = 0 self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.connect((self.host, self.port)) self.file = self.sock.makefile('rb') self.welcome = self.getresp() return self.welcome
def connect(self, host = '', port = 0): '''Connect to host. Arguments are: - host: hostname to connect to (string, default previous host) - port: port to connect to (integer, default previous port)''' if host: self.host = host if port: self.port = port self.passiveserver = 1 self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock.connect((self.host, self.port)) self.file = self.sock.makefile('rb') self.welcome = self.getresp() return self.welcome
12,969
def run (self):
def run (self):
12,970
def build_extensions (self):
def build_extensions (self):
12,971
def build_extensions (self):
def build_extensions (self):
12,972
def find_swig (self): """Return the name of the SWIG executable. On Unix, this is just "swig" -- it should be in the PATH. Tries a bit harder on Windows. """
def find_swig (self): """Return the name of the SWIG executable. On Unix, this is just "swig" -- it should be in the PATH. Tries a bit harder on Windows. """
12,973
def prelink_hook (self):
def prelink_hook (self):
12,974
def __init__ (self, option_table=None):
def __init__ (self, option_table=None):
12,975
def _grok_option_table (self): """Populate the various data structures that keep tabs on the option table. Called by 'getopt()' before it can do anything worthwhile. """ self.long_opts = [] self.short_opts = [] self.short2long.clear() self.repeat = {}
def _grok_option_table (self): """Populate the various data structures that keep tabs on the option table. Called by 'getopt()' before it can do anything worthwhile. """ self.long_opts = [] self.short_opts = [] self.short2long.clear() self.repeat = {}
12,976
def rev(self): if self._rev is not None: return self._rev L = list(self) L.reverse() self._rev = self.__class__(L) return self._rev
defverify(tuple(a).__class__ is tuple) rev(self):verify(tuple(a).__class__ is tuple) ifverify(tuple(a).__class__ is tuple) self._revverify(tuple(a).__class__ is tuple) isverify(tuple(a).__class__ is tuple) notverify(tuple(a).__class__ is tuple) None:verify(tuple(a).__class__ is tuple) returnverify(tuple(a).__class__ is tuple) self._revverify(tuple(a).__class__ is tuple) Lverify(tuple(a).__class__ is tuple) =verify(tuple(a).__class__ is tuple) list(self)verify(tuple(a).__class__ is tuple) L.reverse()verify(tuple(a).__class__ is tuple) self._revverify(tuple(a).__class__ is tuple) =verify(tuple(a).__class__ is tuple) self.__class__(L)verify(tuple(a).__class__ is tuple) returnverify(tuple(a).__class__ is tuple) self._rev
12,977
def __init__(self, s, charset=None, maxlinelen=MAXLINELEN, header_name=None): """Create a MIME-compliant header that can contain many languages.
def __init__(self, s, charset=None, maxlinelen=None, header_name=None): """Create a MIME-compliant header that can contain many languages.
12,978
def __init__(self, s, charset=None, maxlinelen=MAXLINELEN, header_name=None): """Create a MIME-compliant header that can contain many languages.
def __init__(self, s, charset=None, maxlinelen=MAXLINELEN, header_name=None): """Create a MIME-compliant header that can contain many languages.
12,979
def __init__(self, s, charset=None, maxlinelen=MAXLINELEN, header_name=None): """Create a MIME-compliant header that can contain many languages.
def __init__(self, s, charset=None, maxlinelen=MAXLINELEN, header_name=None): """Create a MIME-compliant header that can contain many languages.
12,980
def _split(self, s, charset): # Split up a header safely for use with encode_chunks. BAW: this # appears to be a private convenience method. splittable = charset.to_splittable(s) encoded = charset.from_splittable(splittable) if charset.encoded_header_len(encoded) < self._maxlinelen: return [(encoded, charset)] else: # Divide and conquer. BAW: halfway depends on integer division. # When porting to Python 2.2, use the // operator. halfway = len(splittable) // 2 first = charset.from_splittable(splittable[:halfway], 0) last = charset.from_splittable(splittable[halfway:], 0) return self._split(first, charset) + self._split(last, charset)
def _split(self, s, charset): # Split up a header safely for use with encode_chunks. BAW: this # appears to be a private convenience method. splittable = charset.to_splittable(s) encoded = charset.from_splittable(splittable) elen = charset.encoded_header_len(encoded) if elen <= self._maxlinelen: return [(encoded, charset)] else: # Divide and conquer. BAW: halfway depends on integer division. # When porting to Python 2.2, use the // operator. halfway = len(splittable) // 2 first = charset.from_splittable(splittable[:halfway], 0) last = charset.from_splittable(splittable[halfway:], 0) return self._split(first, charset) + self._split(last, charset)
12,981
def _split(self, s, charset): # Split up a header safely for use with encode_chunks. BAW: this # appears to be a private convenience method. splittable = charset.to_splittable(s) encoded = charset.from_splittable(splittable) if charset.encoded_header_len(encoded) < self._maxlinelen: return [(encoded, charset)] else: # Divide and conquer. BAW: halfway depends on integer division. # When porting to Python 2.2, use the // operator. halfway = len(splittable) // 2 first = charset.from_splittable(splittable[:halfway], 0) last = charset.from_splittable(splittable[halfway:], 0) return self._split(first, charset) + self._split(last, charset)
def _split(self, s, charset): # Split up a header safely for use with encode_chunks. BAW: this # appears to be a private convenience method. splittable = charset.to_splittable(s) encoded = charset.from_splittable(splittable) if charset.encoded_header_len(encoded) < self._maxlinelen: return [(encoded, charset)] else: # Divide and conquer. BAW: halfway depends on integer division. # When porting to Python 2.2, use the // operator. halfway = _intdiv2(len(splittable)) first = charset.from_splittable(splittable[:halfway], 0) last = charset.from_splittable(splittable[halfway:], 0) return self._split(first, charset) + self._split(last, charset)
12,982
def test_attr_values_entities(self): """Substitution of entities and charrefs in attribute values""" # SF bug #1452246 self.check_events("""<a b=&lt; c=&lt;&gt; d=&lt-&gt; e='&lt; ' f="&xxx;" g='&#32;&#33;' h='&#500;' i='x?a=b&c=d;'>""", [("starttag", "a", [("b", "<"), ("c", "<>"), ("d", "&lt->"), ("e", "< "), ("f", "&xxx;"), ("g", " !"), ("h", "&#500;"), ("i", "x?a=b&c=d;"), ])])
def test_attr_values_entities(self): """Substitution of entities and charrefs in attribute values""" # SF bug #1452246 self.check_events("""<a b=&lt; c=&lt;&gt; d=&lt-&gt; e='&lt; ' f="&xxx;" g='&#32;&#33;' h='&#500;' i='x?a=b&c=d;'>""", [("starttag", "a", [("b", "<"), ("c", "<>"), ("d", "&lt->"), ("e", "< "), ("f", "&xxx;"), ("g", " !"), ("h", "&#500;"), ("i", "x?a=b&c=d;"), ])])
12,983
def test_attr_values_entities(self): """Substitution of entities and charrefs in attribute values""" # SF bug #1452246 self.check_events("""<a b=&lt; c=&lt;&gt; d=&lt-&gt; e='&lt; ' f="&xxx;" g='&#32;&#33;' h='&#500;' i='x?a=b&c=d;'>""", [("starttag", "a", [("b", "<"), ("c", "<>"), ("d", "&lt->"), ("e", "< "), ("f", "&xxx;"), ("g", " !"), ("h", "&#500;"), ("i", "x?a=b&c=d;"), ])])
def test_attr_values_entities(self): """Substitution of entities and charrefs in attribute values""" # SF bug #1452246 self.check_events("""<a b=&lt; c=&lt;&gt; d=&lt-&gt; e='&lt; ' f="&xxx;" g='&#32;&#33;' h='&#500;' i='x?a=b&c=d;'>""", [("starttag", "a", [("b", "<"), ("c", "<>"), ("d", "&lt->"), ("e", "< "), ("f", "&xxx;"), ("g", " !"), ("h", "&#500;"), ("i", "x?a=b&c=d;"), ])])
12,984
def select(self, mailbox='INBOX', readonly=None): """Select a mailbox.
def select(self, mailbox='INBOX', readonly=None): """Select a mailbox.
12,985
def _command(self, name, *args):
def _command(self, name, *args):
12,986
def close(f): self.flush()
def close(self): self.flush()
12,987
def reload(self, module, path=None): if path is None and hasattr(module, '__filename__'): head, tail = os.path.split(module.__filename__) path = [os.path.join(head, '')] return ihooks.ModuleImporter.reload(self, module, path)
def reload(self, module, path=None): if path is None and hasattr(module, '__filename__'): head, tail = os.path.split(module.__filename__) path = [os.path.join(head, '')] return ihooks.ModuleImporter.reload(self, module, path)
12,988
def s_apply(self, func, *args, **kw):
def s_apply(self, func, *args, **kw):
12,989
def s_apply(self, func, *args, **kw):
def s_apply(self, func, *args, **kw):
12,990
def basic(src): print "Testing basic accessors..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) L = cf.sections() L.sort() verify(L == [r'Commented Bar', r'Foo Bar', r'Internationalized Stuff', r'Section\with$weird%characters[' '\t', r'Spacey Bar', ], "unexpected list of section names") # The use of spaces in the section names serves as a regression test for # SourceForge bug #115357. # http://sourceforge.net/bugs/?func=detailbug&group_id=5470&bug_id=115357 verify(cf.get('Foo Bar', 'foo', raw=1) == 'bar') verify(cf.get('Spacey Bar', 'foo', raw=1) == 'bar') verify(cf.get('Commented Bar', 'foo', raw=1) == 'bar') verify('__name__' not in cf.options("Foo Bar"), '__name__ "option" should not be exposed by the API!') # Make sure the right things happen for remove_option(); # added to include check for SourceForge bug #123324: verify(cf.remove_option('Foo Bar', 'foo'), "remove_option() failed to report existance of option") verify(not cf.has_option('Foo Bar', 'foo'), "remove_option() failed to remove option") verify(not cf.remove_option('Foo Bar', 'foo'), "remove_option() failed to report non-existance of option" " that was removed") try: cf.remove_option('No Such Section', 'foo') except ConfigParser.NoSectionError: pass else: raise TestFailed( "remove_option() failed to report non-existance of option" " that never existed")
defverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) basic(src):verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) printverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) "Testingverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) basicverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) accessors..."verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) cfverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) =verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) ConfigParser.ConfigParser()verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) sioverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) =verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) StringIO.StringIO(src)verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) cf.readfp(sio)verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) Lverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) =verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) cf.sections()verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) L.sort()verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) verify(Lverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) ==verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) [r'Commentedverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) Bar',verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) r'Fooverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) Bar',verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) r'Internationalizedverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) Stuff',verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) r'Section\with$weird%characters['verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) '\t',verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) r'Spaceyverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) Bar',verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) ],verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) "unexpectedverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) listverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) ofverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) sectionverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) names")verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) #verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) Theverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) useverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) ofverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) spacesverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) inverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) theverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) sectionverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) namesverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) servesverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) asverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) averify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) regressionverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) testverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) forverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) #verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) SourceForgeverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) bugverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) #115357.verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) #verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) http://sourceforge.net/bugs/?func=detailbug&group_id=5470&bug_id=115357verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) verify(cf.get('Fooverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) Bar',verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) 'foo',verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) raw=1)verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) ==verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) 'bar')verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) verify(cf.get('Spaceyverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) Bar',verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) 'foo',verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) raw=1)verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) ==verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) 'bar')verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) verify(cf.get('Commentedverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) Bar',verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) 'foo',verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) raw=1)verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) ==verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) 'bar')verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) verify('__name__'verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) notverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) inverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) cf.options("Fooverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) Bar"),verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) '__name__verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) "option"verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) shouldverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) notverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) beverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) exposedverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) byverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) theverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) API!')verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) #verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) Makeverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) sureverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) theverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) rightverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) thingsverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) happenverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) forverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) remove_option();verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) #verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) addedverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) toverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) includeverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) checkverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) forverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) SourceForgeverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) bugverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) #123324:verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) verify(cf.remove_option('Fooverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) Bar',verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) 'foo'),verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) "remove_option()verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) failedverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) toverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) reportverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) existanceverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) ofverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) option")verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) verify(notverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) cf.has_option('Fooverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) Bar',verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) 'foo'),verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) "remove_option()verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) failedverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) toverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) removeverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) option")verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) verify(notverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) cf.remove_option('Fooverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) Bar',verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) 'foo'),verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) "remove_option()verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) failedverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) toverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) reportverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) non-existanceverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) ofverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) option"verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) "verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) thatverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) wasverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) removed")verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) try:verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) cf.remove_option('Noverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) Suchverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) Section',verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) 'foo')verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) exceptverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) ConfigParser.NoSectionError:verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) passverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) else:verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) raiseverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) TestFailed(verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) "remove_option()verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) failedverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) toverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) reportverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) non-existanceverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) ofverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) option"verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) "verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) thatverify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) neververify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) existed")verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """) verify(cf.get('Long Line', 'foo', raw=1) == 'this line is much, much longer than my editor\nlikes it.') def write(src): print "Testing writing of files..." cf = ConfigParser.ConfigParser() sio = StringIO.StringIO(src) cf.readfp(sio) output = StringIO.StringIO() cf.write(output) verify(output, """[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. """)
12,991
def test_main(): if skip_expected: raise TestSkipped(TESTDATAFILE + " not found, download from " + "http://www.unicode.org/Public/UNIDATA/" + TESTDATAFILE) part1_data = {} for line in open(TESTDATAFILE): if '#' in line: line = line.split('#')[0] line = line.strip() if not line: continue if line.startswith("@Part"): part = line continue try: c1,c2,c3,c4,c5 = [unistr(x) for x in line.split(';')[:-1]] except RangeError: # Skip unsupported characters continue if verbose: print line # Perform tests verify(c2 == NFC(c1) == NFC(c2) == NFC(c3), line) verify(c4 == NFC(c4) == NFC(c5), line) verify(c3 == NFD(c1) == NFD(c2) == NFD(c3), line) verify(c5 == NFD(c4) == NFD(c5), line) verify(c4 == NFKC(c1) == NFKC(c2) == NFKC(c3) == NFKC(c4) == NFKC(c5), line) verify(c5 == NFKD(c1) == NFKD(c2) == NFKD(c3) == NFKD(c4) == NFKD(c5), line) # Record part 1 data if part == "@Part1": part1_data[c1] = 1 # Perform tests for all other data for c in range(sys.maxunicode+1): X = unichr(c) if X in part1_data: continue assert X == NFC(X) == NFD(X) == NFKC(X) == NFKD(X), c
def test_main(): if skip_expected: raise TestSkipped(TESTDATAFILE + " not found, download from " + "http://www.unicode.org/Public/3.2-Update/" + TESTDATAFILE) part1_data = {} for line in open(TESTDATAFILE): if '#' in line: line = line.split('#')[0] line = line.strip() if not line: continue if line.startswith("@Part"): part = line continue try: c1,c2,c3,c4,c5 = [unistr(x) for x in line.split(';')[:-1]] except RangeError: # Skip unsupported characters continue if verbose: print line # Perform tests verify(c2 == NFC(c1) == NFC(c2) == NFC(c3), line) verify(c4 == NFC(c4) == NFC(c5), line) verify(c3 == NFD(c1) == NFD(c2) == NFD(c3), line) verify(c5 == NFD(c4) == NFD(c5), line) verify(c4 == NFKC(c1) == NFKC(c2) == NFKC(c3) == NFKC(c4) == NFKC(c5), line) verify(c5 == NFKD(c1) == NFKD(c2) == NFKD(c3) == NFKD(c4) == NFKD(c5), line) # Record part 1 data if part == "@Part1": part1_data[c1] = 1 # Perform tests for all other data for c in range(sys.maxunicode+1): X = unichr(c) if X in part1_data: continue assert X == NFC(X) == NFD(X) == NFKC(X) == NFKD(X), c
12,992
def __init__(self, fp=None): self._info = {} self._charset = 'iso-8859-1' self._fallback = None if fp is not None: self._parse(fp)
def __init__(self, fp=None): self._info = {} self._charset = None self._fallback = None if fp is not None: self._parse(fp)
12,993
def _parse(self, fp): """Override this method to support alternative .mo formats.""" unpack = struct.unpack filename = getattr(fp, 'name', '') # Parse the .mo file header, which consists of 5 little endian 32 # bit words. self._catalog = catalog = {} self.plural = lambda n: int(n != 1) # germanic plural by default buf = fp.read() buflen = len(buf) # Are we big endian or little endian? magic = unpack('<I', buf[:4])[0] if magic == self.LE_MAGIC: version, msgcount, masteridx, transidx = unpack('<4I', buf[4:20]) ii = '<II' elif magic == self.BE_MAGIC: version, msgcount, masteridx, transidx = unpack('>4I', buf[4:20]) ii = '>II' else: raise IOError(0, 'Bad magic number', filename) # Now put all messages from the .mo file buffer into the catalog # dictionary. for i in xrange(0, msgcount): mlen, moff = unpack(ii, buf[masteridx:masteridx+8]) mend = moff + mlen tlen, toff = unpack(ii, buf[transidx:transidx+8]) tend = toff + tlen if mend < buflen and tend < buflen: msg = buf[moff:mend] tmsg = buf[toff:tend] if msg.find('\x00') >= 0: # Plural forms msgid1, msgid2 = msg.split('\x00') tmsg = tmsg.split('\x00') if self._coerce: msgid1 = unicode(msgid1, self._charset) tmsg = [unicode(x, self._charset) for x in tmsg] for i in range(len(tmsg)): catalog[(msgid1, i)] = tmsg[i] else: if self._coerce: msg = unicode(msg, self._charset) tmsg = unicode(tmsg, self._charset) catalog[msg] = tmsg else: raise IOError(0, 'File is corrupt', filename) # See if we're looking at GNU .mo conventions for metadata if mlen == 0 and tmsg.lower().startswith('project-id-version:'): # Catalog description for item in tmsg.splitlines(): item = item.strip() if not item: continue k, v = item.split(':', 1) k = k.strip().lower() v = v.strip() self._info[k] = v if k == 'content-type': self._charset = v.split('charset=')[1] elif k == 'plural-forms': v = v.split(';')
def _parse(self, fp): """Override this method to support alternative .mo formats.""" unpack = struct.unpack filename = getattr(fp, 'name', '') # Parse the .mo file header, which consists of 5 little endian 32 # bit words. self._catalog = catalog = {} self.plural = lambda n: int(n != 1) # germanic plural by default buf = fp.read() buflen = len(buf) # Are we big endian or little endian? magic = unpack('<I', buf[:4])[0] if magic == self.LE_MAGIC: version, msgcount, masteridx, transidx = unpack('<4I', buf[4:20]) ii = '<II' elif magic == self.BE_MAGIC: version, msgcount, masteridx, transidx = unpack('>4I', buf[4:20]) ii = '>II' else: raise IOError(0, 'Bad magic number', filename) # Now put all messages from the .mo file buffer into the catalog # dictionary. for i in xrange(0, msgcount): mlen, moff = unpack(ii, buf[masteridx:masteridx+8]) mend = moff + mlen tlen, toff = unpack(ii, buf[transidx:transidx+8]) tend = toff + tlen if mend < buflen and tend < buflen: msg = buf[moff:mend] tmsg = buf[toff:tend] if msg.find('\x00') >= 0: # Plural forms msgid1, msgid2 = msg.split('\x00') tmsg = tmsg.split('\x00') if self._coerce: msgid1 = unicode(msgid1, self._charset) tmsg = [unicode(x, self._charset) for x in tmsg] for i in range(len(tmsg)): catalog[(msgid1, i)] = tmsg[i] else: if self._coerce: msg = unicode(msg, self._charset) tmsg = unicode(tmsg, self._charset) catalog[msg] = tmsg else: raise IOError(0, 'File is corrupt', filename) # See if we're looking at GNU .mo conventions for metadata if mlen == 0 and tmsg.lower().startswith('project-id-version:'): # Catalog description for item in tmsg.splitlines(): item = item.strip() if not item: continue k, v = item.split(':', 1) k = k.strip().lower() v = v.strip() self._info[k] = v if k == 'content-type': self._charset = v.split('charset=')[1] elif k == 'plural-forms': v = v.split(';')
12,994
def _parse(self, fp): """Override this method to support alternative .mo formats.""" unpack = struct.unpack filename = getattr(fp, 'name', '') # Parse the .mo file header, which consists of 5 little endian 32 # bit words. self._catalog = catalog = {} self.plural = lambda n: int(n != 1) # germanic plural by default buf = fp.read() buflen = len(buf) # Are we big endian or little endian? magic = unpack('<I', buf[:4])[0] if magic == self.LE_MAGIC: version, msgcount, masteridx, transidx = unpack('<4I', buf[4:20]) ii = '<II' elif magic == self.BE_MAGIC: version, msgcount, masteridx, transidx = unpack('>4I', buf[4:20]) ii = '>II' else: raise IOError(0, 'Bad magic number', filename) # Now put all messages from the .mo file buffer into the catalog # dictionary. for i in xrange(0, msgcount): mlen, moff = unpack(ii, buf[masteridx:masteridx+8]) mend = moff + mlen tlen, toff = unpack(ii, buf[transidx:transidx+8]) tend = toff + tlen if mend < buflen and tend < buflen: msg = buf[moff:mend] tmsg = buf[toff:tend] if msg.find('\x00') >= 0: # Plural forms msgid1, msgid2 = msg.split('\x00') tmsg = tmsg.split('\x00') if self._coerce: msgid1 = unicode(msgid1, self._charset) tmsg = [unicode(x, self._charset) for x in tmsg] for i in range(len(tmsg)): catalog[(msgid1, i)] = tmsg[i] else: if self._coerce: msg = unicode(msg, self._charset) tmsg = unicode(tmsg, self._charset) catalog[msg] = tmsg else: raise IOError(0, 'File is corrupt', filename) # See if we're looking at GNU .mo conventions for metadata if mlen == 0 and tmsg.lower().startswith('project-id-version:'): # Catalog description for item in tmsg.splitlines(): item = item.strip() if not item: continue k, v = item.split(':', 1) k = k.strip().lower() v = v.strip() self._info[k] = v if k == 'content-type': self._charset = v.split('charset=')[1] elif k == 'plural-forms': v = v.split(';')
def _parse(self, fp): """Override this method to support alternative .mo formats.""" unpack = struct.unpack filename = getattr(fp, 'name', '') # Parse the .mo file header, which consists of 5 little endian 32 # bit words. self._catalog = catalog = {} self.plural = lambda n: int(n != 1) # germanic plural by default buf = fp.read() buflen = len(buf) # Are we big endian or little endian? magic = unpack('<I', buf[:4])[0] if magic == self.LE_MAGIC: version, msgcount, masteridx, transidx = unpack('<4I', buf[4:20]) ii = '<II' elif magic == self.BE_MAGIC: version, msgcount, masteridx, transidx = unpack('>4I', buf[4:20]) ii = '>II' else: raise IOError(0, 'Bad magic number', filename) # Now put all messages from the .mo file buffer into the catalog # dictionary. for i in xrange(0, msgcount): mlen, moff = unpack(ii, buf[masteridx:masteridx+8]) mend = moff + mlen tlen, toff = unpack(ii, buf[transidx:transidx+8]) tend = toff + tlen if mend < buflen and tend < buflen: msg = buf[moff:mend] tmsg = buf[toff:tend] if msg.find('\x00') >= 0: # Plural forms msgid1, msgid2 = msg.split('\x00') tmsg = tmsg.split('\x00') if self._coerce: msgid1 = unicode(msgid1, self._charset) tmsg = [unicode(x, self._charset) for x in tmsg] for i in range(len(tmsg)): catalog[(msgid1, i)] = tmsg[i] else: if self._coerce: msg = unicode(msg, self._charset) tmsg = unicode(tmsg, self._charset) catalog[msg] = tmsg else: raise IOError(0, 'File is corrupt', filename) # See if we're looking at GNU .mo conventions for metadata if mlen == 0: # Catalog description for item in tmsg.splitlines(): item = item.strip() if not item: continue k, v = item.split(':', 1) k = k.strip().lower() v = v.strip() self._info[k] = v if k == 'content-type': self._charset = v.split('charset=')[1] elif k == 'plural-forms': v = v.split(';')
12,995
def parse_starttag(self, i): rawdata = self.rawdata if shorttagopen.match(rawdata, i): # SGML shorthand: <tag/data/ == <tag>data</tag> # XXX Can data contain &... (entity or char refs)? # XXX Can data contain < or > (tag characters)? # XXX Can there be whitespace before the first /? match = shorttag.match(rawdata, i) if not match: return -1 tag, data = match.group(1, 2) tag = string.lower(tag) self.finish_shorttag(tag, data) k = match.end(0) return k # XXX The following should skip matching quotes (' or ") match = endbracket.search(rawdata, i+1) if not match: return -1 j = match.start(0) # Now parse the data between i+1 and j into a tag and attrs attrs = [] if rawdata[i:i+2] == '<>': # SGML shorthand: <> == <last open tag seen> k = j tag = self.lasttag else: match = tagfind.match(rawdata, i+1) if not match: raise RuntimeError, 'unexpected call to parse_starttag' k = match.end(0) tag = string.lower(rawdata[i+1:k]) self.lasttag = tag while k < j: match = attrfind.match(rawdata, k) if not match: break attrname, rest, attrvalue = match.group(1, 2, 3) if not rest: attrvalue = attrname elif attrvalue[:1] == '\'' == attrvalue[-1:] or \ attrvalue[:1] == '"' == attrvalue[-1:]: attrvalue = attrvalue[1:-1] attrs.append((string.lower(attrname), attrvalue)) k = match.end(0) if rawdata[j] == '>': j = j+1 self.finish_starttag(tag, attrs) return j
def parse_starttag(self, i): rawdata = self.rawdata if shorttagopen.match(rawdata, i): # SGML shorthand: <tag/data/ == <tag>data</tag> # XXX Can data contain &... (entity or char refs)? # XXX Can data contain < or > (tag characters)? # XXX Can there be whitespace before the first /? match = shorttag.match(rawdata, i) if not match: return -1 tag, data = match.group(1, 2) tag = string.lower(tag) self.finish_shorttag(tag, data) self.__starttag_text = rawdata[start_pos:match.end(1) + 1] return k # XXX The following should skip matching quotes (' or ") match = endbracket.search(rawdata, i+1) if not match: return -1 j = match.start(0) # Now parse the data between i+1 and j into a tag and attrs attrs = [] if rawdata[i:i+2] == '<>': # SGML shorthand: <> == <last open tag seen> k = j tag = self.lasttag else: match = tagfind.match(rawdata, i+1) if not match: raise RuntimeError, 'unexpected call to parse_starttag' self.__starttag_text = rawdata[start_pos:match.end(1) + 1] tag = string.lower(rawdata[i+1:k]) self.lasttag = tag while k < j: match = attrfind.match(rawdata, k) if not match: break attrname, rest, attrvalue = match.group(1, 2, 3) if not rest: attrvalue = attrname elif attrvalue[:1] == '\'' == attrvalue[-1:] or \ attrvalue[:1] == '"' == attrvalue[-1:]: attrvalue = attrvalue[1:-1] attrs.append((string.lower(attrname), attrvalue)) self.__starttag_text = rawdata[start_pos:match.end(1) + 1] if rawdata[j] == '>': j = j+1 self.finish_starttag(tag, attrs) return j
12,996
def open_ftp(self, url): """Use FTP protocol.""" host, path = splithost(url) if not host: raise IOError, ('ftp error', 'no host given') host, port = splitport(host) user, host = splituser(host) if user: user, passwd = splitpasswd(user) else: passwd = None host = unquote(host) user = unquote(user or '') passwd = unquote(passwd or '') host = socket.gethostbyname(host) if not port: import ftplib port = ftplib.FTP_PORT else: port = int(port) path, attrs = splitattr(path) path = unquote(path) dirs = path.split('/') dirs, file = dirs[:-1], dirs[-1] if dirs and not dirs[0]: dirs = dirs[1:] if dirs and not dirs[0]: dirs[0] = '/' key = user, host, port, '/'.join(dirs) # XXX thread unsafe! if len(self.ftpcache) > MAXFTPCACHE: # Prune the cache, rather arbitrarily for k in self.ftpcache.keys(): if k != key: v = self.ftpcache[k] del self.ftpcache[k] v.close() try: if not self.ftpcache.has_key(key): self.ftpcache[key] = \ ftpwrapper(user, passwd, host, port, dirs) if not file: type = 'D' else: type = 'I' for attr in attrs: attr, value = splitvalue(attr) if attr.lower() == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): type = value.upper() (fp, retrlen) = self.ftpcache[key].retrfile(file, type) if retrlen is not None and retrlen >= 0: import mimetools, StringIO headers = mimetools.Message(StringIO.StringIO( 'Content-Length: %d\n' % retrlen)) else: headers = noheaders() return addinfourl(fp, headers, "ftp:" + url) except ftperrors(), msg: raise IOError, ('ftp error', msg), sys.exc_info()[2]
def open_ftp(self, url): """Use FTP protocol.""" host, path = splithost(url) if not host: raise IOError, ('ftp error', 'no host given') host, port = splitport(host) user, host = splituser(host) if user: user, passwd = splitpasswd(user) else: passwd = None host = unquote(host) user = unquote(user or '') passwd = unquote(passwd or '') host = socket.gethostbyname(host) if not port: import ftplib port = ftplib.FTP_PORT else: port = int(port) path, attrs = splitattr(path) path = unquote(path) dirs = path.split('/') dirs, file = dirs[:-1], dirs[-1] if dirs and not dirs[0]: dirs = dirs[1:] if dirs and not dirs[0]: dirs[0] = '/' key = user, host, port, '/'.join(dirs) # XXX thread unsafe! if len(self.ftpcache) > MAXFTPCACHE: # Prune the cache, rather arbitrarily for k in self.ftpcache.keys(): if k != key: v = self.ftpcache[k] del self.ftpcache[k] v.close() try: if not self.ftpcache.has_key(key): self.ftpcache[key] = \ ftpwrapper(user, passwd, host, port, dirs) if not file: type = 'D' else: type = 'I' for attr in attrs: attr, value = splitvalue(attr) if attr.lower() == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): type = value.upper() (fp, retrlen) = self.ftpcache[key].retrfile(file, type) if retrlen is not None and retrlen >= 0: headers += "Content-Length: %d\n" % retrlen headers = mimetools.Message(StringIO.StringIO(headers)) return addinfourl(fp, headers, "ftp:" + url) except ftperrors(), msg: raise IOError, ('ftp error', msg), sys.exc_info()[2]
12,997
def endPrefixMapping(self, prefix): del self._current_context[-1]
def endPrefixMapping(self, prefix): del self._current_context[-1]
12,998
def processingInstruction(self, target, data): self._out.write('<?%s %s?>' % (target, data))
def processingInstruction(self, target, data): self._out.write('<?%s %s?>' % (target, data))
12,999