rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
os.kill(pid, signal.SIGALARM)
os.kill(pid, signal.SIGALRM) print >> sys.__stdout__, " child sent SIGALRM to", pid
def force_test_exit(): # Sigh, both imports seem necessary to avoid errors. import os fork_pid = os.fork() if fork_pid == 0: # In child import os, time try: # Wait 5 seconds longer than the expected alarm to give enough # time for the normal sequence of events to occur. This is # just a stop-gap to prevent the test fr...
return data[:-3] + '\n'
return data.replace('\r\r\n', '\n')
def normalize_output(data): # Some operating systems do conversions on newline. We could possibly # fix that by doing the appropriate termios.tcsetattr()s. I couldn't # figure out the right combo on Tru64 and I don't have an IRIX box. # So just normalize the output and doc the problem O/Ses by allowing # certain comb...
return data[:-2] + '\n'
return data.replace('\r\n', '\n')
def normalize_output(data): # Some operating systems do conversions on newline. We could possibly # fix that by doing the appropriate termios.tcsetattr()s. I couldn't # figure out the right combo on Tru64 and I don't have an IRIX box. # So just normalize the output and doc the problem O/Ses by allowing # certain comb...
line = file.readline() while line[:1] == '
if info and 'b' in info[2]: try: module = imp.load_module(info[0], file, filename, info[1:]) except: return None result = split(module.__doc__ or '', '\n')[0] else:
def synopsis(filename, cache={}): """Get the one-line summary out of a module file.""" mtime = os.stat(filename)[stat.ST_MTIME] lastupdate, result = cache.get(filename, (0, None)) # XXX what if ext is 'rb' type in imp_getsuffixes? if lastupdate < mtime: file = open(filename) line = file.readline() while line[:1] == '#'...
if not line: break if line[-2:] == '\\\n': line = line[:-2] + file.readline() line = strip(line) if line[:3] == '"""': line = line[3:] while strip(line) == '':
while line[:1] == '
def synopsis(filename, cache={}): """Get the one-line summary out of a module file.""" mtime = os.stat(filename)[stat.ST_MTIME] lastupdate, result = cache.get(filename, (0, None)) # XXX what if ext is 'rb' type in imp_getsuffixes? if lastupdate < mtime: file = open(filename) line = file.readline() while line[:1] == '#'...
result = strip(split(line, '"""')[0]) else: result = None
line = strip(line) if line[:4] == 'r"""': line = line[1:] if line[:3] == '"""': line = line[3:] if line[-1:] == '\\': line = line[:-1] while not strip(line): line = file.readline() if not line: break result = strip(split(line, '"""')[0]) else: result = None
def synopsis(filename, cache={}): """Get the one-line summary out of a module file.""" mtime = os.stat(filename)[stat.ST_MTIME] lastupdate, result = cache.get(filename, (0, None)) # XXX what if ext is 'rb' type in imp_getsuffixes? if lastupdate < mtime: file = open(filename) line = file.readline() while line[:1] == '#'...
def modulename(path): """Return the Python module name for a given path, or None.""" filename = os.path.basename(path) suffixes = map(lambda (suffix, mode, kind): (len(suffix), suffix), imp.get_suffixes()) suffixes.sort() suffixes.reverse() for length, suffix in suffixes: if len(filename) > length and filename[-length:...
def stripid(text): """Remove the hexadecimal id from a Python object representation.""" # The behaviour of %p is implementation-dependent, so we need an example. for pattern in [' at 0x[0-9a-f]{6,}>$', ' at [0-9A-F]{8,}>$']: if re.search(pattern, repr(Exception)): return re.sub(pattern, '>', text) return text
return re.sub(r'((\\[\\abfnrtv\'"]|\\x..|\\u....)+)',
return re.sub(r'((\\[\\abfnrtv\'"]|\\[0-9]..|\\x..|\\u....)+)',
def repr_string(self, x, level): test = cram(x, self.maxstring) testrepr = repr(test) if '\\' in test and '\\' not in replace(testrepr, (r'\\', '')): # Backslashes are only literal in the string and are never # needed to make any special characters, so show a raw string. return 'r' + testrepr[0] + self.escape(test) + t...
def section(self, title, fgcol, bgcol, contents, width=20,
def section(self, title, fgcol, bgcol, contents, width=10,
def section(self, title, fgcol, bgcol, contents, width=20, prelude='', marginalia=None, gap='&nbsp;&nbsp;'): """Format a section with a heading.""" if marginalia is None: marginalia = '&nbsp;' * width result = '''
marginalia = '&nbsp;' * width
marginalia = '<tt>' + '&nbsp;' * width + '</tt>'
def section(self, title, fgcol, bgcol, contents, width=20, prelude='', marginalia=None, gap='&nbsp;&nbsp;'): """Format a section with a heading.""" if marginalia is None: marginalia = '&nbsp;' * width result = '''
return result + '<td width="100%%">%s</td></tr></table>' % contents
return result + '\n<td width="100%%">%s</td></tr></table>' % contents
def section(self, title, fgcol, bgcol, contents, width=20, prelude='', marginalia=None, gap='&nbsp;&nbsp;'): """Format a section with a heading.""" if marginalia is None: marginalia = '&nbsp;' * width result = '''
if 0 and hasattr(object, '__all__'): visible = lambda key, all=object.__all__: key in all else: visible = lambda key: key[:1] != '_'
def docmodule(self, object, name=None): """Produce HTML documentation for a module object.""" name = object.__name__ # ignore the passed-in name parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) l...
if visible(key) and ( inspect.getmodule(value) or object) is object:
if (inspect.getmodule(value) or object) is object:
def docmodule(self, object, name=None): """Produce HTML documentation for a module object.""" name = object.__name__ # ignore the passed-in name parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) l...
if visible(key) and (inspect.isbuiltin(value) or inspect.getmodule(value) is object):
if inspect.isbuiltin(value) or inspect.getmodule(value) is object:
def docmodule(self, object, name=None): """Produce HTML documentation for a module object.""" name = object.__name__ # ignore the passed-in name parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) l...
if visible(key): constants.append((key, value))
constants.append((key, value))
def docmodule(self, object, name=None): """Produce HTML documentation for a module object.""" name = object.__name__ # ignore the passed-in name parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) l...
if file[:1] != '_': path = os.path.join(object.__path__[0], file) modname = modulename(file) if modname and modname not in modnames: modpkgs.append((modname, name, 0, 0)) modnames.append(modname) elif ispackage(path): modpkgs.append((file, name, 1, 0))
path = os.path.join(object.__path__[0], file) modname = inspect.getmodulename(file) if modname and modname not in modnames: modpkgs.append((modname, name, 0, 0)) modnames.append(modname) elif ispackage(path): modpkgs.append((file, name, 1, 0))
def docmodule(self, object, name=None): """Produce HTML documentation for a module object.""" name = object.__name__ # ignore the passed-in name parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) l...
doc = self.small(doc and '<tt>%s<br>&nbsp;</tt>' % doc or '<tt>&nbsp;</tt>') return self.section(title, '
doc = self.small(doc and '<tt>%s<br>&nbsp;</tt>' % doc or self.small('&nbsp;')) return self.section(title, '
def docclass(self, object, name=None, funcs={}, classes={}): """Produce HTML documentation for a class object.""" realname = object.__name__ name = name or realname bases = object.__bases__ contents = ''
doc = doc and '<tt>%s</tt>' % doc return '<dl><dt>%s<dd>%s</dl>\n' % (decl, self.small(doc))
doc = doc and '<dd>' + self.small('<tt>%s</tt>' % doc) return '<dl><dt>%s%s</dl>\n' % (decl, doc)
def docroutine(self, object, name=None, funcs={}, classes={}, methods={}, cl=None): """Produce HTML documentation for a function or method object.""" realname = object.__name__ name = name or realname anchor = (cl and cl.__name__ or '') + '-' + name note = '' skipdocs = 0 if inspect.ismethod(object): if cl: if object.i...
if file[:1] != '_' and os.path.isfile(path): modname = modulename(file)
if os.path.isfile(path): modname = inspect.getmodulename(file)
def found(name, ispackage, modpkgs=modpkgs, shadowed=shadowed, seen=seen): if not seen.has_key(name): modpkgs.append((name, '', ispackage, shadowed.has_key(name))) seen[name] = 1 shadowed[name] = 1
namesec = name lines = split(strip(getdoc(object)), '\n') if len(lines) == 1: if lines[0]: namesec = namesec + ' - ' + lines[0] lines = [] elif len(lines) >= 2 and not rstrip(lines[1]): if lines[0]: namesec = namesec + ' - ' + lines[0] lines = lines[2:] result = self.section('NAME', namesec)
synop, desc = splitdoc(getdoc(object)) result = self.section('NAME', name + (synop and ' - ' + synop))
def docmodule(self, object, name=None): """Produce text documentation for a given module object.""" name = object.__name__ # ignore the passed-in name namesec = name lines = split(strip(getdoc(object)), '\n') if len(lines) == 1: if lines[0]: namesec = namesec + ' - ' + lines[0] lines = [] elif len(lines) >= 2 and not r...
if lines: result = result + self.section('DESCRIPTION', join(lines, '\n'))
if desc: result = result + self.section('DESCRIPTION', desc)
def docmodule(self, object, name=None): """Produce text documentation for a given module object.""" name = object.__name__ # ignore the passed-in name namesec = name lines = split(strip(getdoc(object)), '\n') if len(lines) == 1: if lines[0]: namesec = namesec + ' - ' + lines[0] lines = [] elif len(lines) >= 2 and not r...
if key[:1] != '_': constants.append((key, value))
constants.append((key, value))
def docmodule(self, object, name=None): """Produce text documentation for a given module object.""" name = object.__name__ # ignore the passed-in name namesec = name lines = split(strip(getdoc(object)), '\n') if len(lines) == 1: if lines[0]: namesec = namesec + ' - ' + lines[0] lines = [] elif len(lines) >= 2 and not r...
if file[:1] != '_': path = os.path.join(object.__path__[0], file) modname = modulename(file) if modname and modname not in modpkgs: modpkgs.append(modname) elif ispackage(path): modpkgs.append(file + ' (package)')
path = os.path.join(object.__path__[0], file) modname = inspect.getmodulename(file) if modname and modname not in modpkgs: modpkgs.append(modname) elif ispackage(path): modpkgs.append(file + ' (package)')
def docmodule(self, object, name=None): """Produce text documentation for a given module object.""" name = object.__name__ # ignore the passed-in name namesec = name lines = split(strip(getdoc(object)), '\n') if len(lines) == 1: if lines[0]: namesec = namesec + ' - ' + lines[0] lines = [] elif len(lines) >= 2 and not r...
return lambda a: pipepager(a, os.environ['PAGER'])
if sys.platform == 'win32': return lambda a: tempfilepager(a, os.environ['PAGER']) else: return lambda a: pipepager(a, os.environ['PAGER'])
def getpager(): """Decide what method to use for paging through text.""" if type(sys.stdout) is not types.FileType: return plainpager if not sys.stdin.isatty() or not sys.stdout.isatty(): return plainpager if os.environ.has_key('PAGER'): return lambda a: pipepager(a, os.environ['PAGER']) if sys.platform == 'win32': ret...
raise DocImportError(filename, sys.exc_info())
raise ErrorDuringImport(filename, sys.exc_info())
def locate(path): """Locate an object by name (or dotted path), importing as necessary.""" if not path: # special case: imp.find_module('') strangely succeeds return None if type(path) is not types.StringType: return path parts = split(path, '.') n = len(parts) while n > 0: path = join(parts[:n], '.') try: module = fre...
page = html.page('Python: ' + describe(object),
page = html.page(describe(object),
def writedoc(key): """Write HTML documentation to a file in the current directory.""" try: object = locate(key) except ErrorDuringImport, value: print value else: if object: page = html.page('Python: ' + describe(object), html.document(object, object.__name__)) file = open(key + '.html', 'w') file.write(page) file.clos...
modname = modulename(path)
modname = inspect.getmodulename(path)
def writedocs(dir, pkgpath='', done={}): """Write out HTML documentation for all modules in a directory tree.""" for file in os.listdir(dir): path = os.path.join(dir, file) if ispackage(path): writedocs(path, pkgpath + file + '.') elif os.path.isfile(path): modname = modulename(path) if modname: modname = pkgpath + mod...
modname = modulename(path)
modname = inspect.getmodulename(path)
def run(self, key, callback, completer=None): self.quit = 0 seen = {}
print modname, '-', desc or '(no description)'
print modname, desc and '- ' + desc try: import warnings except ImportError: pass else: warnings.filterwarnings('ignore')
def callback(path, modname, desc): if modname[-9:] == '.__init__': modname = modname[:-9] + ' (package)' print modname, '-', desc or '(no description)'
try: import ic ic.launchurl(url)
try: import ic
def open(self, event=None, url=None): url = url or self.server.url try: import webbrowser webbrowser.open(url) except ImportError: # pre-webbrowser.py compatibility if sys.platform == 'win32': os.system('start "%s"' % url) elif sys.platform == 'mac': try: import ic ic.launchurl(url) except ImportError: pass else: rc = ...
Pop up a graphical interface for serving and finding documentation.
Pop up a graphical interface for finding and serving documentation.
def ready(server): print 'server ready at %s' % server.url
directory. If <name> contains a '%s', it is treated as a filename.
directory. If <name> contains a '%s', it is treated as a filename; if it names a directory, documentation is written for all the contents.
def ready(server): print 'server ready at %s' % server.url
self.saved_clear() self.hrefstack.append(href) def anchor_end(self): if self.proc: title = cgi.escape(self.saved_get(), True) path = self.path + '/' + self.hrefstack.pop()
def anchor_bgn(self, href, name, type): if self.proc: self.saved_clear() self.hrefstack.append(href)
test_classes = (TestBasicOps, TestVariousIteratorArgs, TestGC)
test_classes = (TestBasicOps, TestVariousIteratorArgs, TestGC, RegressionTests)
def test_main(verbose=None): test_classes = (TestBasicOps, TestVariousIteratorArgs, TestGC) test_support.run_unittest(*test_classes) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in xrange(len(counts)): test_support.run_unittest(*test_classes) gc.colle...
self.bytecompile(outfiles)
if outfiles is not None: self.bytecompile(outfiles)
def run (self):
del Popen3, Popen4, _active, _cleanup
del Popen3, Popen4
def __init__(self, cmd, bufsize=-1): _cleanup() p2cread, p2cwrite = os.pipe() c2pread, c2pwrite = os.pipe() self.pid = os.fork() if self.pid == 0: # Child os.dup2(p2cread, 0) os.dup2(c2pwrite, 1) os.dup2(c2pwrite, 2) self._run_child(cmd) os.close(p2cread) self.tochild = os.fdopen(p2cwrite, 'w', bufsize) os.close(c2pwri...
dir = os.path.join(*paths) return os.path.normcase(os.path.abspath(dir)) L = sys.modules.values() for m in L:
dir = os.path.abspath(os.path.join(*paths)) return dir, os.path.normcase(dir) for m in sys.modules.values():
def makepath(*paths): dir = os.path.join(*paths) return os.path.normcase(os.path.abspath(dir))
m.__file__ = makepath(m.__file__) del m, L
m.__file__ = os.path.abspath(m.__file__) del m
def makepath(*paths): dir = os.path.join(*paths) return os.path.normcase(os.path.abspath(dir))
dir = makepath(dir) if dir not in L:
dir, dircase = makepath(dir) if not dirs_in_sys_path.has_key(dircase):
def makepath(*paths): dir = os.path.join(*paths) return os.path.normcase(os.path.abspath(dir))
sitedir = makepath(sitedir) if sitedir not in sys.path:
sitedir, sitedircase = makepath(sitedir) if not dirs_in_sys_path.has_key(sitedircase):
def addsitedir(sitedir): sitedir = makepath(sitedir) if sitedir not in sys.path: sys.path.append(sitedir) # Add path component try: names = os.listdir(sitedir) except os.error: return names = map(os.path.normcase, names) names.sort() for name in names: if name[-4:] == endsep + "pth": addpackage(sitedir, name)
names = map(os.path.normcase, names)
def addsitedir(sitedir): sitedir = makepath(sitedir) if sitedir not in sys.path: sys.path.append(sitedir) # Add path component try: names = os.listdir(sitedir) except os.error: return names = map(os.path.normcase, names) names.sort() for name in names: if name[-4:] == endsep + "pth": addpackage(sitedir, name)
dir = makepath(sitedir, dir) if dir not in sys.path and os.path.exists(dir):
dir, dircase = makepath(sitedir, dir) if not dirs_in_sys_path.has_key(dircase) and os.path.exists(dir):
def addpackage(sitedir, name): 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 = makepath(sitedir, dir) if dir not in sys.p...
sitedirs = [makepath(prefix, "lib", "python" + sys.version[:3], "site-packages"), makepath(prefix, "lib", "site-python")]
sitedirs = [os.path.join(prefix, "lib", "python" + sys.version[:3], "site-packages"), os.path.join(prefix, "lib", "site-python")]
def addpackage(sitedir, name): 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 = makepath(sitedir, dir) if dir not in sys.p...
sitedirs = [makepath(prefix, "lib", "site-packages")]
sitedirs = [os.path.join(prefix, "lib", "site-packages")]
def addpackage(sitedir, name): 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 = makepath(sitedir, dir) if dir not in sys.p...
testf.write(data)
if DEBUG: testf.write(data)
def write(self, data):
fss, ok = macfs.StandardGetFile()
fss, ok = macfs.PromptGetFile('File to convert:')
def _test(): if os.name == 'mac': fss, ok = macfs.StandardGetFile() if not ok: sys.exit(0) fname = fss.as_pathname() else: fname = sys.argv[1] #binhex(fname, fname+'.hqx') #hexbin(fname+'.hqx', fname+'.viahqx') hexbin(fname, fname+'.unpacked') sys.exit(1)
rc = os.system("%s %s" % (self.name, url))
rc = os.system(cmd)
def _remote(self, url, action, autoraise): autoraise = int(bool(autoraise)) # always 0/1 raise_opt = self.raise_opts and self.raise_opts[autoraise] or '' cmd = "%s %s %s '%s' >/dev/null 2>&1" % (self.name, raise_opt, self.remote_cmd, action) if self.remote_background: cmd += ' &' rc = os.system(cmd) if rc: # bad return...
rc = os.system(self.name + " -d '%s'" % url)
rc = os.system(self.name + " -d '%s' &" % url)
def _remote(self, url, action): # kfmclient is the new KDE way of opening URLs. cmd = "kfmclient %s >/dev/null 2>&1" % action rc = os.system(cmd) # Fall back to other variants. if rc: if _iscommand("konqueror"): rc = os.system(self.name + " --silent '%s' &" % url) elif _iscommand("kfm"): rc = os.system(self.name + " -d...
script = _safequote('open location "%s"', url)
script = 'open location "%s"' % url.replace('"', '%22')
def open(self, url, new=0, autoraise=1): assert "'" not in url # new must be 0 or 1 new = int(bool(new)) if self.name == "default": # User called open, open_new or get without a browser parameter script = _safequote('open location "%s"', url) # opens in default browser else: # User called get and chose a browser if sel...
cmd = _safequote('OpenURL "%s"', url)
cmd = 'OpenURL "%s"' % url.replace('"', '%22')
def open(self, url, new=0, autoraise=1): assert "'" not in url # new must be 0 or 1 new = int(bool(new)) if self.name == "default": # User called open, open_new or get without a browser parameter script = _safequote('open location "%s"', url) # opens in default browser else: # User called get and chose a browser if sel...
if r.status in (200, 206): resp = addinfourl(r.fp, r.msg, req.get_full_url()) resp.code = r.status resp.msg = r.reason return resp else: return self.parent.error("http", req, r.fp, r.status, r.msg, r.msg.dict)
resp = addinfourl(r.fp, r.msg, req.get_full_url()) resp.code = r.status resp.msg = r.reason return resp
def do_open(self, http_class, req): """Return an addinfourl object for the request, using http_class.
self.__messages.setdefault(msg, []).append(entry)
self.__messages.setdefault(msg, {})[entry] = 1
def __addentry(self, msg, lineno=None): if lineno is None: lineno = self.__lineno if not msg in self.__options.toexclude: entry = (self.__curfile, lineno) self.__messages.setdefault(msg, []).append(entry)
sys.stderr.write(_("Can't read --exclude-file: %s") % options.excludefilename)
print >> sys.stderr, _( "Can't read --exclude-file: %s") % options.excludefilename
def main(): global default_keywords try: opts, args = getopt.getopt( sys.argv[1:], 'ad:DEhk:Kno:p:S:Vvw:x:', ['extract-all', 'default-domain', 'escape', 'help', 'keyword=', 'no-default-keywords', 'add-location', 'no-location', 'output=', 'output-dir=', 'style=', 'verbose', 'version', 'width=', 'exclude-file=', 'docstri...
sys.stderr.write('%s: %s, line %d, column %d\n' % (e[0], filename, e[1][0], e[1][1]))
print >> sys.stderr, '%s: %s, line %d, column %d' % ( e[0], filename, e[1][0], e[1][1])
def main(): global default_keywords try: opts, args = getopt.getopt( sys.argv[1:], 'ad:DEhk:Kno:p:S:Vvw:x:', ['extract-all', 'default-domain', 'escape', 'help', 'keyword=', 'no-default-keywords', 'add-location', 'no-location', 'output=', 'output-dir=', 'style=', 'verbose', 'version', 'width=', 'exclude-file=', 'docstri...
def _(s): return s
try: import fintl _ = fintl.gettext except ImportError: def _(s): return s
def _(s): return s
for i in range(256): if i < 32 or i > 127: escapes.append("\\%03o" % i) else: escapes.append(chr(i)) escapes[ord('\\')] = '\\\\' escapes[ord('\t')] = '\\t' escapes[ord('\r')] = '\\r' escapes[ord('\n')] = '\\n' escapes[ord('\"')] = '\\"'
def make_escapes(pass_iso8859): global escapes for i in range(256): if pass_iso8859: i = i % 128 if 32 <= i <= 126: escapes.append(chr(i)) else: escapes.append("\\%03o" % i) escapes[ord('\\')] = '\\\\' escapes[ord('\t')] = '\\t' escapes[ord('\r')] = '\\r' escapes[ord('\n')] = '\\n' escapes[ord('\"')] = '\\"'
def usage(code, msg=''): print __doc__ % globals() if msg: print msg sys.exit(code)
entry = (self.__curfile, self.__lineno) linenos = self.__messages.get(msg) if linenos is None: self.__messages[msg] = [entry] else: linenos.append(entry)
if not msg in self.__options.toexclude: entry = (self.__curfile, self.__lineno) linenos = self.__messages.get(msg) if linenos is None: self.__messages[msg] = [entry] else: linenos.append(entry)
def __openseen(self, ttype, tstring, lineno): if ttype == tokenize.OP and tstring == ')': # We've seen the last of the translatable strings. Record the # line number of the first line of the strings and update the list # of messages seen. Reset state for the next batch. If there # were no strings inside _(), then ju...
for filename, lineno in v: d = {'filename': filename, 'lineno': lineno} if options.location == options.SOLARIS:
if options.location == options.SOLARIS: for filename, lineno in v: d = {'filename': filename, 'lineno': lineno}
def write(self, fp): options = self.__options timestamp = time.ctime(time.time()) # common header try: sys.stdout = fp # The time stamp in the header doesn't have the same format # as that generated by xgettext... print pot_header % {'time': timestamp, 'version':__version__} for k, v in self.__messages.items(): for fil...
elif options.location == options.GNU: print _('
elif options.location == options.GNU: locline = ' for filename, lineno in v: d = {'filename': filename, 'lineno': lineno} s = _(' %(filename)s:%(lineno)d') % d if len(locline) + len(s) <= options.width: locline = locline + s else: print locline locline = " if len(locline) > 2: print locline
def write(self, fp): options = self.__options timestamp = time.ctime(time.time()) # common header try: sys.stdout = fp # The time stamp in the header doesn't have the same format # as that generated by xgettext... print pot_header % {'time': timestamp, 'version':__version__} for k, v in self.__messages.items(): for fil...
print 'msgstr ""' print
print 'msgstr ""\n'
def write(self, fp): options = self.__options timestamp = time.ctime(time.time()) # common header try: sys.stdout = fp # The time stamp in the header doesn't have the same format # as that generated by xgettext... print pot_header % {'time': timestamp, 'version':__version__} for k, v in self.__messages.items(): for fil...
'k:d:n:hv', ['keyword', 'default-domain', 'help', 'add-location=', 'no-location', 'verbose'])
'ad:Ehk:n:o:p:Vvw:x:', ['extract-all', 'default-domain', 'escape', 'help', 'keyword', 'add-location', 'no-location', 'output=', 'output-dir=', 'verbose', 'version', 'width=', 'exclude-file=', ])
def main(): default_keywords = ['_'] try: opts, args = getopt.getopt( sys.argv[1:], 'k:d:n:hv', ['keyword', 'default-domain', 'help', 'add-location=', 'no-location', 'verbose']) except getopt.error, msg: usage(1, msg) # for holding option values class Options: # constants GNU = 1 SOLARIS = 2 # defaults keywords = [] o...
elif opt in ('-d', '--default-domain'): options.outfile = arg + '.pot'
def main(): default_keywords = ['_'] try: opts, args = getopt.getopt( sys.argv[1:], 'k:d:n:hv', ['keyword', 'default-domain', 'help', 'add-location=', 'no-location', 'verbose']) except getopt.error, msg: usage(1, msg) # for holding option values class Options: # constants GNU = 1 SOLARIS = 2 # defaults keywords = [] o...
def deepcopyrecursive(): if verbose: print "Testing deepcopy of recursive objects..." class Node: pass a = Node() b = Node() a.b = b b.a = a z = deepcopy(a)
def strops(): try: 'a' + 5 except TypeError: pass else: raise TestFailed, "'' + 5 doesn't raise TypeError" try: ''.split('') except ValueError: pass else: raise TestFailed, "''.split('') doesn't raise ValueError" try: ''.join([0]) except TypeError: pass else: raise TestFailed, "''.join([0]) doesn't raise TypeError" ...
"Please save first!")
"The buffer for %s is not saved.\n" % name + "Please save it first!")
def getfilename(self): # Logic to make sure we have a saved filename # XXX Better logic would offer to save! if not self.editwin.get_saved(): self.errorbox("Not saved", "Please save first!") self.editwin.text.focus_set() return filename = self.editwin.io.filename if not filename: self.errorbox("No file name", "This win...
self.fail("expected TypeError")
def test_union_update(self): try: self.set |= self.other self.fail("expected TypeError") except TypeError: pass
try: self.other | self.set self.fail("expected TypeError") except TypeError: pass try: self.set | self.other self.fail("expected TypeError") except TypeError: pass
self.assertRaises(TypeError, lambda: self.set | self.other) self.assertRaises(TypeError, lambda: self.other | self.set)
def test_union(self): try: self.other | self.set self.fail("expected TypeError") except TypeError: pass try: self.set | self.other self.fail("expected TypeError") except TypeError: pass
self.fail("expected TypeError")
def test_intersection_update(self): try: self.set &= self.other self.fail("expected TypeError") except TypeError: pass
try: self.other & self.set self.fail("expected TypeError") except TypeError: pass try: self.set & self.other self.fail("expected TypeError") except TypeError: pass
self.assertRaises(TypeError, lambda: self.set & self.other) self.assertRaises(TypeError, lambda: self.other & self.set)
def test_intersection(self): try: self.other & self.set self.fail("expected TypeError") except TypeError: pass try: self.set & self.other self.fail("expected TypeError") except TypeError: pass
self.fail("expected TypeError")
def test_sym_difference_update(self): try: self.set ^= self.other self.fail("expected TypeError") except TypeError: pass
try: self.other ^ self.set self.fail("expected TypeError") except TypeError: pass try: self.set ^ self.other self.fail("expected TypeError") except TypeError: pass
self.assertRaises(TypeError, lambda: self.set ^ self.other) self.assertRaises(TypeError, lambda: self.other ^ self.set)
def test_sym_difference(self): try: self.other ^ self.set self.fail("expected TypeError") except TypeError: pass try: self.set ^ self.other self.fail("expected TypeError") except TypeError: pass
self.fail("expected TypeError")
def test_difference_update(self): try: self.set -= self.other self.fail("expected TypeError") except TypeError: pass
try: self.other - self.set self.fail("expected TypeError") except TypeError: pass try: self.set - self.other self.fail("expected TypeError") except TypeError: pass
self.assertRaises(TypeError, lambda: self.set - self.other) self.assertRaises(TypeError, lambda: self.other - self.set)
def test_difference(self): try: self.other - self.set self.fail("expected TypeError") except TypeError: pass try: self.set - self.other self.fail("expected TypeError") except TypeError: pass
if not args: usage('hostname missing') host = args[0]
def main(): global verbose, interactive, mac, rmok, nologin try: opts, args = getopt.getopt(sys.argv[1:], 'a:bil:mnp:qrs:v') except getopt.error, msg: usage(msg) login = '' passwd = '' account = '' for o, a in opts: if o == '-l': login = a if o == '-p': passwd = a if o == '-a': account = a if o == '-v': verbose = verbo...
exts.append( Extension('errno', ['errnomodule.c']) )
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
print set
def __init__(self, set):
if pattern[index] == 'iI':
if pattern[index] in 'iI':
def compile(pattern, flags=0): stack = [] index = 0 label = 0 register = 1 groupindex = {} callouts = [] while (index < len(pattern)): char = pattern[index] index = index + 1 if char == '\\': if index < len(pattern): next = pattern[index] index = index + 1 if next == 't': stack.append([Exact(chr(9))]) elif next == 'n'...
elif pattern[index] == 'mM':
elif pattern[index] in 'mM':
def compile(pattern, flags=0): stack = [] index = 0 label = 0 register = 1 groupindex = {} callouts = [] while (index < len(pattern)): char = pattern[index] index = index + 1 if char == '\\': if index < len(pattern): next = pattern[index] index = index + 1 if next == 't': stack.append([Exact(chr(9))]) elif next == 'n'...
elif pattern[index] == 'sS':
elif pattern[index] in 'sS':
def compile(pattern, flags=0): stack = [] index = 0 label = 0 register = 1 groupindex = {} callouts = [] while (index < len(pattern)): char = pattern[index] index = index + 1 if char == '\\': if index < len(pattern): next = pattern[index] index = index + 1 if next == 't': stack.append([Exact(chr(9))]) elif next == 'n'...
if err[0] == socket.SSL_ERROR_ZERO_RETURN:
if (err[0] == socket.SSL_ERROR_ZERO_RETURN or err[0] == socket.SSL_ERROR_EOF):
def makefile(self, mode, bufsize=None): """Return a readable file-like object with data from socket.
if sys.platform == 'Darwin1.2':
if platform == 'Darwin1.2':
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
if (self.compiler.find_library_file(lib_dirs, 'ndbm')): exts.append( Extension('dbm', ['dbmmodule.c'], libraries = ['ndbm'] ) ) else: exts.append( Extension('dbm', ['dbmmodule.c']) )
if platform not in ['cygwin']: if (self.compiler.find_library_file(lib_dirs, 'ndbm')): exts.append( Extension('dbm', ['dbmmodule.c'], libraries = ['ndbm'] ) ) else: exts.append( Extension('dbm', ['dbmmodule.c']) )
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
if sys.platform not in ['mac', 'win32']:
if platform not in ['mac', 'win32']:
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
exts.append( Extension('resource', ['resource.c']) )
if platform not in ['cygwin']: exts.append( Extension('resource', ['resource.c']) )
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
if sys.platform == 'sunos4':
if platform == 'sunos4':
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
if sys.platform == 'irix5':
if platform == 'irix5':
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
plat = sys.platform if plat == 'linux2':
if platform == 'linux2':
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
if plat == 'sunos5':
if platform == 'sunos5':
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.append('/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.append( '/usr/local/include' )
if sys.platform == 'sunos5':
platform = self.get_platform() if platform == 'sunos5':
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. # # The command for _tkinter is long and site specific. Please # uncomment and/or edit those parts as indicated. If you don't have a # specific extension (e.g. Tix or BLT), leave the corresponding line # commented out. (Leave the trailing backslash...
if sys.platform in ['aix3', 'aix4']:
if platform in ['aix3', 'aix4']:
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. # # The command for _tkinter is long and site specific. Please # uncomment and/or edit those parts as indicated. If you don't have a # specific extension (e.g. Tix or BLT), leave the corresponding line # commented out. (Leave the trailing backslash...
self.previous_importer = namespace['__import__'] self.namespace = namespace
def install(self, namespace=vars(__builtin__)): "Install this ImportManager into the specified namespace."
>>> x = [pickle.PicklingError()] * 2
>>> from pickletools import _Example >>> x = [_Example(42)] * 2
def dis(pickle, out=None, memo=None, indentlevel=4): """Produce a symbolic disassembly of a pickle. 'pickle' is a file-like object, or string, containing a (at least one) pickle. The pickle is disassembled from the current position, through the first STOP opcode encountered. Optional arg 'out' is a file-like object ...
6: i INST 'pickle PicklingError' (MARK at 5)
6: i INST 'pickletools _Example' (MARK at 5)
def dis(pickle, out=None, memo=None, indentlevel=4): """Produce a symbolic disassembly of a pickle. 'pickle' is a file-like object, or string, containing a (at least one) pickle. The pickle is disassembled from the current position, through the first STOP opcode encountered. Optional arg 'out' is a file-like object ...
36: S STRING 'args' 44: p PUT 3 47: ( MARK 48: t TUPLE (MARK at 47) 49: s SETITEM 50: b BUILD 51: a APPEND 52: g GET 1 55: a APPEND 56: . STOP
36: S STRING 'value' 45: p PUT 3 48: I INT 42 52: s SETITEM 53: b BUILD 54: a APPEND 55: g GET 1 58: a APPEND 59: . STOP
def dis(pickle, out=None, memo=None, indentlevel=4): """Produce a symbolic disassembly of a pickle. 'pickle' is a file-like object, or string, containing a (at least one) pickle. The pickle is disassembled from the current position, through the first STOP opcode encountered. Optional arg 'out' is a file-like object ...
5: c GLOBAL 'pickle PicklingError'
5: c GLOBAL 'pickletools _Example'
def dis(pickle, out=None, memo=None, indentlevel=4): """Produce a symbolic disassembly of a pickle. 'pickle' is a file-like object, or string, containing a (at least one) pickle. The pickle is disassembled from the current position, through the first STOP opcode encountered. Optional arg 'out' is a file-like object ...
35: U SHORT_BINSTRING 'args' 41: q BINPUT 4 43: ) EMPTY_TUPLE 44: s SETITEM 45: b BUILD 46: h BINGET 2 48: e APPENDS (MARK at 3) 49: . STOP
35: U SHORT_BINSTRING 'value' 42: q BINPUT 4 44: K BININT1 42 46: s SETITEM 47: b BUILD 48: h BINGET 2 50: e APPENDS (MARK at 3) 51: . STOP
def dis(pickle, out=None, memo=None, indentlevel=4): """Produce a symbolic disassembly of a pickle. 'pickle' is a file-like object, or string, containing a (at least one) pickle. The pickle is disassembled from the current position, through the first STOP opcode encountered. Optional arg 'out' is a file-like object ...
if self.rpm3_mode: rpm_base = os.path.join(self.bdist_base, "rpm") else: rpm_base = self.bdist_base
def run (self):
rpm_dir[d] = os.path.join(rpm_base, d)
rpm_dir[d] = os.path.join(self.rpm_base, d)
def run (self):
'_topdir %s/%s' % (os.getcwd(), rpm_base),])
'_topdir %s/%s' % (os.getcwd(), self.rpm_base),])
def run (self):
('postun', 'post_uninstall', None))
('postun', 'post_uninstall', None),
def _make_spec_file(self): """Generate the text of an RPM spec file and return it as a list of strings (one per line). """ # definitions and headers spec_file = [ '%define name ' + self.distribution.get_name(), '%define version ' + self.distribution.get_version(), '%define release ' + self.release, '', 'Summary: ' + se...
"times", "getlogin", "getloadavg", "tmpnam",
"times", "getloadavg", "tmpnam",
def testNoArgFunctions(self): # test posix functions which take no arguments and have # no side-effects which we need to cleanup (e.g., fork, wait, abort) NO_ARG_FUNCTIONS = [ "ctermid", "getcwd", "getcwdu", "uname", "times", "getlogin", "getloadavg", "tmpnam", "getegid", "geteuid", "getgid", "getgroups", "getpid", "ge...