rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
self.rpcpid = os.spawnv(os.P_NOWAIT, args[0], args) | self.rpcpid = os.spawnv(os.P_NOWAIT, sys.executable, args) | def spawn_subprocess(self): args = self.subprocess_arglist self.rpcpid = os.spawnv(os.P_NOWAIT, args[0], args) |
return [sys.executable] + w + ["-c", command, str(self.port)] | if sys.platform[:3] == 'win' and ' ' in sys.executable: decorated_exec = '"%s"' % sys.executable else: decorated_exec = sys.executable return [decorated_exec] + w + ["-c", command, str(self.port)] | def build_subprocess_arglist(self): w = ['-W' + s for s in sys.warnoptions] # Maybe IDLE is installed and is being accessed via sys.path, # or maybe it's not installed and the idle.py script is being # run from the IDLE source directory. del_exitf = idleConf.GetOption('main', 'General', 'delete-exitfunc', default=False... |
curses_libs = ['curses', 'termcap'] | curses_libs = ['curses'] | def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') |
if os.path.exists(filename) or hasattr(getmodule(object), '__loader__'): | if os.path.exists(filename): return filename if filename[:1]!='<' and hasattr(getmodule(object), '__loader__'): | def getsourcefile(object): """Return the Python source file an object was defined in, if it exists.""" filename = getfile(object) if string.lower(filename[-4:]) in ('.pyc', '.pyo'): filename = filename[:-4] + '.py' for suffix, mode, kind in imp.get_suffixes(): if 'b' in mode and string.lower(filename[-len(suffix):]) ==... |
a.pop() | x = a.pop() if x != 'e': raise TestFailed, "array(%s) pop-test" % `type` | def testtype(type, example): a = array.array(type) a.append(example) if verbose: print 40*'*' print 'array after append: ', a a.typecode a.itemsize if a.typecode in ('i', 'b', 'h', 'l'): a.byteswap() if a.typecode == 'c': f = open(TESTFN, "w") f.write("The quick brown fox jumps over the lazy dog.\n") f.close() f = op... |
a.pop() | x = a.pop() if x != 5: raise TestFailed, "array(%s) pop-test" % `type` | def testtype(type, example): a = array.array(type) a.append(example) if verbose: print 40*'*' print 'array after append: ', a a.typecode a.itemsize if a.typecode in ('i', 'b', 'h', 'l'): a.byteswap() if a.typecode == 'c': f = open(TESTFN, "w") f.write("The quick brown fox jumps over the lazy dog.\n") f.close() f = op... |
r'(?P<header>[-\w_.*,(){} ]+)' | r'(?P<header>[^]]+)' | def remove_section(self, section): """Remove a file section.""" if self.__sections.has_key(section): del self.__sections[section] return 1 else: return 0 |
if not str: | if not s: | def decode(in_file, out_file=None, mode=None): """Decode uuencoded file""" # # Open the input file, if needed. # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): in_file = open(in_file) # # Read until a begin is encountered or we've exhausted the file # while 1: hdr = in_file.readline() if not hdr... |
if platform_specific: | if plat_specific: | 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 ... |
def __init__(self, environ=os.environ): self.dict = self.data = parse(environ=environ) | def __init__(self, environ=os.environ, keep_blank_values=0, strict_parsing=0): self.dict = self.data = parse(environ=environ, keep_blank_values=keep_blank_values, strict_parsing=strict_parsing) | def __init__(self, environ=os.environ): self.dict = self.data = parse(environ=environ) self.query_string = environ['QUERY_STRING'] |
if not grouping:return s | if not grouping:return (s, 0) | def _group(s): conv=localeconv() grouping=conv['grouping'] if not grouping:return s result="" seps = 0 spaces = "" if s[-1] == ' ': sp = s.find(' ') spaces = s[sp:] s = s[:sp] while s and grouping: # if grouping is -1, we are done if grouping[0]==CHAR_MAX: break # 0: re-use last group ad infinitum elif grouping[0]!=0: ... |
event = self.getevent(mask, wait) if event: | ok, event = self.getevent(mask, wait) if IsDialogEvent(event): if self.do_dialogevent(event): return if ok: | def do1event(self, mask = everyEvent, wait = 0): event = self.getevent(mask, wait) if event: self.dispatch(event) |
if ok: return event else: return None | return ok, event | def getevent(self, mask = everyEvent, wait = 0): ok, event = WaitNextEvent(mask, wait) if ok: return event else: return None |
if IsDialogEvent(event): self.do_dialogevent(event) return | def dispatch(self, event): if IsDialogEvent(event): self.do_dialogevent(event) return (what, message, when, where, modifiers) = event if eventname.has_key(what): name = "do_" + eventname[what] else: name = "do_%d" % what try: handler = getattr(self, name) except AttributeError: handler = self.do_unknownevent handler(ev... | |
window.do_itemhit(item, event) | self._windows[window].do_itemhit(item, event) | def do_dialogevent(self, event): gotone, window, item = DialogSelect(event) if gotone: if self._windows.has_key(window): window.do_itemhit(item, event) else: print 'Dialog event for unknown dialog' |
self.wid.DisposeDialog() | def close(self): self.wid.DisposeDialog() self.do_postclose() | |
iv = (float(i)/float(maxi-1))-0.5 | if maxi = 1: iv = 0 else: iv = (float(i)/float(maxi-1))-0.5 | def initcmap(ybits,ibits,qbits,chrompack): if ybits+ibits+qbits > 11: raise 'Sorry, 11 bits max' maxy = pow(2,ybits) maxi = pow(2,ibits) maxq = pow(2,qbits) for i in range(2048,4096-256): mapcolor(i, 0, 255, 0) for y in range(maxy): yv = float(y)/float(maxy-1) for i in range(maxi): iv = (float(i)/float(maxi-1))-0.5 for... |
qv = (float(q)/float(maxq-1))-0.5 | if maxq = 1: qv = 0 else: qv = (float(q)/float(maxq-1))-0.5 | def initcmap(ybits,ibits,qbits,chrompack): if ybits+ibits+qbits > 11: raise 'Sorry, 11 bits max' maxy = pow(2,ybits) maxi = pow(2,ibits) maxq = pow(2,qbits) for i in range(2048,4096-256): mapcolor(i, 0, 255, 0) for y in range(maxy): yv = float(y)/float(maxy-1) for i in range(maxi): iv = (float(i)/float(maxi-1))-0.5 for... |
assert len(a) == 1 | vereq(len(a), 1) | def __init__(self, *a, **kw): if a: assert len(a) == 1 self.state = a[0] if kw: for k, v in kw.items(): self[v] = k |
assert isinstance(key, type(0)) | verify(isinstance(key, type(0))) | def __setitem__(self, key, value): assert isinstance(key, type(0)) dict.__setitem__(self, key, value) |
assert x.__class__ == a.__class__ assert sorteditems(x.__dict__) == sorteditems(a.__dict__) assert y.__class__ == b.__class__ assert sorteditems(y.__dict__) == sorteditems(b.__dict__) assert `x` == `a` assert `y` == `b` | vereq(x.__class__, a.__class__) vereq(sorteditems(x.__dict__), sorteditems(a.__dict__)) vereq(y.__class__, b.__class__) vereq(sorteditems(y.__dict__), sorteditems(b.__dict__)) vereq(`x`, `a`) vereq(`y`, `b`) | def __repr__(self): return "C2(%r, %r)<%r>" % (self.a, self.b, int(self)) |
return self.socket.recvfrom(self.max_packet_size) | data, client_addr = self.socket.recvfrom(self.max_packet_size) return (data, self.socket), client_addr def server_activate(self): pass | def get_request(self): return self.socket.recvfrom(self.max_packet_size) |
unsigned int uiValue; | Py_UCS4 value; | typedef struct |
except ValueError: pass else: raise TestFailed, "int(%s)" % `s[1:]` + " should raise ValueError" | except: raise TestFailed, "int(%s)" % `s[1:]` + " should return long" | def f(): pass |
try: int('1' * 512) except ValueError: pass else: raise TestFailed("int('1' * 512) didn't raise ValueError") | try: int('1' * 600) except: raise TestFailed("int('1' * 600) didn't return long") if have_unicode: try: int(unichr(0x661) * 600) except: raise TestFailed("int('\\u0661' * 600) didn't return long") | def f(): pass |
elif type( item )==StringType: | elif type( item ) in [StringType, UnicodeType]: | def _getName( item, nameFromNum ): "Helper function -- don't use it directly" if type( item ) == IntType: try: keyname = nameFromNum( item ) except (WindowsError, EnvironmentError): raise IndexError, item elif type( item )==StringType: keyname=item else: raise exceptions.TypeError, \ "Requires integer index or string ... |
if type( data )==StringType: | if type( data ) in [StringType, UnicodeType]: | def setValue( self, valname, data, regtype=None ): "Set a data value's data (and optionally type)" if regtype: typeint=regtype.intval else: if type( data )==StringType: typeint=_winreg.REG_SZ elif type( data )==IntType: typeint=_winreg.REG_DWORD elif type( data )==array.ArrayType: typeint=_winreg.REG_BINARY data=data.t... |
data=data.tostring() | def setValue( self, valname, data, regtype=None ): "Set a data value's data (and optionally type)" if regtype: typeint=regtype.intval else: if type( data )==StringType: typeint=_winreg.REG_SZ elif type( data )==IntType: typeint=_winreg.REG_DWORD elif type( data )==array.ArrayType: typeint=_winreg.REG_BINARY data=data.t... | |
def _monthcalendar(year, month): | def monthcalendar(year, month): | def _monthcalendar(year, month): """Return a matrix representing a month's calendar. Each row represents a week; days outside this month are zero.""" day1, ndays = monthrange(year, month) rows = [] r7 = range(7) day = 1 - day1 while day <= ndays: row = [0, 0, 0, 0, 0, 0, 0] for i in r7: if 1 <= day <= ndays: row[i] = d... |
day = 1 - day1 | day = (_firstweekday - day1 + 6) % 7 - 5 | def _monthcalendar(year, month): """Return a matrix representing a month's calendar. Each row represents a week; days outside this month are zero.""" day1, ndays = monthrange(year, month) rows = [] r7 = range(7) day = 1 - day1 while day <= ndays: row = [0, 0, 0, 0, 0, 0, 0] for i in r7: if 1 <= day <= ndays: row[i] = d... |
_mc_cache = {} def monthcalendar(year, month): """Caching interface to _monthcalendar.""" key = (year, month) if _mc_cache.has_key(key): return _mc_cache[key] else: _mc_cache[key] = ret = _monthcalendar(year, month) return ret | def _monthcalendar(year, month): """Return a matrix representing a month's calendar. Each row represents a week; days outside this month are zero.""" day1, ndays = monthrange(year, month) rows = [] r7 = range(7) day = 1 - day1 while day <= ndays: row = [0, 0, 0, 0, 0, 0, 0] for i in r7: if 1 <= day <= ndays: row[i] = d... | |
def prweek(week, width): | def prweek(theweek, width): | def _center(str, width): """Center a string in a field.""" n = width - len(str) if n <= 0: return str return ' '*((n+1)/2) + str + ' '*((n)/2) |
for day in week: if day == 0: s = '' else: s = `day` print _center(s, width), | print week(theweek, width), def week(theweek, width): """Returns a single week in a string (no newline).""" days = [] for day in theweek: if day == 0: s = '' else: s = '%2i' % day days.append(_center(s, width)) return ' '.join(days) | def prweek(week, width): """Print a single week (no newline).""" for day in week: if day == 0: s = '' else: s = `day` print _center(s, width), |
str = '' if width >= 9: names = day_name else: names = day_abbr for i in range(7): if str: str = str + ' ' str = str + _center(names[i%7][:width], width) return str def prmonth(year, month, w = 0, l = 0): | if width >= 9: names = day_name else: names = day_abbr days = [] for i in range(_firstweekday, _firstweekday + 7): days.append(_center(names[i%7][:width], width)) return ' '.join(days) def prmonth(theyear, themonth, w=0, l=0): | def weekheader(width): """Return a header for a week.""" str = '' if width >= 9: names = day_name else: names = day_abbr for i in range(7): if str: str = str + ' ' str = str + _center(names[i%7][:width], width) return str |
print _center(month_name[month] + ' ' + `year`, 7*(w+1) - 1), print '\n'*l, print weekheader(w), print '\n'*l, for week in monthcalendar(year, month): prweek(week, w) print '\n'*l, | s = (_center(month_name[themonth] + ' ' + `theyear`, 7 * (w + 1) - 1).rstrip() + '\n' * l + weekheader(w).rstrip() + '\n' * l) for aweek in monthcalendar(theyear, themonth): s = s + week(aweek, w).rstrip() + '\n' * l return s[:-l] + '\n' | def prmonth(year, month, w = 0, l = 0): """Print a month's calendar.""" w = max(2, w) l = max(1, l) print _center(month_name[month] + ' ' + `year`, 7*(w+1) - 1), print '\n'*l, print weekheader(w), print '\n'*l, for week in monthcalendar(year, month): prweek(week, w) print '\n'*l, |
_spacing = ' '*4 def format3c(a, b, c): """3-column formatting for year calendars""" print _center(a, _colwidth), print _spacing, print _center(b, _colwidth), print _spacing, print _center(c, _colwidth) def prcal(year): | _spacing = 6 def format3c(a, b, c, colwidth=_colwidth, spacing=_spacing): """Prints 3-column formatting for year calendars""" print format3cstring(a, b, c, colwidth, spacing) def format3cstring(a, b, c, colwidth=_colwidth, spacing=_spacing): """Returns a string formatted from 3 strings, centered within 3 columns.""" ... | def prmonth(year, month, w = 0, l = 0): """Print a month's calendar.""" w = max(2, w) l = max(1, l) print _center(month_name[month] + ' ' + `year`, 7*(w+1) - 1), print '\n'*l, print weekheader(w), print '\n'*l, for week in monthcalendar(year, month): prweek(week, w) print '\n'*l, |
header = weekheader(2) format3c('', `year`, '') | print calendar(year, w, l, c), def calendar(year, w=0, l=0, c=_spacing): """Returns a year's calendar as a multi-line string.""" w = max(2, w) l = max(1, l) c = max(2, c) colwidth = (w + 1) * 7 - 1 s = _center(`year`, colwidth * 3 + c * 2).rstrip() + '\n' * l header = weekheader(w) header = format3cstring(header, head... | def prcal(year): """Print a year's calendar.""" header = weekheader(2) format3c('', `year`, '') for q in range(January, January+12, 3): print format3c(month_name[q], month_name[q+1], month_name[q+2]) format3c(header, header, header) data = [] height = 0 for month in range(q, q+3): cal = monthcalendar(year, month) if le... |
print format3c(month_name[q], month_name[q+1], month_name[q+2]) format3c(header, header, header) | s = (s + '\n' * l + format3cstring(month_name[q], month_name[q+1], month_name[q+2], colwidth, c).rstrip() + '\n' * l + header + '\n' * l) | def prcal(year): """Print a year's calendar.""" header = weekheader(2) format3c('', `year`, '') for q in range(January, January+12, 3): print format3c(month_name[q], month_name[q+1], month_name[q+2]) format3c(header, header, header) data = [] height = 0 for month in range(q, q+3): cal = monthcalendar(year, month) if le... |
for month in range(q, q+3): cal = monthcalendar(year, month) if len(cal) > height: height = len(cal) | for amonth in range(q, q + 3): cal = monthcalendar(year, amonth) if len(cal) > height: height = len(cal) | def prcal(year): """Print a year's calendar.""" header = weekheader(2) format3c('', `year`, '') for q in range(January, January+12, 3): print format3c(month_name[q], month_name[q+1], month_name[q+2]) format3c(header, header, header) data = [] height = 0 for month in range(q, q+3): cal = monthcalendar(year, month) if le... |
print ' '*_colwidth, | weeks.append('') | def prcal(year): """Print a year's calendar.""" header = weekheader(2) format3c('', `year`, '') for q in range(January, January+12, 3): print format3c(month_name[q], month_name[q+1], month_name[q+2]) format3c(header, header, header) data = [] height = 0 for month in range(q, q+3): cal = monthcalendar(year, month) if le... |
prweek(cal[i], 2) print _spacing, print | weeks.append(week(cal[i], w)) s = s + format3cstring(weeks[0], weeks[1], weeks[2], colwidth, c).rstrip() + '\n' * l return s[:-l] + '\n' | def prcal(year): """Print a year's calendar.""" header = weekheader(2) format3c('', `year`, '') for q in range(January, January+12, 3): print format3c(month_name[q], month_name[q+1], month_name[q+2]) format3c(header, header, header) data = [] height = 0 for month in range(q, q+3): cal = monthcalendar(year, month) if le... |
def loop(timeout=30.0, use_poll=False, map=None): | def loop(timeout=30.0, use_poll=False, map=None, count=None): | def loop(timeout=30.0, use_poll=False, map=None): if map is None: map = socket_map if use_poll and hasattr(select, 'poll'): poll_fun = poll2 else: poll_fun = poll while map: poll_fun(timeout, map) |
while map: poll_fun(timeout, map) | if count is None: while map: poll_fun(timeout, map) else: while map and count > 0: poll_fun(timeout, map) count = count - 1 | def loop(timeout=30.0, use_poll=False, map=None): if map is None: map = socket_map if use_poll and hasattr(select, 'poll'): poll_fun = poll2 else: poll_fun = poll while map: poll_fun(timeout, map) |
"""Fail if the two objects are unequal as determined by the '!=' | """Fail if the two objects are unequal as determined by the '==' | def failUnlessEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '!=' operator. """ if first != second: raise self.failureException, \ (msg or '%s != %s' % (`first`, `second`)) |
if first != second: | if not first == second: | def failUnlessEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '!=' operator. """ if first != second: raise self.failureException, \ (msg or '%s != %s' % (`first`, `second`)) |
return '\n'.join(output) | return '\n'.join(output) + '\n' | def script_from_examples(s): r"""Extract script from text with examples. Converts text with examples to a Python script. Example input is converted to regular code. Example output and all other words are converted to comments: >>> text = ''' ... Here are examples of simple math. ... ... Python has s... |
msg = self.idb.set_break(filename, lineno) if msg: text.bell() return | self.idb.set_break(filename, lineno) | def set_breakpoint_here(self, filename, lineno): msg = self.idb.set_break(filename, lineno) if msg: text.bell() return |
msg = self.idb.clear_break(filename, lineno) if msg: text.bell() return | self.idb.clear_break(filename, lineno) | def clear_breakpoint_here(self, filename, lineno): msg = self.idb.clear_break(filename, lineno) if msg: text.bell() return |
msg = self.idb.clear_all_file_breaks(filename) if msg: text.bell() return | self.idb.clear_all_file_breaks(filename) | def clear_file_breaks(self, filename): msg = self.idb.clear_all_file_breaks(filename) if msg: text.bell() return |
raise error, "flags should be one of 'r', 'w', 'c' or 'n' or use the bsddb.db.DB_* flags" | raise db.DBError, "flags should be one of 'r', 'w', 'c' or 'n' or use the bsddb.db.DB_* flags" | def open(filename, flags=db.DB_CREATE, mode=0660, filetype=db.DB_HASH, dbenv=None, dbname=None): """ A simple factory function for compatibility with the standard shleve.py module. It can be used like this, where key is a string and data is a pickleable object: from bsddb import dbshelve db = dbshelve.open(filename) ... |
data = cPickle.dumps(value, self.binary) return self.db.append(data, txn) | if self.get_type() != db.DB_RECNO: self.append = self.__append return self.append(value, txn=txn) raise db.DBError, "append() only supported when dbshelve opened with filetype=dbshelve.db.DB_RECNO" | def append(self, value, txn=None): data = cPickle.dumps(value, self.binary) return self.db.append(data, txn) |
import os | import os, fcntl | def export_add(self, x, y): return x + y |
class Backquote(Node): def __init__(self, expr, lineno=None): self.expr = expr self.lineno = lineno def getChildren(self): return self.expr, def getChildNodes(self): return self.expr, def __repr__(self): return "Backquote(%s)" % (repr(self.expr),) | def __repr__(self): return "AugAssign(%s, %s, %s)" % (repr(self.node), repr(self.op), repr(self.expr)) | |
self.local_hostname = socket.getfqdn() | fqdn = socket.getfqdn() if '.' in fqdn: self.local_hostname = fqdn else: addr = socket.gethostbyname(socket.gethostname()) self.local_hostname = '[%s]' % addr | def __init__(self, host = '', port = 0, local_hostname = None): """Initialize a new instance. |
list of strings (???) containing version numbers; the list will be | list of strings containing version numbers; the list will be | def get_devstudio_versions (): """Get list of devstudio versions from the Windows registry. Return a list of strings (???) containing version numbers; the list will be empty if we were unable to access the registry (eg. couldn't import a registry-access module) or the appropriate registry keys weren't found. (XXX is... |
found. (XXX is this correct???)""" | found.""" | def get_devstudio_versions (): """Get list of devstudio versions from the Windows registry. Return a list of strings (???) containing version numbers; the list will be empty if we were unable to access the registry (eg. couldn't import a registry-access module) or the appropriate registry keys weren't found. (XXX is... |
return None | return [] | def get_msvc_paths (path, version='6.0', platform='x86'): """Get a devstudio path (include, lib or path).""" try: import win32api import win32con except ImportError: return None L = [] if path=='lib': path= 'Library' path = string.upper(path + ' Dirs') K = ('Software\\Microsoft\\Devstudio\\%s\\' + 'Build System\\Compo... |
def _find_exe(exe): for v in get_devstudio_versions(): for p in get_msvc_paths('path',v): fn = os.path.join(os.path.abspath(p),exe) if os.path.isfile(fn): return fn try: for p in string.split(os.environ['Path'],';'): fn=os.path.join(os.path.abspath(p),exe) if os.path.isfile(fn): return fn except: pass return exe d... | def find_exe (exe, version_number): """Try to find an MSVC executable program 'exe' (from version 'version_number' of MSVC) in several places: first, one of the MSVC program search paths from the registry; next, the directories in the PATH environment variable. If any of those work, return an absolute path that is kno... | def _find_exe(exe): for v in get_devstudio_versions(): for p in get_msvc_paths('path',v): fn = os.path.join(os.path.abspath(p),exe) if os.path.isfile(fn): return fn #didn't find it; try existing path try: for p in string.split(os.environ['Path'],';'): fn=os.path.join(os.path.abspath(p),exe) if os.path.isfile(fn): retu... |
os.environ[n] = string.join(p,';') | os.environ[name]=string.join(p,';') | def _do_SET(n): p = _find_SET(n) if p: os.environ[n] = string.join(p,';') |
self.cc = _find_exe("cl.exe") self.link = _find_exe("link.exe") _do_SET('lib') _do_SET('include') path=_find_SET('path') try: for p in string.split(os.environ['path'],';'): path.append(p) except KeyError: pass os.environ['path'] = string.join(path,';') | vNum = get_devstudio_versions () if vNum: vNum = vNum[0] self.cc = _find_exe("cl.exe", vNum) self.link = _find_exe("link.exe", vNum) _do_SET('lib', vNum) _do_SET('include', vNum) path=_find_SET('path', vNum) try: for p in string.split(os.environ['path'],';'): path.append(p) except KeyError: pass os.environ['path'] ... | def __init__ (self, verbose=0, dry_run=0, force=0): |
self.compile_options = [ '/nologo', '/Ox', '/MD' ] | self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3' ] | def __init__ (self, verbose=0, dry_run=0, force=0): |
'/nologo', '/Od', '/MDd', '/Z7', '/D_DEBUG' | '/nologo', '/Od', '/MDd', '/W3', '/Z7', '/D_DEBUG' | def __init__ (self, verbose=0, dry_run=0, force=0): |
if ( PyString_Check(args) ) { OSStatus err; | if ( PyString_Check(v) ) { | #ifdef WITHOUT_FRAMEWORKS |
PyErr_Mac(ErrorObject, err); | PyMac_Error(err); | #ifdef WITHOUT_FRAMEWORKS |
if (FSpMakeFSRef(&((FSSpecObject *)v)->ob_itself, fsr)) | if ((err=FSpMakeFSRef(&((FSSpecObject *)v)->ob_itself, fsr)) == 0) | #ifdef WITHOUT_FRAMEWORKS |
getsetlist = [ ("data", """int size; PyObject *rv; size = GetHandleSize((Handle)self->ob_itself); HLock((Handle)self->ob_itself); rv = PyString_FromStringAndSize(*(Handle)self->ob_itself, size); HUnlock((Handle)self->ob_itself); return rv; """, None, "Raw data of the alias object" ) ] | def output_tp_initBody(self): Output("PyObject *v;") Output("char *kw[] = {\"itself\", 0};") Output() Output("if (!PyArg_ParseTupleAndKeywords(args, kwds, \"O\", kw, &v))") Output("return -1;") Output("if (myPyMac_GetFSRef(v, &((%s *)self)->ob_itself)) return 0;", self.objecttype) Output("return -1;") | |
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff) | module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff, longname=LONGMODNAME) | def parseArgumentList(self, args): args0, arg1, argsrest = args[:1], args[1], args[2:] t0, n0, m0 = arg1 args = args0 + argsrest if m0 != InMode: raise ValueError, "method's 'self' must be 'InMode'" self.itself = Variable(t0, "_self->ob_itself", SelfMode) FunctionGenerator.parseArgumentList(self, args) self.argumentLis... |
self.compile = None self.no_compile = None | self.compile = 0 | def initialize_options (self): |
import sys | if debug_stderr: sys.stderr = debug_stderr | def __init__(self): self.preffilepath = ":Python:PythonIDE preferences" Wapplication.Application.__init__(self, 'Pide') from Carbon import AE from Carbon import AppleEvents AE.AEInstallEventHandler(AppleEvents.kCoreEventClass, AppleEvents.kAEOpenApplication, self.ignoreevent) AE.AEInstallEventHandler(AppleEvents.kCore... |
self.filename = filename | self.filename = _normpath(filename) | def __init__(self, filename="NoName", date_time=(1980,1,1,0,0,0)): self.filename = filename # Name of the file in the archive self.date_time = date_time # year, month, day, hour, min, sec # Standard values: self.compress_type = ZIP_STORED # Type of compression for the file self.comment = "" # ... |
key = (filename, lineno,) | key = filename, lineno | def localtrace_trace_and_count(self, frame, why, arg): if why == 'line': # record the file name and line number of every trace # XXX I wish inspect offered me an optimized # `getfilename(frame)' to use in place of the presumably # heavier `getframeinfo()'. --Zooko 2001-10-14 filename, lineno, funcname, context, linei... |
listfuncs = false | listfuncs = False | def main(argv=None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:l", ["help", "version", "trace", "count", "report", "no-report", "file=", "missing", "ignore-module=", "ignore-dir=", "coverdir=", "listfuncs",]) except getopt.error, msg: sys.stderr.write("... |
listfuncs = true | listfuncs = True | def main(argv=None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:l", ["help", "version", "trace", "count", "report", "no-report", "file=", "missing", "ignore-module=", "ignore-dir=", "coverdir=", "listfuncs",]) except getopt.error, msg: sys.stderr.write("... |
if isdir(name) and not islink(name): | st = os.lstat(name) if stat.S_ISDIR(st[stat.ST_MODE]): | def walk(top, func, arg): """walk(top,func,arg) calls func(arg, d, files) for each directory "d" |
self.socket.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... | |
def __init__(self, s): self.__lines = s.split('\n') | def __init__(self, name, data, files=(), dirs=()): self.__name = name self.__data = data self.__files = files self.__dirs = dirs self.__lines = None def __setup(self): if self.__lines: return data = None for dir in self.__dirs: for file in self.__files: file = os.path.join(dir, file) try: fp = open(file) data = fp.rea... | def __init__(self, s): self.__lines = s.split('\n') self.__linecnt = len(self.__lines) |
return '' __builtin__.copyright = _Printer(sys.copyright) __builtin__.credits = _Printer( '''Python development is led by BeOpen PythonLabs (www.pythonlabs.com).''') def make_license(filename): try: return _Printer(open(filename).read()) except IOError: return None | __builtin__.copyright = _Printer("copyright", sys.copyright) __builtin__.credits = _Printer("credits", "Python development is led by BeOpen PythonLabs (www.pythonlabs.com).") | def __repr__(self): prompt = 'Hit Return for more, or q (and Return) to quit: ' lineno = 0 while 1: try: for i in range(lineno, lineno + self.MAXLINES): print self.__lines[i] except IndexError: break else: lineno += self.MAXLINES key = None while key is None: key = raw_input(prompt) if key not in ('', 'q'): key = None ... |
for dir in here, os.path.join(here, os.pardir), os.curdir: for file in "LICENSE.txt", "LICENSE": lic = make_license(os.path.join(dir, file)) if lic: break if lic: __builtin__.license = lic break else: __builtin__.license = _Printer('See http://hdl.handle.net/1895.22/1012') | __builtin__.license = _Printer( "license", "See http://www.pythonlabs.com/products/python2.0/license.html", ["LICENSE.txt", "LICENSE"], [here, os.path.join(here, os.pardir), os.curdir]) | def make_license(filename): try: return _Printer(open(filename).read()) except IOError: return None |
adlist = None | adlist = "" | def getrouteaddr(self): """Parse a route address (Return-path value). |
result.append('\\') result.append(char) | if char == '\000': result.append(r'\000') else: result.append('\\' + char) else: result.append(char) | def escape(pattern): "Escape all non-alphanumeric characters in pattern." result = [] alphanum=string.letters+'_'+string.digits for char in pattern: if char not in alphanum: result.append('\\') result.append(char) return string.join(result, '') |
while not self.state: | if not self.state: | def wait(self): self.posted.acquire() while not self.state: self.posted.wait() self.posted.release() |
self.plist.CFBundleExecutable = self.name | def preProcess(self): self.plist.CFBundleExecutable = self.name resdir = pathjoin("Contents", "Resources") if self.executable is not None: if self.mainprogram is None: execpath = pathjoin(self.execdir, self.name) else: execpath = pathjoin(resdir, os.path.basename(self.executable)) self.files.append((self.executable, ex... | |
python [options] command | python bundlebuilder.py [options] command | def pathjoin(*args): """Safe wrapper for os.path.join: asserts that all but the first argument are relative paths.""" for seg in args[1:]: assert seg[0] != "/" return os.path.join(*args) |
b = (12,) c = (6, 6) d = (4, 4, 4) e = (3, 3, 3, 3) | b = (1,) c = (1, 2) d = (1, 2, 3) e = (1, 2, 3, 4) | def test_short_tuples(self): a = () b = (12,) c = (6, 6) d = (4, 4, 4) e = (3, 3, 3, 3) for proto in 0, 1, 2: for x in a, b, c, d, e: s = self.dumps(x, proto) y = self.loads(s) self.assertEqual(x, y, (proto, x, s, y)) |
if not debugger: | if not debugger and \ self.editwin.getvar("<<toggle-jit-stack-viewer>>"): | def run_module_event(self, event, debugger=None): if not self.editwin.get_saved(): tkMessageBox.showerror("Not saved", "Please save first!", master=self.editwin.text) self.editwin.text.focus_set() return filename = self.editwin.io.filename if not filename: tkMessageBox.showerror("No file name", "This window has no file... |
to_convert = to_convert[:] to_convert.sort(key=len, reverse=True) | def __seqToRE(self, to_convert, directive): """Convert a list to a regex string for matching a directive. | |
def test_main(): | def test_basic(): | def test_main(): test_support.requires('network') if not hasattr(socket, "ssl"): raise test_support.TestSkipped("socket module has no ssl support") import urllib socket.RAND_status() try: socket.RAND_egd(1) except TypeError: pass else: print "didn't raise TypeError" socket.RAND_add("this is a random string", 75.0) f... |
if not self._dict['Download-URL']: | if not self._dict.get('Download-URL'): | def prerequisites(self): """Return a list of prerequisites for this package. The list contains 2-tuples, of which the first item is either a PimpPackage object or None, and the second is a descriptive string. The first item can be None if this package depends on something that isn't pimp-installable, in which case the... |
fp = os.popen(cmd, "r") | dummy, fp = os.popen4(cmd, "r") dummy.close() | def _cmd(self, output, dir, *cmditems): """Internal routine to run a shell command in a given directory.""" cmd = ("cd \"%s\"; " % dir) + " ".join(cmditems) if output: output.write("+ %s\n" % cmd) if NO_EXECUTE: return 0 fp = os.popen(cmd, "r") while 1: line = fp.readline() if not line: break if output: output.write(l... |
cast = "(PyObject*(*)(void*))" | self.emit("{", depth) self.emit("int i, n = asdl_seq_LEN(%s);" % value, depth+1) self.emit("value = PyList_New(n);", depth+1) self.emit("if (!value) goto failed;", depth+1) self.emit("for(i = 0; i < n; i++)", depth+1) self.emit("PyList_SET_ITEM(value, i, ast2obj_%s((%s_ty)asdl_seq_GET(%s, i)));" % (field.type, field.t... | def set(self, field, value, depth): if field.seq: if field.type.value == "cmpop": # XXX check that this cast is safe, i.e. works independent on whether # sizeof(cmpop_ty) != sizeof(void*) cast = "(PyObject*(*)(void*))" else: cast = "" self.emit("value = ast2obj_list(%s, %sast2obj_%s);" % (value, cast, field.type), dept... |
cast = "" self.emit("value = ast2obj_list(%s, %sast2obj_%s);" % (value, cast, field.type), depth) | self.emit("value = ast2obj_list(%s, ast2obj_%s);" % (value, field.type), depth) | def set(self, field, value, depth): if field.seq: if field.type.value == "cmpop": # XXX check that this cast is safe, i.e. works independent on whether # sizeof(cmpop_ty) != sizeof(void*) cast = "(PyObject*(*)(void*))" else: cast = "" self.emit("value = ast2obj_list(%s, %sast2obj_%s);" % (value, cast, field.type), dept... |
if not string.find(value, "%("): | if string.find(value, "%(") >= 0: | def get(self, section, option, raw=0, vars=None): """Get an option value for a given section. |
onoff = 0 else: onoff = 255 if self.barx: self.barx.HiliteControl(onoff) if self.bary: self.bary.HiliteControl(onoff) | if self.barx and self.barx_enabled: self.barx.HiliteControl(0) if self.bary and self.bary_enabled: self.bary.HiliteControl(0) else: if self.barx: self.barx.HiliteControl(255) if self.bary: self.bary.HiliteControl(255) | def do_activate(self, onoff, event): if onoff: onoff = 0 else: onoff = 255 if self.barx: self.barx.HiliteControl(onoff) if self.bary: self.bary.HiliteControl(onoff) |
self.barx.SetControlValue(vx) | if vx == None: self.barx.HiliteControl(255) self.barx_enabled = 0 else: if not self.barx_enabled: self.barx_enabled = 1 if self.activated: self.barx.HiliteControl(0) self.barx.SetControlValue(vx) | def updatescrollbars(self): SetPort(self.wid) vx, vy = self.getscrollbarvalues() if self.barx: self.barx.SetControlValue(vx) if self.bary: self.bary.SetControlValue(vy) |
self.bary.SetControlValue(vy) | if vy == None: self.bary.HiliteControl(255) self.bary_enabled = 0 else: if not self.bary_enabled: self.bary_enabled = 1 if self.activated: self.bary.HiliteControl(0) self.bary.SetControlValue(vy) def scalebarvalue(self, absmin, absmax, curmin, curmax): if curmin <= absmin and curmax >= absmax: return None if curmin ... | def updatescrollbars(self): SetPort(self.wid) vx, vy = self.getscrollbarvalues() if self.barx: self.barx.SetControlValue(vx) if self.bary: self.bary.SetControlValue(vy) |
for i in range(3): | for count in range(3): | def test_trashcan(): # "trashcan" is a hack to prevent stack overflow when deallocating # very deeply nested tuples etc. It works in part by abusing the # type pointer and refcount fields, and that can yield horrible # problems when gc tries to traverse the structures. # If this test fails (as it does in 2.0, 2.1 and ... |
if s1[-2:] == "\r\n": s1 = s1[:-2] + "\n" sys.stdout.write(s1) | sys.stdout.write(s1.replace("\r\n", "\n")) | def debug(msg): pass |
if s2[-2:] == "\r\n": s2 = s2[:-2] + "\n" sys.stdout.write(s2) | sys.stdout.write(s2.replace("\r\n", "\n")) | def debug(msg): pass |
pid, status = os.wait() | exited_pid, status = os.waitpid(pid, 0) | def test_lock_conflict(self): # Fork off a subprocess that will lock the file for 2 seconds, # unlock it, and then exit. if not hasattr(os, 'fork'): return pid = os.fork() if pid == 0: # In the child, lock the mailbox. self._box.lock() time.sleep(2) self._box.unlock() os._exit(0) |
(typ, [data]) = <instance>.search(charset, criterium, ...) | (typ, [data]) = <instance>.search(charset, criterion, ...) | def search(self, charset, *criteria): """Search mailbox for matching messages. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.