rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
return '<' + x.__class__.__name__ + ' instance at ' + \ hex(id(x))[2:] + '>' | return '<%s instance at %x>' % (x.__class__.__name__, id(x)) | def repr_instance(self, x, level): try: s = __builtin__.repr(x) # Bugs in x.__repr__() can cause arbitrary # exceptions -- then make up something except: return '<' + x.__class__.__name__ + ' instance at ' + \ hex(id(x))[2:] + '>' if len(s) > self.maxstring: i = max(0, (self.maxstring-3)//2) j = max(0, self.maxstring-3... |
return False | try: import macfs return macfs.ResolveAliasFile(s)[2] except: return False | def islink(s): """Return true if the pathname refers to a symbolic link. Always false on the Mac, until we understand Aliases.)""" return False |
if isdir(name): | if isdir(name) and not islink(name): | def walk(top, func, arg): """Directory tree walk with callback function. For each directory in the directory tree rooted at top (including top itself, but excluding '.' and '..'), call func(arg, dirname, fnames). dirname is the name of the directory, and fnames a list of the names of the files and subdirectories in di... |
realpath = abspath | def realpath(path): path = abspath(path) try: import macfs except ImportError: return path if not path: return path components = path.split(':') path = components[0] + ':' for c in components[1:]: path = join(path, c) path = macfs.ResolveAliasFile(path)[0].as_pathname() return path | def abspath(path): """Return an absolute path.""" if not isabs(path): path = join(os.getcwd(), path) return normpath(path) |
mode = ((os.stat(file)[ST_MODE]) | 0111) & 07777 | mode = ((os.stat(file)[ST_MODE]) | 0555) & 07777 | def run (self): if not self.skip_build: self.run_command('build_scripts') self.outfiles = self.copy_tree(self.build_dir, self.install_dir) if os.name == 'posix': # Set the executable bits (owner, group, and world) on # all the scripts we just installed. for file in self.get_outputs(): if self.dry_run: log.info("changin... |
mbox = '/usr/mail/' + mbox | if os.path.isfile('/var/mail/' + mbox): mbox = '/var/mail/' + mbox else: mbox = '/usr/mail/' + mbox | def _test(): import sys args = sys.argv[1:] if not args: for key in 'MAILDIR', 'MAIL', 'LOGNAME', 'USER': if os.environ.has_key(key): mbox = os.environ[key] break else: print "$MAIL, $LOGNAME nor $USER set -- who are you?" return else: mbox = args[0] if mbox[:1] == '+': mbox = os.environ['HOME'] + '/Mail/' + mbox[1:] ... |
(ccshared,opt) = sysconfig.get_config_vars('CCSHARED','OPT') args['compiler_so'] = compiler + ' ' + opt + ' ' + ccshared | (ccshared,opt,base) = sysconfig.get_config_vars('CCSHARED','OPT','BASECFLAGS') args['compiler_so'] = compiler + ' ' + opt + ' ' + ccshared + ' ' + base | def build_extensions(self): |
"'ascii' codec can't encode character '\\xfc' in position 1: ouch" | "'ascii' codec can't encode character u'\\xfc' in position 1: ouch" | def test_unicodeencodeerror(self): self.check_exceptionobjectargs( UnicodeEncodeError, ["ascii", u"g\xfcrk", 1, 2, "ouch"], "'ascii' codec can't encode character '\\xfc' in position 1: ouch" ) self.check_exceptionobjectargs( UnicodeEncodeError, ["ascii", u"g\xfcrk", 1, 4, "ouch"], "'ascii' codec can't encode characters... |
"'ascii' codec can't encode character '\\xfc' in position 0: ouch" | "'ascii' codec can't encode character u'\\xfc' in position 0: ouch" | def test_unicodeencodeerror(self): self.check_exceptionobjectargs( UnicodeEncodeError, ["ascii", u"g\xfcrk", 1, 2, "ouch"], "'ascii' codec can't encode character '\\xfc' in position 1: ouch" ) self.check_exceptionobjectargs( UnicodeEncodeError, ["ascii", u"g\xfcrk", 1, 4, "ouch"], "'ascii' codec can't encode characters... |
"'ascii' codec can't encode character '\\u0100' in position 0: ouch" | "'ascii' codec can't encode character u'\\u0100' in position 0: ouch" | def test_unicodeencodeerror(self): self.check_exceptionobjectargs( UnicodeEncodeError, ["ascii", u"g\xfcrk", 1, 2, "ouch"], "'ascii' codec can't encode character '\\xfc' in position 1: ouch" ) self.check_exceptionobjectargs( UnicodeEncodeError, ["ascii", u"g\xfcrk", 1, 4, "ouch"], "'ascii' codec can't encode characters... |
"'ascii' codec can't encode character '\\uffff' in position 0: ouch" | "'ascii' codec can't encode character u'\\uffff' in position 0: ouch" | def test_unicodeencodeerror(self): self.check_exceptionobjectargs( UnicodeEncodeError, ["ascii", u"g\xfcrk", 1, 2, "ouch"], "'ascii' codec can't encode character '\\xfc' in position 1: ouch" ) self.check_exceptionobjectargs( UnicodeEncodeError, ["ascii", u"g\xfcrk", 1, 4, "ouch"], "'ascii' codec can't encode characters... |
"'ascii' codec can't encode character '\\U00010000' in position 0: ouch" | "'ascii' codec can't encode character u'\\U00010000' in position 0: ouch" | def test_unicodeencodeerror(self): self.check_exceptionobjectargs( UnicodeEncodeError, ["ascii", u"g\xfcrk", 1, 2, "ouch"], "'ascii' codec can't encode character '\\xfc' in position 1: ouch" ) self.check_exceptionobjectargs( UnicodeEncodeError, ["ascii", u"g\xfcrk", 1, 4, "ouch"], "'ascii' codec can't encode characters... |
"can't translate character '\\xfc' in position 1: ouch" | "can't translate character u'\\xfc' in position 1: ouch" | def test_unicodetranslateerror(self): self.check_exceptionobjectargs( UnicodeTranslateError, [u"g\xfcrk", 1, 2, "ouch"], "can't translate character '\\xfc' in position 1: ouch" ) self.check_exceptionobjectargs( UnicodeTranslateError, [u"g\u0100rk", 1, 2, "ouch"], "can't translate character '\\u0100' in position 1: ouch... |
"can't translate character '\\u0100' in position 1: ouch" | "can't translate character u'\\u0100' in position 1: ouch" | def test_unicodetranslateerror(self): self.check_exceptionobjectargs( UnicodeTranslateError, [u"g\xfcrk", 1, 2, "ouch"], "can't translate character '\\xfc' in position 1: ouch" ) self.check_exceptionobjectargs( UnicodeTranslateError, [u"g\u0100rk", 1, 2, "ouch"], "can't translate character '\\u0100' in position 1: ouch... |
"can't translate character '\\uffff' in position 1: ouch" | "can't translate character u'\\uffff' in position 1: ouch" | def test_unicodetranslateerror(self): self.check_exceptionobjectargs( UnicodeTranslateError, [u"g\xfcrk", 1, 2, "ouch"], "can't translate character '\\xfc' in position 1: ouch" ) self.check_exceptionobjectargs( UnicodeTranslateError, [u"g\u0100rk", 1, 2, "ouch"], "can't translate character '\\u0100' in position 1: ouch... |
"can't translate character '\\U00010000' in position 1: ouch" | "can't translate character u'\\U00010000' in position 1: ouch" | def test_unicodetranslateerror(self): self.check_exceptionobjectargs( UnicodeTranslateError, [u"g\xfcrk", 1, 2, "ouch"], "can't translate character '\\xfc' in position 1: ouch" ) self.check_exceptionobjectargs( UnicodeTranslateError, [u"g\u0100rk", 1, 2, "ouch"], "can't translate character '\\u0100' in position 1: ouch... |
def visitLambda(self, node, parent): | def visitLambda(self, node, parent, assign=0): assert not assign | def visitLambda(self, node, parent): for n in node.defaults: self.visit(n, parent) scope = LambdaScope(self.module, self.klass) if parent.nested or isinstance(parent, FunctionScope): scope.nested = 1 self.scopes[node] = scope self._do_args(scope, node.argnames) self.visit(node.code, scope) self.handle_free_vars(scope, ... |
userlist = self.__class__() userlist.data[:] = self.data[i:j] return userlist | return self.__class__(self.data[i:j]) | def __getslice__(self, i, j): i = max(i, 0); j = max(j, 0) userlist = self.__class__() userlist.data[:] = self.data[i:j] return userlist |
("CompilePyc", 18, "python.exe", r"[TARGETDIR]Lib\compileall.py [TARGETDIR]Lib"), ("CompilePyo", 18, "python.exe", r"-O [TARGETDIR]Lib\compileall.py [TARGETDIR]Lib") | ("CompilePyc", 18, "python.exe", compileargs), ("CompilePyo", 18, "python.exe", "-O "+compileargs), | def add_ui(db): x = y = 50 w = 370 h = 300 title = "[ProductName] Setup" # see "Dialog Style Bits" modal = 3 # visible | modal modeless = 1 # visible track_disk_space = 32 add_data(db, 'ActionText', uisample.ActionText) add_data(db, 'UIText', uisample.UIText) # Bitmaps if not os.path.exists(srcdir+r"\PC\pytho... |
return url2pathname(splithost(url1)[1]), None | return url2pathname(splithost(url1)[1]), hdrs | def retrieve(self, url, filename=None): url = unwrap(url) if self.tempcache and self.tempcache.has_key(url): return self.tempcache[url] type, url1 = splittype(url) if not filename and (not type or type == 'file'): try: fp = self.open_local_file(url1) del fp return url2pathname(splithost(url1)[1]), None except IOError, ... |
filename = tempfile.mktemp() | garbage, path = splittype(url) print (garbage, path) garbage, path = splithost(path or "") print (garbage, path) path, garbage = splitquery(path or "") print (path, garbage) path, garbage = splitattr(path or "") print (path, garbage) suffix = os.path.splitext(path)[1] filename = tempfile.mktemp(suffix) | def retrieve(self, url, filename=None): url = unwrap(url) if self.tempcache and self.tempcache.has_key(url): return self.tempcache[url] type, url1 = splittype(url) if not filename and (not type or type == 'file'): try: fp = self.open_local_file(url1) del fp return url2pathname(splithost(url1)[1]), None except IOError, ... |
noheaders(), 'file:'+file) | headers, 'file:'+file) | def open_local_file(self, url): host, file = splithost(url) if not host: return addinfourl( open(url2pathname(file), 'rb'), noheaders(), 'file:'+file) host, port = splitport(host) if not port and socket.gethostbyname(host) in ( localhost(), thishost()): file = unquote(file) return addinfourl( open(url2pathname(file), '... |
req.add_header(self.auth_header, auth_val) | req.add_unredirected_header(self.auth_header, auth_val) | def retry_http_digest_auth(self, req, auth): token, challenge = auth.split(' ', 1) chal = parse_keqv_list(parse_http_list(challenge)) auth = self.get_authorization(req, chal) if auth: auth_val = 'Digest %s' % auth if req.headers.get(self.auth_header, None) == auth_val: return None req.add_header(self.auth_header, auth_... |
print string.ljust(opname[op], 15), | print string.ljust(opname[op], 20), | def disassemble(co, lasti=-1): """Disassemble a code object.""" code = co.co_code labels = findlabels(code) n = len(code) i = 0 while i < n: c = code[i] op = ord(c) if op == SET_LINENO and i > 0: print # Extra blank line if i == lasti: print '-->', else: print ' ', if i in labels: print '>>', else: print ' ', print ... |
if callable(template): filter = template else: template = _compile_repl(template, pattern) if not template[0] and len(template[1]) == 1: filter = template[1][0] else: def filter(match, template=template): return sre_parse.expand_template(template, match) | template = _compile_repl(template, pattern) if not template[0] and len(template[1]) == 1: return template[1][0] def filter(match, template=template): return sre_parse.expand_template(template, match) | def _subx(pattern, template): # internal: pattern.sub/subn implementation helper if callable(template): filter = template else: template = _compile_repl(template, pattern) if not template[0] and len(template[1]) == 1: # literal replacement filter = template[1][0] else: def filter(match, template=template): return sre_p... |
def _sub(pattern, template, text, count=0): return _subn(pattern, template, text, count)[0] def _subn(pattern, template, text, count=0): filter = _subx(pattern, template) if not callable(filter): def filter(match, literal=filter): return literal n = i = 0 s = [] append = s.append c = pattern.scanner(text) while n... | def filter(match, template=template): return sre_parse.expand_template(template, match) | |
cmd = form.getvalue("cmd") or "view" page = form.getvalue("page") or "FrontPage" | cmd = form.getvalue("cmd", "view") page = form.getvalue("page", "FrontPage") | def main(): form = cgi.FieldStorage() print "Content-type: text/html" print cmd = form.getvalue("cmd") or "view" page = form.getvalue("page") or "FrontPage" wiki = WikiPage(page) wiki.load() method = getattr(wiki, 'cmd_' + cmd, None) or wiki.cmd_view method(form) |
homedir = os.path.dirname(sys.argv[0]) | homedir = "/tmp" | def main(): form = cgi.FieldStorage() print "Content-type: text/html" print cmd = form.getvalue("cmd") or "view" page = form.getvalue("page") or "FrontPage" wiki = WikiPage(page) wiki.load() method = getattr(wiki, 'cmd_' + cmd, None) or wiki.cmd_view method(form) |
print "<p>", self.mklink("edit", self.name, "Edit this page") + "," | print "<p>", self.mklink("edit", self.name, "Edit this page") + ";" | def cmd_view(self, form): print "<h1>", escape(self.splitwikiword(self.name)), "</h1>" print "<p>" for line in self.data.splitlines(): line = line.rstrip() if not line: print "<p>" continue words = re.split('(\W+)', line) for i in range(len(words)): word = words[i] if self.iswikiword(word): if os.path.isfile(self.mkfil... |
self.store() self.cmd_view(form) | error = self.store() if error: print "<h1>I'm sorry. That didn't work</h1>" print "<p>An error occurred while attempting to write the file:" print "<p>", escape(error) else: self.cmd_view(form) | def cmd_create(self, form): self.data = form.getvalue("text", "").strip() self.store() self.cmd_view(form) |
usage(2, msg) | usage(msg) return 2 | def main(): try: opts, args = getopt.getopt(sys.argv[1:], "h") except getopt.error, msg: usage(2, msg) for o, a in opts: if o == "-h": help() if not args: usage(2, "at least one file argument is required") if args[1:]: sys.stderr.write("%s: extra file arguments ignored\n", sys.argv[0]) readwarnings(args[0]) |
help() | print __doc__ return | def main(): try: opts, args = getopt.getopt(sys.argv[1:], "h") except getopt.error, msg: usage(2, msg) for o, a in opts: if o == "-h": help() if not args: usage(2, "at least one file argument is required") if args[1:]: sys.stderr.write("%s: extra file arguments ignored\n", sys.argv[0]) readwarnings(args[0]) |
usage(2, "at least one file argument is required") | usage("at least one file argument is required") return 2 | def main(): try: opts, args = getopt.getopt(sys.argv[1:], "h") except getopt.error, msg: usage(2, msg) for o, a in opts: if o == "-h": help() if not args: usage(2, "at least one file argument is required") if args[1:]: sys.stderr.write("%s: extra file arguments ignored\n", sys.argv[0]) readwarnings(args[0]) |
readwarnings(args[0]) def usage(exit, msg=None): if msg: sys.stderr.write("%s: %s\n" % (sys.argv[0], msg)) | warnings = readwarnings(args[0]) if warnings is None: return 1 files = warnings.keys() if not files: print "No classic division warnings read from", args[0] return files.sort() exit = None for file in files: x = process(file, warnings[file]) exit = exit or x return exit def usage(msg): sys.stderr.write("%s: %s\n" % (s... | def main(): try: opts, args = getopt.getopt(sys.argv[1:], "h") except getopt.error, msg: usage(2, msg) for o, a in opts: if o == "-h": help() if not args: usage(2, "at least one file argument is required") if args[1:]: sys.stderr.write("%s: extra file arguments ignored\n", sys.argv[0]) readwarnings(args[0]) |
sys.exit(exit) def help(): print __doc__ sys.exit(0) | PATTERN = ("^(.+?):(\d+): DeprecationWarning: " "classic (int|long|float|complex) division$") | def usage(exit, msg=None): if msg: sys.stderr.write("%s: %s\n" % (sys.argv[0], msg)) sys.stderr.write("Usage: %s warnings\n" % sys.argv[0]) sys.stderr.write("Try `%s -h' for more information.\n" % sys.argv[0]) sys.exit(exit) |
pat = re.compile( "^(.+?):(\d+): DeprecationWarning: classic ([a-z]+) division$") | prog = re.compile(PATTERN) | def readwarnings(warningsfile): pat = re.compile( "^(.+?):(\d+): DeprecationWarning: classic ([a-z]+) division$") try: f = open(warningsfile) except IOError, msg: sys.stderr.write("can't open: %s\n" % msg) return warnings = {} while 1: line = f.readline() if not line: break m = pat.match(line) if not m: if line.find("d... |
m = pat.match(line) | m = prog.match(line) | def readwarnings(warningsfile): pat = re.compile( "^(.+?):(\d+): DeprecationWarning: classic ([a-z]+) division$") try: f = open(warningsfile) except IOError, msg: sys.stderr.write("can't open: %s\n" % msg) return warnings = {} while 1: line = f.readline() if not line: break m = pat.match(line) if not m: if line.find("d... |
files = warnings.keys() files.sort() for file in files: process(file, warnings[file]) | return warnings | def readwarnings(warningsfile): pat = re.compile( "^(.+?):(\d+): DeprecationWarning: classic ([a-z]+) division$") try: f = open(warningsfile) except IOError, msg: sys.stderr.write("can't open: %s\n" % msg) return warnings = {} while 1: line = f.readline() if not line: break m = pat.match(line) if not m: if line.find("d... |
if not list: sys.stderr.write("no division warnings for %s\n" % file) return | assert list | def process(file, list): print "-"*70 if not list: sys.stderr.write("no division warnings for %s\n" % file) return try: fp = open(file) except IOError, msg: sys.stderr.write("can't open: %s\n" % msg) return print "Processing:", file f = FileContext(fp) list.sort() index = 0 # list[:index] has been processed, list[index... |
return print "Processing:", file | return 1 print "Index:", file | def process(file, list): print "-"*70 if not list: sys.stderr.write("no division warnings for %s\n" % file) return try: fp = open(file) except IOError, msg: sys.stderr.write("can't open: %s\n" % msg) return print "Processing:", file f = FileContext(fp) list.sort() index = 0 # list[:index] has been processed, list[index... |
orphans = [] unknown = [] | def process(file, list): print "-"*70 if not list: sys.stderr.write("no division warnings for %s\n" % file) return try: fp = open(file) except IOError, msg: sys.stderr.write("can't open: %s\n" % msg) return print "Processing:", file f = FileContext(fp) list.sort() index = 0 # list[:index] has been processed, list[index... | |
report(slashes, "Unexecuted code") | report(slashes, "No conclusive evidence") | def process(file, list): print "-"*70 if not list: sys.stderr.write("no division warnings for %s\n" % file) return try: fp = open(file) except IOError, msg: sys.stderr.write("can't open: %s\n" % msg) return print "Processing:", file f = FileContext(fp) list.sort() index = 0 # list[:index] has been processed, list[index... |
main() | sys.exit(main()) | def chop(line): if line.endswith("\n"): return line[:-1] else: return line |
ret = decompress(data) | ret = bz2.decompress(data) | def decompress(self, data): pop = popen2.Popen3("bunzip2", capturestderr=1) pop.tochild.write(data) pop.tochild.close() ret = pop.fromchild.read() pop.fromchild.close() if pop.wait() != 0: ret = decompress(data) return ret |
data = compress(self.TEXT) | if self.skip_decompress_tests: return data = bz2.compress(self.TEXT) | def testCompress(self): # "Test compress() function" data = compress(self.TEXT) self.assertEqual(self.decompress(data), self.TEXT) |
text = decompress(self.DATA) | text = bz2.decompress(self.DATA) | def testDecompress(self): # "Test decompress() function" text = decompress(self.DATA) self.assertEqual(text, self.TEXT) |
text = decompress("") | text = bz2.decompress("") | def testDecompressEmpty(self): # "Test decompress() function with empty string" text = decompress("") self.assertEqual(text, "") |
self.assertRaises(ValueError, decompress, self.DATA[:-10]) | self.assertRaises(ValueError, bz2.decompress, self.DATA[:-10]) | def testDecompressIncomplete(self): # "Test decompress() function with incomplete data" self.assertRaises(ValueError, decompress, self.DATA[:-10]) |
test_support.run_unittest(BZ2FileTest) test_support.run_unittest(BZ2CompressorTest) test_support.run_unittest(BZ2DecompressorTest) test_support.run_unittest(FuncTest) | suite = unittest.TestSuite() for test in (BZ2FileTest, BZ2CompressorTest, BZ2DecompressorTest, FuncTest): suite.addTest(unittest.makeSuite(test)) test_support.run_suite(suite) | def test_main(): test_support.run_unittest(BZ2FileTest) test_support.run_unittest(BZ2CompressorTest) test_support.run_unittest(BZ2DecompressorTest) test_support.run_unittest(FuncTest) |
for version in ['8.4', '84', '8.3', '83', '8.2', | for version in ['8.5', '85', '8.4', '84', '8.3', '83', '8.2', | def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module. |
text='when tab key inserts spaces,\nspaces per tab') | text='when tab key inserts spaces,\nspaces per indent') | def CreatePageFontTab(self): #tkVars self.fontSize=StringVar(self) self.fontBold=BooleanVar(self) self.fontName=StringVar(self) self.spaceNum=IntVar(self) self.tabCols=IntVar(self) self.indentBySpaces=BooleanVar(self) self.editFont=tkFont.Font(self,('courier',12,'normal')) ##widget creation #body frame frame=self.tabPa... |
labeltabColsTitle=Label(frameIndentSize,justify=LEFT, text='when tab key inserts tabs,\ncolumns per tab') self.scaleTabCols=Scale(frameIndentSize,variable=self.tabCols, orient='horizontal',tickinterval=2,from_=2,to=8) | def CreatePageFontTab(self): #tkVars self.fontSize=StringVar(self) self.fontBold=BooleanVar(self) self.fontName=StringVar(self) self.spaceNum=IntVar(self) self.tabCols=IntVar(self) self.indentBySpaces=BooleanVar(self) self.editFont=tkFont.Font(self,('courier',12,'normal')) ##widget creation #body frame frame=self.tabPa... | |
labeltabColsTitle.pack(side=TOP,anchor=W,padx=5) self.scaleTabCols.pack(side=TOP,padx=5,fill=X) | def CreatePageFontTab(self): #tkVars self.fontSize=StringVar(self) self.fontBold=BooleanVar(self) self.fontName=StringVar(self) self.spaceNum=IntVar(self) self.tabCols=IntVar(self) self.indentBySpaces=BooleanVar(self) self.editFont=tkFont.Font(self,('courier',12,'normal')) ##widget creation #body frame frame=self.tabPa... | |
tabCols=idleConf.GetOption('main','Indent','tab-cols', default=4,type='int') | def LoadTabCfg(self): ##indent type radibuttons spaceIndent=idleConf.GetOption('main','Indent','use-spaces', default=1,type='bool') self.indentBySpaces.set(spaceIndent) ##indent sizes spaceNum=idleConf.GetOption('main','Indent','num-spaces', default=4,type='int') tabCols=idleConf.GetOption('main','Indent','tab-cols', d... | |
self.tabCols.set(tabCols) | def LoadTabCfg(self): ##indent type radibuttons spaceIndent=idleConf.GetOption('main','Indent','use-spaces', default=1,type='bool') self.indentBySpaces.set(spaceIndent) ##indent sizes spaceNum=idleConf.GetOption('main','Indent','num-spaces', default=4,type='int') tabCols=idleConf.GetOption('main','Indent','tab-cols', d... | |
elif compiler == "gcc" or compiler == "g++": | elif compiler[:3] == "gcc" or compiler[:3] == "g++": | def runtime_library_dir_option(self, dir): # XXX Hackish, at the very least. See Python bug #445902: # http://sourceforge.net/tracker/index.php # ?func=detail&aid=445902&group_id=5470&atid=105470 # Linkers on different platforms need different options to # specify that directories need to be added to the list of # d... |
marshal.load(file(test_support.TESTFN, "rb")) | new = marshal.load(file(test_support.TESTFN, "rb")) | def test_unicode(self): for s in [u"", u"Andr Previn", u"abc", u" "*10000]: new = marshal.loads(marshal.dumps(s)) self.assertEqual(s, new) self.assertEqual(type(s), type(new)) marshal.dump(s, file(test_support.TESTFN, "wb")) marshal.load(file(test_support.TESTFN, "rb")) self.assertEqual(s, new) self.assertEqual(type(s)... |
marshal.load(file(test_support.TESTFN, "rb")) | new = marshal.load(file(test_support.TESTFN, "rb")) | def test_string(self): for s in ["", "Andr Previn", "abc", " "*10000]: new = marshal.loads(marshal.dumps(s)) self.assertEqual(s, new) self.assertEqual(type(s), type(new)) marshal.dump(s, file(test_support.TESTFN, "wb")) marshal.load(file(test_support.TESTFN, "rb")) self.assertEqual(s, new) self.assertEqual(type(s), typ... |
marshal.load(file(test_support.TESTFN, "rb")) | new = marshal.load(file(test_support.TESTFN, "rb")) | def test_buffer(self): for s in ["", "Andr Previn", "abc", " "*10000]: b = buffer(s) new = marshal.loads(marshal.dumps(b)) self.assertEqual(s, new) marshal.dump(b, file(test_support.TESTFN, "wb")) marshal.load(file(test_support.TESTFN, "rb")) self.assertEqual(s, new) os.unlink(test_support.TESTFN) |
marshal.load(file(test_support.TESTFN, "rb")) | new = marshal.load(file(test_support.TESTFN, "rb")) | def test_dict(self): new = marshal.loads(marshal.dumps(self.d)) self.assertEqual(self.d, new) marshal.dump(self.d, file(test_support.TESTFN, "wb")) marshal.load(file(test_support.TESTFN, "rb")) self.assertEqual(self.d, new) os.unlink(test_support.TESTFN) |
marshal.load(file(test_support.TESTFN, "rb")) | new = marshal.load(file(test_support.TESTFN, "rb")) | def test_list(self): lst = self.d.items() new = marshal.loads(marshal.dumps(lst)) self.assertEqual(lst, new) marshal.dump(lst, file(test_support.TESTFN, "wb")) marshal.load(file(test_support.TESTFN, "rb")) self.assertEqual(lst, new) os.unlink(test_support.TESTFN) |
marshal.load(file(test_support.TESTFN, "rb")) | new = marshal.load(file(test_support.TESTFN, "rb")) | def test_tuple(self): t = tuple(self.d.keys()) new = marshal.loads(marshal.dumps(t)) self.assertEqual(t, new) marshal.dump(t, file(test_support.TESTFN, "wb")) marshal.load(file(test_support.TESTFN, "rb")) self.assertEqual(t, new) os.unlink(test_support.TESTFN) |
marshal.load(file(test_support.TESTFN, "rb")) | new = marshal.load(file(test_support.TESTFN, "rb")) | def test_sets(self): for constructor in (set, frozenset): t = constructor(self.d.keys()) new = marshal.loads(marshal.dumps(t)) self.assertEqual(t, new) self.assert_(isinstance(new, constructor)) self.assertNotEqual(id(t), id(new)) marshal.dump(t, file(test_support.TESTFN, "wb")) marshal.load(file(test_support.TESTFN, "... |
cmd_obj = self.get_command_obj (command) for (key, val) in cmd_options.items(): cmd_obj.set_option (key, val) | opt_dict = self.get_option_dict(command) for (opt, val) in cmd_options.items(): opt_dict[opt] = ("setup script", val) | def __init__ (self, attrs=None): """Construct a new Distribution instance: initialize all the attributes of a Distribution, and then uses 'attrs' (a dictionary mapping attribute names to values) to assign some of those attributes their "real" values. (Any attributes not mentioned in 'attrs' will be assigned to some nu... |
if not self.command_options.has_key(section): self.command_options[section] = {} opts = self.command_options[section] | opt_dict = self.get_option_dict(section) | def parse_config_files (self, filenames=None): |
opts[opt] = (filename, parser.get(section,opt)) | opt_dict[opt] = (filename, parser.get(section,opt)) | def parse_config_files (self, filenames=None): |
if not self.command_options.has_key(command): self.command_options[command] = {} cmd_opts = self.command_options[command] | opt_dict = self.get_option_dict(command) | def _parse_command_opts (self, parser, args): |
cmd_opts[name] = ("command line", value) | opt_dict[name] = ("command line", value) | def _parse_command_opts (self, parser, args): |
__all__ = ["Random","seed","random","uniform","randint","choice", | __all__ = ["Random","seed","random","uniform","randint","choice","sample", | def create_generators(num, delta, firstseed=None): ""\"Return list of num distinct generators. Each generator has its own unique segment of delta elements from Random.random()'s full period. Seed the first generator with optional arg firstseed (default is None, to seed from current time). ""\" from random import Rando... |
def _test(N=20000): | def _test_sample(n): population = xrange(n) for k in xrange(n+1): s = sample(population, k) assert len(dict([(elem,True) for elem in s])) == len(s) == k def _sample_generator(n, k): return sample(xrange(n), k)[k//2] def _test(N=2000): | def _test(N=20000): print 'TWOPI =', TWOPI print 'LOG4 =', LOG4 print 'NV_MAGICCONST =', NV_MAGICCONST print 'SG_MAGICCONST =', SG_MAGICCONST _test_generator(N, 'random()') _test_generator(N, 'normalvariate(0.0, 1.0)') _test_generator(N, 'lognormvariate(0.0, 1.0)') _test_generator(N, 'cunifvariate(0.0,... |
def check_processing_instruction_only(self): | def test_processing_instruction_only(self): | def check_processing_instruction_only(self): self._run_check("<?processing instruction>", [ ("pi", "processing instruction"), ]) |
def check_simple_html(self): | def test_simple_html(self): | def check_simple_html(self): self._run_check(""" |
def check_bad_nesting(self): | def test_bad_nesting(self): | def check_bad_nesting(self): self._run_check("<a><b></a></b>", [ ("starttag", "a", []), ("starttag", "b", []), ("endtag", "a"), ("endtag", "b"), ]) |
def check_attr_syntax(self): | def test_attr_syntax(self): | def check_attr_syntax(self): output = [ ("starttag", "a", [("b", "v"), ("c", "v"), ("d", "v"), ("e", None)]) ] self._run_check("""<a b='v' c="v" d=v e>""", output) self._run_check("""<a b = 'v' c = "v" d = v e>""", output) self._run_check("""<a\nb\n=\n'v'\nc\n=\n"v"\nd\n=\nv\ne>""", output) self._run_check("""<a\tb\t=... |
def check_attr_values(self): | def test_attr_values(self): | def check_attr_values(self): self._run_check("""<a b='xxx\n\txxx' c="yyy\t\nyyy" d='\txyz\n'>""", [("starttag", "a", [("b", "xxx\n\txxx"), ("c", "yyy\t\nyyy"), ("d", "\txyz\n")]) ]) self._run_check("""<a b='' c="">""", [ ("starttag", "a", [("b", ""), ("c", "")]), ]) |
def check_attr_entity_replacement(self): | def test_attr_entity_replacement(self): | def check_attr_entity_replacement(self): self._run_check("""<a b='&><"''>""", [ ("starttag", "a", [("b", "&><\"'")]), ]) |
def check_attr_funky_names(self): | def test_attr_funky_names(self): | def check_attr_funky_names(self): self._run_check("""<a a.b='v' c:d=v e-f=v>""", [ ("starttag", "a", [("a.b", "v"), ("c:d", "v"), ("e-f", "v")]), ]) |
def check_starttag_end_boundary(self): | def test_starttag_end_boundary(self): | def check_starttag_end_boundary(self): self._run_check("""<a b='<'>""", [("starttag", "a", [("b", "<")])]) self._run_check("""<a b='>'>""", [("starttag", "a", [("b", ">")])]) |
def check_buffer_artefacts(self): | def test_buffer_artefacts(self): | def check_buffer_artefacts(self): output = [("starttag", "a", [("b", "<")])] self._run_check(["<a b='<'>"], output) self._run_check(["<a ", "b='<'>"], output) self._run_check(["<a b", "='<'>"], output) self._run_check(["<a b=", "'<'>"], output) self._run_check(["<a b='<", "'>"], output) self._run_check(["<a b='<'", ">"... |
def check_starttag_junk_chars(self): | def test_starttag_junk_chars(self): | def check_starttag_junk_chars(self): self._parse_error("<") self._parse_error("<>") self._parse_error("</>") self._parse_error("</$>") self._parse_error("</") self._parse_error("</a") self._parse_error("<a<a>") self._parse_error("</a<a>") self._parse_error("<$") self._parse_error("<$>") self._parse_error("<!") self._pa... |
def check_declaration_junk_chars(self): | def test_declaration_junk_chars(self): | def check_declaration_junk_chars(self): self._parse_error("<!DOCTYPE foo $ >") |
def check_startendtag(self): | def test_startendtag(self): | def check_startendtag(self): self._run_check("<p/>", [ ("startendtag", "p", []), ]) self._run_check("<p></p>", [ ("starttag", "p", []), ("endtag", "p"), ]) self._run_check("<p><img src='foo' /></p>", [ ("starttag", "p", []), ("startendtag", "img", [("src", "foo")]), ("endtag", "p"), ]) |
def check_get_starttag_text(self): | def test_get_starttag_text(self): | def check_get_starttag_text(self): s = """<foo:bar \n one="1"\ttwo=2 >""" self._run_check_extra(s, [ ("starttag", "foo:bar", [("one", "1"), ("two", "2")]), ("starttag_text", s)]) |
def check_cdata_content(self): | def test_cdata_content(self): | def check_cdata_content(self): s = """<script> <!-- not a comment --> ¬-an-entity-ref; </script>""" self._run_check(s, [ ("starttag", "script", []), ("data", " <!-- not a comment --> ¬-an-entity-ref; "), ("endtag", "script"), ]) s = """<script> <not a='start tag'> </script>""" self._run_check(s, [ ("starttag", "s... |
'lib.' + self.plat) | 'lib-' + plat_specifier) | def finalize_options (self): |
'temp.' + self.plat) | 'temp-' + plat_specifier) | def finalize_options (self): |
if not self.py_modules and not self.packages: return if self.py_modules and self.packages: raise DistutilsOptionError, \ "build_py: supplying both 'packages' and 'py_modules' " + \ "options is not allowed" | def run (self): | |
else: | if self.packages: | def run (self): |
modules = self.find_modules() else: modules = [] | modules.extend(self.find_modules()) if self.packages: | def find_all_modules (self): """Compute the list of all modules that will be built, whether they are specified one-module-at-a-time ('self.py_modules') or by whole packages ('self.packages'). Return a list of tuples (package, module, module_file), just like 'find_modules()' and 'find_package_modules()' do.""" |
if not port: port = SMTP_PORT | if not port: port = self.default_port | def connect(self, host='localhost', port = 0): """Connect to a host on a given port. |
self.sock = socket.socket(af, socktype, proto) if self.debuglevel > 0: print>>stderr, 'connect:', sa self.sock.connect(sa) | self._get_socket(af,socktype,proto,sa) | def connect(self, host='localhost', port = 0): """Connect to a host on a given port. |
self.detect_ctypes() | self.detect_ctypes(inc_dirs, lib_dirs) | 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') |
(srcdir,) = sysconfig.get_config_vars('srcdir') ffi_builddir = os.path.join(self.build_temp, 'libffi') ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules', '_ctypes', 'libffi')) ffi_configfile = os.path.join(ffi_builddir, 'fficonfig.py') if self.force or not os.path.exists(ffi_configfile): from distutils.dir_u... | if not self.use_system_libffi: (srcdir,) = sysconfig.get_config_vars('srcdir') ffi_builddir = os.path.join(self.build_temp, 'libffi') ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules', '_ctypes', 'libffi')) ffi_configfile = os.path.join(ffi_builddir, 'fficonfig.py') if self.force or not os.path.exists(ffi_co... | def configure_ctypes(self, ext): (srcdir,) = sysconfig.get_config_vars('srcdir') ffi_builddir = os.path.join(self.build_temp, 'libffi') ffi_srcdir = os.path.abspath(os.path.join(srcdir, 'Modules', '_ctypes', 'libffi')) ffi_configfile = os.path.join(ffi_builddir, 'fficonfig.py') |
def detect_ctypes(self): | def detect_ctypes(self, inc_dirs, lib_dirs): self.use_system_libffi = False | def detect_ctypes(self): include_dirs = [] extra_compile_args = [] sources = ['_ctypes/_ctypes.c', '_ctypes/callbacks.c', '_ctypes/callproc.c', '_ctypes/stgdict.c', '_ctypes/cfield.c', '_ctypes/malloc_closure.c'] depends = ['_ctypes/ctypes.h'] |
def checkJoin(relurl, expected): global errors result = urlparse.urljoin(RFC1808_BASE, relurl) print "%-13s = %r" % (relurl, result) if result != expected: errors += 1 print "urljoin(%r, %r)" % (RFC1808_BASE, relurl) print ("expected %r,\n" " got %r") % (expected, result) | def test_RFC1808(self): self.checkJoin(RFC1808_BASE, 'g:h', 'g:h') self.checkJoin(RFC1808_BASE, 'g', 'http://a/b/c/g') self.checkJoin(RFC1808_BASE, './g', 'http://a/b/c/g') self.checkJoin(RFC1808_BASE, 'g/', 'http://a/b/c/g/') self.checkJoin(RFC1808_BASE, '/g', 'http://a/g') self.checkJoin(RFC1808_BASE, '//g', 'http:/... | def checkJoin(relurl, expected): global errors result = urlparse.urljoin(RFC1808_BASE, relurl) print "%-13s = %r" % (relurl, result) if result != expected: errors += 1 print "urljoin(%r, %r)" % (RFC1808_BASE, relurl) print ("expected %r,\n" " got %r") % (expected, result) |
print "urlparse.urljoin() tests" print | self.checkJoin(RFC1808_BASE, '', 'http://a/b/c/d;p?q self.checkJoin(RFC1808_BASE, '../../../g', 'http://a/../g') self.checkJoin(RFC1808_BASE, '../../../../g', 'http://a/../../g') self.checkJoin(RFC1808_BASE, '/./g', 'http://a/./g') self.checkJoin(RFC1808_BASE, '/../g', 'http://a/../g') self.checkJoin(RFC1808_BASE, 'g.'... | def checkJoin(relurl, expected): global errors result = urlparse.urljoin(RFC1808_BASE, relurl) print "%-13s = %r" % (relurl, result) if result != expected: errors += 1 print "urljoin(%r, %r)" % (RFC1808_BASE, relurl) print ("expected %r,\n" " got %r") % (expected, result) |
checkJoin('g:h', 'g:h') checkJoin('g', 'http://a/b/c/g') checkJoin('./g', 'http://a/b/c/g') checkJoin('g/', 'http://a/b/c/g/') checkJoin('/g', 'http://a/g') checkJoin('//g', 'http://g') checkJoin('?y', 'http://a/b/c/d;p?y') checkJoin('g?y', 'http://a/b/c/g?y') checkJoin('g?y/./x', 'http://a/b/c/g?y/./x') checkJoin(' ch... | def checkJoin(relurl, expected): global errors result = urlparse.urljoin(RFC1808_BASE, relurl) print "%-13s = %r" % (relurl, result) if result != expected: errors += 1 print "urljoin(%r, %r)" % (RFC1808_BASE, relurl) print ("expected %r,\n" " got %r") % (expected, result) | |
checkJoin('', 'http://a/b/c/d;p?q checkJoin('../../../g', 'http://a/../g') checkJoin('../../../../g', 'http://a/../../g') checkJoin('/./g', 'http://a/./g') checkJoin('/../g', 'http://a/../g') checkJoin('g.', 'http://a/b/c/g.') checkJoin('.g', 'http://a/b/c/.g') checkJoin('g..', 'http://a/b/c/g..') checkJoin('..g', 'htt... | def test_RFC2396(self): | def checkJoin(relurl, expected): global errors result = urlparse.urljoin(RFC1808_BASE, relurl) print "%-13s = %r" % (relurl, result) if result != expected: errors += 1 print "urljoin(%r, %r)" % (RFC1808_BASE, relurl) print ("expected %r,\n" " got %r") % (expected, result) |
print errors, "errors" | self.checkJoin(RFC2396_BASE, 'g:h', 'g:h') self.checkJoin(RFC2396_BASE, 'g', 'http://a/b/c/g') self.checkJoin(RFC2396_BASE, './g', 'http://a/b/c/g') self.checkJoin(RFC2396_BASE, 'g/', 'http://a/b/c/g/') self.checkJoin(RFC2396_BASE, '/g', 'http://a/g') self.checkJoin(RFC2396_BASE, '//g', 'http://g') self.checkJoin(RFC23... | def checkJoin(relurl, expected): global errors result = urlparse.urljoin(RFC1808_BASE, relurl) print "%-13s = %r" % (relurl, result) if result != expected: errors += 1 print "urljoin(%r, %r)" % (RFC1808_BASE, relurl) print ("expected %r,\n" " got %r") % (expected, result) |
font=tkFont.Font(self,Label().cget('font')) | font=tkFont.Font(self,Label(self).cget('font')) | def __init__(self,parent,title): Toplevel.__init__(self, parent) self.configure(borderwidth=5) self.geometry("+%d+%d" % (parent.winfo_rootx()+30, parent.winfo_rooty()+30)) #elguavas - config placeholders til config stuff completed self.bg="#555555" self.fg="#ffffff" #no ugly bold default font on *nix font=tkFont.Font(s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.