rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
self.socket.close() | self.server_close() | def process_request(self, request, client_address): """Fork a new subprocess to process the request.""" self.collect_children() pid = os.fork() if pid: # Parent process if self.active_children is None: self.active_children = [] self.active_children.append(pid) return else: # Child process. # This must never return, hen... |
"""Configure resources of an item. | """Configure resources of an ITEM. | def itemconfigure(self, index, cnf=None, **kw): """Configure resources of an item. |
hasn't been loaded yet). The file is searched on sys.path.""" | hasn't been loaded yet). The file is searched on sys.path; the .py suffix may be omitted.""" | def help_b(self): print """b(reak) ([file:]lineno | function) [, "condition"] |
print """cl(ear) [lineno] | print """cl(ear) [file:][lineno] | def help_cl(self): print """cl(ear) [lineno] |
hasn't been loaded yet). The file is searched on sys.path.""" | hasn't been loaded yet). The file is searched on sys.path; the .py suffix may be omitted.""" | def help_cl(self): print """cl(ear) [lineno] |
Output("static int %s_init(PyObject *self, PyObject *args, PyObject *kwds)", self.prefix) | Output("static int %s_tp_init(PyObject *self, PyObject *args, PyObject *kwds)", self.prefix) | def output_tp_init(self): if self.output_tp_initBody: Output("static int %s_init(PyObject *self, PyObject *args, PyObject *kwds)", self.prefix) OutLbrace() self.output_tp_initBody() OutRbrace() else: Output("#define %s_tp_init 0", self.prefix) Output() |
os.environ.update(env) | 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... | |
if os.path.isabs(curkeyvalue): | if string.lower(curkeyvalue[:10]) == '{compiler}': curkeyvalue = curkeyvalue[10:] self.dict['pathtype'] = 'CodeWarrior' elif string.lower(curkeyvalue[:9]) == '{project}': curkeyvalue = curkeyvalue[9:] self.dict['pathtype'] = 'Project' elif curkeyvalue[0] == '{': raise Error, "Unknown {} escape in %s"%curkeyvalue elif o... | def _generate_one_template(self, tmpl): resultname, datasource, dataname, key = tmpl result = '' if key: # This is a multi-element rule. Run for every item in dict[key] if self.dict.has_key(key): keyvalues = self.dict[key] try: if not type(keyvalues) in (type(()), type([])): raise Error, "List or tuple expected for %s"... |
def yview(self, *what): | def xview_moveto(self, fraction): """Adjusts the view in the window so that FRACTION of the total width of the canvas is off-screen to the left.""" self.tk.call(self._w, 'xview', 'moveto', fraction) def xview_scroll(self, number, what): """Shift the x-view according to NUMBER which is measured in "units" or "pages" (WH... | def yview(self, *what): """Query and change vertical position of the view.""" if not what: return self._getdoubles(self.tk.call(self._w, 'yview')) self.tk.call((self._w, 'yview') + what) |
if not what: | if not args: | def yview(self, *what): """Query and change vertical position of the view.""" if not what: return self._getdoubles(self.tk.call(self._w, 'yview')) self.tk.call((self._w, 'yview') + what) |
self.tk.call((self._w, 'yview') + what) | self.tk.call((self._w, 'yview') + args) def yview_moveto(self, fraction): """Adjusts the view in the window so that FRACTION of the total height of the canvas is off-screen to the top.""" self.tk.call(self._w, 'yview', 'moveto', fraction) def yview_scroll(self, number, what): """Shift the y-view according to NUMBER whi... | def yview(self, *what): """Query and change vertical position of the view.""" if not what: return self._getdoubles(self.tk.call(self._w, 'yview')) self.tk.call((self._w, 'yview') + what) |
self.tabCols=IntVar(self) | 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... | |
orient='horizontal',tickinterval=2,from_=2,to=8) | orient='horizontal',tickinterval=2,from_=2,to=10) | 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... |
self.tabCols.trace_variable('w',self.VarChanged_tabCols) | def AttachVarCallbacks(self): self.fontSize.trace_variable('w',self.VarChanged_fontSize) self.fontName.trace_variable('w',self.VarChanged_fontName) self.fontBold.trace_variable('w',self.VarChanged_fontBold) self.spaceNum.trace_variable('w',self.VarChanged_spaceNum) self.tabCols.trace_variable('w',self.VarChanged_tabCol... | |
def VarChanged_tabCols(self,*params): value=self.tabCols.get() self.AddChangedItem('main','Indent','tab-cols',value) | def VarChanged_tabCols(self,*params): value=self.tabCols.get() self.AddChangedItem('main','Indent','tab-cols',value) | |
if pw: | if pw is not None: | def retry_http_basic_auth(self, host, req, realm): user,pw = self.passwd.find_user_password(realm, host) if pw: raw = "%s:%s" % (user, pw) auth = 'Basic %s' % base64.encodestring(raw).strip() if req.headers.get(self.auth_header, None) == auth: return None req.add_header(self.auth_header, auth) return self.parent.open(r... |
vars, lasttoken, parent, prefix = [], None, None, '' | vars, lasttoken, parent, prefix, value = [], None, None, '', __UNDEF__ | def scanvars(reader, frame, locals): """Scan one logical line of Python and look up values of variables used.""" import tokenize, keyword vars, lasttoken, parent, prefix = [], None, None, '' for ttype, token, start, end, line in tokenize.generate_tokens(reader): if ttype == tokenize.NEWLINE: break if ttype == tokenize.... |
<<<<<<< Vrec.py | def main(): format = SV.RGB8_FRAMES qsize = 2 audio = 0 rate = 2 width = 0 norecord = 0 drop = 0 mono = 0 grey = 0 monotreshold = -1 opts, args = getopt.getopt(sys.argv[1:], 'aq:r:w:ndgmM:') for opt, arg in opts: if opt == '-a': audio = 1 elif opt == '-q': qsize = string.atoi(arg) elif opt == '-r': rate = string.atoi(... | |
======= param = [SV.FIELDDROP, 0] v.SetParam(param) >>>>>>> 1.7 | def main(): format = SV.RGB8_FRAMES qsize = 2 audio = 0 rate = 2 width = 0 norecord = 0 drop = 0 mono = 0 grey = 0 monotreshold = -1 opts, args = getopt.getopt(sys.argv[1:], 'aq:r:w:ndgmM:') for opt, arg in opts: if opt == '-a': audio = 1 elif opt == '-q': qsize = string.atoi(arg) elif opt == '-r': rate = string.atoi(... | |
queue.put(data, int(id*tpf)) | queue.put((data, int(id*tpf))) | def record(v, info, filename, audiofilename, mono, grey, monotreshold): import thread format, x, y, qsize, rate = info fps = 59.64 # Fields per second # XXX (Strange: need fps of Indigo monitor, not of PAL or NTSC!) tpf = 1000.0 / fps # Time per field in msec if filename: vout = VFile.VoutFile().init(filename) if mono:... |
print 'Captured',count*2, 'fields,', 0.1*int(count*20000.0/(t1-t0)), 'f/s', print count*200.0/lastid, '%,', print count*rate*200.0/lastid, '% of wanted rate' | print 'Captured',count*2, 'fields,', print 0.1*int(count*20000.0/(t1-t0)), 'f/s', if lastid: print count*200.0/lastid, '%,', print count*rate*200.0/lastid, '% of wanted rate', print | def record(v, info, filename, audiofilename, mono, grey, monotreshold): import thread format, x, y, qsize, rate = info fps = 59.64 # Fields per second # XXX (Strange: need fps of Indigo monitor, not of PAL or NTSC!) tpf = 1000.0 / fps # Time per field in msec if filename: vout = VFile.VoutFile().init(filename) if mono:... |
print 'ratecv' state = (-8000, ((256, 512),)) if audioop.ratecv(data[0], 1, 1, 8000, 16000, state) != \ ('\001\000\000\001\001\002', state): return 0 | print 'ratecv' state = None d1, state = audioop.ratecv(data[0], 1, 1, 8000, 16000, state) d2, state = audioop.ratecv(data[0], 1, 1, 8000, 16000, state) if d1 + d2 != '\000\000\001\001\002\001\000\000\001\001\002': return 0 | def testratecv(data): if verbose: print 'ratecv' state = (-8000, ((256, 512),)) if audioop.ratecv(data[0], 1, 1, 8000, 16000, state) != \ ('\001\000\000\001\001\002', state): return 0 return 1 |
@contextmanager | @contextfactory | def contextfactory(func): """@contextfactory decorator. Typical usage: @contextmanager def some_generator(<arguments>): <setup> try: yield <value> finally: <cleanup> This makes this: with some_generator(<arguments>) as <variable>: <body> equivalent to this: <setup> try: <variable> = <value> <body> finally: <clean... |
self.extrasize = len(buf) + self.extrasize | self.extrasize = len(self.extrabuf) | def _unread(self, buf): self.extrabuf = buf + self.extrabuf self.extrasize = len(buf) + self.extrasize |
bufs.append(c[:i]) | bufs.append(c[:i+1]) | 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]) self._unread(c[i+1:]) return string.join(bufs, '') bufs.append(c) readsize = readsize * 2 |
return os.path.join(prefix, "include", "python" + sys.version[:3]) | return os.path.join(prefix, "include", "python" + get_python_version()) | def get_python_inc(plat_specific=0, prefix=None): """Return the directory containing installed Python header files. If 'plat_specific' is false (the default), this is the path to the non-platform-specific header files, i.e. Python.h and so on; otherwise, this is the path to platform-specific header files (namely pycon... |
if sys.version < "2.2": | if get_python_version() < "2.2": | def get_python_lib(plat_specific=0, standard_lib=0, prefix=None): """Return the directory containing the Python library (standard or site additions). If 'plat_specific' is true, return the directory containing platform-specific modules, i.e. any module from a non-pure-Python module distribution; otherwise, return the ... |
if sys.version < '2.2': | if get_python_version() < '2.2': | def get_config_h_filename(): """Return full pathname of installed pyconfig.h file.""" if python_build: inc_dir = os.curdir else: inc_dir = get_python_inc(plat_specific=1) if sys.version < '2.2': config_h = 'config.h' else: # The name of the config.h file changed in 2.2 config_h = 'pyconfig.h' return os.path.join(inc_di... |
elif sys.version < '2.1': | elif get_python_version() < '2.1': | 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... |
(linkerscript, PREFIX, sys.version[0:3])) | (linkerscript, PREFIX, get_python_version())) | 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... |
if pass_iso8859: i = i % 128 if 32 <= i <= 126: | if 32 <= (i % mod) <= 126: | def make_escapes(pass_iso8859): global escapes for i in range(256): if pass_iso8859: # Allow iso-8859 characters to pass through so that e.g. 'msgid # "Hhe"' would result not result in 'msgid "H\366he"'. Otherwise # we escape any character outside the 32..126 range. i = i % 128 if 32 <= i <= 126: escapes.append(chr(i)... |
make_escapes(options.escapes) | make_escapes(options.escape) | def main(): default_keywords = ['_'] try: opts, args = getopt.getopt( sys.argv[1:], 'ad:Ehk:n:o:p:Vvw:x:', ['extract-all', 'default-domain', 'escape', 'help', 'keyword', 'add-location', 'no-location', 'output=', 'output-dir=', 'verbose', 'version', 'width=', 'exclude-file=', ]) except getopt.error, msg: usage(1, msg) ... |
mainname = os.path.basename(self.mainprogram) self.files.append((self.mainprogram, pathjoin(resdir, mainname))) mainprogram = self.mainprogram | mainprogram = os.path.basename(self.mainprogram) self.files.append((self.mainprogram, pathjoin(resdir, mainprogram))) | def preProcess(self): resdir = "Contents/Resources" if self.executable is not None: if self.mainprogram is None: execname = self.name else: execname = os.path.basename(self.executable) execpath = pathjoin(self.execdir, execname) if not self.symlink_exec: self.files.append((self.executable, execpath)) self.binaries.appe... |
mainwrapperpath = pathjoin(execdir, self.name) | bootstrappath = pathjoin(execdir, self.name) | def preProcess(self): resdir = "Contents/Resources" if self.executable is not None: if self.mainprogram is None: execname = self.name else: execname = os.path.basename(self.executable) execpath = pathjoin(self.execdir, execname) if not self.symlink_exec: self.files.append((self.executable, execpath)) self.binaries.appe... |
open(mainwrapperpath, "w").write(BOOTSTRAP_SCRIPT % locals()) os.chmod(mainwrapperpath, 0775) | open(bootstrappath, "w").write(BOOTSTRAP_SCRIPT % locals()) os.chmod(bootstrappath, 0775) | def preProcess(self): resdir = "Contents/Resources" if self.executable is not None: if self.mainprogram is None: execname = self.name else: execname = os.path.basename(self.executable) execpath = pathjoin(self.execdir, execname) if not self.symlink_exec: self.files.append((self.executable, execpath)) self.binaries.appe... |
id(data), | id(data)+12, | def mk16pixmap(w, h, data): """kludge a pixmap together""" rv = struct.pack("lhhhhhhhlllhhhhlll", id(data), w*2 + 0x8000, 0, 0, h, w, 0, 0, 0, # XXXX? 72<<16, 72<<16, 16, 16, # XXXX 3, 5, 0, 0, 0) print 'Our pixmap, size %d:'%len(rv) dumppixmap(rv) return Qd.RawBitMap(rv) |
currect, QuickDraw.srcCopy, None) | currect, QuickDraw.srcCopy+QuickDraw.ditherCopy, None) | def do_update(self, *args): pass currect = self.fitrect() print 'PICT:', self.pictrect print 'WIND:', currect print 'ARGS:', (self.pixmap, self.wid.GetWindowPort().portBits, self.pictrect, currect, QuickDraw.srcCopy, None) self.info() Qd.CopyBits(self.pixmap, self.wid.GetWindowPort().portBits, self.pictrect, currect, Q... |
def serve(rcvr, hdlr): server = rcvr(handler=hdlr) | def serve(rcvr, hdlr, port): server = rcvr(port=port, handler=hdlr) | def serve(rcvr, hdlr): server = rcvr(handler=hdlr) global _listener logging._acquireLock() _listener = server logging._releaseLock() server.serve_until_stopped() |
return threading.Thread(target=serve, args=(ConfigSocketReceiver, ConfigStreamHandler)) | return threading.Thread(target=serve, args=(ConfigSocketReceiver, ConfigStreamHandler, port)) | def serve(rcvr, hdlr): server = rcvr(handler=hdlr) global _listener logging._acquireLock() _listener = server logging._releaseLock() server.serve_until_stopped() |
self.Bindings.default_keydefs=idleConf.GetCurrentKeySet() keydefs = self.Bindings.default_keydefs | self.Bindings.default_keydefs = keydefs = idleConf.GetCurrentKeySet() | def RemoveKeybindings(self): "Remove the keybindings before they are changed." # Called from configDialog.py self.Bindings.default_keydefs=idleConf.GetCurrentKeySet() keydefs = self.Bindings.default_keydefs for event, keylist in keydefs.items(): self.text.event_delete(event, *keylist) for extensionName in self.get_stan... |
keydefs = idleConf.GetExtensionBindings(extensionName) if keydefs: for event, keylist in keydefs.items(): | xkeydefs = idleConf.GetExtensionBindings(extensionName) if xkeydefs: for event, keylist in xkeydefs.items(): | def RemoveKeybindings(self): "Remove the keybindings before they are changed." # Called from configDialog.py self.Bindings.default_keydefs=idleConf.GetCurrentKeySet() keydefs = self.Bindings.default_keydefs for event, keylist in keydefs.items(): self.text.event_delete(event, *keylist) for extensionName in self.get_stan... |
self.Bindings.default_keydefs=idleConf.GetCurrentKeySet() | self.Bindings.default_keydefs = keydefs = idleConf.GetCurrentKeySet() | def ApplyKeybindings(self): "Update the keybindings after they are changed" # Called from configDialog.py self.Bindings.default_keydefs=idleConf.GetCurrentKeySet() self.apply_bindings() for extensionName in self.get_standard_extension_names(): keydefs = idleConf.GetExtensionBindings(extensionName) if keydefs: self.appl... |
keydefs = idleConf.GetExtensionBindings(extensionName) if keydefs: self.apply_bindings(keydefs) | xkeydefs = idleConf.GetExtensionBindings(extensionName) if xkeydefs: self.apply_bindings(xkeydefs) | def ApplyKeybindings(self): "Update the keybindings after they are changed" # Called from configDialog.py self.Bindings.default_keydefs=idleConf.GetCurrentKeySet() self.apply_bindings() for extensionName in self.get_standard_extension_names(): keydefs = idleConf.GetExtensionBindings(extensionName) if keydefs: self.appl... |
"""Basic (multiple values per field) form content as dictionary. | """Form content as dictionary with a list of values per field. | def make_file(self, binary=None): """Overridable: return a readable & writable file. |
"""Strict single-value expecting form content as dictionary. IF you only expect a single value for each field, then form[key] | """Form content as dictionary expecting a single value per field. If you only expect a single value for each field, then form[key] | def __init__(self, environ=os.environ): self.dict = self.data = parse(environ=environ) self.query_string = environ['QUERY_STRING'] |
that expectation is not true. IF you expect a field to have | that expectation is not true. If you expect a field to have | def __init__(self, environ=os.environ): self.dict = self.data = parse(environ=environ) self.query_string = environ['QUERY_STRING'] |
lis = [] for each in self.dict.values(): if len( each ) == 1 : lis.append(each[0]) else: lis.append(each) return lis | result = [] for value in self.dict.values(): if len(value) == 1: result.append(value[0]) else: result.append(value) return result | def values(self): lis = [] for each in self.dict.values(): if len( each ) == 1 : lis.append(each[0]) else: lis.append(each) return lis |
lis = [] for key,value in self.dict.items(): if len(value) == 1 : lis.append((key, value[0])) else: lis.append((key, value)) return lis | result = [] for key, value in self.dict.items(): if len(value) == 1: result.append((key, value[0])) else: result.append((key, value)) return result | def items(self): lis = [] for key,value in self.dict.items(): if len(value) == 1 : lis.append((key, value[0])) else: lis.append((key, value)) return lis |
def values( self ): lis = [] | def values(self): result = [] | def values( self ): lis = [] for key in self.keys(): try: lis.append( self[key] ) except IndexError: lis.append( self.dict[key] ) return lis |
lis.append( self[key] ) | result.append(self[key]) | def values( self ): lis = [] for key in self.keys(): try: lis.append( self[key] ) except IndexError: lis.append( self.dict[key] ) return lis |
lis.append( self.dict[key] ) return lis def items( self ): lis = [] | result.append(self.dict[key]) return result def items(self): result = [] | def values( self ): lis = [] for key in self.keys(): try: lis.append( self[key] ) except IndexError: lis.append( self.dict[key] ) return lis |
lis.append( (key, self[key]) ) | result.append((key, self[key])) | def items( self ): lis = [] for key in self.keys(): try: lis.append( (key, self[key]) ) except IndexError: lis.append( (key, self.dict[key]) ) return lis |
lis.append( (key, self.dict[key]) ) return lis | result.append((key, self.dict[key])) return result | def items( self ): lis = [] for key in self.keys(): try: lis.append( (key, self[key]) ) except IndexError: lis.append( (key, self.dict[key]) ) return lis |
print_directory() print_arguments() | def test(environ=os.environ): """Robust test CGI script, usable as main program. Write minimal HTTP headers and dump all information provided to the script in HTML form. """ import traceback print "Content-type: text/html" print sys.stderr = sys.stdout try: form = FieldStorage() # Replace with other classes to test... | |
print_directory() print_arguments() | def g(f=f): f() | |
SetDialogItemText(text_h, "Progress...") | SetDialogItemText(text_h, label) | def __init__(self, label="Working...", maxval=100): self.label = label self.maxval = maxval self.curval = -1 self.d = GetNewDialog(259, -1) tp, text_h, rect = self.d.GetDialogItem(2) SetDialogItemText(text_h, "Progress...") self._update(0) |
Qd.PaintRect(inner_rect) l, t, r, b = inner_rect r = int(l + (r-l)*value/self.maxval) inner_rect = l, t, r, b Qd.ForeColor(QuickDraw.blackColor) Qd.BackColor(QuickDraw.blackColor) Qd.PaintRect(inner_rect) | Qd.PaintRect((int(l + (r-l)*value/self.maxval), t, r, b)) | def _update(self, value): tp, h, bar_rect = self.d.GetDialogItem(3) Qd.SetPort(self.d) Qd.FrameRect(bar_rect) # Draw outline inner_rect = Qd.InsetRect(bar_rect, 1, 1) Qd.ForeColor(QuickDraw.whiteColor) Qd.BackColor(QuickDraw.whiteColor) Qd.PaintRect(inner_rect) # Clear internal l, t, r, b = inner_rect r = int(l + (r... |
if __name__ == "__main__": | def test_main(): | def get_file(): return __file__ |
attrs.getQNames() == [] and \ | (attrs.getQNames() == [] or attrs.getQNames() == ["ns:attr"]) and \ | def test_expat_nsattrs_wattr(): parser = create_parser(1) gather = AttrGatherer() parser.setContentHandler(gather) parser.feed("<doc xmlns:ns='%s' ns:attr='val'/>" % ns_uri) parser.close() attrs = gather._attrs return attrs.getLength() == 1 and \ attrs.getNames() == [(ns_uri, "attr")] and \ attrs.getQNames() == [] a... |
import sys, traceback | import traceback | def _run_exitfuncs(): """run any registered exit functions _exithandlers is traversed in reverse order so functions are executed last in, first out. """ exc_info = None while _exithandlers: func, targs, kargs = _exithandlers.pop() try: func(*targs, **kargs) except SystemExit: exc_info = sys.exc_info() except: import ... |
import sys | def register(func, *targs, **kargs): """register a function to be executed upon normal program termination func - function to be called at exit targs - optional arguments to pass to func kargs - optional keyword arguments to pass to func """ _exithandlers.append((func, targs, kargs)) | |
del sys | def register(func, *targs, **kargs): """register a function to be executed upon normal program termination func - function to be called at exit targs - optional arguments to pass to func kargs - optional keyword arguments to pass to func """ _exithandlers.append((func, targs, kargs)) | |
def check_module_event(self, event): | def check_module_event(self, event=None): | def check_module_event(self, event): filename = self.getfilename() if not filename: return if not self.tabnanny(filename): return self.checksyntax(filename) |
filename = self.getfilename() if not filename: return if not self.tabnanny(filename): return code = self.checksyntax(filename) | code = self.check_module_event(event) | def run_module_event(self, event): """Run the module after setting up the environment. |
self.saved_dbc_key = c.current(0,0,0)[0] | try: self.saved_dbc_key = c.current(0,0,0)[0] except db.DBError: pass | def _closeCursors(self, save=1): if self.dbc: c = self.dbc self.dbc = None if save: self.saved_dbc_key = c.current(0,0,0)[0] c.close() del c for cref in self._cursor_refs.values(): c = cref() if c is not None: c.close() |
self.reset() | def feed(self, data, isFinal = 0): if not self._parsing: self._parsing = 1 self.reset() self._cont_handler.startDocument() | |
import difflib a = expected.splitlines() b = output.splitlines() | a = expected.splitlines(1) b = output.splitlines(1) | def reportdiff(expected, output): print "*" * 70 import difflib a = expected.splitlines() b = output.splitlines() sm = difflib.SequenceMatcher(a=a, b=b) tuples = sm.get_opcodes() def pair(x0, x1): x0 += 1 if x0 >= x1: return str(x0) else: return "%d,%d" % (x0, x1) for op, a0, a1, b0, b1 in tuples: if op == 'equal': pas... |
return str(x0) else: return "%d,%d" % (x0, x1) | return "line " + str(x0) else: return "lines %d-%d" % (x0, x1) | def pair(x0, x1): x0 += 1 if x0 >= x1: return str(x0) else: return "%d,%d" % (x0, x1) |
print pair(a0, a1) + "d" + pair(b0, b1) | print "***", pair(a0, a1), "of expected output missing:" | def pair(x0, x1): x0 += 1 if x0 >= x1: return str(x0) else: return "%d,%d" % (x0, x1) |
print "<", line | print "-", line, | def pair(x0, x1): x0 += 1 if x0 >= x1: return str(x0) else: return "%d,%d" % (x0, x1) |
print pair(a0, a1) + "c" + pair(b0, b1) for line in a[a0:a1]: print "<", line print "---" | print "*** mismatch between", pair(a0, a1), "of expected", \ "output and", pair(b0, b1), "of actual output:" for line in difflib.ndiff(a[a0:a1], b[b0:b1]): print line, elif op == 'insert': print "***", pair(b0, b1), "of actual output doesn't appear", \ "in expected output after line", str(a1)+":" | def pair(x0, x1): x0 += 1 if x0 >= x1: return str(x0) else: return "%d,%d" % (x0, x1) |
print ">", line elif op == 'insert': print str(a0) + "a" + pair(b0, b1) for line in b[b0:b1]: print ">", line | print "+", line, | def pair(x0, x1): x0 += 1 if x0 >= x1: return str(x0) else: return "%d,%d" % (x0, x1) |
try: del sys.modules[modname] except KeyError: pass | def check_all(modname): names = {} try: exec "import %s" % modname in names except ImportError: # silent fail here seems the best route since some modules # may not be available in all environments return verify(hasattr(sys.modules[modname], "__all__"), "%s has no __all__ attribute" % modname) names = {} exec "from %s ... | |
def basic_test_inplace_repeat(self, size): l = [''] l *= size self.assertEquals(len(l), size) self.failUnless(l[0] is l[-1]) del l l = [''] * size l *= 2 self.assertEquals(len(l), size * 2) self.failUnless(l[size - 1] is l[-1]) @bigmemtest(minsize=_2G // 2 + 2, memuse=16) def test_inplace_repeat_small(self, size): re... | def test_repeat_large(self, size): return self.basic_test_repeat(size) | |
@bigmemtest(minsize=_2G // 2 + 2, memuse=8) | @bigmemtest(minsize=_2G // 2 + 2, memuse=16) | def basic_test_extend(self, size): l = [file] * size l.extend(l) self.assertEquals(len(l), size * 2) self.failUnless(l[0] is l[-1]) self.failUnless(l[size - 1] is l[size + 1]) |
@bigmemtest(minsize=_2G + 2, memuse=8) | @bigmemtest(minsize=_2G + 2, memuse=16) | def test_extend_small(self, size): return self.basic_test_extend(size) |
if co_filename in ('rpc.py', '<string>'): | if co_filename in (r'.\rpc.py', 'rpc.py','<string>'): | def user_line(self, frame): # get the currently executing function ##print>>sys.__stderr__, "*function: ", frame.f_code.co_name ##print>>sys.__stderr__, "*file: ", frame.f_code.co_filename ##print>>sys.__stderr__, "*line number: ", frame.f_code.co_firstlineno co_filename = frame.f_code.co_filename co_name = frame.f_cod... |
return WeakValuedItemIterator(self) | for wr in self.data.itervalues(): value = wr() if value is not None: yield wr.key, value | def iteritems(self): return WeakValuedItemIterator(self) |
__iter__ = iterkeys | def __iter__(self): return self.data.iterkeys() | def iterkeys(self): return self.data.iterkeys() |
return WeakValuedValueIterator(self) | for wr in self.data.itervalues(): obj = wr() if obj is not None: yield obj | def itervalues(self): return WeakValuedValueIterator(self) |
return WeakKeyedItemIterator(self) | for wr, value in self.data.iteritems(): key = wr() if key is not None: yield key, value | def iteritems(self): return WeakKeyedItemIterator(self) |
return WeakKeyedKeyIterator(self) __iter__ = iterkeys | for wr in self.data.iterkeys(): obj = wr() if obj is not None: yield obj def __iter__(self): return self.iterkeys() | def iterkeys(self): return WeakKeyedKeyIterator(self) |
def WeakKeyedKeyIterator(weakdict): for wr in weakdict.data.iterkeys(): obj = wr() if obj is not None: yield obj def WeakKeyedItemIterator(weakdict): for wr, value in weakdict.data.iteritems(): key = wr() if key is not None: yield key, value def WeakValuedValueIterator(weakdict): for wr in weakdict.data.itervalues():... | def update(self, dict=None, **kwargs): d = self.data if dict is not None: if not hasattr(dict, "items"): dict = type({})(dict) for key, value in dict.items(): d[ref(key, self._remove)] = value if len(kwargs): self.update(kwargs) | |
self.assertEqual(p.stderr.read(), "strawberry") | self.assertEqual(remove_stderr_debug_decorations(p.stderr.read()), "strawberry") | def test_stderr_pipe(self): # stderr redirection p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("strawberry")'], stderr=subprocess.PIPE) self.assertEqual(p.stderr.read(), "strawberry") |
self.assertEqual(os.read(d, 1024), "strawberry") | self.assertEqual(remove_stderr_debug_decorations(os.read(d, 1024)), "strawberry") | def test_stderr_filedes(self): # stderr is set to open file descriptor tf = tempfile.TemporaryFile() d = tf.fileno() p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("strawberry")'], stderr=d) p.wait() os.lseek(d, 0, 0) self.assertEqual(os.read(d, 1024), "strawberry") |
self.assertEqual(tf.read(), "strawberry") | self.assertEqual(remove_stderr_debug_decorations(tf.read()), "strawberry") | def test_stderr_fileobj(self): # stderr is set to open file object tf = tempfile.TemporaryFile() p = subprocess.Popen([sys.executable, "-c", 'import sys; sys.stderr.write("strawberry")'], stderr=tf) p.wait() tf.seek(0) self.assertEqual(tf.read(), "strawberry") |
self.assertEqual(p.stdout.read(), "appleorange") | output = p.stdout.read() stripped = remove_stderr_debug_decorations(output) self.assertEqual(stripped, "appleorange") | def test_stdout_stderr_pipe(self): # capture stdout and stderr to the same pipe p = subprocess.Popen([sys.executable, "-c", 'import sys;' \ 'sys.stdout.write("apple");' \ 'sys.stdout.flush();' \ 'sys.stderr.write("orange")'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) self.assertEqual(p.stdout.read(), "appleoran... |
self.assertEqual(tf.read(), "appleorange") | output = tf.read() stripped = remove_stderr_debug_decorations(output) self.assertEqual(stripped, "appleorange") | def test_stdout_stderr_file(self): # capture stdout and stderr to the same open file tf = tempfile.TemporaryFile() p = subprocess.Popen([sys.executable, "-c", 'import sys;' \ 'sys.stdout.write("apple");' \ 'sys.stdout.flush();' \ 'sys.stderr.write("orange")'], stdout=tf, stderr=tf) p.wait() tf.seek(0) self.assertEqual(... |
self.assertEqual(stderr, "pineapple") | self.assertEqual(remove_stderr_debug_decorations(stderr), "pineapple") | def test_communicate(self): p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' \ 'sys.stderr.write("pineapple");' \ 'sys.stdout.write(sys.stdin.read())'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (stdout, stderr) = p.communicate("banana") self.assertEqual(stdout, "banana") self.a... |
self.assertEqual(stderr, "") | self.assertEqual(remove_stderr_debug_decorations(stderr), "") | def test_writes_before_communicate(self): # stdin.write before communicate() p = subprocess.Popen([sys.executable, "-c", 'import sys,os;' \ 'sys.stdout.write(sys.stdin.read())'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) p.stdin.write("banana") (stdout, stderr) = p.communicate("split") self... |
UserDict.UserDict.__init__(self, *args, **kw) | def __init__(self, *args, **kw): UserDict.UserDict.__init__(self, *args, **kw) def remove(wr, selfref=ref(self)): self = selfref() if self is not None: del self.data[wr.key] self._remove = remove | |
self.min_readsize = 64 | def __init__(self, filename=None, mode=None, compresslevel=9, fileobj=None): """Constructor for the GzipFile class. | |
if size < 0: size = sys.maxint readsize = self.min_readsize else: readsize = size bufs = "" | if size < 0: size = sys.maxint bufs = [] readsize = min(100, size) | def readline(self, size=-1): if size < 0: size = sys.maxint # Line can be as long as maxint readsize = self.min_readsize # Read from file in small chunks else: readsize = size # Only read in as much as specified |
if size == 0: return bufs | if size == 0: return "".join(bufs) | def readline(self, size=-1): if size < 0: size = sys.maxint # Line can be as long as maxint readsize = self.min_readsize # Read from file in small chunks else: readsize = size # Only read in as much as specified |
if size is not None: if i==-1 and len(c) > size: i=size-1 elif size <= i: i = size -1 | def readline(self, size=-1): if size < 0: size = sys.maxint # Line can be as long as maxint readsize = self.min_readsize # Read from file in small chunks else: readsize = size # Only read in as much as specified | |
if size <= i: i = size - 1 self._unread(c[i+1:]) return bufs + c[:i+1] else: if len(c) > size: i = size - 1 bufs = bufs + c size = size - len(c) readsize = min(size, int(readsize * 1.1)) if readsize > self.min_readsize: self.min_readsize = readsize | bufs.append(c[:i+1]) self._unread(c[i+1:]) return ''.join(bufs) bufs.append(c) size = size - len(c) readsize = min(size, readsize * 2) | def readline(self, size=-1): if size < 0: size = sys.maxint # Line can be as long as maxint readsize = self.min_readsize # Read from file in small chunks else: readsize = size # Only read in as much as specified |
libraries, extradirs, extraexportsymbols) | libraries, extradirs, extraexportsymbols, outputdir) | def genpluginproject(architecture, module, project=None, projectdir=None, sources=[], sourcedirs=[], libraries=[], extradirs=[], extraexportsymbols=[], outputdir=":::Lib:lib-dynload"): if architecture == "all": # For the time being we generate two project files. Not as nice as # a single multitarget project, but easier... |
genpluginproject("ppc", "Icn", libraries=["IconServicesLib"]) | genpluginproject("ppc", "Icn", libraries=["IconServicesLib"], outputdir="::Lib:Carbon") | def genpluginproject(architecture, module, project=None, projectdir=None, sources=[], sourcedirs=[], libraries=[], extradirs=[], extraexportsymbols=[], outputdir=":::Lib:lib-dynload"): if architecture == "all": # For the time being we generate two project files. Not as nice as # a single multitarget project, but easier... |
print x return x | def __del__(self): x = self.ref() print x return x | |
waste = self.rfile.read(1) | if not self.rfile.read(1): break | 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.