bugged stringlengths 4 228k | fixed stringlengths 0 96.3M | __index_level_0__ int64 0 481k |
|---|---|---|
def recolorize_main(self): next = "1.0" while 1: item = self.tag_nextrange("TODO", next) if not item: break head, tail = item self.tag_remove("SYNC", head, tail) item = self.tag_prevrange("SYNC", head) if item: head = item[1] else: head = "1.0" | def recolorize_main(self): next = "1.0" while True: item = self.tag_nextrange("TODO", next) if not item: break head, tail = item self.tag_remove("SYNC", head, tail) item = self.tag_prevrange("SYNC", head) if item: head = item[1] else: head = "1.0" | 8,800 |
def recolorize_main(self): next = "1.0" while 1: item = self.tag_nextrange("TODO", next) if not item: break head, tail = item self.tag_remove("SYNC", head, tail) item = self.tag_prevrange("SYNC", head) if item: head = item[1] else: head = "1.0" | def recolorize_main(self): next = "1.0" while 1: item = self.tag_nextrange("TODO", next) if not item: break head, tail = item self.tag_remove("SYNC", head, tail) item = self.tag_prevrange("SYNC", head) if item: head = item[1] else: head = "1.0" | 8,801 |
def readfp(self): """Read a single mime.types-format file.""" map = self.types_map while 1: line = f.readline() if not line: break words = line.split() for i in range(len(words)): if words[i][0] == '#': del words[i:] break if not words: continue type, suffixes = words[0], words[1:] for suff in suffixes: map['.' + suff]... | def readfp(self, fp): """Read a single mime.types-format file.""" map = self.types_map while 1: line = f.readline() if not line: break words = line.split() for i in range(len(words)): if words[i][0] == '#': del words[i:] break if not words: continue type, suffixes = words[0], words[1:] for suff in suffixes: map['.' + s... | 8,802 |
def readfp(self): """Read a single mime.types-format file.""" map = self.types_map while 1: line = f.readline() if not line: break words = line.split() for i in range(len(words)): if words[i][0] == '#': del words[i:] break if not words: continue type, suffixes = words[0], words[1:] for suff in suffixes: map['.' + suff]... | def readfp(self): """Read a single mime.types-format file.""" map = self.types_map while 1: line = fp.readline() if not line: break words = line.split() for i in range(len(words)): if words[i][0] == '#': del words[i:] break if not words: continue type, suffixes = words[0], words[1:] for suff in suffixes: map['.' + suff... | 8,803 |
def assertListEq(self, l1, l2, ignore): ''' succeed iff {l1} - {ignore} == {l2} - {ignore} ''' try: for p1, p2 in (l1, l2), (l2, l1): for item in p1: ok = (item in p2) or (item in ignore) if not ok: self.fail("%r missing" % item) except: print >>sys.stderr, "l1=%r, l2=%r, ignore=%r" % (l1, l2, ignore) raise | def assertListEq(self, l1, l2, ignore): ''' succeed iff {l1} - {ignore} == {l2} - {ignore} ''' try: for p1, p2 in (l1, l2), (l2, l1): for item in p1: ok = (item in p2) or (item in ignore) if not ok: self.fail("%r missing" % item) except: print >>sys.stderr, "l1=%r\nl2=%r\nignore=%r" % (l1, l2, ignore) raise | 8,804 |
def checkModule(self, moduleName, module=None, ignore=()): ''' succeed iff pyclbr.readmodule_ex(modulename) corresponds to the actual module object, module. Any identifiers in ignore are ignored. If no module is provided, the appropriate module is loaded with __import__.''' | def checkModule(self, moduleName, module=None, ignore=()): ''' succeed iff pyclbr.readmodule_ex(modulename) corresponds to the actual module object, module. Any identifiers in ignore are ignored. If no module is provided, the appropriate module is loaded with __import__.''' | 8,805 |
def checkModule(self, moduleName, module=None, ignore=()): ''' succeed iff pyclbr.readmodule_ex(modulename) corresponds to the actual module object, module. Any identifiers in ignore are ignored. If no module is provided, the appropriate module is loaded with __import__.''' | def checkModule(self, moduleName, module=None, ignore=()): ''' succeed iff pyclbr.readmodule_ex(modulename) corresponds to the actual module object, module. Any identifiers in ignore are ignored. If no module is provided, the appropriate module is loaded with __import__.''' | 8,806 |
def checkModule(self, moduleName, module=None, ignore=()): ''' succeed iff pyclbr.readmodule_ex(modulename) corresponds to the actual module object, module. Any identifiers in ignore are ignored. If no module is provided, the appropriate module is loaded with __import__.''' | def checkModule(self, moduleName, module=None, ignore=()): ''' succeed iff pyclbr.readmodule_ex(modulename) corresponds to the actual module object, module. Any identifiers in ignore are ignored. If no module is provided, the appropriate module is loaded with __import__.''' | 8,807 |
def test_easy(self): self.checkModule('pyclbr') self.checkModule('doctest', ignore=['_isclass', '_isfunction', '_ismodule', '_classify_class_attrs']) self.checkModule('rfc822', ignore=["get"]) self.checkModule('difflib') | def test_easy(self): self.checkModule('pyclbr') self.checkModule('doctest') self.checkModule('rfc822') self.checkModule('difflib') | 8,808 |
def test_others(self): cm = self.checkModule | def test_others(self): cm = self.checkModule | 8,809 |
def test_others(self): cm = self.checkModule | def test_others(self): cm = self.checkModule | 8,810 |
def test_others(self): cm = self.checkModule | def test_others(self): cm = self.checkModule | 8,811 |
def getatime(filename): """Return the last access time of a file, reported by os.stat().""" st = os.stat(filename) return st[stat.ST_MTIME] | def getatime(filename): """Return the last access time of a file, reported by os.stat().""" st = os.stat(filename) return st[stat.ST_ATIME] | 8,812 |
def force_test_exit(): # Sigh, both imports seem necessary to avoid errors. import os fork_pid = os.fork() if fork_pid: # In parent. return fork_pid # In child. import os, time try: # Wait 5 seconds longer than the expected alarm to give enough # time for the normal sequence of events to occur. This is # just a stop-... | def force_test_exit(): # Sigh, both imports seem necessary to avoid errors. import os fork_pid = os.fork() if fork_pid: # In parent. return fork_pid # In child. import os, time try: # Wait 5 seconds longer than the expected alarm to give enough # time for the normal sequence of events to occur. This is # just a stop-... | 8,813 |
def __hasattr__(self, attr): "Delegate attribute access to the interpreter object" return hasattr(self.tk, attr) | def __hasattr__(self, attr): "Delegate attribute access to the interpreter object" return hasattr(self.tk, attr) | 8,814 |
def read(self, size=None): if self.extrasize <= 0 and self.fileobj is None: return '' | def read(self, size=None): if self.extrasize <= 0 and self.fileobj is None: return '' | 8,815 |
def _unread(self, buf): self.extrabuf = buf + self.extrabuf self.extrasize = len(self.extrabuf) | def _unread(self, buf): self.extrabuf = buf + self.extrabuf self.extrasize = len(self.extrabuf) | 8,816 |
def readlines(self): buf = self.read() return string.split(buf, '\n') | def readlines(self): buf = self.read() return string.split(buf, '\n') | 8,817 |
def urlparse(url, scheme = '', allow_fragments = 1): key = url, scheme, allow_fragments cached = _parse_cache.get(key, None) if cached: return cached if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth clear_cache() find = string.find netloc = path = params = query = fragment = '' i = find(url, ':') if i > 0... | def urlparse(url, scheme = '', allow_fragments = 1): key = url, scheme, allow_fragments cached = _parse_cache.get(key, None) if cached: return cached if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth clear_cache() find = string.find netloc = path = params = query = fragment = '' i = find(url, ':') if i > 0... | 8,818 |
def urlparse(url, scheme = '', allow_fragments = 1): key = url, scheme, allow_fragments cached = _parse_cache.get(key, None) if cached: return cached if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth clear_cache() find = string.find netloc = path = params = query = fragment = '' i = find(url, ':') if i > 0... | def urlparse(url, scheme = '', allow_fragments = 1): key = url, scheme, allow_fragments cached = _parse_cache.get(key, None) if cached: return cached if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth clear_cache() find = string.find netloc = path = params = query = fragment = '' i = find(url, ':') if i > 0... | 8,819 |
def urlparse(url, scheme = '', allow_fragments = 1): key = url, scheme, allow_fragments cached = _parse_cache.get(key, None) if cached: return cached if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth clear_cache() find = string.find netloc = path = params = query = fragment = '' i = find(url, ':') if i > 0... | def urlparse(url, scheme = '', allow_fragments = 1): key = url, scheme, allow_fragments cached = _parse_cache.get(key, None) if cached: return cached if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth clear_cache() find = string.find netloc = path = params = query = fragment = '' i = find(url, ':') if i > 0... | 8,820 |
def urlparse(url, scheme = '', allow_fragments = 1): key = url, scheme, allow_fragments cached = _parse_cache.get(key, None) if cached: return cached if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth clear_cache() find = string.find netloc = path = params = query = fragment = '' i = find(url, ':') if i > 0... | def urlparse(url, scheme = '', allow_fragments = 1): key = url, scheme, allow_fragments cached = _parse_cache.get(key, None) if cached: return cached if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth clear_cache() find = string.find netloc = path = params = query = fragment = '' i = find(url, ':') if i > 0... | 8,821 |
>>> def f(): list(i for i in [(yield 26)]) | >>> def f(): list(i for i in [(yield 26)]) | 8,822 |
>>> def f(): return lambda x=(yield): 1 | >>> def f(): return lambda x=(yield): 1 | 8,823 |
>>> def f(): x = yield = y | >>> def f(): x = yield = y | 8,824 |
def warn_explicit(message, category, filename, lineno, module=None, registry=None): if module is None: module = filename if module[-3:].lower() == ".py": module = module[:-3] # XXX What about leading pathname? if registry is None: registry = {} if isinstance(message, Warning): text = str(message) category = message.__c... | def warn_explicit(message, category, filename, lineno, module=None, registry=None): if module is None: module = filename if module[-3:].lower() == ".py": module = module[:-3] # XXX What about leading pathname? if registry is None: registry = {} if isinstance(message, Warning): text = str(message) category = message.__c... | 8,825 |
def putnextpacket(self, pos, data): if self.disp.format == 'mono': # Unfortunately size-check is difficult for # packed video nline = (len(data)*8)/self.vw elif self.disp.format == 'grey2': nline = (len(data)*4)/self.vw elif self.disp.format == 'grey4': nline = (len(data)*2)/self.vw else: nline = len(data)/self.vw if n... | def putnextpacket(self, pos, data): if self.disp.format == 'mono': # Unfortunately size-check is difficult for # packed video nline = (len(data)*8)/self.vw elif self.disp.format == 'grey2': nline = (len(data)*4)/self.vw elif self.disp.format == 'grey4': nline = (len(data)*2)/self.vw else: nline = len(data)/self.vw if n... | 8,826 |
def handle(self): """ Handle multiple requests - each expected to be a 4-byte length, followed by the LogRecord in pickle format. Logs the record according to whatever policy is configured locally. """ while 1: try: chunk = self.connection.recv(4) if len(chunk) < 4: break slen = struct.unpack(">L", chunk)[0] #print sle... | defhandle(self):"""Handlemultiplerequests-eachexpectedtobea4-bytelength,followedbytheLogRecordinpickleformat.Logstherecordaccordingtowhateverpolicyisconfiguredlocally."""while1:try:chunk=self.connection.recv(4)iflen(chunk)<4:breakslen=struct.unpack(">L",chunk)[0]#printslenchunk=self.connection.recv(slen)whilelen(chunk)... | 8,827 |
def serve_until_stopped(self): abort = 0 while not abort: rd, wr, ex = select([self.socket.fileno()], [], [], self.timeout) if rd: self.handle_request() abort = self.abort | def serve_until_stopped(self): abort = 0 while not abort: rd, wr, ex = select.select([self.socket.fileno()], [], [], self.timeout) if rd: self.handle_request() abort = self.abort | 8,828 |
def test_main(): rootLogger = logging.getLogger("") rootLogger.setLevel(logging.DEBUG) hdlr = logging.StreamHandler(sys.stdout) fmt = logging.Formatter(logging.BASIC_FORMAT) hdlr.setFormatter(fmt) rootLogger.addHandler(hdlr) #Set up a handler such that all events are sent via a socket to the log #receiver (logrecv). #... | def test_main(): rootLogger = logging.getLogger("") rootLogger.setLevel(logging.DEBUG) hdlr = logging.StreamHandler(sys.stdout) fmt = logging.Formatter(logging.BASIC_FORMAT) hdlr.setFormatter(fmt) rootLogger.addHandler(hdlr) #Set up a handler such that all events are sent via a socket to the log #receiver (logrecv). #... | 8,829 |
def test_main(): rootLogger = logging.getLogger("") rootLogger.setLevel(logging.DEBUG) hdlr = logging.StreamHandler(sys.stdout) fmt = logging.Formatter(logging.BASIC_FORMAT) hdlr.setFormatter(fmt) rootLogger.addHandler(hdlr) #Set up a handler such that all events are sent via a socket to the log #receiver (logrecv). #... | def test_main(): rootLogger = logging.getLogger("") rootLogger.setLevel(logging.DEBUG) hdlr = logging.StreamHandler(sys.stdout) fmt = logging.Formatter(logging.BASIC_FORMAT) hdlr.setFormatter(fmt) rootLogger.addHandler(hdlr) #Set up a handler such that all events are sent via a socket to the log #receiver (logrecv). #... | 8,830 |
def test_main(): rootLogger = logging.getLogger("") rootLogger.setLevel(logging.DEBUG) hdlr = logging.StreamHandler(sys.stdout) fmt = logging.Formatter(logging.BASIC_FORMAT) hdlr.setFormatter(fmt) rootLogger.addHandler(hdlr) #Set up a handler such that all events are sent via a socket to the log #receiver (logrecv). #... | def test_main(): rootLogger = logging.getLogger("") rootLogger.setLevel(logging.DEBUG) hdlr = logging.StreamHandler(sys.stdout) fmt = logging.Formatter(logging.BASIC_FORMAT) hdlr.setFormatter(fmt) rootLogger.addHandler(hdlr) #Set up a handler such that all events are sent via a socket to the log #receiver (logrecv). #... | 8,831 |
def build_extension(self, ext): | def build_extension(self, ext): | 8,832 |
def disassemble(co, lasti=-1): """Disassemble a code object.""" code = co.co_code labels = findlabels(code) n = len(code) i = 0 while i < n: c = code[i] op = ord(c) if op == SET_LINENO and i > 0: print # Extra blank line if i == lasti: print '-->', else: print ' ', if i in labels: print '>>', else: print ' ', print ... | def disassemble(co, lasti=-1): """Disassemble a code object.""" code = co.co_code labels = findlabels(code) n = len(code) i = 0 while i < n: c = code[i] op = ord(c) if op == SET_LINENO and i > 0: print # Extra blank line if i == lasti: print '-->', else: print ' ', if i in labels: print '>>', else: print ' ', print ... | 8,833 |
def writeValue(self, value): if isinstance(value, (str, unicode)): self.simpleElement("string", value) elif isinstance(value, bool): # must switch for bool before int, as bool is a # subclass of int... if value: self.simpleElement("true") else: self.simpleElement("false") elif isinstance(value, int): self.simpleElement... | def writeValue(self, value): if isinstance(value, (str, unicode)): self.simpleElement("string", value) elif isinstance(value, bool): # must switch for bool before int, as bool is a # subclass of int... if value: self.simpleElement("true") else: self.simpleElement("false") elif isinstance(value, int): self.simpleElement... | 8,834 |
def fromBase64(cls, data): import base64 return cls(base64.decodestring(data)) | def fromBase64(cls, data): return cls(base64.decodestring(data)) | 8,835 |
def asBase64(self): import base64 return base64.encodestring(self.data) | def asBase64(self): return base64.encodestring(self.data) | 8,836 |
def __repr__(self): return "%s(%s)" % (self.__class__.__name__, repr(self.data)) | def __repr__(self): return "%s(%s)" % (self.__class__.__name__, repr(self.data)) | 8,837 |
def __init__(self, date): if isinstance(date, str): from xml.utils.iso8601 import parse date = parse(date) self.date = date | def __init__(self, date): if isinstance(date, datetime.datetime): pass elif isinstance(date, (float, int)): date = datetime.datetime.fromtimestamp(date) elif isinstance(date, basestring): order = ('year', 'month', 'day', 'hour', 'minute', 'second') gd = _dateParser.match(date).groupdict() lst = [] for key in order: val... | 8,838 |
def toString(self): from xml.utils.iso8601 import tostring return tostring(self.date) | def toString(self): from xml.utils.iso8601 import tostring return tostring(self.date) | 8,839 |
def __cmp__(self, other): if isinstance(other, self.__class__): return cmp(self.date, other.date) elif isinstance(other, (int, float)): return cmp(self.date, other) else: return cmp(id(self), id(other)) | def __cmp__(self, other): if isinstance(other, self.__class__): return cmp(self.date, other.date) elif isinstance(other, (datetime.datetime, float, int, basestring)): return cmp(self.date, Date(other).date) else: return cmp(id(self), id(other)) | 8,840 |
def parse(self, file): from xml.parsers.expat import ParserCreate parser = ParserCreate() parser.StartElementHandler = self.handleBeginElement parser.EndElementHandler = self.handleEndElement parser.CharacterDataHandler = self.handleData parser.ParseFile(file) return self.root | def parse(self, fileobj): from xml.parsers.expat import ParserCreate parser = ParserCreate() parser.StartElementHandler = self.handleBeginElement parser.EndElementHandler = self.handleEndElement parser.CharacterDataHandler = self.handleData parser.ParseFile(file) return self.root | 8,841 |
def parse(self, file): from xml.parsers.expat import ParserCreate parser = ParserCreate() parser.StartElementHandler = self.handleBeginElement parser.EndElementHandler = self.handleEndElement parser.CharacterDataHandler = self.handleData parser.ParseFile(file) return self.root | def parse(self, file): from xml.parsers.expat import ParserCreate parser = ParserCreate() parser.StartElementHandler = self.handleBeginElement parser.EndElementHandler = self.handleEndElement parser.CharacterDataHandler = self.handleData parser.ParseFile(fileobj) return self.root | 8,842 |
def compile_path(skip_curdir=1, maxlevels=0, force=0): """Byte-compile all module on sys.path. Arguments (all optional): skip_curdir: if true, skip current directory (default true) maxlevels: max recursion level (default 0) force: as for compile_dir() (default 0) """ for dir in sys.path: if (not dir or dir == os.c... | def compile_path(skip_curdir=1, maxlevels=0, force=0): """Byte-compile all module on sys.path. Arguments (all optional): skip_curdir: if true, skip current directory (default true) maxlevels: max recursion level (default 0) force: as for compile_dir() (default 0) """ for dir in sys.path: if (not dir or dir == os.c... | 8,843 |
def main(): """Script main program.""" import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'lfd:') except getopt.error, msg: print msg print "usage: compileall [-l] [-f] [-d destdir] [directory ...]" print "-l: don't recurse down" print "-f: force rebuild even if timestamps are up-to-date" print "-d destdir: pu... | def main(): """Script main program.""" import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'lfd:') except getopt.error, msg: print msg print "usage: compileall [-l] [-f] [-d destdir] [directory ...]" print "-l: don't recurse down" print "-f: force rebuild even if timestamps are up-to-date" print "-d destdir: pu... | 8,844 |
def main(): """Script main program.""" import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'lfd:') except getopt.error, msg: print msg print "usage: compileall [-l] [-f] [-d destdir] [directory ...]" print "-l: don't recurse down" print "-f: force rebuild even if timestamps are up-to-date" print "-d destdir: pu... | def main(): """Script main program.""" import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'lfd:') except getopt.error, msg: print msg print "usage: compileall [-l] [-f] [-d destdir] [directory ...]" print "-l: don't recurse down" print "-f: force rebuild even if timestamps are up-to-date" print "-d destdir: pu... | 8,845 |
def main(): """Script main program.""" import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'lfd:') except getopt.error, msg: print msg print "usage: compileall [-l] [-f] [-d destdir] [directory ...]" print "-l: don't recurse down" print "-f: force rebuild even if timestamps are up-to-date" print "-d destdir: pu... | def main(): """Script main program.""" import getopt try: opts, args = getopt.getopt(sys.argv[1:], 'lfd:') except getopt.error, msg: print msg print "usage: compileall [-l] [-f] [-d destdir] [directory ...]" print "-l: don't recurse down" print "-f: force rebuild even if timestamps are up-to-date" print "-d destdir: pu... | 8,846 |
def test_badbom(self): s = StringIO.StringIO("\xff\xff") f = codecs.getwriter(self.encoding)(s) self.assertRaises(UnicodeError, f.read) | def test_badbom(self): s = StringIO.StringIO("\xff\xff") f = codecs.getreader(self.encoding)(s) self.assertRaises(UnicodeError, f.read) | 8,847 |
def test_badbom(self): s = StringIO.StringIO("\xff\xff") f = codecs.getwriter(self.encoding)(s) self.assertRaises(UnicodeError, f.read) | def test_badbom(self): s = StringIO.StringIO("\xff\xff") f = codecs.getreader(self.encoding)(s) self.assertRaises(UnicodeError, f.read) | 8,848 |
def addwork(self, job): if not job: raise TypeError, 'cannot add null job' self.mutex.acquire() self.work.append(job) self.mutex.release() if len(self.work) == 1: self.todo.release() | def addwork(self, func, args): job = (func, args) self.mutex.acquire() self.work.append(job) self.mutex.release() if len(self.work) == 1: self.todo.release() | 8,849 |
def rectangle(win, uly, ulx, lry, lrx): "Draw a rectangle." win.vline(uly+1, ulx, curses.ACS_VLINE, lry - uly - 1) win.hline(uly, ulx+1, curses.ACS_HLINE, lrx - ulx - 1) win.hline(lry, ulx+1, curses.ACS_HLINE, lrx - ulx - 1) win.vline(uly+1, lrx, curses.ACS_VLINE, lry - uly - 1) win.addch(uly, ulx, curses.ACS_ULCORNER)... | def rectangle(win, uly, ulx, lry, lrx): "Draw a rectangle." win.vline(uly+1, ulx, curses.ACS_VLINE, lry - uly - 1) win.hline(uly, ulx+1, curses.ACS_HLINE, lrx - ulx - 1) win.hline(lry, ulx+1, curses.ACS_HLINE, lrx - ulx - 1) win.vline(uly+1, lrx, curses.ACS_VLINE, lry - uly - 1) win.addch(uly, ulx, curses.ACS_ULCORNER)... | 8,850 |
def rectangle(win, uly, ulx, lry, lrx): "Draw a rectangle." win.vline(uly+1, ulx, curses.ACS_VLINE, lry - uly - 1) win.hline(uly, ulx+1, curses.ACS_HLINE, lrx - ulx - 1) win.hline(lry, ulx+1, curses.ACS_HLINE, lrx - ulx - 1) win.vline(uly+1, lrx, curses.ACS_VLINE, lry - uly - 1) win.addch(uly, ulx, curses.ACS_ULCORNER)... | def rectangle(win, uly, ulx, lry, lrx): "Draw a rectangle." win.vline(uly+1, ulx, curses.ACS_VLINE, lry - uly - 1) win.hline(uly, ulx+1, curses.ACS_HLINE, lrx - ulx - 1) win.hline(lry, ulx+1, curses.ACS_HLINE, lrx - ulx - 1) win.vline(uly+1, lrx, curses.ACS_VLINE, lry - uly - 1) win.addch(uly, ulx, curses.ACS_ULCORNER)... | 8,851 |
def firstblank(self, y): "Go to the location of the first blank on the given line." last = self.maxx while 1: if ascii.ascii(self.win.inch(y, last)) != ascii.SP: last = last + 1 break elif last == 0: break last = last - 1 return last | def _end_of_line(self, y): "Go to the location of the first blank on the given line." last = self.maxx while 1: if ascii.ascii(self.win.inch(y, last)) != ascii.SP: last = last + 1 break elif last == 0: break last = last - 1 return last | 8,852 |
def do_command(self, ch): "Process a single editing command." (y, x) = self.win.getyx() self.lastcmd = ch if ascii.isprint(ch): if y < self.maxy or x < self.maxx: # The try-catch ignores the error we trigger from some curses # versions by trying to write into the lowest-rightmost spot # in the self.window. try: self.wi... | def do_command(self, ch): "Process a single editing command." (y, x) = self.win.getyx() self.lastcmd = ch if ascii.isprint(ch): if y < self.maxy or x < self.maxx: # The try-catch ignores the error we trigger from some curses # versions by trying to write into the lowest-rightmost spot # in the self.window. try: self.wi... | 8,853 |
def do_command(self, ch): "Process a single editing command." (y, x) = self.win.getyx() self.lastcmd = ch if ascii.isprint(ch): if y < self.maxy or x < self.maxx: # The try-catch ignores the error we trigger from some curses # versions by trying to write into the lowest-rightmost spot # in the self.window. try: self.wi... | def do_command(self, ch): "Process a single editing command." (y, x) = self.win.getyx() self.lastcmd = ch if ascii.isprint(ch): if y < self.maxy or x < self.maxx: # The try-catch ignores the error we trigger from some curses # versions by trying to write into the lowest-rightmost spot # in the self.window. try: self.wi... | 8,854 |
def do_command(self, ch): "Process a single editing command." (y, x) = self.win.getyx() self.lastcmd = ch if ascii.isprint(ch): if y < self.maxy or x < self.maxx: # The try-catch ignores the error we trigger from some curses # versions by trying to write into the lowest-rightmost spot # in the self.window. try: self.wi... | def do_command(self, ch): "Process a single editing command." (y, x) = self.win.getyx() self.lastcmd = ch if ascii.isprint(ch): if y < self.maxy or x < self.maxx: # The try-catch ignores the error we trigger from some curses # versions by trying to write into the lowest-rightmost spot # in the self.window. try: self.wi... | 8,855 |
def gather(self): "Collect and return the contents of the window." result = "" for y in range(self.maxy+1): self.win.move(y, 0) stop = self.firstblank(y) #sys.stderr.write("y=%d, firstblank(y)=%d\n" % (y, stop)) if stop == 0 and self.stripspaces: continue for x in range(self.maxx+1): if self.stripspaces and x == stop: ... | def gather(self): "Collect and return the contents of the window." result = "" for y in range(self.maxy+1): self.win.move(y, 0) stop = self.firstblank(y) #sys.stderr.write("y=%d, firstblank(y)=%d\n" % (y, stop)) if stop == 0 and self.stripspaces: continue for x in range(self.maxx+1): if self.stripspaces and x == stop: ... | 8,856 |
def gotopluginfolder(): """Go to the plugin folder, assuming we are somewhere in the Python tree""" import os while not os.path.isdir(":Mac:Plugins"): os.chdir("::") os.chdir(":Mac:Plugins") if verbose: print "current directory is", os.getcwd() | def gotopluginfolder(): """Go to the plugin folder, assuming we are somewhere in the Python tree""" import os while not os.path.isdir(":Mac:PlugIns"): os.chdir("::") os.chdir(":Mac:Plugins") if verbose: print "current directory is", os.getcwd() | 8,857 |
def gotopluginfolder(): """Go to the plugin folder, assuming we are somewhere in the Python tree""" import os while not os.path.isdir(":Mac:Plugins"): os.chdir("::") os.chdir(":Mac:Plugins") if verbose: print "current directory is", os.getcwd() | def gotopluginfolder(): """Go to the plugin folder, assuming we are somewhere in the Python tree""" import os while not os.path.isdir(":Mac:Plugins"): os.chdir("::") os.chdir(":Mac:PlugIns") if verbose: print "current directory is", os.getcwd() | 8,858 |
def mkcorealias(src, altsrc): import string import macostools version = string.split(sys.version)[0] dst = getextensiondirfile(src+ ' ' + version) if not os.path.exists(src): if not os.path.exists(altsrc): if verbose: print '*', src, 'not found' return 0 src = altsrc try: os.unlink(dst) except os.error: pass macostool... | def mkcorealias(src, altsrc): import string import macostools version = string.split(sys.version)[0] dst = getextensiondirfile(src+ ' ' + version) if not os.path.exists(os.path.join(sys.exec_prefix, src)): if not os.path.exists(os.path.join(sys.exec_prefix, altsrc)): if verbose: print '*', src, 'not found' return 0 sr... | 8,859 |
def mkcorealias(src, altsrc): import string import macostools version = string.split(sys.version)[0] dst = getextensiondirfile(src+ ' ' + version) if not os.path.exists(src): if not os.path.exists(altsrc): if verbose: print '*', src, 'not found' return 0 src = altsrc try: os.unlink(dst) except os.error: pass macostool... | def mkcorealias(src, altsrc): import string import macostools version = string.split(sys.version)[0] dst = getextensiondirfile(src+ ' ' + version) if not os.path.exists(src): if not os.path.exists(altsrc): if verbose: print '*', src, 'not found' return 0 src = altsrc try: os.unlink(dst) except os.error: pass macostool... | 8,860 |
def cmdloop(self, intro=None): """Repeatedly issue a prompt, accept input, parse an initial prefix off the received input, and dispatch to action methods, passing them the remainder of the line as argument. | def cmdloop(self, intro=None): """Repeatedly issue a prompt, accept input, parse an initial prefix off the received input, and dispatch to action methods, passing them the remainder of the line as argument. | 8,861 |
def postloop(self): """Hook method executed once when the cmdloop() method is about to return. | def postloop(self): """Hook method executed once when the cmdloop() method is about to return. | 8,862 |
def run_suite(suite): """Run tests from a unittest.TestSuite-derived class.""" if verbose: runner = unittest.TextTestRunner(sys.stdout, verbosity=2) else: runner = BasicTestRunner() result = runner.run(suite) if not result.wasSuccessful(): if len(result.errors) == 1 and not result.failures: err = result.errors[0][1] e... | def run_suite(suite, testclass=None): """Run tests from a unittest.TestSuite-derived class.""" if verbose: runner = unittest.TextTestRunner(sys.stdout, verbosity=2) else: runner = BasicTestRunner() result = runner.run(suite) if not result.wasSuccessful(): if len(result.errors) == 1 and not result.failures: err = resul... | 8,863 |
def run_suite(suite): """Run tests from a unittest.TestSuite-derived class.""" if verbose: runner = unittest.TextTestRunner(sys.stdout, verbosity=2) else: runner = BasicTestRunner() result = runner.run(suite) if not result.wasSuccessful(): if len(result.errors) == 1 and not result.failures: err = result.errors[0][1] e... | def run_suite(suite): """Run tests from a unittest.TestSuite-derived class.""" if verbose: runner = unittest.TextTestRunner(sys.stdout, verbosity=2) else: runner = BasicTestRunner() result = runner.run(suite) if not result.wasSuccessful(): if len(result.errors) == 1 and not result.failures: err = result.errors[0][1] e... | 8,864 |
def run_unittest(testclass): """Run tests from a unittest.TestCase-derived class.""" run_suite(unittest.makeSuite(testclass)) | def run_unittest(testclass): """Run tests from a unittest.TestCase-derived class.""" run_suite(unittest.makeSuite(testclass), testclass) | 8,865 |
def _fixresult(self, widget, result): if isinstance(result, tuple): # multiple results: result = tuple([getattr(r, "string", r) for r in result]) if result: import os path, file = os.path.split(result[0]) self.options["initialdir"] = path # don't set initialfile or filename, as we have multiple of these return result i... | def _fixresult(self, widget, result): if isinstance(result, tuple): # multiple results: result = tuple([getattr(r, "string", r) for r in result]) if result: import os path, file = os.path.split(result[0]) self.options["initialdir"] = path # don't set initialfile or filename, as we have multiple of these return result i... | 8,866 |
def _import_hook(self, fqname, globals=None, locals=None, fromlist=None): """Python calls this hook to locate and import a module.""" | def _import_hook(self, fqname, globals=None, locals=None, fromlist=None): """Python calls this hook to locate and import a module.""" | 8,867 |
def _import_hook(self, fqname, globals=None, locals=None, fromlist=None): """Python calls this hook to locate and import a module.""" | def _import_hook(self, fqname, globals=None, locals=None, fromlist=None): """Python calls this hook to locate and import a module.""" | 8,868 |
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.tabP... | 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',10,'normal')) ##widget creation #body frame frame=self.tabP... | 8,869 |
def OnListFontButtonRelease(self,event): self.fontName.set(self.listFontName.get(ANCHOR)) self.SetFontSample() | def OnListFontButtonRelease(self,event): font = self.listFontName.get(ANCHOR) self.fontName.set(font.lower()) self.SetFontSample() | 8,870 |
def LoadFontCfg(self): ##base editor font selection list fonts=list(tkFont.families(self)) fonts.sort() for font in fonts: self.listFontName.insert(END,font) configuredFont=idleConf.GetOption('main','EditorWindow','font', default='courier') self.fontName.set(configuredFont) if configuredFont in fonts: currentFontIndex=... | def LoadFontCfg(self): ##base editor font selection list fonts=list(tkFont.families(self)) fonts.sort() for font in fonts: self.listFontName.insert(END,font) configuredFont=idleConf.GetOption('main','EditorWindow','font', default='courier') lc_configuredFont = configuredFont.lower() self.fontName.set(lc_configuredFont)... | 8,871 |
def LoadFontCfg(self): ##base editor font selection list fonts=list(tkFont.families(self)) fonts.sort() for font in fonts: self.listFontName.insert(END,font) configuredFont=idleConf.GetOption('main','EditorWindow','font', default='courier') self.fontName.set(configuredFont) if configuredFont in fonts: currentFontIndex=... | def LoadFontCfg(self): ##base editor font selection list fonts=list(tkFont.families(self)) fonts.sort() for font in fonts: self.listFontName.insert(END,font) configuredFont=idleConf.GetOption('main','EditorWindow','font', default='courier') self.fontName.set(configuredFont) if configuredFont in fonts: currentFontIndex=... | 8,872 |
def initialize_options (self): self.bdist_dir = None self.plat_name = None self.format = None self.keep_temp = 0 self.dist_dir = None self.skip_build = 0 | defself.relative = 0 initialize_optionsself.relative = 0 (self):self.relative = 0 self.bdist_dirself.relative = 0 =self.relative = 0 Noneself.relative = 0 self.plat_nameself.relative = 0 =self.relative = 0 Noneself.relative = 0 self.formatself.relative = 0 =self.relative = 0 Noneself.relative = 0 self.keep_... | 8,873 |
def run (self): | def run (self): | 8,874 |
def test_buffer_info(self): a = array.array(self.typecode, self.example) self.assertRaises(TypeError, a.buffer_info, 42) bi = a.buffer_info() self.assert_(isinstance(bi, tuple)) self.assertEqual(len(bi), 2) self.assert_(isinstance(bi[0], int)) self.assert_(isinstance(bi[1], int)) self.assertEqual(bi[1], len(a)) | def test_buffer_info(self): a = array.array(self.typecode, self.example) self.assertRaises(TypeError, a.buffer_info, 42) bi = a.buffer_info() self.assert_(isinstance(bi, tuple)) self.assertEqual(len(bi), 2) self.assert_(isinstance(bi[0], (int, long))) self.assert_(isinstance(bi[1], int)) self.assertEqual(bi[1], len(a)) | 8,875 |
def CreateWidgets(self): frameMain = Frame(self, borderwidth=2, relief=SUNKEN) frameButtons = Frame(self) frameButtons.pack(side=BOTTOM, fill=X) frameMain.pack(side=TOP, expand=TRUE, fill=BOTH) self.buttonOk = Button(frameButtons, text='Close', command=self.Ok) self.buttonOk.pack(padx=5, pady=5) #self.picture = Image('... | def CreateWidgets(self): frameMain = Frame(self, borderwidth=2, relief=SUNKEN) frameButtons = Frame(self) frameButtons.pack(side=BOTTOM, fill=X) frameMain.pack(side=TOP, expand=TRUE, fill=BOTH) self.buttonOk = Button(frameButtons, text='Close', command=self.Ok) self.buttonOk.pack(padx=5, pady=5) #self.picture = Image('... | 8,876 |
def CreateWidgets(self): frameMain = Frame(self, borderwidth=2, relief=SUNKEN) frameButtons = Frame(self) frameButtons.pack(side=BOTTOM, fill=X) frameMain.pack(side=TOP, expand=TRUE, fill=BOTH) self.buttonOk = Button(frameButtons, text='Close', command=self.Ok) self.buttonOk.pack(padx=5, pady=5) #self.picture = Image('... | def CreateWidgets(self): frameMain = Frame(self, borderwidth=2, relief=SUNKEN) frameButtons = Frame(self) frameButtons.pack(side=BOTTOM, fill=X) frameMain.pack(side=TOP, expand=TRUE, fill=BOTH) self.buttonOk = Button(frameButtons, text='Close', command=self.Ok) self.buttonOk.pack(padx=5, pady=5) #self.picture = Image('... | 8,877 |
def ViewFile(self, viewTitle, viewFile, encoding=None): fn=os.path.join(os.path.abspath(os.path.dirname(__file__)),viewFile) if encoding: import codecs try: textFile = codecs.open(fn, 'r') except IOError: tkMessageBox.showerror(title='File Load Error', message='Unable to load file '+ `fileName`+' .') return else: data ... | def ViewFile(self, viewTitle, viewFile, encoding=None): fn = os.path.join(os.path.abspath(os.path.dirname(__file__)), viewFile) if encoding: import codecs try: textFile = codecs.open(fn, 'r') except IOError: tkMessageBox.showerror(title='File Load Error', message='Unable to load file '+ `fileName`+' .') return else: da... | 8,878 |
def run(): import aboutDialog aboutDialog.AboutDialog(root,'About') | def run(): import aboutDialog aboutDialog.AboutDialog(root,'About') | 8,879 |
def readmodule_ex(module, path=[], inpackage=0): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module.''' dict = {} i = module.rfind('.') if i >= 0: # Dotted module name pa... | def readmodule_ex(module, path=[], inpackage=0): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module.''' dict = {} i = module.rfind('.') if i >= 0: # Dotted module name pa... | 8,880 |
def readmodule_ex(module, path=[], inpackage=0): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module.''' dict = {} i = module.rfind('.') if i >= 0: # Dotted module name pa... | def readmodule_ex(module, path=[], inpackage=0): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module.''' dict = {} i = module.rfind('.') if i >= 0: # Dotted module name pa... | 8,881 |
def readmodule_ex(module, path=[], inpackage=0): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module.''' dict = {} i = module.rfind('.') if i >= 0: # Dotted module name pa... | def readmodule_ex(module, path=[], inpackage=0): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module.''' dict = {} i = module.rfind('.') if i >= 0: # Dotted module name pa... | 8,882 |
def process_common_macho(template, progress, code, rsrcname, destname, is_update, raw=0, others=[], filename=None): # Check that we have a filename if filename is None: raise BuildError, "Need source filename on MacOSX" # First make sure the name ends in ".app" if destname[-4:] != '.app': destname = destname + '.app' #... | def process_common_macho(template, progress, code, rsrcname, destname, is_update, raw=0, others=[], filename=None): # Check that we have a filename if filename is None: raise BuildError, "Need source filename on MacOSX" # First make sure the name ends in ".app" if destname[-4:] != '.app': destname = destname + '.app' #... | 8,883 |
def grid_slaves(self, row=None, column=None): args = () if row: args = args + ('-row', row) if column: args = args + ('-column', column) return map(self._nametowidget, self.tk.splitlist(self.tk.call( ('grid', 'slaves', self._w) + args))) | def grid_slaves(self, row=None, column=None): args = () if row is not None: args = args + ('-row', row) if column: args = args + ('-column', column) return map(self._nametowidget, self.tk.splitlist(self.tk.call( ('grid', 'slaves', self._w) + args))) | 8,884 |
def grid_slaves(self, row=None, column=None): args = () if row: args = args + ('-row', row) if column: args = args + ('-column', column) return map(self._nametowidget, self.tk.splitlist(self.tk.call( ('grid', 'slaves', self._w) + args))) | def grid_slaves(self, row=None, column=None): args = () if row: args = args + ('-row', row) if column is not None: args = args + ('-column', column) return map(self._nametowidget, self.tk.splitlist(self.tk.call( ('grid', 'slaves', self._w) + args))) | 8,885 |
def tag_bind(self, tagOrId, sequence=None, func=None, add=None): return self._bind((self._w, 'bind', tagOrId), sequence, func, add) | def tag_bind(self, tagOrId, sequence=None, func=None, add=None): return self._bind((self._w, 'bind', tagOrId), sequence, func, add) | 8,886 |
def search(self, charset, criteria): """Search mailbox for matching messages. | def search(self, charset, *criteria): """Search mailbox for matching messages. | 8,887 |
def search(self, charset, criteria): """Search mailbox for matching messages. | def search(self, charset, criteria): """Search mailbox for matching messages. | 8,888 |
def search(self, charset, criteria): """Search mailbox for matching messages. | def search(self, charset, criteria): """Search mailbox for matching messages. | 8,889 |
def print_log(): _mesg('last %d IMAP4 interactions:' % len(_cmd_log)) for secs,line in _cmd_log: _mesg(line, secs) | def print_log(): _mesg('last %d IMAP4 interactions:' % len(_cmd_log)) for secs,line in _cmd_log: _mesg(line, secs) | 8,890 |
def print_log(): _mesg('last %d IMAP4 interactions:' % len(_cmd_log)) for secs,line in _cmd_log: _mesg(line, secs) | def print_log(): _mesg('last %d IMAP4 interactions:' % len(_cmd_log)) for secs,line in _cmd_log: _mesg(line, secs) | 8,891 |
def run(cmd, args): _mesg('%s %s' % (cmd, args)) typ, dat = apply(eval('M.%s' % cmd), args) _mesg('%s => %s %s' % (cmd, typ, dat)) return dat | def run(cmd, args): _mesg('%s %s' % (cmd, args)) typ, dat = apply(eval('M.%s' % cmd), args) _mesg('%s => %s %s' % (cmd, typ, dat)) return dat | 8,892 |
def load_module(self, fullname): ispkg, code = self.modules[fullname] mod = imp.new_module(fullname) sys.modules[fullname] = mod mod.__file__ = "<%s>" % self.__class__.__name__ mod.__loader__ = self if ispkg: mod.__path__ = self._get__path__() exec code in mod.__dict__ return mod | def load_module(self, fullname): ispkg, code = self.modules[fullname] mod = sys.modules.setdefault(fullname,imp.new_module(fullname)) mod.__file__ = "<%s>" % self.__class__.__name__ mod.__loader__ = self if ispkg: mod.__path__ = self._get__path__() exec code in mod.__dict__ return mod | 8,893 |
def generate_help (header=None): """Generate help text (a list of strings, one per suggested line of output) from the option table for this FancyGetopt object.""" | def generate_help (self, header=None): """Generate help text (a list of strings, one per suggested line of output) from the option table for this FancyGetopt object.""" | 8,894 |
def print_help (self, file=None, header=None): if file is None: file = sys.stdout for line in self.generate_help (header): file.write (line + "\n") | def print_help (self, header=None, file=None): if file is None: file = sys.stdout for line in self.generate_help (header): file.write (line + "\n") | 8,895 |
def main(): testtype('c', 'c') testtype('u', u'\u263a') for type in (['b', 'h', 'i', 'l', 'f', 'd']): testtype(type, 1) testunicode() testsubclassing() unlink(TESTFN) | def main(): testtype('c', 'c') if have_unicode: testtype('u', unicode(r'\u263a', 'unicode-escape')) for type in (['b', 'h', 'i', 'l', 'f', 'd']): testtype(type, 1) testunicode() testsubclassing() unlink(TESTFN) | 8,896 |
def main(): testtype('c', 'c') testtype('u', u'\u263a') for type in (['b', 'h', 'i', 'l', 'f', 'd']): testtype(type, 1) testunicode() testsubclassing() unlink(TESTFN) | def main(): testtype('c', 'c') testtype('u', u'\u263a') for type in (['b', 'h', 'i', 'l', 'f', 'd']): testtype(type, 1) if have_unicode: testunicode() testsubclassing() unlink(TESTFN) | 8,897 |
def testunicode(): try: array.array('b', u'foo') except TypeError: pass else: raise TestFailed("creating a non-unicode array from " "a Unicode string should fail") x = array.array('u', u'\xa0\xc2\u1234') x.fromunicode(u' ') x.fromunicode(u'') x.fromunicode(u'') x.fromunicode(u'\x11abc\xff\u1234') s = x.tounicode() if ... | def testunicode(): try: array.array('b', unicode('foo', 'ascii')) except TypeError: pass else: raise TestFailed("creating a non-unicode array from " "a Unicode string should fail") x = array.array('u', u'\xa0\xc2\u1234') x.fromunicode(u' ') x.fromunicode(u'') x.fromunicode(u'') x.fromunicode(u'\x11abc\xff\u1234') s = ... | 8,898 |
def testunicode(): try: array.array('b', u'foo') except TypeError: pass else: raise TestFailed("creating a non-unicode array from " "a Unicode string should fail") x = array.array('u', u'\xa0\xc2\u1234') x.fromunicode(u' ') x.fromunicode(u'') x.fromunicode(u'') x.fromunicode(u'\x11abc\xff\u1234') s = x.tounicode() if ... | def testunicode(): try: array.array('b', u'foo') except TypeError: pass else: raise TestFailed("creating a non-unicode array from " "a Unicode string should fail") x = array.array('u', unicode(r'\xa0\xc2\u1234', 'unicode-escape')) x.fromunicode(unicode(' ', 'ascii')) x.fromunicode(unicode('', 'ascii')) x.fromunicode(u... | 8,899 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.