rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
os.mkdir(dst) | os.makedirs(dst) copystat(src, dst) | def copytree(src, dst, symlinks=False): """Recursively copy a directory tree using copy2(). The destination directory must not already exist. If exception(s) occur, an Error is raised with a list of reasons. If the optional symlinks flag is true, symbolic links in the source tree result in symbolic links in the desti... |
dupDB.associate(secDB, lambda a, b: a+b) | def f(a,b): return a+b dupDB.associate(secDB, f) | def test00_associateDBError(self): if verbose: print '\n', '-=' * 30 print "Running %s.test00_associateDBError..." % \ self.__class__.__name__ |
self.primary.open(self.filename, "primary", self.dbtype, | if db.version() >= (4, 1): self.primary.open(self.filename, "primary", self.dbtype, | def createDB(self, txn=None): |
self.getDB().associate(self.secDB, self.getGenre, txn=txn) | if db.version() >= (4,1): self.getDB().associate(self.secDB, self.getGenre, txn=txn) else: self.getDB().associate(self.secDB, self.getGenre) | def test13_associate_in_transaction(self): if verbose: print '\n', '-=' * 30 print "Running %s.test13_associateAutoCommit..." % \ self.__class__.__name__ |
suite.addTest(unittest.makeSuite(AssociateBTreeTxnTestCase)) | if db.version() >= (4, 1): suite.addTest(unittest.makeSuite(AssociateBTreeTxnTestCase)) | def test_suite(): suite = unittest.TestSuite() if db.version() >= (3, 3, 11): suite.addTest(unittest.makeSuite(AssociateErrorTestCase)) suite.addTest(unittest.makeSuite(AssociateHashTestCase)) suite.addTest(unittest.makeSuite(AssociateBTreeTestCase)) suite.addTest(unittest.makeSuite(AssociateRecnoTestCase)) suite.ad... |
def err(args): | def err(*args): | def err(args): savestdout = sys.stdout try: sys.stdout = sys.stderr for i in args: print i, print finally: sys.stdout = savestdout |
e = 'Function', func, 'too complicated:' err(e + (a_type, a_mode, a_factor, a_sub)) | err('Function', func, 'too complicated:', a_type, a_mode, a_factor, a_sub) | def generate(type, func, database): # # Check that we can handle this case: # no variable size reply arrays yet # n_in_args = 0 n_out_args = 0 # for a_type, a_mode, a_factor, a_sub in database: if a_mode == 's': n_in_args = n_in_args + 1 elif a_mode == 'r': n_out_args = n_out_args + 1 else: # Can't happen raise arg_err... |
sys.path.append('/ufs/guido/src/video') | sys.path.append('/ufs/jack/src/av/video') | def help(): print 'Usage: video2rgb [options] [file] ...' print print 'Options:' print '-q : quiet, no informative messages' print '-m : create monochrome (greyscale) image files' print '-f prefix : create image files with names "prefix0000.rgb"' print 'file ... : file(s) to convert; default film.vid... |
m=None | m = (None, None) | def quoteaddr(addr): """Quote a subset of the email addresses defined by RFC 821. Should be able to handle anything rfc822.parseaddr can handle. """ m=None try: m=rfc822.parseaddr(addr)[1] except AttributeError: pass if not m: #something weird here.. punt -ddm return addr else: return "<%s>" % m |
if not m: | if m == (None, None): | def quoteaddr(addr): """Quote a subset of the email addresses defined by RFC 821. Should be able to handle anything rfc822.parseaddr can handle. """ m=None try: m=rfc822.parseaddr(addr)[1] except AttributeError: pass if not m: #something weird here.. punt -ddm return addr else: return "<%s>" % m |
return addr | return "<%s>" % addr | def quoteaddr(addr): """Quote a subset of the email addresses defined by RFC 821. Should be able to handle anything rfc822.parseaddr can handle. """ m=None try: m=rfc822.parseaddr(addr)[1] except AttributeError: pass if not m: #something weird here.. punt -ddm return addr else: return "<%s>" % m |
if kwargs.has_key('command') | if kwargs.has_key('command'): | def __init__(self, master, variable, value, *values, **kwargs): kw = {"borderwidth": 2, "textvariable": variable, "indicatoron": 1, "relief": RAISED, "anchor": "c", "highlightthickness": 2} Widget.__init__(self, master, "menubutton", kw) self.widgetName = 'tk_optionMenu' menu = self.__menu = Menu(self, name="menu", tea... |
s = marshal.dumps(f) | s = marshal.dumps(f, 2) | def test_floats(self): # Test a few floats small = 1e-25 n = sys.maxint * 3.7e250 while n > small: for expected in (-n, n): f = float(expected) s = marshal.dumps(f) got = marshal.loads(s) self.assertEqual(f, got) marshal.dump(f, file(test_support.TESTFN, "wb")) got = marshal.load(file(test_support.TESTFN, "rb")) self.a... |
fp = open(MOFILE, 'w') | fp = open(MOFILE, 'wb') | def setup(): os.makedirs(LOCALEDIR) fp = open(MOFILE, 'w') fp.write(base64.decodestring(GNU_MO_DATA)) fp.close() |
packkey(ae, key, value) | ae.AEPutAttributeDesc(key, pack(value)) | def packevent(ae, parameters = {}, attributes = {}): for key, value in parameters.items(): packkey(ae, key, value) for key, value in attributes.items(): packkey(ae, key, value) |
arguments[key] = edict[v] | arguments[key] = Enum(edict[v]) | def enumsubst(arguments, key, edict): """Substitute a single enum keyword argument, if it occurs""" if not arguments.has_key(key) or edict is None: return v = arguments[key] ok = edict.values() if edict.has_key(v): arguments[key] = edict[v] elif not v in ok: raise TypeError, 'Unknown enumerator: %s'%v |
opt_dict[opt] = (filename, parser.get(section,opt)) | val = parser.get(section,opt) opt = string.replace(opt, '-', '_') opt_dict[opt] = (filename, val) | def parse_config_files (self, filenames=None): |
true if command-line were successfully parsed and we should carry | true if command-line was successfully parsed and we should carry | def parse_command_line (self): """Parse the setup script's command line, taken from the 'script_args' instance attribute (which defaults to 'sys.argv[1:]' -- see 'setup()' in core.py). This list is first processed for "global options" -- options that set attributes of the Distribution instance. Then, it is alternatel... |
'command_obj' must be a Commnd instance. If 'option_dict' is not | 'command_obj' must be a Command instance. If 'option_dict' is not | def _set_command_options (self, command_obj, option_dict=None): """Set the options for 'command_obj' from 'option_dict'. Basically this means copying elements of a dictionary ('option_dict') to attributes of an instance ('command'). |
if not hasattr(command_obj, option): raise DistutilsOptionError, \ ("error in %s: command '%s' has no such option '%s'") % \ (source, command_name, option) setattr(command_obj, option, value) | try: bool_opts = command_obj.boolean_options except AttributeError: bool_opts = [] try: neg_opt = command_obj.negative_opt except AttributeError: neg_opt = {} try: if neg_opt.has_key(option): setattr(command_obj, neg_opt[option], not strtobool(value)) elif option in bool_opts: setattr(command_obj, option, strtobool(va... | def _set_command_options (self, command_obj, option_dict=None): """Set the options for 'command_obj' from 'option_dict'. Basically this means copying elements of a dictionary ('option_dict') to attributes of an instance ('command'). |
os.execve(scriptfile, args, env) | os.execve(scriptfile, args, os.environ) | def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scrip... |
self.error("expected name token") | self.error("expected name token at %r" % rawdata[declstartpos:declstartpos+20]) | def _scan_name(self, i, declstartpos): rawdata = self.rawdata n = len(rawdata) if i == n: return None, -1 m = _declname_match(rawdata, i) if m: s = m.group() name = s.strip() if (i + len(s)) == n: return None, -1 # end of buffer return name.lower(), m.end() else: self.updatepos(declstartpos, i) self.error("expected na... |
st = os.stat(src) mode = stat.S_IMODE(st[stat.ST_MODE]) os.chmod(dst, mode) | if hasattr(os, 'chmod'): st = os.stat(src) mode = stat.S_IMODE(st[stat.ST_MODE]) os.chmod(dst, mode) | def copymode(src, dst): """Copy mode bits from src to dst""" st = os.stat(src) mode = stat.S_IMODE(st[stat.ST_MODE]) os.chmod(dst, mode) |
os.utime(dst, (st[stat.ST_ATIME], st[stat.ST_MTIME])) os.chmod(dst, mode) | if hasattr(os, 'utime'): os.utime(dst, (st[stat.ST_ATIME], st[stat.ST_MTIME])) if hasattr(os, 'chmod'): os.chmod(dst, mode) | def copystat(src, dst): """Copy all stat info (mode bits, atime and mtime) from src to dst""" st = os.stat(src) mode = stat.S_IMODE(st[stat.ST_MODE]) os.utime(dst, (st[stat.ST_ATIME], st[stat.ST_MTIME])) os.chmod(dst, mode) |
matches = (['class', name], ['class', name + ':']) | pat = re.compile(r'^\s*class\s*' + name + r'\b') | def findsource(object): """Return the entire source file and starting line number for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of all the lines in the file and the line number indexes a line in that list. An IOError is r... |
if string.split(lines[i])[:2] in matches: return lines, i | if pat.match(lines[i]): return lines, i | def findsource(object): """Return the entire source file and starting line number for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of all the lines in the file and the line number indexes a line in that list. An IOError is r... |
if string.split(lines[lnum])[:1] == ['def']: break | if pat.match(lines[lnum]): break | def findsource(object): """Return the entire source file and starting line number for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of all the lines in the file and the line number indexes a line in that list. An IOError is r... |
print 'h=',h | def getentry(self, which): self._check() if which == 'in': cmd = IN_ENTRY_SENSE elif which == 'out': cmd = OUT_ENTRY_SENSE self.replycmd(cmd) h = self._getnumber(2) print 'h=',h m = self._getnumber(2) print 'm=',m s = self._getnumber(2) print 's=',s f = self._getnumber(2) print 'f=',f return (h, m, s, f) | |
print 'm=',m | def getentry(self, which): self._check() if which == 'in': cmd = IN_ENTRY_SENSE elif which == 'out': cmd = OUT_ENTRY_SENSE self.replycmd(cmd) h = self._getnumber(2) print 'h=',h m = self._getnumber(2) print 'm=',m s = self._getnumber(2) print 's=',s f = self._getnumber(2) print 'f=',f return (h, m, s, f) | |
print 's=',s | def getentry(self, which): self._check() if which == 'in': cmd = IN_ENTRY_SENSE elif which == 'out': cmd = OUT_ENTRY_SENSE self.replycmd(cmd) h = self._getnumber(2) print 'h=',h m = self._getnumber(2) print 'm=',m s = self._getnumber(2) print 's=',s f = self._getnumber(2) print 'f=',f return (h, m, s, f) | |
print 'f=',f | def getentry(self, which): self._check() if which == 'in': cmd = IN_ENTRY_SENSE elif which == 'out': cmd = OUT_ENTRY_SENSE self.replycmd(cmd) h = self._getnumber(2) print 'h=',h m = self._getnumber(2) print 'm=',m s = self._getnumber(2) print 's=',s f = self._getnumber(2) print 'f=',f return (h, m, s, f) | |
if self.re._num_regs == 1: return () return apply(self.group, tuple(range(1, self.re._num_regs) ) ) | result = [] for g in range(1, self.re._num_regs): if (self.regs[g][0] == -1) or (self.regs[g][1] == -1): result.append(None) else: result.append(self.string[self.regs[g][0]:self.regs[g][1]]) return tuple(result) | def groups(self): |
def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): | def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False, exclude=False, single=False, randomize=False, fromfile=None, findleaks=False, use_resources=None, trace=False): | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdi... |
The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. | The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, use_resources, and trace) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdi... |
opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', | opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:T', | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdi... |
'findleaks', 'use=', 'threshold=']) | 'findleaks', 'use=', 'threshold=', 'trace', ]) | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdi... |
quiet = 1; | quiet = True; | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdi... |
generate = 1 | generate = True | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdi... |
exclude = 1 | exclude = True | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdi... |
single = 1 | single = True | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdi... |
randomize = 1 | randomize = True | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdi... |
findleaks = 1 | findleaks = True | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdi... |
findleaks = 0 | findleaks = False | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdi... |
ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) | if trace: tracer.runctx('runtest(test, generate, verbose, quiet, testdir)', globals=globals(), locals=vars()) | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdi... |
skipped.append(test) if ok == -2: resource_denieds.append(test) | ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdi... |
path = os.path.join(os.path.dirname(test_email.__file__), 'data', filename) | path = os.path.join(os.path.dirname(test_support_file), 'data', filename) | def openfile(filename): path = os.path.join(os.path.dirname(test_email.__file__), 'data', filename) return open(path) |
if __name__ == '__main__': unittest.main(defaultTest='suite') else: | def test_main(): | def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestMessageAPI)) suite.addTest(unittest.makeSuite(TestEncoders)) suite.addTest(unittest.makeSuite(TestLongHeaders)) suite.addTest(unittest.makeSuite(TestFromMangling)) suite.addTest(unittest.makeSuite(TestMIMEAudio)) suite.addTest(unittest.makeS... |
def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', '')) | def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', '')) | |
try: | for thisType in [int, long, float, complex]: | def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', '')) |
thisType = type(seval(row[col])) except OverflowError: thisType = type(seval(row[col] + 'L')) thisType = type(0) except: | thisType(row[col]) break except ValueError, OverflowError: pass else: | def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', '')) |
eval("%s(%s)" % (colType.__name__, header[col])) except: | colType(header[col]) except ValueError, TypeError: | def seval(item): """ Strips parens from item prior to calling eval in an attempt to make it safer """ return eval(item.replace('(', '').replace(')', '')) |
return s.split(NUL, 1)[0] | return s.rstrip(NUL) | def nts(s): """Convert a null-terminated string buffer to a python string. """ return s.split(NUL, 1)[0] |
parts.append(value + (fieldsize - l) * NUL) | parts.append(value[:fieldsize] + (fieldsize - l) * NUL) | def tobuf(self): """Return a tar header block as a 512 byte string. """ name = self.name |
self.chunks = [0] | def __init__(self, name=None, mode="r", fileobj=None): """Open an (uncompressed) tar archive `name'. `mode' is either 'r' to read from an existing archive, 'a' to append data to an existing file or 'w' to create a new file overwriting an existing one. `mode' defaults to 'r'. If `fileobj' is given, it is used for readin... | |
self.members.append(tarinfo) self.membernames.append(tarinfo.name) self.chunks.append(self.offset) | self._record_member(tarinfo) | def addfile(self, tarinfo, fileobj=None): """Add the TarInfo object `tarinfo' to the archive. If `fileobj' is given, tarinfo.size bytes are read from it and added to the archive. You can create TarInfo objects using gettarinfo(). On Windows platforms, `fileobj' should always be opened with mode 'rb' to avoid irritation... |
self.fileobj.seek(self.chunks[-1]) | self.fileobj.seek(self.offset) | def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m |
if self.chunks[-1] == 0: | if self.offset == 0: | def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m |
tarinfo = self.TYPE_METH[tarinfo.type](self, tarinfo) else: tarinfo.offset_data = self.offset if tarinfo.isreg() or tarinfo.type not in SUPPORTED_TYPES: self.offset += self._block(tarinfo.size) | return self.TYPE_METH[tarinfo.type](self, tarinfo) tarinfo.offset_data = self.offset if tarinfo.isreg() or tarinfo.type not in SUPPORTED_TYPES: self.offset += self._block(tarinfo.size) | def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m |
self.members.append(tarinfo) self.membernames.append(tarinfo.name) self.chunks.append(self.offset) | self._record_member(tarinfo) | def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m |
name = nts(buf) if tarinfo.type == GNUTYPE_LONGLINK: linkname = nts(buf) buf = self.fileobj.read(BLOCKSIZE) tarinfo = TarInfo.frombuf(buf) tarinfo.offset = self.offset self.offset += BLOCKSIZE tarinfo.offset_data = self.offset tarinfo.name = name or tarinfo.name tarinfo.linkname = linkname or tarinfo.linkname if tar... | next.name = nts(buf) elif tarinfo.type == GNUTYPE_LONGLINK: next.linkname = nts(buf) return next | def proc_gnulong(self, tarinfo): """Evaluate the blocks that hold a GNU longname or longlink member. """ buf = "" name = None linkname = None count = tarinfo.size while count > 0: block = self.fileobj.read(BLOCKSIZE) buf += block self.offset += BLOCKSIZE count -= BLOCKSIZE |
onerror() | onerror(name) | def seen(p, m={}): if p in m: return True m[p] = True |
for item in walk_packages(path, name+'.'): | for item in walk_packages(path, name+'.', onerror): | def seen(p, m={}): if p in m: return True m[p] = True |
return self.fp.tell() - self.start | return self.fp.tell() - len(self.readahead) - self.start | def tell(self): if self.level > 0: return self.lastpos return self.fp.tell() - self.start |
test_support.run_unittest( TrivialTests, OpenerDirectorTests, HandlerTests, MiscTests, ) | tests = (TrivialTests, OpenerDirectorTests, HandlerTests, MiscTests) if test_support.is_resource_enabled('network'): tests += (NetworkTests,) test_support.run_unittest(*tests) | def test_main(verbose=None): from test import test_sets test_support.run_unittest( TrivialTests, OpenerDirectorTests, HandlerTests, MiscTests, ) |
assert output_dir is not None | if output_dir is None: output_dir = '' | def object_filenames(self, source_filenames, strip_dir=0, output_dir=''): assert output_dir is not None obj_names = [] for src_name in source_filenames: base, ext = os.path.splitext(src_name) if ext not in self.src_extensions: raise UnknownFileError, \ "unknown file type '%s' (from '%s')" % (ext, src_name) if strip_dir... |
ext_modules=[Extension('struct', ['structmodule.c'])], | ext_modules=[Extension('_struct', ['_struct.c'])], | def main(): # turn off warnings when deprecated modules are imported import warnings warnings.filterwarnings("ignore",category=DeprecationWarning) setup(# PyPI Metadata (PEP 301) name = "Python", version = sys.version.split()[0], url = "http://www.python.org/%s" % sys.version[:3], maintainer = "Guido van Rossum and the... |
regexp=None, nocase=None, count=None): | regexp=None, nocase=None, count=None, elide=None): | def search(self, pattern, index, stopindex=None, forwards=None, backwards=None, exact=None, regexp=None, nocase=None, count=None): """Search PATTERN beginning from INDEX until STOPINDEX. Return the index of the first character of a match or an empty string.""" args = [self._w, 'search'] if forwards: args.append('-forwa... |
def checkSetMinor(self): | def test_checkSetMinor(self): | def checkSetMinor(self): au = MIMEAudio(self._audiodata, 'fish') self.assertEqual(im.get_type(), 'audio/fish') |
self.assertEqual(im.get_type(), 'audio/fish') | self.assertEqual(au.get_type(), 'audio/fish') | def checkSetMinor(self): au = MIMEAudio(self._audiodata, 'fish') self.assertEqual(im.get_type(), 'audio/fish') |
def checkSetMinor(self): | def test_checkSetMinor(self): | def checkSetMinor(self): im = MIMEImage(self._imgdata, 'fish') self.assertEqual(im.get_type(), 'image/fish') |
if (code in (301, 302, 303, 307) and req.method() in ("GET", "HEAD") or code in (302, 303) and req.method() == "POST"): | if "location" in headers: newurl = headers["location"] elif "uri" in headers: newurl = headers["uri"] else: return newurl = urlparse.urljoin(req.get_full_url(), newurl) m = req.get_method() if (code in (301, 302, 303, 307) and m in ("GET", "HEAD") or code in (302, 303) and m == "POST"): | def redirect_request(self, req, fp, code, msg, headers): """Return a Request or None in response to a redirect. |
try: h = http_class(host) if req.has_data(): data = req.get_data() h.putrequest('POST', req.get_selector()) if not 'Content-type' in req.headers: h.putheader('Content-type', 'application/x-www-form-urlencoded') if not 'Content-length' in req.headers: h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('G... | h = http_class(host) if req.has_data(): data = req.get_data() h.putrequest('POST', req.get_selector()) if not 'Content-type' in req.headers: h.putheader('Content-type', 'application/x-www-form-urlencoded') if not 'Content-length' in req.headers: h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', ... | def do_open(self, http_class, req): host = req.get_host() if not host: raise URLError('no host given') |
h.endheaders() | try: h.endheaders() except socket.error, err: raise URLError(err) | def do_open(self, http_class, req): host = req.get_host() if not host: raise URLError('no host given') |
timestamp = 1000000000 utc = FixedOffset(0, "utc", 0) expected = datetime(2001, 9, 9, 1, 46, 40) got = datetime.utcfromtimestamp(timestamp) self.failUnless(abs(got - expected) < timedelta(minutes=1)) est = FixedOffset(-5*60, "est", 0) expected -= timedelta(hours=5) got = datetime.fromtimestamp(timestamp, est).replac... | timestamp = 1000000000 utcdatetime = datetime.utcfromtimestamp(timestamp) utcoffset = timedelta(hours=-15, minutes=39) tz = FixedOffset(utcoffset, "tz", 0) expected = utcdatetime + utcoffset got = datetime.fromtimestamp(timestamp, tz) self.assertEqual(expected, got.replace(tzinfo=None)) | def test_tzinfo_fromtimestamp(self): import time meth = self.theclass.fromtimestamp ts = time.time() # Ensure it doesn't require tzinfo (i.e., that this doesn't blow up). base = meth(ts) # Try with and without naming the keyword. off42 = FixedOffset(42, "42") another = meth(ts, off42) again = meth(ts, tz=off42) self.fa... |
self._arrow = _canvas.create_line(x-dx,y+dy,x,y, | self._arrow = self._canvas.create_line(x-dx,y+dy,x,y, | def _draw_turtle(self,position=[]): if not self._tracing: return if position == []: position = self._position x,y = position distance = 8 dx = distance * cos(self._angle*self._invradian) dy = distance * sin(self._angle*self._invradian) self._delete_turtle() self._arrow = _canvas.create_line(x-dx,y+dy,x,y, width=self._w... |
print 'DBG interaction' | def edit_applet(name): pref_handle = openpreffile(READ) app_handle = openapplet(name) notfound = '' l, sr = getprefpath(OVERRIDE_PATH_STRINGS_ID) if l == None: notfound = 'path' l, dummy = getprefpath(PATH_STRINGS_ID) if l == None: message('Cannot find any sys.path resource! (Old python?)') sys.exit(0) fss, dr, fss_... | |
def readline(self): | def readline(self, size=-1): if size < 0: size = sys.maxint | def readline(self): bufs = [] readsize = 100 while 1: c = self.read(readsize) i = string.find(c, '\n') if i >= 0 or c == '': bufs.append(c[:i+1]) self._unread(c[i+1:]) return string.join(bufs, '') bufs.append(c) readsize = readsize * 2 |
readsize = 100 | orig_size = size readsize = min(100, size) | def readline(self): bufs = [] readsize = 100 while 1: c = self.read(readsize) i = string.find(c, '\n') if i >= 0 or c == '': bufs.append(c[:i+1]) self._unread(c[i+1:]) return string.join(bufs, '') bufs.append(c) readsize = readsize * 2 |
readsize = readsize * 2 def readlines(self, ignored=None): buf = self.read() lines = string.split(buf, '\n') for i in range(len(lines)-1): lines[i] = lines[i] + '\n' if lines and not lines[-1]: del lines[-1] return lines | size = size - len(c) readsize = min(size, readsize * 2) def readlines(self, sizehint=0): if sizehint <= 0: sizehint = sys.maxint L = [] while sizehint > 0: line = self.readline() if line == "": break L.append( line ) sizehint = sizehint - len(line) return L | def readline(self): bufs = [] readsize = 100 while 1: c = self.read(readsize) i = string.find(c, '\n') if i >= 0 or c == '': bufs.append(c[:i+1]) self._unread(c[i+1:]) return string.join(bufs, '') bufs.append(c) readsize = readsize * 2 |
retval = os.spawnl(os.P_WAIT, sys.executable, sys.executable, tester, v, fd) | if sys.platform in ('win32'): decorated = '"%s"' % sys.executable tester = '"%s"' % tester else: decorated = sys.executable retval = os.spawnl(os.P_WAIT, sys.executable, decorated, tester, v, fd) | def test_noinherit(self): # _mkstemp_inner file handles are not inherited by child processes if not has_spawnl: return # ugh, can't use TestSkipped. |
def createMessage(self, dir): | def createMessage(self, dir, mbox=False): | def createMessage(self, dir): t = int(time.time() % 1000000) pid = self._counter self._counter += 1 filename = os.extsep.join((str(t), str(pid), "myhostname", "mydomain")) tmpname = os.path.join(self._dir, "tmp", filename) newname = os.path.join(self._dir, dir, filename) fp = open(tmpname, "w") self._msgfiles.append(tm... |
t>>11, (t>>5)&0x3F, t&0x1F * 2 ) | t>>11, (t>>5)&0x3F, (t&0x1F) * 2 ) | def _GetContents(self): "Read in the table of contents for the zip file" fp = self.fp fp.seek(-22, 2) # Start of end-of-archive record filesize = fp.tell() + 22 # Get file size endrec = fp.read(22) # Archive must not end with a comment! if endrec[0:4] != stringEndArchive or endrec[-2:] != "\000\000": raise BadZipfile,... |
def AS_TYPE_64BIT(as_): return \ | def AS_TYPE_64BIT(as): return \ | def AS_TYPE_64BIT(as_): return \ |
if request.command in ('post', 'put'): | if request.command.lower() in ('post', 'put'): | def handle_request (self, request): [path, params, query, fragment] = request.split_uri() |
res[i] = '%%%02x' % ord(c) | res[i] = '%%%02X' % ord(c) | def _fast_quote(s): global _fast_safe if _fast_safe is None: _fast_safe = {} for c in _fast_safe_test: _fast_safe[c] = c res = list(s) for i in range(len(res)): c = res[i] if not _fast_safe.has_key(c): res[i] = '%%%02x' % ord(c) return ''.join(res) |
res[i] = '%%%02x' % ord(c) | res[i] = '%%%02X' % ord(c) | def quote(s, safe = '/'): """quote('abc def') -> 'abc%20def' Each part of a URL, e.g. the path info, the query, etc., has a different set of reserved characters that must be quoted. RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax lists the following reserved characters. reserved = ";" | "/" | "?" | ":... |
else: p = "%s-ast.h" % mod.name f = open(p, "wb") print >> f, auto_gen_msg print >> f, ' c = ChainOfVisitors(TypeDefVisitor(f), StructVisitor(f), PrototypeVisitor(f), ) c.visit(mod) print >>f, "PyObject* PyAST_mod2obj(mod_ty t);" f.close() | f = open(p, "wb") print >> f, auto_gen_msg print >> f, ' c = ChainOfVisitors(TypeDefVisitor(f), StructVisitor(f), PrototypeVisitor(f), ) c.visit(mod) print >>f, "PyObject* PyAST_mod2obj(mod_ty t);" f.close() | def main(srcfile): argv0 = sys.argv[0] components = argv0.split(os.sep) argv0 = os.sep.join(components[-2:]) auto_gen_msg = '/* File automatically generated by %s */\n' % argv0 mod = asdl.parse(srcfile) if not asdl.check(mod): sys.exit(1) if INC_DIR: p = "%s/%s-ast.h" % (INC_DIR, mod.name) else: p = "%s-ast.h" % mod.na... |
else: p = "%s-ast.c" % mod.name f = open(p, "wb") print >> f, auto_gen_msg print >> f, ' print >> f, ' print >> f print >>f, "static PyTypeObject* AST_type;" v = ChainOfVisitors( PyTypesDeclareVisitor(f), PyTypesVisitor(f), FunctionVisitor(f), ObjVisitor(f), ASTModuleVisitor(f), PartingShots(f), ) v.visit(mod) f.close(... | f = open(p, "wb") print >> f, auto_gen_msg print >> f, ' print >> f, ' print >> f print >>f, "static PyTypeObject* AST_type;" v = ChainOfVisitors( PyTypesDeclareVisitor(f), PyTypesVisitor(f), FunctionVisitor(f), ObjVisitor(f), ASTModuleVisitor(f), PartingShots(f), ) v.visit(mod) f.close() | def main(srcfile): argv0 = sys.argv[0] components = argv0.split(os.sep) argv0 = os.sep.join(components[-2:]) auto_gen_msg = '/* File automatically generated by %s */\n' % argv0 mod = asdl.parse(srcfile) if not asdl.check(mod): sys.exit(1) if INC_DIR: p = "%s/%s-ast.h" % (INC_DIR, mod.name) else: p = "%s-ast.h" % mod.na... |
exts.append( Extension('ossaudiodev', ['ossaudiodev.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') | |
if len(a) < len(b): a, b = b, a res = a[:] for i in range(len(b)): res[i] = res[i] - b[i] return normalize(res) | neg_b = map(lambda x: -x, b[:]) return plus(a, neg_b) | def minus(a, b): if len(a) < len(b): a, b = b, a # make sure a is the longest res = a[:] # make a copy for i in range(len(b)): res[i] = res[i] - b[i] return normalize(res) |
if type (package) is StringType: path = string.split (package, '.') elif type (package) in (TupleType, ListType): path = list (package) else: raise TypeError, "'package' must be a string, list, or tuple" | path = string.split (package, '.') | def get_package_dir (self, package): """Return the directory, relative to the top of the source distribution, where package 'package' should be found (at least according to the 'package_dir' option, if any).""" |
package = tuple (path[0:-1]) | package = string.join(path[0:-1], '.') | def find_modules (self): """Finds individually-specified Python modules, ie. those listed by module name in 'self.py_modules'. Returns a list of tuples (package, module_base, filename): 'package' is a tuple of the path through package-space to the module; 'module_base' is the bare (no packages, no dots) module name, a... |
newurl = basejoin("http:" + url, newurl) | newurl = basejoin(self.type + ":" + url, newurl) | def redirect_internal(self, url, fp, errcode, errmsg, headers, data): if headers.has_key('location'): newurl = headers['location'] elif headers.has_key('uri'): newurl = headers['uri'] else: return void = fp.read() fp.close() # In case the server sent a relative URL, join with original: newurl = basejoin("http:" + url, ... |
if sys.argv[-1] == "Release": | if sys.argv[1] == "Release": | def main(): build_all = "-a" in sys.argv if sys.argv[-1] == "Release": arch = "x86" debug = False configure = "VC-WIN32" makefile = "32.mak" elif sys.argv[-1] == "Debug": arch = "x86" debug = True configure = "VC-WIN32" makefile="d32.mak" elif sys.argv[-1] == "ReleaseItanium": arch = "ia64" debug = False configure = "V... |
elif sys.argv[-1] == "Debug": | elif sys.argv[1] == "Debug": | def main(): build_all = "-a" in sys.argv if sys.argv[-1] == "Release": arch = "x86" debug = False configure = "VC-WIN32" makefile = "32.mak" elif sys.argv[-1] == "Debug": arch = "x86" debug = True configure = "VC-WIN32" makefile="d32.mak" elif sys.argv[-1] == "ReleaseItanium": arch = "ia64" debug = False configure = "V... |
elif sys.argv[-1] == "ReleaseItanium": | elif sys.argv[1] == "ReleaseItanium": | def main(): build_all = "-a" in sys.argv if sys.argv[-1] == "Release": arch = "x86" debug = False configure = "VC-WIN32" makefile = "32.mak" elif sys.argv[-1] == "Debug": arch = "x86" debug = True configure = "VC-WIN32" makefile="d32.mak" elif sys.argv[-1] == "ReleaseItanium": arch = "ia64" debug = False configure = "V... |
elif sys.argv[-1] == "ReleaseAMD64": | elif sys.argv[1] == "ReleaseAMD64": | def main(): build_all = "-a" in sys.argv if sys.argv[-1] == "Release": arch = "x86" debug = False configure = "VC-WIN32" makefile = "32.mak" elif sys.argv[-1] == "Debug": arch = "x86" debug = True configure = "VC-WIN32" makefile="d32.mak" elif sys.argv[-1] == "ReleaseItanium": arch = "ia64" debug = False configure = "V... |
self.plist.CFBundleExecutable = self.name | def setup(self): if self.mainprogram is None and self.executable is None: raise TypeError, ("must specify either or both of " "'executable' and 'mainprogram'") | |
try: fp = open(file) except: return None | fp = open(file) | def __init__(self, file=None): if not file: file = os.path.join(os.environ['HOME'], ".netrc") try: fp = open(file) except: return None self.hosts = {} self.macros = {} lexer = shlex.shlex(fp) |
emit(LOGHEADER, self.ui, os.environ, date=date, _file=tfn) | emit(LOGHEADER, self.ui, os.environ, date=date, _file=tf) | def commit(self, entry): file = entry.file # Normalize line endings in body if '\r' in self.ui.body: self.ui.body = re.sub('\r\n?', '\n', self.ui.body) # Normalize whitespace in title self.ui.title = ' '.join(self.ui.title.split()) # Check that there were any changes if self.ui.body == entry.body and self.ui.title == e... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.