rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
def remove_message():
def remove_message(e=None):
def remove_message(): itop = scanbox.nearest(0) sel = scanbox.curselection() if not sel: dialog(root, "No Message To Remove", "Please select a message to remove", "", 0, "OK") return todo = [] for i in sel: line = scanbox.get(i) if scanparser.match(line) >= 0: todo.append(string.atoi(scanparser.group(1))) mhf.removemes...
def refile_message():
def refile_message(e=None):
def refile_message(): global lastrefile, tofolder itop = scanbox.nearest(0) sel = scanbox.curselection() if not sel: dialog(root, "No Message To Refile", "Please select a message to refile", "", 0, "OK") return foldersel = folderbox.curselection() if len(foldersel) != 1: if not foldersel: msg = "Please select a folder ...
print 'refile', todo, tofolder
def refile_message(): global lastrefile, tofolder itop = scanbox.nearest(0) sel = scanbox.curselection() if not sel: dialog(root, "No Message To Refile", "Please select a message to refile", "", 0, "OK") return foldersel = folderbox.curselection() if len(foldersel) != 1: if not foldersel: msg = "Please select a folder ...
print 'new folder'
def refile_message(): global lastrefile, tofolder itop = scanbox.nearest(0) sel = scanbox.curselection() if not sel: dialog(root, "No Message To Refile", "Please select a message to refile", "", 0, "OK") return foldersel = folderbox.curselection() if len(foldersel) != 1: if not foldersel: msg = "Please select a folder ...
print 'yview', `itop`
def fixfocus(near, itop): n = scanbox.size() for i in range(n): line = scanbox.get(`i`) if scanparser.match(line) >= 0: num = string.atoi(scanparser.group(1)) if num >= near: break else: i = 'end' scanbox.select_from(i) print 'yview', `itop` scanbox.yview(itop)
try: winsound.PlaySound( '!"$%&/( winsound.SND_ALIAS | winsound.SND_NODEFAULT ) except RuntimeError: pass
self.assertRaises(RuntimeError, winsound.PlaySound, '!"$%&/( winsound.SND_ALIAS | winsound.SND_NODEFAULT)
def test_alias_nofallback(self): try: winsound.PlaySound( '!"$%&/(#+*', winsound.SND_ALIAS | winsound.SND_NODEFAULT ) except RuntimeError: pass
makedirs(head, mode)
try: makedirs(head, mode) except OSError, e: if e.errno != EEXIST: raise
def makedirs(name, mode=0777): """makedirs(path [, mode=0777]) Super-mkdir; create a leaf directory and all intermediate ones. Works like mkdir, except that any intermediate path segment (not just the rightmost) will be created if it does not exist. This is recursive. """ head, tail = path.split(name) if not tail: h...
from errno import ENOENT, ENOTDIR
def _execvpe(file, args, env=None): from errno import ENOENT, ENOTDIR if env is not None: func = execve argrest = (args, env) else: func = execv argrest = (args,) env = environ head, tail = path.split(file) if head: func(file, *argrest) return if 'PATH' in env: envpath = env['PATH'] else: envpath = defpath PATH = env...
def mktemp():
def mktemp(suffix=""):
def mktemp(): global counter dir = gettempdir() pre = gettempprefix() while 1: counter = counter + 1 file = os.path.join(dir, pre + `counter`) if not os.path.exists(file): return file
file = os.path.join(dir, pre + `counter`)
file = os.path.join(dir, pre + `counter` + suffix)
def mktemp(): global counter dir = gettempdir() pre = gettempprefix() while 1: counter = counter + 1 file = os.path.join(dir, pre + `counter`) if not os.path.exists(file): return file
if args and (len(args) == 1) and args[0]:
if args and (len(args) == 1) and args[0] and (type(args[0]) == types.DictType):
def __init__(self, name, level, pathname, lineno, msg, args, exc_info): """ Initialize a logging record with interesting information. """ ct = time.time() self.name = name self.msg = msg # # The following statement allows passing of a dictionary as a sole # argument, so that you can do something like # logging.debug("...
else: a.write(data) a.close()
a.bufsize() a.obufcount() a.obuffree() a.getptr() a.fileno() a.setparameters(rate, 8, nchannels, linuxaudiodev.AFMT_MU_LAW, 1) a.write(data) a.flush() a.close() def test_errors(): a = linuxaudiodev.open("w") size = 8 fmt = linuxaudiodev.AFMT_U8 rate = 8000 nchannels = 1 try: a.setparameters(-1, size, nchannels, fmt)...
def play_sound_file(path): fp = open(path, 'r') data = fp.read() fp.close() try: a = linuxaudiodev.open('w') except linuxaudiodev.error, msg: if msg[0] in (errno.EACCES, errno.ENODEV): raise TestSkipped, msg raise TestFailed, msg else: a.write(data) a.close()
def main():
def findtemplate(): """Locate the applet template along sys.path"""
def main(): # Find the template # (there's no point in proceeding if we can't find it) for p in sys.path: template = os.path.join(p, TEMPLATE) try: template, d1, d2 = macfs.ResolveAliasFile(template) break except (macfs.error, ValueError): continue else: die("Template %s not found on sys.path" % `TEMPLATE`) return te...
print "Processing", `filename`, "..."
if DEBUG: print "Processing", `filename`, "..."
def process(template, filename, output): print "Processing", `filename`, "..." # Read the source and compile it # (there's no point overwriting the destination if it has a syntax error) fp = open(filename) text = fp.read() fp.close() try: code = compile(text, filename, "exec") except (SyntaxError, EOFError): die("Sy...
print "Creating resource fork..."
if DEBUG: print "Creating resource fork..."
def process(template, filename, output): print "Processing", `filename`, "..." # Read the source and compile it # (there's no point overwriting the destination if it has a syntax error) fp = open(filename) text = fp.read() fp.close() try: code = compile(text, filename, "exec") except (SyntaxError, EOFError): die("Sy...
except MacOS.Error:
except (MacOS.Error, ValueError): print 'No resource file', rsrcname
def process(template, filename, output): print "Processing", `filename`, "..." # Read the source and compile it # (there's no point overwriting the destination if it has a syntax error) fp = open(filename) text = fp.read() fp.close() try: code = compile(text, filename, "exec") except (SyntaxError, EOFError): die("Sy...
print id, type, name, size, hex(attrs)
if DEBUG: print id, type, name, size, hex(attrs)
def copyres(input, output): ctor = None UseResFile(input) ntypes = Count1Types() for itype in range(1, 1+ntypes): type = Get1IndType(itype) nresources = Count1Resources(type) for ires in range(1, 1+nresources): res = Get1IndResource(type, ires) id, type, name = res.GetResInfo() lcname = string.lower(name) if (type, lcn...
print "Overwriting..."
if DEBUG: print "Overwriting..."
def copyres(input, output): ctor = None UseResFile(input) ntypes = Count1Types() for itype in range(1, 1+ntypes): type = Get1IndType(itype) nresources = Count1Resources(type) for ires in range(1, 1+nresources): res = Get1IndResource(type, ires) id, type, name = res.GetResInfo() lcname = string.lower(name) if (type, lcn...
print "New attrs =", hex(attrs)
if DEBUG: print "New attrs =", hex(attrs)
def copyres(input, output): ctor = None UseResFile(input) ntypes = Count1Types() for itype in range(1, 1+ntypes): type = Get1IndType(itype) nresources = Count1Resources(type) for ires in range(1, 1+nresources): res = Get1IndResource(type, ires) id, type, name = res.GetResInfo() lcname = string.lower(name) if (type, lcn...
def urlparse(url, scheme = '', allow_framents = 1): key = url, scheme, allow_framents
def urlparse(url, scheme = '', allow_fragments = 1): key = url, scheme, allow_fragments
def urlparse(url, scheme = '', allow_framents = 1): key = url, scheme, allow_framents try: return _parse_cache[key] except KeyError: pass if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth clear_cache() netloc = path = params = query = fragment = '' i = string.find(url, ':') if i > 0: for c in url[:i]: if c...
if allow_framents and scheme in uses_fragment:
if allow_fragments and scheme in uses_fragment:
def urlparse(url, scheme = '', allow_framents = 1): key = url, scheme, allow_framents try: return _parse_cache[key] except KeyError: pass if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth clear_cache() netloc = path = params = query = fragment = '' i = string.find(url, ':') if i > 0: for c in url[:i]: if c...
def urljoin(base, url, allow_framents = 1):
def urljoin(base, url, allow_fragments = 1):
def urljoin(base, url, allow_framents = 1): if not base: return url bscheme, bnetloc, bpath, bparams, bquery, bfragment = \ urlparse(base, '', allow_framents) scheme, netloc, path, params, query, fragment = \ urlparse(url, bscheme, allow_framents) # XXX Unofficial hack: default netloc to bnetloc even if # schemes diffe...
urlparse(base, '', allow_framents)
urlparse(base, '', allow_fragments)
def urljoin(base, url, allow_framents = 1): if not base: return url bscheme, bnetloc, bpath, bparams, bquery, bfragment = \ urlparse(base, '', allow_framents) scheme, netloc, path, params, query, fragment = \ urlparse(url, bscheme, allow_framents) # XXX Unofficial hack: default netloc to bnetloc even if # schemes diffe...
urlparse(url, bscheme, allow_framents)
urlparse(url, bscheme, allow_fragments)
def urljoin(base, url, allow_framents = 1): if not base: return url bscheme, bnetloc, bpath, bparams, bquery, bfragment = \ urlparse(base, '', allow_framents) scheme, netloc, path, params, query, fragment = \ urlparse(url, bscheme, allow_framents) # XXX Unofficial hack: default netloc to bnetloc even if # schemes diffe...
"""translate(s,table [,deletechars]) -> string
"""translate(s,table [,deletions]) -> string
def translate(s, table, deletions=""): """translate(s,table [,deletechars]) -> string Return a copy of the string s, where all characters occurring in the optional argument deletechars are removed, and the remaining characters have been mapped through the given translation table, which must be a string of length 256. ...
in the optional argument deletechars are removed, and the
in the optional argument deletions are removed, and the
def translate(s, table, deletions=""): """translate(s,table [,deletechars]) -> string Return a copy of the string s, where all characters occurring in the optional argument deletechars are removed, and the remaining characters have been mapped through the given translation table, which must be a string of length 256. ...
translation table, which must be a string of length 256. """ return s.translate(table, deletions)
translation table, which must be a string of length 256. The deletions argument is not allowed for Unicode strings. """ if deletions: return s.translate(table, deletions) else: return s.translate(table + s[:0])
def translate(s, table, deletions=""): """translate(s,table [,deletechars]) -> string Return a copy of the string s, where all characters occurring in the optional argument deletechars are removed, and the remaining characters have been mapped through the given translation table, which must be a string of length 256. ...
if not installDir: installDir = DEFAULT_INSTALLDIR
def __init__(self, flavorOrder=None, downloadDir=None, buildDir=None, installDir=None, pimpDatabase=None): if not flavorOrder: flavorOrder = DEFAULT_FLAVORORDER if not downloadDir: downloadDir = DEFAULT_DOWNLOADDIR if not buildDir: buildDir = DEFAULT_BUILDDIR if not installDir: installDir = DEFAULT_INSTALLDIR if not pi...
def _cmd(self, output, dir, *cmditems): """Internal routine to run a shell command in a given directory.""" cmd = ("cd \"%s\"; " % dir) + " ".join(cmditems) if output: output.write("+ %s\n" % cmd) if NO_EXECUTE: return 0 child = popen2.Popen4(cmd) child.tochild.close() while 1: line = child.fromchild.readline() if not...
def _cmd(self, output, dir, *cmditems): """Internal routine to run a shell command in a given directory.""" cmd = ("cd \"%s\"; " % dir) + " ".join(cmditems) if output: output.write("+ %s\n" % cmd) if NO_EXECUTE: return 0 child = popen2.Popen4(cmd) child.tochild.close() while 1: line = child.fromchild.readline() if not...
if self._cmd(output, self._db.preferences.downloadDir,
if _cmd(output, self._db.preferences.downloadDir,
def downloadPackageOnly(self, output=None): """Download a single package, if needed. An MD5 signature is used to determine whether download is needed, and to test that we actually downloaded what we expected. If output is given it is a file-like object that will receive a log of what happens. If anything unforeseen h...
for ext, cmd in ARCHIVE_FORMATS:
for ext, unpackerClass, arg in ARCHIVE_FORMATS:
def unpackPackageOnly(self, output=None): """Unpack a downloaded package archive.""" filename = os.path.split(self.archiveFilename)[1] for ext, cmd in ARCHIVE_FORMATS: if filename[-len(ext):] == ext: break else: return "unknown extension for archive file: %s" % filename self.basename = filename[:-len(ext)] cmd = cmd %...
cmd = cmd % self.archiveFilename if self._cmd(output, self._db.preferences.buildDir, cmd): return "unpack command failed"
unpacker = unpackerClass(arg, dir=self._db.preferences.buildDir) rv = unpacker.unpack(self.archiveFilename, output=output) if rv: return rv
def unpackPackageOnly(self, output=None): """Unpack a downloaded package archive.""" filename = os.path.split(self.archiveFilename)[1] for ext, cmd in ARCHIVE_FORMATS: if filename[-len(ext):] == ext: break else: return "unknown extension for archive file: %s" % filename self.basename = filename[:-len(ext)] cmd = cmd %...
print 'PimpPackage_binary installPackageOnly'
def installPackageOnly(self, output=None): """Install a single source package. If output is given it should be a file-like object and it will receive a log of what happened.""" print 'PimpPackage_binary installPackageOnly' msgs = [] if self._dict.has_key('Pre-install-command'): msg.append("%s: Pre-install-command ign...
msgs = []
if self._dict.has_key('Install-command'): return "%s: Binary package cannot have Install-command" % self.fullname()
def installPackageOnly(self, output=None): """Install a single source package. If output is given it should be a file-like object and it will receive a log of what happened.""" print 'PimpPackage_binary installPackageOnly' msgs = [] if self._dict.has_key('Pre-install-command'): msg.append("%s: Pre-install-command ign...
msg.append("%s: Pre-install-command ignored" % self.fullname()) if self._dict.has_key('Install-command'): msgs.append("%s: Install-command ignored" % self.fullname()) if self._dict.has_key('Post-install-command'): msgs.append("%s: Post-install-command ignored" % self.fullname())
if _cmd(output, self._buildDirname, self._dict['Pre-install-command']): return "pre-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Pre-install-command'])
def installPackageOnly(self, output=None): """Install a single source package. If output is given it should be a file-like object and it will receive a log of what happened.""" print 'PimpPackage_binary installPackageOnly' msgs = [] if self._dict.has_key('Pre-install-command'): msg.append("%s: Pre-install-command ign...
for ext, cmd in ARCHIVE_FORMATS:
for ext, unpackerClass, arg in ARCHIVE_FORMATS:
def installPackageOnly(self, output=None): """Install a single source package. If output is given it should be a file-like object and it will receive a log of what happened.""" print 'PimpPackage_binary installPackageOnly' msgs = [] if self._dict.has_key('Pre-install-command'): msg.append("%s: Pre-install-command ign...
return "unknown extension for archive file: %s" % filename cmd = cmd % self.archiveFilename if self._cmd(output, "/", cmd): return "unpack command failed"
return "%s: unknown extension for archive file: %s" % (self.fullname(), filename) self.basename = filename[:-len(ext)] install_renames = [] for k, newloc in self._db.preferences.installLocations: if not newloc: continue if k == "--install-lib": oldloc = DEFAULT_INSTALLDIR else: return "%s: Don't know installLocation %...
def installPackageOnly(self, output=None): """Install a single source package. If output is given it should be a file-like object and it will receive a log of what happened.""" print 'PimpPackage_binary installPackageOnly' msgs = [] if self._dict.has_key('Pre-install-command'): msg.append("%s: Pre-install-command ign...
if self._cmd(output, self._buildDirname, self._dict['Post-install-command']): return "post-install %s: running \"%s\" failed" % \
if _cmd(output, self._buildDirname, self._dict['Post-install-command']): return "%s: post-install: running \"%s\" failed" % \
def installPackageOnly(self, output=None): """Install a single source package. If output is given it should be a file-like object and it will receive a log of what happened.""" print 'PimpPackage_binary installPackageOnly' msgs = [] if self._dict.has_key('Pre-install-command'): msg.append("%s: Pre-install-command ign...
if self._cmd(output, self._buildDirname, self._dict['Pre-install-command']):
if _cmd(output, self._buildDirname, self._dict['Pre-install-command']):
def installPackageOnly(self, output=None): """Install a single source package. If output is given it should be a file-like object and it will receive a log of what happened.""" if self._dict.has_key('Pre-install-command'): if self._cmd(output, self._buildDirname, self._dict['Pre-install-command']): return "pre-instal...
installcmd = '"%s" setup.py install' % sys.executable if self._cmd(output, self._buildDirname, installcmd):
extra_args = "" for k, v in self._db.preferences.installLocations: if not v: if not unwanted_install_dir: unwanted_install_dir = tempfile.mkdtemp() v = unwanted_install_dir extra_args = extra_args + " %s \"%s\"" % (k, v) installcmd = '"%s" setup.py install %s' % (sys.executable, extra_args) if _cmd(output, self._buil...
def installPackageOnly(self, output=None): """Install a single source package. If output is given it should be a file-like object and it will receive a log of what happened.""" if self._dict.has_key('Pre-install-command'): if self._cmd(output, self._buildDirname, self._dict['Pre-install-command']): return "pre-instal...
if self._cmd(output, self._buildDirname, self._dict['Post-install-command']):
if _cmd(output, self._buildDirname, self._dict['Post-install-command']):
def installPackageOnly(self, output=None): """Install a single source package. If output is given it should be a file-like object and it will receive a log of what happened.""" if self._dict.has_key('Pre-install-command'): if self._cmd(output, self._buildDirname, self._dict['Pre-install-command']): return "pre-instal...
def _run(mode, verbose, force, args):
def _run(mode, verbose, force, args, prefargs):
def _run(mode, verbose, force, args): """Engine for the main program""" prefs = PimpPreferences() prefs.check() db = PimpDatabase(prefs) db.appendURL(prefs.pimpDatabase) if mode == 'dump': db.dump(sys.stdout) elif mode =='list': if not args: args = db.listnames() print "%-20.20s\t%s" % ("Package", "Description") prin...
prefs = PimpPreferences() prefs.check()
prefs = PimpPreferences(**prefargs) rv = prefs.check() if rv: sys.stdout.write(rv)
def _run(mode, verbose, force, args): """Engine for the main program""" prefs = PimpPreferences() prefs.check() db = PimpDatabase(prefs) db.appendURL(prefs.pimpDatabase) if mode == 'dump': db.dump(sys.stdout) elif mode =='list': if not args: args = db.listnames() print "%-20.20s\t%s" % ("Package", "Description") prin...
print "\tDownload URL:\t", pkg.downloadURL()
try: print "\tDownload URL:\t", pkg.downloadURL() except KeyError: pass
def _run(mode, verbose, force, args): """Engine for the main program""" prefs = PimpPreferences() prefs.check() db = PimpDatabase(prefs) db.appendURL(prefs.pimpDatabase) if mode == 'dump': db.dump(sys.stdout) elif mode =='list': if not args: args = db.listnames() print "%-20.20s\t%s" % ("Package", "Description") prin...
print "Usage: pimp [-v] -s [package ...] List installed status" print " pimp [-v] -l [package ...] Show package information" print " pimp [-vf] -i package ... Install packages" print " pimp -d Dump database to stdout"
print "Usage: pimp [options] -s [package ...] List installed status" print " pimp [options] -l [package ...] Show package information" print " pimp [options] -i package ... Install packages" print " pimp -d Dump database to stdout"
def _help(): print "Usage: pimp [-v] -s [package ...] List installed status" print " pimp [-v] -l [package ...] Show package information" print " pimp [-vf] -i package ... Install packages" print " pimp -d Dump database to stdout" print "Options:" print " -v Verbose" pri...
print " -v Verbose" print " -f Force installation"
print " -v Verbose" print " -f Force installation" print " -D dir Set destination directory (default: site-packages)"
def _help(): print "Usage: pimp [-v] -s [package ...] List installed status" print " pimp [-v] -l [package ...] Show package information" print " pimp [-vf] -i package ... Install packages" print " pimp -d Dump database to stdout" print "Options:" print " -v Verbose" pri...
opts, args = getopt.getopt(sys.argv[1:], "slifvd")
opts, args = getopt.getopt(sys.argv[1:], "slifvdD:")
def _help(): print "Usage: pimp [-v] -s [package ...] List installed status" print " pimp [-v] -l [package ...] Show package information" print " pimp [-vf] -i package ... Install packages" print " pimp -d Dump database to stdout" print "Options:" print " -v Verbose" pri...
_run(mode, verbose, force, args)
_run(mode, verbose, force, args, prefargs)
def _help(): print "Usage: pimp [-v] -s [package ...] List installed status" print " pimp [-v] -l [package ...] Show package information" print " pimp [-vf] -i package ... Install packages" print " pimp -d Dump database to stdout" print "Options:" print " -v Verbose" pri...
'<<run-module>>': ['<F5>'], '<<debug-module>>': ['<Control-F5>'],
'<<import-module>>': ['<F5>'], '<<run-script>>': ['<Control-F5>'],
def flush(self): pass
('Run module', '<<run-module>>'), ('Debug module', '<<debug-module>>'),
('Import module', '<<import-module>>'), ('Run script', '<<run-script>>'),
def flush(self): pass
def run_module_event(self, event, debugger=None):
def import_module_event(self, event): filename = self.getfilename() if not filename: return modname, ext = os.path.splitext(os.path.basename(filename)) if sys.modules.has_key(modname): mod = sys.modules[modname] else: mod = imp.new_module(modname) sys.modules[modname] = mod mod.__file__ = filename setattr(sys.modules[...
def run_module_event(self, event, debugger=None): if not self.editwin.get_saved(): tkMessageBox.showerror("Not saved", "Please save first!", master=self.editwin.text) self.editwin.text.focus_set() return filename = self.editwin.io.filename if not filename: tkMessageBox.showerror("No file name", "This window has no file...
modname, ext = os.path.splitext(os.path.basename(filename)) if sys.modules.has_key(modname): mod = sys.modules[modname] else: mod = imp.new_module(modname) sys.modules[modname] = mod mod.__file__ = filename saveout = sys.stdout saveerr = sys.stderr owin = OnDemandOutputWindow(self.editwin.flist) try: sys.stderr = Pseud...
return filename
def run_module_event(self, event, debugger=None): if not self.editwin.get_saved(): tkMessageBox.showerror("Not saved", "Please save first!", master=self.editwin.text) self.editwin.text.focus_set() return filename = self.editwin.io.filename if not filename: tkMessageBox.showerror("No file name", "This window has no file...
if type(iterable) not in (list, tuple, dict, file, xrange, str): iterable = tuple(iterable) it = iter(iterable)
def _update(self, iterable): # The main loop for update() and the subclass __init__() methods. data = self._data
while True: try: for element in it:
if type(iterable) in (list, tuple, xrange): it = iter(iterable) while True: try: for element in it: data[element] = value return except TypeError: transform = getattr(element, "_as_immutable", None) if transform is None: raise data[transform()] = value else: for element in iterable: try:
def _update(self, iterable): # The main loop for update() and the subclass __init__() methods. data = self._data
return except TypeError: transform = getattr(element, "_as_immutable", None) if transform is None: raise data[transform()] = value
except TypeError: transform = getattr(element, "_as_immutable", None) if transform is None: raise data[transform()] = value
def _update(self, iterable): # The main loop for update() and the subclass __init__() methods. data = self._data
return getint(
return self.tk.getint(
def winfo_id(self): return getint( self.tk.call('winfo', 'id', self._w))
str = '%s %s%s' % (cmd, args, CRLF)
if args == "": str = '%s%s' % (cmd, CRLF) else: str = '%s %s%s' % (cmd, args, CRLF)
def putcmd(self, cmd, args=""): """Send a command to the server.""" str = '%s %s%s' % (cmd, args, CRLF) self.send(str)
optionlist = string.join(options, ' ') self.putcmd("mail", "FROM:%s %s" % (quoteaddr(sender) ,optionlist))
optionlist = ' ' + string.join(options, ' ') self.putcmd("mail", "FROM:%s%s" % (quoteaddr(sender) ,optionlist))
def mail(self,sender,options=[]): """SMTP 'mail' command -- begins mail xfer session.""" optionlist = '' if options and self.does_esmtp: optionlist = string.join(options, ' ') self.putcmd("mail", "FROM:%s %s" % (quoteaddr(sender) ,optionlist)) return self.getreply()
list.append(errordict[e], errorfirst[e], errorlast[e], e)
list.append((errordict[e], errorfirst[e], errorlast[e], e))
def parsedir(dir, modify): os.chdir(dir) pat = re.compile('^[0-9]*$') errordict = {} errorfirst = {} errorlast = {} nok = nwarn = nbad = 0 # find all numeric file names and sort them files = filter(lambda fn, pat=pat: pat.match(fn) is not None, os.listdir('.')) files.sort(sort_numeric) for fn in files: # Lets try to ...
Execution: --help Display this help then exit. --version Output version information then exit. -t,--trace Print the line to be executed to sys.stdout. -c,--count Count the number of times a line is executed. Results are written in the results file, if given. -r,--report Genera...
Meta-options: --help Display this help then exit. --version Output version information then exit. Otherwise, exactly one of the following three options must be given: -t, --trace Print each line to sys.stdout before it is executed. -c, --count Count the number of times ea...
def usage(outfile): outfile.write("""Usage: %s [OPTIONS] <file> [ARGS]
def run(trace, cmd): import __main__ dict = __main__.__dict__ sys.settrace(trace) try: exec cmd in dict, dict finally: sys.settrace(None) def runctx(trace, cmd, globals=None, locals=None): if globals is None: globals = {} if locals is None: locals = {} sys.settrace(trace) try: exec cmd in dict, dict finally: sys.settr...
def run(trace, cmd): import __main__ dict = __main__.__dict__ sys.settrace(trace) try: exec cmd in dict, dict finally: sys.settrace(None)
def __init__(self, counts = {}, modules = {}): self.counts = counts.copy() self.modules = modules.copy()
def __init__(self, counts=None, calledfuncs=None, infile=None, outfile=None): self.counts = counts if self.counts is None: self.counts = {} self.counter = self.counts.copy() self.calledfuncs = calledfuncs if self.calledfuncs is None: self.calledfuncs = {} self.calledfuncs = self.calledfuncs.copy() self.infile = infile ...
def __init__(self, counts = {}, modules = {}): self.counts = counts.copy() # map (filename, lineno) to count self.modules = modules.copy() # map filenames to modules
modules = self.modules other_modules = other.modules
other_calledfuncs = other.calledfuncs
def update(self, other): """Merge in the data from another CoverageResults""" counts = self.counts other_counts = other.counts modules = self.modules other_modules = other.modules
counts[key] = counts.get(key, 0) + other_counts[key] for key in other_modules.keys(): if modules.has_key(key): assert modules[key] == other_modules[key], \ "Strange! filename %s has two different module " \ "names: %s and %s" % \ (key, modules[key], other_modules[key])
if key != 'calledfuncs': counts[key] = counts.get(key, 0) + other_counts[key] for key in other_calledfuncs.keys(): calledfuncs[key] = 1 def write_results(self, show_missing = 1, summary = 0, coverdir = None): """ @param coverdir """ for (filename, modulename, funcname,) in self.calledfuncs.keys(): print "filename: %s...
def update(self, other): """Merge in the data from another CoverageResults""" counts = self.counts other_counts = other.counts modules = self.modules other_modules = other.modules
modules[key] = other_modules[key]
thiscoverdir = os.path.dirname(os.path.abspath(filename)) tx = None try: os.makedirs(thiscoverdir) except OSError, x: tx = x if not os.path.isdir(thiscoverdir): if tx: raise tx raise exceptions.IOError, "unknown error prevented creation of directory: %s" % thiscoverdir if "." in modulename: finalname = modulen...
def update(self, other): """Merge in the data from another CoverageResults""" counts = self.counts other_counts = other.counts modules = self.modules other_modules = other.modules
def create_results_log(results, dirname = ".", show_missing = 1, save_counts = 0, summary = 0, coverdir = None): import re per_file = {} for filename, lineno in results.counts.keys(): lines_hit = per_file[filename] = per_file.get(filename, {}) lines_hit[lineno] = results.counts[(filename, lineno)] try: counts = mar...
class Trace: def __init__(self, count=1, trace=1, countfuncs=0, ignoremods=(), ignoredirs=(), infile=None, outfile=None): """ @param count true iff it should count number of times each line is executed @param trace true iff it should print out each line that is being counted @param countfuncs true iff it should just ou...
def create_results_log(results, dirname = ".", show_missing = 1, save_counts = 0, summary = 0, coverdir = None): import re # turn the counts data ("(filename, lineno) = count") into something # accessible on a per-file basis per_file = {} for filename, lineno in results.counts.keys(): lines_hit = per_file[filename] = p...
fndir = os.path.dirname(filename) if os.path.isabs(filename): coverpath = fndir
self.donothing = 1 def run(self, cmd): import __main__ dict = __main__.__dict__ if not self.donothing: sys.settrace(self.globaltrace) try: exec cmd in dict, dict finally: if not self.donothing: sys.settrace(None) def runctx(self, cmd, globals=None, locals=None): if globals is None: globals = {} if locals is None: loc...
def create_results_log(results, dirname = ".", show_missing = 1, save_counts = 0, summary = 0, coverdir = None): import re # turn the counts data ("(filename, lineno) = count") into something # accessible on a per-file basis per_file = {} for filename, lineno in results.counts.keys(): lines_hit = per_file[filename] = p...
coverpath = os.path.join(dirname, fndir) if "." in modulename: finalname = modulename.split(".")[-1] listfilename = os.path.join(coverpath, finalname + ".cover")
modulename = None self._calledfuncs[(filename, modulename, funcname,)] = 1 def globaltrace_lt(self, frame, why, arg): """ Handles `call' events (why == 'call') and if the code block being entered is to be ignored then it returns `None', else it returns `self.localtrace'. """ if why == 'call': (filename, lineno, funcna...
def create_results_log(results, dirname = ".", show_missing = 1, save_counts = 0, summary = 0, coverdir = None): import re # turn the counts data ("(filename, lineno) = count") into something # accessible on a per-file basis per_file = {} for filename, lineno in results.counts.keys(): lines_hit = per_file[filename] = p...
listfilename = os.path.join(coverpath, modulename + ".cover") try: lines = open(filename, 'r').readlines() except IOError, err: print >> sys.stderr, "trace: Could not open %s for reading " \ "because: %s - skipping" % (`filename`, err) continue try: outfile = open(listfilename, 'w') except IOError, err: sys.stderr.w...
return None def localtrace_trace_and_count(self, frame, why, arg): if why == 'line': (filename, lineno, funcname, context, lineindex,) = inspect.getframeinfo(frame, 1) key = (filename, lineno,) self.counts[key] = self.counts.get(key, 0) + 1 bname = self.pathtobasename.get(filename) if bname is None: bname = self.p...
def create_results_log(results, dirname = ".", show_missing = 1, save_counts = 0, summary = 0, coverdir = None): import re # turn the counts data ("(filename, lineno) = count") into something # accessible on a per-file basis per_file = {} for filename, lineno in results.counts.keys(): lines_hit = per_file[filename] = p...
marshal.dump(results.counts, open(os.path.join(dirname, "counts"), "w")) marshal.dump(results.modules, open(os.path.join(dirname, "modules"), "w")) except IOError, err: sys.stderr.write("cannot save counts/modules " \ "files because %s" % err) if summary and sums: mods = sums.keys() mods.sort() print "lines cov% m...
print "%s(%d): %s" % (bname, lineno, context[lineindex],), except IndexError: pass return self.localtrace def localtrace_trace(self, frame, why, arg):
def create_results_log(results, dirname = ".", show_missing = 1, save_counts = 0, summary = 0, coverdir = None): import re # turn the counts data ("(filename, lineno) = count") into something # accessible on a per-file basis per_file = {} for filename, lineno in results.counts.keys(): lines_hit = per_file[filename] = p...
filename = frame.f_globals.get("__file__", None) if filename is None: filename = frame.f_code.co_filename
(filename, lineno, funcname, context, lineindex,) = inspect.getframeinfo(frame) bname = self.pathtobasename.get(filename) if bname is None: bname = self.pathtobasename.setdefault(filename, os.path.basename(filename))
def trace(self, frame, why, arg): if why == 'line': # something is fishy about getting the file name filename = frame.f_globals.get("__file__", None) if filename is None: filename = frame.f_code.co_filename try: modulename = frame.f_globals["__name__"] except KeyError: # PyRun_String() for example # XXX what to do? mod...
modulename = frame.f_globals["__name__"] except KeyError: modulename = None ignore_it = self.ignore_names.get(modulename, -1) if ignore_it == -1: sys.settrace(None) ignore_it = self.ignore.names(filename, modulename) sys.settrace(self.trace) self.modules[filename] = modulename if not ignore_it: lineno = frame.f...
print "%s(%d): %s" % (bname, lineno, context[lineindex],), except IndexError: pass return self.localtrace def localtrace_count(self, frame, why, arg): if why == 'line': (filename, lineno, funcname, context, lineindex,) = inspect.getframeinfo(frame) key = (filename, lineno,) self.counts[key] = self.counts.get(key, ...
def trace(self, frame, why, arg): if why == 'line': # something is fishy about getting the file name filename = frame.f_globals.get("__file__", None) if filename is None: filename = frame.f_code.co_filename try: modulename = frame.f_globals["__name__"] except KeyError: # PyRun_String() for example # XXX what to do? mod...
return CoverageResults(self.counts, self.modules) class Trace: def __init__(self, ignore = Ignore()): self.ignore = ignore self.ignore_names = ignore._ignore self.files = {'<string>': None} def trace(self, frame, why, arg): if why == 'line': filename = frame.f_code.co_filename try: modulename = frame.f_globals["__n...
return CoverageResults(self.counts, infile=self.infile, outfile=self.outfile, calledfuncs=self._calledfuncs)
def results(self): return CoverageResults(self.counts, self.modules)
print >> sys.stderr, "%s: %s" % (sys.argv[0], msg)
sys.stderr.write("%s: %s\n" % (sys.argv[0], msg))
def _err_exit(msg): print >> sys.stderr, "%s: %s" % (sys.argv[0], msg) sys.exit(1)
opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:",
opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:l",
def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr,...
"file=", "logdir=", "missing",
"file=", "missing",
def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr,...
"coverdir="])
"coverdir=", "listfuncs",])
def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr,...
print >> sys.stderr, "%s: %s" % (sys.argv[0], msg) print >> sys.stderr, "Try `%s --help' for more information" \ % sys.argv[0]
sys.stderr.write("%s: %s\n" % (sys.argv[0], msg)) sys.stderr.write("Try `%s --help' for more information\n" % sys.argv[0])
def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr,...
logdir = "."
def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr,...
continue if opt == "-d" or opt == "--logdir": logdir = val
def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr,...
if len(prog_argv) == 0: _err_exit("missing name of file to run") if count + trace + report > 1: _err_exit("can only specify one of --trace, --count or --report") if count + trace + report == 0: _err_exit("must specify one of --trace, --count or --report") if report and counts_file is None: _err_exit("--report requir...
if listfuncs and (count or trace): _err_exit("cannot specify both --listfuncs and (--trace or --count)") if not count and not trace and not report and not listfuncs: _err_exit("must specify one of --trace, --count, --report or --listfuncs")
def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr,...
if logdir is not None: if not os.path.isdir(logdir): sys.stderr.write( "trace: WARNING, --logdir directory %s is not available\n" % `logdir`) sys.argv = prog_argv progname = prog_argv[0] if eval(sys.version[:3])>1.3: sys.path[0] = os.path.split(progname)[0]
if report and not counts_file: _err_exit("--report requires a --file") if no_report and len(prog_argv) == 0: _err_exit("missing name of file to run")
def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr,...
ignore = Ignore(ignore_modules, ignore_dirs) if trace: t = Trace(ignore)
if report: results = CoverageResults(infile=counts_file, outfile=counts_file) results.write_results(missing, summary=summary, coverdir=coverdir) else: sys.argv = prog_argv progname = prog_argv[0] if eval(sys.version[:3])>1.3: sys.path[0] = os.path.split(progname)[0] t = Trace(count, trace, countfuncs=listfuncs, ignore...
def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr,...
run(t.trace, 'execfile(' + `progname` + ')')
t.run('execfile(' + `progname` + ')')
def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr,...
_err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err)) elif count: t = Coverage(ignore) try: run(t.trace, 'execfile(' + `progname` + ')') except IOError, err: _err_exit("Cannot run file %s because: %s" % \ (`sys.argv[0]`, err))
_err_exit("Cannot run file %s because: %s" % (`sys.argv[0]`, err))
def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr,...
results.modules[progname] = os.path.splitext(progname)[0] if counts_file: try: old_counts, old_modules = marshal.load(open(counts_file, 'rb')) except IOError: pass else: results.update(CoverageResults(old_counts, old_modules))
def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr,...
create_results_log(results, logdir, missing, summary=summary, coverdir=coverdir) if counts_file: try: marshal.dump( (results.counts, results.modules), open(counts_file, 'wb')) except IOError, err: _err_exit("Cannot save counts file %s because: %s" % \ (`counts_file`, err)) elif report: old_counts, old_modules = marsh...
results.write_results(missing, summary=summary, coverdir=coverdir)
def main(argv = None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:", ["help", "version", "trace", "count", "report", "no-report", "file=", "logdir=", "missing", "ignore-module=", "ignore-dir=", "coverdir="]) except getopt.error, msg: print >> sys.stderr,...
fp.write("%s = %s\n" % (key, value))
fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t')))
def write(self, fp): """Write an .ini-format representation of the configuration state.""" if self.__defaults: fp.write("[DEFAULT]\n") for (key, value) in self.__defaults.items(): fp.write("%s = %s\n" % (key, value)) fp.write("\n") for section in self.sections(): fp.write("[" + section + "]\n") sectdict = self.__sectio...
def group(i):
def group(self, i):
def group(i):
def assemble_set(self, position, labels):
def assemble(self, position, labels):
def assemble_set(self, position, labels):
if c in self.set[2]:
if c in self.set:
def assemble_set(self, position, labels):
result = result + `char`
result = result + char
def __repr__(self):
if stack[-1][0][1] > 0:
if stack[-1][0].register > 0:
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'...
log1_y = log(1.0 - random()) z = cos(x2pi) * log1_y gauss_next = sin(x2pi) * log1_y
g2rad = sqrt(-2.0 * log(1.0 - random())) z = cos(x2pi) * g2rad gauss_next = sin(x2pi) * g2rad
def gauss(mu, sigma): # When x and y are two variables from [0, 1), uniformly # distributed, then # # cos(2*pi*x)*log(1-y) # sin(2*pi*x)*log(1-y) # # are two *independent* variables with normal distribution # (mu = 0, sigma = 1). # (Lambert Meertens) global gauss_next if gauss_next != None: z = gauss_next gaus...
pkg = PimpPackage(self, dict(p))
p = dict(p) flavor = p.get('Flavor') if flavor == 'source': pkg = PimpPackage_source(self, p) elif flavor == 'binary': pkg = PimpPackage_binary(self, p) else: pkg = PimpPackage(self, dict(p))
def _appendPackages(self, packages): """Given a list of dictionaries containing package descriptions create the PimpPackage objects and append them to our internal storage.""" for p in packages: pkg = PimpPackage(self, dict(p)) self._packages.append(pkg)
def homepage(self): return self._dict['Home-page']
def homepage(self): return self._dict.get('Home-page')
def homepage(self): return self._dict['Home-page']
if not self._dict['Prerequisites']:
if not self._dict.get('Prerequisites'):
def prerequisites(self): """Return a list of prerequisites for this package. The list contains 2-tuples, of which the first item is either a PimpPackage object or None, and the second is a descriptive string. The first item can be None if this package depends on something that isn't pimp-installable, in which case the...
def downloadSinglePackage(self, output=None):
def downloadPackageOnly(self, output=None):
def downloadSinglePackage(self, output=None): """Download a single package, if needed. An MD5 signature is used to determine whether download is needed, and to test that we actually downloaded what we expected. If output is given it is a file-like object that will receive a log of what happens. If anything unforeseen...
def unpackSinglePackage(self, output=None):
def unpackPackageOnly(self, output=None):
def unpackSinglePackage(self, output=None): """Unpack a downloaded package archive.""" filename = os.path.split(self.archiveFilename)[1] for ext, cmd in ARCHIVE_FORMATS: if filename[-len(ext):] == ext: break else: return "unknown extension for archive file: %s" % filename basename = filename[:-len(ext)] cmd = cmd % se...
self._buildDirname = os.path.join(self._db.preferences.buildDir, basename)
def unpackSinglePackage(self, output=None): """Unpack a downloaded package archive.""" filename = os.path.split(self.archiveFilename)[1] for ext, cmd in ARCHIVE_FORMATS: if filename[-len(ext):] == ext: break else: return "unknown extension for archive file: %s" % filename basename = filename[:-len(ext)] cmd = cmd % se...