rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
self.bind('<Alt-r>',self.LicenseButtonBinding) | self.bind('<Alt-l>',self.LicenseButtonBinding) | 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... |
if __debug__ and self.debug >= 1: _mesg('new IMAP4 connection, tag=%s' % self.tagpre) | if __debug__: if self.debug >= 1: _mesg('new IMAP4 connection, tag=%s' % self.tagpre) | def __init__(self, host = '', port = IMAP4_PORT): self.host = host self.port = port self.debug = Debug self.state = 'LOGOUT' self.literal = None # A literal argument to a command self.tagged_commands = {} # Tagged commands awaiting response self.untagged_responses = {} # {typ: [data, ...], ...} self.continuation_respo... |
if __debug__ and self.debug >= 3: _mesg('CAPABILITIES: %s' % `self.capabilities`) | if __debug__: if self.debug >= 3: _mesg('CAPABILITIES: %s' % `self.capabilities`) | def __init__(self, host = '', port = IMAP4_PORT): self.host = host self.port = port self.debug = Debug self.state = 'LOGOUT' self.literal = None # A literal argument to a command self.tagged_commands = {} # Tagged commands awaiting response self.untagged_responses = {} # {typ: [data, ...], ...} self.continuation_respo... |
(typ, [data]) = <instance>.list(user, password) """ typ, dat = self._simple_command('LOGIN', user, password) | (typ, [data]) = <instance>.login(user, password) NB: 'password' will be quoted. """ typ, dat = self._simple_command('LOGIN', user, self._quote(password)) | def login(self, user, password): """Identify client using plaintext password. |
if __debug__ and self.debug >= 3: _dump_ur(self.untagged_responses) | if __debug__: if self.debug >= 3: _dump_ur(self.untagged_responses) | def noop(self): """Send NOOP command. |
if __debug__ and self.debug >= 1: _dump_ur(self.untagged_responses) | if __debug__: if self.debug >= 1: _dump_ur(self.untagged_responses) | def select(self, mailbox='INBOX', readonly=None): """Select a mailbox. |
if __debug__ and self.debug >= 5: _mesg('untagged_responses[%s] %s += %s' % (typ, len(ur.get(typ,'')), dat)) | if __debug__: if self.debug >= 5: _mesg('untagged_responses[%s] %s += ["%s"]' % (typ, len(ur.get(typ,'')), dat)) | def _append_untagged(self, typ, dat): |
for d in args: if d is None: continue if type(d) is type(''): l = len(string.split(d)) else: l = 1 if l == 0 or l > 1 and (d[0],d[-1]) not in (('(',')'),('"','"')): data = '%s "%s"' % (data, d) else: data = '%s %s' % (data, d) | for arg in args: if arg is None: continue data = '%s %s' % (data, self._checkquote(arg)) | def _command(self, name, *args): |
if __debug__ and self.debug >= 4: _mesg('> %s' % data) | def _command(self, name, *args): | |
if __debug__ and self.debug >= 4: _mesg('write literal size %s' % len(literal)) | if __debug__: if self.debug >= 4: _mesg('write literal size %s' % len(literal)) | def _command(self, name, *args): |
if self.untagged_responses.has_key('BYE') and name != 'LOGOUT': raise self.abort(self.untagged_responses['BYE'][-1]) | self._check_bye() | def _command_complete(self, name, tag): try: typ, data = self._get_tagged_response(tag) except self.abort, val: raise self.abort('command: %s => %s' % (name, val)) except self.error, val: raise self.error('command: %s => %s' % (name, val)) if self.untagged_responses.has_key('BYE') and name != 'LOGOUT': raise self.abort... |
if __debug__ and self.debug >= 4: _mesg('read literal size %s' % size) | if __debug__: if self.debug >= 4: _mesg('read literal size %s' % size) | def _get_response(self): |
if __debug__ and self.debug >= 1 and typ in ('NO', 'BAD'): _mesg('%s response: %s' % (typ, dat)) | if __debug__: if self.debug >= 1 and typ in ('NO', 'BAD', 'BYE'): _mesg('%s response: %s' % (typ, dat)) | def _get_response(self): |
if __debug__ and self.debug >= 4: _mesg('< %s' % line) | if __debug__: if self.debug >= 4: _mesg('< %s' % line) else: _log('< %s' % line) | def _get_line(self): |
if __debug__ and self.mo is not None and self.debug >= 5: _mesg("\tmatched r'%s' => %s" % (cre.pattern, `self.mo.groups()`)) | if __debug__: if self.mo is not None and self.debug >= 5: _mesg("\tmatched r'%s' => %s" % (cre.pattern, `self.mo.groups()`)) | def _match(self, cre, s): |
if __debug__ and self.debug >= 5: _mesg('untagged_responses[%s] => %s' % (name, data)) | if __debug__: if self.debug >= 5: _mesg('untagged_responses[%s] => %s' % (name, data)) | def _untagged_response(self, typ, dat, name): |
if dttype is type(1): | if dttype is type(1) or dttype is type(1.1): | def Time2Internaldate(date_time): """Convert 'date_time' to IMAP4 INTERNALDATE representation. Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"' """ dttype = type(date_time) if dttype is type(1): tt = time.localtime(date_time) elif dttype is type(()): tt = date_time elif dttype is type(""): return date_time # As... |
def _mesg(s): sys.stderr.write('\t'+s+'\n') | def _mesg(s, secs=None): if secs is None: secs = time.time() tm = time.strftime('%M:%S', time.localtime(secs)) sys.stderr.write(' %s.%02d %s\n' % (tm, (secs*100)%100, s)) | def _mesg(s): |
if __debug__ and __name__ == '__main__': | _cmd_log = [] _cmd_log_len = 10 def _log(line): if len(_cmd_log) == _cmd_log_len: del _cmd_log[0] _cmd_log.append((time.time(), line)) def print_log(): _mesg('last %d IMAP4 interactions:' % len(_cmd_log)) for secs,line in _cmd_log: _mesg(line, secs) if __name__ == '__main__': | def _dump_ur(dict): # Dump untagged responses (in `dict'). l = dict.items() if not l: return t = '\n\t\t' j = string.join l = map(lambda x,j=j:'%s: "%s"' % (x[0], x[1][0] and j(x[1], '" "') or ''), l) _mesg('untagged responses dump:%s%s' % (t, j(l, t))) |
_mesg(' %s %s\n => %s %s' % (cmd, args, typ, dat)) | _mesg('%s => %s %s' % (cmd, typ, dat)) | def run(cmd, args): typ, dat = apply(eval('M.%s' % cmd), args) _mesg(' %s %s\n => %s %s' % (cmd, args, typ, dat)) return dat |
uid = string.split(dat[-1])[-1] run('uid', ('FETCH', '%s' % uid, | uid = string.split(dat[-1]) if not uid: continue run('uid', ('FETCH', '%s' % uid[-1], | def run(cmd, args): typ, dat = apply(eval('M.%s' % cmd), args) _mesg(' %s %s\n => %s %s' % (cmd, args, typ, dat)) return dat |
elif sys.version < '2.1': if sys.platform == 'aix4': python_lib = get_python_lib(standard_lib=1) ld_so_aix = os.path.join(python_lib, 'config', 'ld_so_aix') python_exp = os.path.join(python_lib, 'config', 'python.exp') g['LDSHARED'] = "%s %s -bI:%s" % (ld_so_aix, g['CC'], python_exp) elif sys.platform == 'beos': ... | def _init_posix(): """Initialize the module as appropriate for POSIX systems.""" g = {} # load the installed Makefile: try: filename = get_makefile_filename() parse_makefile(filename, g) except IOError, msg: my_msg = "invalid Python installation: unable to open %s" % filename if hasattr(msg, "strerror"): my_msg = my_ms... | |
(fd, name) = tempfile.mkstemp(suffix=['.html', '.txt'][text], | (fd, path) = tempfile.mkstemp(suffix=['.html', '.txt'][text], | def handle(self, info=None): info = info or sys.exc_info() self.file.write(reset()) |
except AttributeError: pass else: raise TestFailed, 'expected AttributeError' if b.__dict__ <> None: raise TestFailed, 'expected unassigned func.__dict__ to be None' | except AttributeError: pass else: raise TestFailed, 'expected AttributeError' if b.__dict__ <> {}: raise TestFailed, 'expected unassigned func.__dict__ to be {}' | def b(): 'my docstring' pass |
del b.__dict__ if b.__dict__ <> None: raise TestFailed, 'del func.__dict__ did not result in __dict__ == None' | try: del b.__dict__ except TypeError: pass else: raise TestFailed, 'del func.__dict__ expected TypeError' | def b(): 'my docstring' pass |
b.__dict__ = None if b.__dict__ <> None: raise TestFailed, 'func.__dict__ = None did not result in __dict__ == None' | try: b.__dict__ = None except TypeError: pass else: raise TestFailed, 'func.__dict__ = None expected TypeError' d = {'hello': 'world'} b.__dict__ = d if b.func_dict is not d: raise TestFailed, 'func.__dict__ assignment to dictionary failed' if b.hello <> 'world': raise TestFailed, 'attribute after func.__dict__ assign... | def b(): 'my docstring' pass |
del another.__dict__ del another.func_dict another.func_dict = None | try: del another.__dict__ except TypeError: pass else: raise TestFailed try: del another.func_dict except TypeError: pass else: raise TestFailed try: another.func_dict = None except TypeError: pass else: raise TestFailed | def another(): pass |
self.tagpre = Int2AP(random.randint(0, 31999)) | self.tagpre = Int2AP(random.randint(4096, 65535)) | def __init__(self, host = '', port = IMAP4_PORT): self.debug = Debug self.state = 'LOGOUT' self.literal = None # A literal argument to a command self.tagged_commands = {} # Tagged commands awaiting response self.untagged_responses = {} # {typ: [data, ...], ...} self.continuation_response = '' # Las... |
msgbuf = "" | msgbuf = [] | def makefile(self, mode, bufsize=None): """Return a readable file-like object with data from socket. |
msgbuf = msgbuf + self.__ssl.read() | buf = self.__ssl.read() | def makefile(self, mode, bufsize=None): """Return a readable file-like object with data from socket. |
return StringIO(msgbuf) | if buf == '': break msgbuf.append(buf) return StringIO("".join(msgbuf)) | def makefile(self, mode, bufsize=None): """Return a readable file-like object with data from socket. |
self.assertEqual(re.match('(x)*', 50000*'x').span(), (0, 50000)) | try: re.match('(x)*', 50000*'x') except RuntimeError, v: self.assertEqual(str(v), "maximum recursion limit exceeded") else: self.fail("re.match('(x)*', 50000*'x') should have failed") | def test_limitations(self): # Try nasty case that overflows the straightforward recursive # implementation of repeated groups. self.assertEqual(re.match('(x)*', 50000*'x').span(), (0, 50000)) |
if not ':' in head: | if os.sep == ':' and not ':' in head: | def mkdirs(dst): """Make directories leading to 'dst' if they don't exist yet""" if dst == '' or os.path.exists(dst): return head, tail = os.path.split(dst) if not ':' in head: head = head + ':' mkdirs(head) os.mkdir(dst, 0777) |
WalkTests | WalkTests, MakedirTests, | def test_main(): test_support.run_unittest( TemporaryFileTests, StatAttributeTests, EnvironTests, WalkTests ) |
"""retrieve(url) returns (filename, None) for a local object | """retrieve(url) returns (filename, headers) for a local object | def retrieve(self, url, filename=None, reporthook=None, data=None): """retrieve(url) returns (filename, None) for a local object or (tempfilename, headers) for a remote object.""" url = unwrap(toBytes(url)) if self.tempcache and url in self.tempcache: return self.tempcache[url] type, url1 = splittype(url) if filename i... |
'DocTestTestFailure', | >>> def f(x): | |
def _utest(tester, name, doc, filename, lineno): import sys from StringIO import StringIO old = sys.stdout sys.stdout = new = StringIO() try: failures, tries = tester.runstring(doc, name) finally: sys.stdout = old if failures: msg = new.getvalue() lname = '.'.join(name.split('.')[-1:]) if not lineno: lineno = "0 (don... | from StringIO import StringIO import os import sys import tempfile import unittest class DocTestTestCase(unittest.TestCase): """A test case that wraps a test function. This is useful for slipping pre-existing test functions into the PyUnit framework. Optionally, set-up and tidy-up functions can be supplied. As with T... | def _find_tests(module, prefix=None): if prefix is None: prefix = module.__name__ mdict = module.__dict__ tests = [] # Get the module-level doctest (if any). _get_doctest(prefix, module, tests, '', lineno="1 (or above)") # Recursively search the module __dict__ for doctests. if prefix: prefix += "." _extract_doctests(m... |
import unittest module = _normalize_module(module) tests = _find_tests(module) | def __init__(self, tester, name, doc, filename, lineno, setUp=None, tearDown=None): unittest.TestCase.__init__(self) (self.__tester, self.__name, self.__doc, self.__filename, self.__lineno, self.__setUp, self.__tearDown ) = tester, name, doc, filename, lineno, setUp, tearDown def setUp(self): if self.__setUp is not No... | def DocTestSuite(module=None): """Convert doctest tests for a module to a unittest TestSuite. The returned TestSuite is to be run by the unittest framework, and runs each doctest in the module. If any of the doctests fail, then the synthesized unit test fails, and an error is raised showing the name of the file conta... |
def runit(name=name, doc=doc, filename=filename, lineno=lineno): _utest(tester, name, doc, filename, lineno) suite.addTest(unittest.FunctionTestCase( runit, description="doctest of " + name)) | suite.addTest(DocTestTestCase( tester, name, doc, filename, lineno, setUp, tearDown)) | def runit(name=name, doc=doc, filename=filename, lineno=lineno): _utest(tester, name, doc, filename, lineno) |
def _normalizeModule(module): if module is None: module = sys._getframe(2).f_globals['__name__'] module = sys.modules[module] elif isinstance(module, (str, unicode)): module = __import__(module, globals(), locals(), ["*"]) return module def _doc(name, object, tests, prefix, filename='', lineno=''): doc = getattr(o... | def runit(name=name, doc=doc, filename=filename, lineno=lineno): _utest(tester, name, doc, filename, lineno) | |
"""Extract the doctest examples from a docstring. | """Extract the test sources from a doctest test docstring as a script | def testsource(module, name): """Extract the doctest examples from a docstring. Provide the module (or dotted name of the module) containing the tests to be extracted, and the name (within the module) of the object with the docstring containing the tests to be extracted. The doctest examples are returned as a string ... |
tests to be extracted, and the name (within the module) of the object with the docstring containing the tests to be extracted. The doctest examples are returned as a string containing Python code. The expected output blocks in the examples are converted to Python comments. | test to be debugged and the name (within the module) of the object with the doc string with tests to be debugged. | def testsource(module, name): """Extract the doctest examples from a docstring. Provide the module (or dotted name of the module) containing the tests to be extracted, and the name (within the module) of the object with the docstring containing the tests to be extracted. The doctest examples are returned as a string ... |
module = _normalize_module(module) tests = _find_tests(module, "") test = [doc for (tname, doc, dummy, dummy) in tests if tname == name] | module = _normalizeModule(module) tests = _findTests(module, "") test = [doc for (tname, doc, f, l) in tests if tname == name] | def testsource(module, name): """Extract the doctest examples from a docstring. Provide the module (or dotted name of the module) containing the tests to be extracted, and the name (within the module) of the object with the docstring containing the tests to be extracted. The doctest examples are returned as a string ... |
examples = [source + _expect(expect) for source, expect, dummy in _extract_examples(test)] return '\n'.join(examples) def debug(module, name): """Debug a single docstring containing doctests. Provide the module (or dotted name of the module) containing the docstring to be debugged, and the name (within the module) of... | examples = _extract_examples(test) testsrc = '\n'.join([ "%s%s" % (source, _expect(expect)) for (source, expect, lineno) in examples ]) return testsrc def debug_src(src, pm=False, globs=None): """Debug a single doctest test doc string The string is provided directly | def testsource(module, name): """Extract the doctest examples from a docstring. Provide the module (or dotted name of the module) containing the tests to be extracted, and the name (within the module) of the object with the docstring containing the tests to be extracted. The doctest examples are returned as a string ... |
import os | examples = _extract_examples(src) src = '\n'.join([ "%s%s" % (source, _expect(expect)) for (source, expect, lineno) in examples ]) debug_script(src, pm, globs) def debug_script(src, pm=False, globs=None): "Debug a test script" | def debug(module, name): """Debug a single docstring containing doctests. Provide the module (or dotted name of the module) containing the docstring to be debugged, and the name (within the module) of the object with the docstring to be debugged. The doctest examples are extracted (see function testsource()), and wri... |
import tempfile module = _normalize_module(module) testsrc = testsource(module, name) | def debug(module, name): """Debug a single docstring containing doctests. Provide the module (or dotted name of the module) containing the docstring to be debugged, and the name (within the module) of the object with the docstring to be debugged. The doctest examples are extracted (see function testsource()), and wri... | |
f = file(srcfilename, 'w') f.write(testsrc) f.close() globs = {} globs.update(module.__dict__) | open(srcfilename, 'w').write(src) if globs: globs = globs.copy() else: globs = {} | def debug(module, name): """Debug a single docstring containing doctests. Provide the module (or dotted name of the module) containing the docstring to be debugged, and the name (within the module) of the object with the docstring to be debugged. The doctest examples are extracted (see function testsource()), and wri... |
pdb.run("execfile(%r)" % srcfilename, globs, globs) | if pm: try: execfile(srcfilename, globs, globs) except: print sys.exc_info()[1] pdb.post_mortem(sys.exc_info()[2]) else: pdb.run("execfile(%r)" % srcfilename, globs, globs) | def debug(module, name): """Debug a single docstring containing doctests. Provide the module (or dotted name of the module) containing the docstring to be debugged, and the name (within the module) of the object with the docstring to be debugged. The doctest examples are extracted (see function testsource()), and wri... |
text = editwin.text text.bind("<<run-module>>", self.run_module) text.bind("<<run-script>>", self.run_script) text.bind("<<new-shell>>", self.new_shell) | self.flist = self.editwin.flist self.root = self.flist.root | def __init__(self, editwin): self.editwin = editwin text = editwin.text text.bind("<<run-module>>", self.run_module) text.bind("<<run-script>>", self.run_script) text.bind("<<new-shell>>", self.new_shell) |
def run_module(self, event=None): | 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 | def run_module(self, event=None): filename = self.editwin.io.filename if not filename: tkMessageBox.showerror("No file name", "This window has no file name", master=self.editwin.text) return modname, ext = os.path.splitext(os.path.basename(filename)) try: mod = sys.modules[modname] except KeyError: mod = imp.new_module... |
try: | if sys.modules.has_key(modname): | def run_module(self, event=None): filename = self.editwin.io.filename if not filename: tkMessageBox.showerror("No file name", "This window has no file name", master=self.editwin.text) return modname, ext = os.path.splitext(os.path.basename(filename)) try: mod = sys.modules[modname] except KeyError: mod = imp.new_module... |
except KeyError: | else: | def run_module(self, event=None): filename = self.editwin.io.filename if not filename: tkMessageBox.showerror("No file name", "This window has no file name", master=self.editwin.text) return modname, ext = os.path.splitext(os.path.basename(filename)) try: mod = sys.modules[modname] except KeyError: mod = imp.new_module... |
source = self.editwin.text.get("1.0", "end") exec source in mod.__dict__ | mod.__file__ = filename saveout = sys.stdout saveerr = sys.stderr owin = OnDemandOutputWindow(self.editwin.flist) try: sys.stderr = PseudoFile(owin, "stderr") try: sys.stdout = PseudoFile(owin, "stdout") try: if debugger: debugger.run("execfile(%s)" % `filename`, mod.__dict__) else: execfile(filename, mod.__dict__) exc... | def run_module(self, event=None): filename = self.editwin.io.filename if not filename: tkMessageBox.showerror("No file name", "This window has no file name", master=self.editwin.text) return modname, ext = os.path.splitext(os.path.basename(filename)) try: mod = sys.modules[modname] except KeyError: mod = imp.new_module... |
def run_script(self, event=None): | def debug_module_event(self, event): import Debugger debugger = Debugger.Debugger(self) self.run_module_event(event, debugger) def close_debugger(self): | def run_script(self, event=None): pass |
def new_shell(self, event=None): import PyShell pyshell = PyShell.PyShell(self.editwin.flist) pyshell.begin() | def run_script(self, event=None): pass | |
self.check_extension_list() | self.check_extensions_list(self.extensions) | def get_source_files (self): self.check_extension_list() filenames = [] |
if startupinfo == None: startupinfo = STARTUPINFO() if not None in (p2cread, c2pwrite, errwrite): startupinfo.dwFlags |= STARTF_USESTDHANDLES startupinfo.hStdInput = p2cread startupinfo.hStdOutput = c2pwrite startupinfo.hStdError = errwrite | def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite): """Execute program (MS Windows version)""" | |
raise TestFailed, "NotImplemented should have caused TypeErrpr" | raise TestFailed, "NotImplemented should have caused TypeError" | def __add__(self, other): return NotImplemented |
t = threading.Thread(target = self.finish_request, | t = threading.Thread(target = self.process_request_thread, | def process_request(self, request, client_address): """Start a new thread to process the request.""" import threading t = threading.Thread(target = self.finish_request, args = (request, client_address)) t.start() |
exec('def f(a, a): pass') | exec 'def f(a, a): pass' | exec('def f(a, a): pass') |
exec('def f(a = 0, a = 1): pass') | exec 'def f(a = 0, a = 1): pass' | exec('def f(a = 0, a = 1): pass') |
exec('def f(a): global a; a = 1') | exec 'def f(a): global a; a = 1' | exec('def f(a): global a; a = 1') |
return '%s/%s' % (str(self.__num), str(self.__den)) | return '(%s/%s)' % (str(self.__num), str(self.__den)) | def __str__(self): if self.__den == 1: return str(self.__num) else: return '%s/%s' % (str(self.__num), str(self.__den)) |
diff = a - b | diff = Rat(a - b) | def __cmp__(a, b): diff = a - b if diff.__num < 0: return -1 elif diff.__num > 0: return 1 else: return 0 |
11/10 11/10 | (11/10) (11/10) | def test(): '''\ Test function for rat module. The expected output is (module some differences in floating precission): -1 -1 0 0L 0.1 (0.1+0j) [Rat(1,2), Rat(-3,10), Rat(1,25), Rat(1,4)] [Rat(-3,10), Rat(1,25), Rat(1,4), Rat(1,2)] 0 11/10 11/10 1.1 OK 2 1.5 3/2 (1.5+1.5j) 15707963/5000000 2 2 2.0 (2+0j) 4 0 4 1 4 0 ... |
2 1.5 3/2 (1.5+1.5j) 15707963/5000000 | 2 1.5 (3/2) (1.5+1.5j) (15707963/5000000) | def test(): '''\ Test function for rat module. The expected output is (module some differences in floating precission): -1 -1 0 0L 0.1 (0.1+0j) [Rat(1,2), Rat(-3,10), Rat(1,25), Rat(1,4)] [Rat(-3,10), Rat(1,25), Rat(1,4), Rat(1,2)] 0 11/10 11/10 1.1 OK 2 1.5 3/2 (1.5+1.5j) 15707963/5000000 2 2 2.0 (2+0j) 4 0 4 1 4 0 ... |
7/2 1/2 3 4/3 2.82842712475 1 | (7/2) (1/2) 3 (4/3) 2.82842712475 1 | def test(): '''\ Test function for rat module. The expected output is (module some differences in floating precission): -1 -1 0 0L 0.1 (0.1+0j) [Rat(1,2), Rat(-3,10), Rat(1,25), Rat(1,4)] [Rat(-3,10), Rat(1,25), Rat(1,4), Rat(1,2)] 0 11/10 11/10 1.1 OK 2 1.5 3/2 (1.5+1.5j) 15707963/5000000 2 2 2.0 (2+0j) 4 0 4 1 4 0 ... |
3/2 1 1.5 (1.5+0j) 7/2 -1/2 3 3/4 9/4 -1 | (3/2) 1 1.5 (1.5+0j) (7/2) (-1/2) 3 (3/4) (9/4) -1 | def test(): '''\ Test function for rat module. The expected output is (module some differences in floating precission): -1 -1 0 0L 0.1 (0.1+0j) [Rat(1,2), Rat(-3,10), Rat(1,25), Rat(1,4)] [Rat(-3,10), Rat(1,25), Rat(1,4), Rat(1,2)] 0 11/10 11/10 1.1 OK 2 1.5 3/2 (1.5+1.5j) 15707963/5000000 2 2 2.0 (2+0j) 4 0 4 1 4 0 ... |
3 0 9/4 1 1.83711730709 0 | 3 0 (9/4) 1 1.83711730709 0 | def test(): '''\ Test function for rat module. The expected output is (module some differences in floating precission): -1 -1 0 0L 0.1 (0.1+0j) [Rat(1,2), Rat(-3,10), Rat(1,25), Rat(1,4)] [Rat(-3,10), Rat(1,25), Rat(1,4), Rat(1,2)] 0 11/10 11/10 1.1 OK 2 1.5 3/2 (1.5+1.5j) 15707963/5000000 2 2 2.0 (2+0j) 4 0 4 1 4 0 ... |
"[-s regexp] [directory ...]" | "[-x regexp] [directory ...]" | def main(): """Script main program.""" import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'lfqd:x:') except getopt.error, msg: print msg print "usage: python compileall.py [-l] [-f] [-q] [-d destdir] " \ "[-s regexp] [directory ...]" print "-l: don't recurse down" print "-f: force rebuild even if timestamps ar... |
int i; | int i, result; | def visitModule(self, mod): self.emit(""" |
return PyObject_SetAttrString((PyObject*)type, "_attributes", l) >=0; | result = PyObject_SetAttrString((PyObject*)type, "_attributes", l) >= 0; Py_DECREF(l); return result; | def visitModule(self, mod): self.emit(""" |
self.emit("static int initialized;", 0) | def visitModule(self, mod): self.emit(""" | |
SGI and Linux/BSD version.""" | SGI and generic BSD version, for when openpty() fails.""" | def master_open(): """Open pty master and return (master_fd, tty_name). SGI and Linux/BSD version.""" try: import sgi except ImportError: pass else: try: tty_name, master_fd = sgi._getpty(FCNTL.O_RDWR, 0666, 0) except IOError, msg: raise os.error, msg return master_fd, tty_name for x in 'pqrstuvwxyzPQRST': for y in '01... |
master_fd, tty_name = master_open() | try: pid, fd = os.forkpty() except (AttributeError, OSError): pass else: if pid == CHILD: try: os.setsid() except OSError: pass return pid, fd master_fd, slave_fd = openpty() | def fork(): """Fork and make the child a session leader with a controlling terminal. Return (pid, master_fd).""" master_fd, tty_name = master_open() pid = os.fork() if pid == CHILD: # Establish a new session. os.setsid() # Acquire controlling terminal. slave_fd = slave_open(tty_name) os.close(master_fd) # Slave becom... |
slave_fd = slave_open(tty_name) | def fork(): """Fork and make the child a session leader with a controlling terminal. Return (pid, master_fd).""" master_fd, tty_name = master_open() pid = os.fork() if pid == CHILD: # Establish a new session. os.setsid() # Acquire controlling terminal. slave_fd = slave_open(tty_name) os.close(master_fd) # Slave becom... | |
def writen(fd, data): | def _writen(fd, data): | def writen(fd, data): """Write all the data to a descriptor.""" while data != '': n = os.write(fd, data) data = data[n:] |
def read(fd): | def _read(fd): | def read(fd): """Default read function.""" return os.read(fd, 1024) |
def copy(master_fd, master_read=read, stdin_read=read): | def _copy(master_fd, master_read=_read, stdin_read=_read): | def copy(master_fd, master_read=read, stdin_read=read): """Parent copy loop. Copies pty master -> standard output (master_read) standard input -> pty master (stdin_read)""" while 1: rfds, wfds, xfds = select( [master_fd, STDIN_FILENO], [], []) if master_fd in rfds: data = master_read(master_fd) os.write(STDOUT_FILENO, ... |
writen(master_fd, data) | _writen(master_fd, data) | def copy(master_fd, master_read=read, stdin_read=read): """Parent copy loop. Copies pty master -> standard output (master_read) standard input -> pty master (stdin_read)""" while 1: rfds, wfds, xfds = select( [master_fd, STDIN_FILENO], [], []) if master_fd in rfds: data = master_read(master_fd) os.write(STDOUT_FILENO, ... |
"could not extract parameter group: " + `line`) | "could not extract parameter %s for %s: %s" % (attrname, macroname, `line[:100]`)) | def subconvert(line, ofp, table, discards, autoclosing, knownempty, endchar=None): stack = [] while line: if line[0] == endchar and not stack: return line[1:] m = _comment_rx.match(line) if m: text = m.group(1) if text: ofp.write("(COMMENT\n") ofp.write("- %s \n" % encode(text)) ofp.write(")COMMENT\n") ofp.write("-\\n\... |
co.co_firstlineno, co.co_lnotab) | co.co_firstlineno, co.co_lnotab, co.co_freevars, co.co_cellvars) | def replace_paths_in_code(self, co): new_filename = original_filename = os.path.normpath(co.co_filename) for f,r in self.replace_paths: if original_filename.startswith(f): new_filename = r+original_filename[len(f):] break |
pass | def __str__(self): return repr(self) | def _stringify(string): return string |
(repr(self.faultCode), repr(self.faultString)) | (self.faultCode, repr(self.faultString)) | def __repr__(self): return ( "<Fault %s: %s>" % (repr(self.faultCode), repr(self.faultString)) ) |
xmllib.XMLParser.__init__(self) | try: xmllib.XMLParser.__init__(self, accept_utf8=1) except TypeError: xmllib.XMLParser.__init__(self) | def __init__(self, target): import xmllib # lazy subclassing (!) if xmllib.XMLParser not in SlowParser.__bases__: SlowParser.__bases__ = (xmllib.XMLParser,) self.handle_xml = target.xml self.unknown_starttag = target.start self.handle_data = target.data self.unknown_endtag = target.end xmllib.XMLParser.__init__(self) |
messages (start, data, end). Call close to get the resulting | messages (start, data, end). Call close() to get the resulting | def dump_instance(self, value): # check for special wrappers if value.__class__ in WRAPPERS: value.encode(self) else: # store instance attributes as a struct (really?) self.dump_struct(value.__dict__) |
as necessary. | where necessary. | def dumps(params, methodname=None, methodresponse=None, encoding=None): """data [,options] -> marshalled data Convert an argument tuple or a Fault instance to an XML-RPC request (or response, if the methodresponse option is used). In addition to the data object, the following options can be given as keyword arguments... |
self.emit('PyObject_SetAttrString(result, "%s", value);' % a.name, 1) | self.emit('if (PyObject_SetAttrString(result, "%s", value) < 0)' % a.name, 1) self.emit('goto failed;', 2) self.emit('Py_DECREF(value);', 1) | def visitSum(self, sum, name): if is_simple(sum): self.simpleSum(sum, name) return self.func_begin(name) self.emit("switch (o->kind) {", 1) for i in range(len(sum.types)): t = sum.types[i] self.visitConstructor(t, i + 1, name) self.emit("}", 1) for a in sum.attributes: self.emit("value = ast2obj_%s(o->%s);" % (a.type, ... |
('cygwin.*', 'cygwin'), | ('cygwin.*', 'unix'), | def mkpath (self, name, mode=0777): mkpath (name, mode, self.verbose, self.dry_run) |
tests = [Signed_TestCase, Unsigned_TestCase] | tests = [Signed_TestCase, Unsigned_TestCase, Tuple_TestCase] | def test_main(): tests = [Signed_TestCase, Unsigned_TestCase] try: from _testcapi import getargs_L, getargs_K except ImportError: pass # PY_LONG_LONG not available else: tests.append(LongLong_TestCase) test_support.run_unittest(*tests) |
except (Carbon.File.error, ValueError): | except (Carbon.File.Error, ValueError): | def findtemplate(template=None): """Locate the applet template along sys.path""" if MacOS.runtimemodel == 'macho': if template: return template return findtemplate_macho() if not template: template=TEMPLATE for p in sys.path: file = os.path.join(p, template) try: file, d1, d2 = Carbon.File.FSResolveAliasFile(file, 1) b... |
Res.FSCreateResourceFile(destdir, destfile, RESOURCE_FORK_NAME) | Res.FSCreateResourceFile(destdir, unicode(destfile), RESOURCE_FORK_NAME) | def process_common(template, progress, code, rsrcname, destname, is_update, copy_codefragment, raw=0, others=[]): if MacOS.runtimemodel == 'macho': return process_common_macho(template, progress, code, rsrcname, destname, is_update, raw, others) if others: raise BuildError, "Extra files only allowed for MachoPython app... |
dset_fss = Carbon.File.FSSpec(destname) | dest_fss = Carbon.File.FSSpec(destname) | def process_common(template, progress, code, rsrcname, destname, is_update, copy_codefragment, raw=0, others=[]): if MacOS.runtimemodel == 'macho': return process_common_macho(template, progress, code, rsrcname, destname, is_update, raw, others) if others: raise BuildError, "Extra files only allowed for MachoPython app... |
limit = sqrt(n+1) | limit = sqrt(float(n+1)) | def fact(n): if n < 1: raise error # fact() argument should be >= 1 if n == 1: return [] # special case res = [] # Treat even factors special, so we can use i = i+2 later while n%2 == 0: res.append(2) n = n/2 # Try odd numbers up to sqrt(n) limit = sqrt(n+1) i = 3 while i <= limit: if n%i == 0: res.append(i) n = n/i li... |
res.append(n) | if n != 1: res.append(n) | def fact(n): if n < 1: raise error # fact() argument should be >= 1 if n == 1: return [] # special case res = [] # Treat even factors special, so we can use i = i+2 later while n%2 == 0: res.append(2) n = n/2 # Try odd numbers up to sqrt(n) limit = sqrt(n+1) i = 3 while i <= limit: if n%i == 0: res.append(i) n = n/i li... |
exts.append( Extension('MacOS', ['macosmodule.c']) ) exts.append( Extension('icglue', ['icgluemodule.c']) ) exts.append( Extension('macfs', ['macfsmodule.c', '../Python/getapplbycreator.c']) ) exts.append( Extension('_CF', ['cf/_CFmodule.c'], extra_link_args=['-framework', 'CoreFoundation']) ) exts.append( Extension('_... | exts.append( Extension('MacOS', ['macosmodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('icglue', ['icgluemodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('macfs', ['macfsmodule.c', '../Python/getapplbycreator.c'], extra_link_args=['-framework', 'Carbon']) ) e... | def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.insert(0, '/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.insert(0, '/usr/local/include' ) |
exts.append( Extension('Nav', ['Nav.c']) ) exts.append( Extension('_AE', ['ae/_AEmodule.c']) ) exts.append( Extension('_App', ['app/_Appmodule.c']) ) exts.append( Extension('_Cm', ['cm/_Cmmodule.c']) ) exts.append( Extension('_Ctl', ['ctl/_Ctlmodule.c']) ) exts.append( Extension('_Dlg', ['dlg/_Dlgmodule.c']) ) exts.app... | exts.append( Extension('Nav', ['Nav.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_AE', ['ae/_AEmodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_App', ['app/_Appmodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Cm', ['cm/_Cmmodule... | def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.insert(0, '/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.insert(0, '/usr/local/include' ) |
extra_link_args=['-framework', 'QuickTime']) ) | extra_link_args=['-framework', 'QuickTime', '-framework', 'Carbon']) ) | def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.insert(0, '/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.insert(0, '/usr/local/include' ) |
exts.append( Extension('_TE', ['te/_TEmodule.c']) ) | exts.append( Extension('_TE', ['te/_TEmodule.c'], extra_link_args=['-framework', 'Carbon']) ) | def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.insert(0, '/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.insert(0, '/usr/local/include' ) |
exts.append( Extension('_Win', ['win/_Winmodule.c']) ) | exts.append( Extension('_Win', ['win/_Winmodule.c'], extra_link_args=['-framework', 'Carbon']) ) | def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.insert(0, '/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.insert(0, '/usr/local/include' ) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.