bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
|---|---|---|
def close(self): """Flush and close the mailbox.""" self.flush() if self._locked: self.unlock() self._file.close()
|
def close(self): """Flush and close the mailbox.""" self.flush() if self._locked: self.unlock() self._file.close()
| 6,600
|
def add(self, message): """Add message and return assigned key.""" keys = self.keys() if len(keys) == 0: new_key = 1 else: new_key = max(keys) + 1 new_path = os.path.join(self._path, str(new_key)) f = _create_carefully(new_path) try: if self._locked: _lock_file(f) try: self._dump_message(message, f) if isinstance(message, MHMessage): self._dump_sequences(message, new_key) finally: if self._locked: _unlock_file(f) finally: f.close() return new_key
|
def add(self, message): """Add message and return assigned key.""" keys = self.keys() if len(keys) == 0: new_key = 1 else: new_key = max(keys) + 1 new_path = os.path.join(self._path, str(new_key)) f = _create_carefully(new_path) try: if self._locked: _lock_file(f) try: self._dump_message(message, f) if isinstance(message, MHMessage): self._dump_sequences(message, new_key) finally: if self._locked: _unlock_file(f) finally: _sync_close(f) return new_key
| 6,601
|
def __setitem__(self, key, message): """Replace the keyed message; raise KeyError if it doesn't exist.""" path = os.path.join(self._path, str(key)) try: f = open(path, 'rb+') except IOError, e: if e.errno == errno.ENOENT: raise KeyError('No message with key: %s' % key) else: raise try: if self._locked: _lock_file(f) try: os.close(os.open(path, os.O_WRONLY | os.O_TRUNC)) self._dump_message(message, f) if isinstance(message, MHMessage): self._dump_sequences(message, key) finally: if self._locked: _unlock_file(f) finally: f.close()
|
def __setitem__(self, key, message): """Replace the keyed message; raise KeyError if it doesn't exist.""" path = os.path.join(self._path, str(key)) try: f = open(path, 'rb+') except IOError, e: if e.errno == errno.ENOENT: raise KeyError('No message with key: %s' % key) else: raise try: if self._locked: _lock_file(f) try: os.close(os.open(path, os.O_WRONLY | os.O_TRUNC)) self._dump_message(message, f) if isinstance(message, MHMessage): self._dump_sequences(message, key) finally: if self._locked: _unlock_file(f) finally: f.close()
| 6,602
|
def unlock(self): """Unlock the mailbox if it is locked.""" if self._locked: _unlock_file(self._file) self._file.close() del self._file self._locked = False
|
def unlock(self): """Unlock the mailbox if it is locked.""" if self._locked: _unlock_file(self._file) _sync_close(self._file) del self._file self._locked = False
| 6,603
|
def set_sequences(self, sequences): """Set sequences using the given name-to-key-list dictionary.""" f = open(os.path.join(self._path, '.mh_sequences'), 'r+') try: os.close(os.open(f.name, os.O_WRONLY | os.O_TRUNC)) for name, keys in sequences.iteritems(): if len(keys) == 0: continue f.write('%s:' % name) prev = None completing = False for key in sorted(set(keys)): if key - 1 == prev: if not completing: completing = True f.write('-') elif completing: completing = False f.write('%s %s' % (prev, key)) else: f.write(' %s' % key) prev = key if completing: f.write(str(prev) + '\n') else: f.write('\n') finally: f.close()
|
def set_sequences(self, sequences): """Set sequences using the given name-to-key-list dictionary.""" f = open(os.path.join(self._path, '.mh_sequences'), 'r+') try: os.close(os.open(f.name, os.O_WRONLY | os.O_TRUNC)) for name, keys in sequences.iteritems(): if len(keys) == 0: continue f.write('%s:' % name) prev = None completing = False for key in sorted(set(keys)): if key - 1 == prev: if not completing: completing = True f.write('-') elif completing: completing = False f.write('%s %s' % (prev, key)) else: f.write(' %s' % key) prev = key if completing: f.write(str(prev) + '\n') else: f.write('\n') finally: f.close()
| 6,604
|
def __repr__ (self): try: status = [] if self.accepting and self.addr: status.append ('listening') elif self.connected: status.append ('connected') if self.addr: if type(self.addr) == types.TupleType: status.append ('%s:%d' % self.addr) else: status.append (self.addr) return '<%s %s at %x>' % (self.__class__.__name__, ' '.join (status), id (self)) except: pass
|
def __repr__ (self): try: status = [self.__class__.__module__+"."+self.__class__.__name__] if self.accepting and self.addr: status.append ('listening') elif self.connected: status.append ('connected') if self.addr: if type(self.addr) == types.TupleType: status.append ('%s:%d' % self.addr) else: status.append (self.addr) return '<%s %s at %x>' % (self.__class__.__name__, ' '.join (status), id (self)) except: pass
| 6,605
|
def __repr__ (self): try: status = [] if self.accepting and self.addr: status.append ('listening') elif self.connected: status.append ('connected') if self.addr: if type(self.addr) == types.TupleType: status.append ('%s:%d' % self.addr) else: status.append (self.addr) return '<%s %s at %x>' % (self.__class__.__name__, ' '.join (status), id (self)) except: pass
|
def __repr__ (self): try: status = [] if self.accepting and self.addr: status.append ('listening') elif self.connected: status.append ('connected') if self.addr: if type(self.addr) == types.TupleType: status.append ('%s:%d' % self.addr) else: status.append (self.addr) return '<%s at % except: pass
| 6,606
|
def register_X_browsers(): # The default Gnome browser if _iscommand("gconftool-2"): # get the web browser string from gconftool gc = 'gconftool-2 -g /desktop/gnome/url-handlers/http/command 2>/dev/null' out = os.popen(gc) commd = out.read().strip() retncode = out.close() # if successful, register it if retncode is None and commd: register("gnome", None, BackgroundBrowser(commd)) # First, the Mozilla/Netscape browsers for browser in ("mozilla-firefox", "firefox", "mozilla-firebird", "firebird", "seamonkey", "mozilla", "netscape"): if _iscommand(browser): register(browser, None, Mozilla(browser)) # Konqueror/kfm, the KDE browser. if _iscommand("kfm"): register("kfm", Konqueror, Konqueror("kfm")) elif _iscommand("konqueror"): register("konqueror", Konqueror, Konqueror("konqueror")) # Gnome's Galeon and Epiphany for browser in ("galeon", "epiphany"): if _iscommand(browser): register(browser, None, Galeon(browser)) # Skipstone, another Gtk/Mozilla based browser if _iscommand("skipstone"): register("skipstone", None, BackgroundBrowser("skipstone")) # Opera, quite popular if _iscommand("opera"): register("opera", None, Opera("opera")) # Next, Mosaic -- old but still in use. if _iscommand("mosaic"): register("mosaic", None, BackgroundBrowser("mosaic")) # Grail, the Python browser. Does anybody still use it? if _iscommand("grail"): register("grail", Grail, None)
|
def register_X_browsers(): # The default Gnome browser if _iscommand("gconftool-2"): # get the web browser string from gconftool gc = 'gconftool-2 -g /desktop/gnome/url-handlers/http/command 2>/dev/null' out = os.popen(gc) commd = out.read().strip() retncode = out.close() # if successful, register it if retncode is None and commd: register("gnome", None, BackgroundBrowser(commd.split())) # First, the Mozilla/Netscape browsers for browser in ("mozilla-firefox", "firefox", "mozilla-firebird", "firebird", "seamonkey", "mozilla", "netscape"): if _iscommand(browser): register(browser, None, Mozilla(browser)) # Konqueror/kfm, the KDE browser. if _iscommand("kfm"): register("kfm", Konqueror, Konqueror("kfm")) elif _iscommand("konqueror"): register("konqueror", Konqueror, Konqueror("konqueror")) # Gnome's Galeon and Epiphany for browser in ("galeon", "epiphany"): if _iscommand(browser): register(browser, None, Galeon(browser)) # Skipstone, another Gtk/Mozilla based browser if _iscommand("skipstone"): register("skipstone", None, BackgroundBrowser("skipstone")) # Opera, quite popular if _iscommand("opera"): register("opera", None, Opera("opera")) # Next, Mosaic -- old but still in use. if _iscommand("mosaic"): register("mosaic", None, BackgroundBrowser("mosaic")) # Grail, the Python browser. Does anybody still use it? if _iscommand("grail"): register("grail", Grail, None)
| 6,607
|
def get_package_dir (self, package): """Return the directory, relative to the top of the source distribution, where package 'package' should be found (at least according to the 'package_dir' option, if any)."""
|
def get_package_dir (self, package): """Return the directory, relative to the top of the source distribution, where package 'package' should be found (at least according to the 'package_dir' option, if any)."""
| 6,608
|
def get_package_dir (self, package): """Return the directory, relative to the top of the source distribution, where package 'package' should be found (at least according to the 'package_dir' option, if any)."""
|
def get_package_dir (self, package): """Return the directory, relative to the top of the source distribution, where package 'package' should be found (at least according to the 'package_dir' option, if any)."""
| 6,609
|
def get_package_dir (self, package): """Return the directory, relative to the top of the source distribution, where package 'package' should be found (at least according to the 'package_dir' option, if any)."""
|
def get_package_dir (self, package): """Return the directory, relative to the top of the source distribution, where package 'package' should be found (at least according to the 'package_dir' option, if any)."""
| 6,610
|
def check_package (self, package, package_dir):
|
def check_package (self, package, package_dir):
| 6,611
|
def build_module (self, module, module_file, package):
|
def build_module (self, module, module_file, package):
| 6,612
|
def docroutine(self, object, name=None, mod=None, funcs={}, classes={}, methods={}, cl=None): """Produce HTML documentation for a function or method object.""" realname = object.__name__ name = name or realname anchor = (cl and cl.__name__ or '') + '-' + name note = '' skipdocs = 0 if inspect.ismethod(object): if cl: imclass = object.im_class if imclass is not cl: url = '%s.html#%s-%s' % ( imclass.__module__, imclass.__name__, name) note = ' from <a href="%s">%s</a>' % ( url, classname(imclass, mod)) skipdocs = 1 else: note = (object.im_self and ' method of %s instance' + object.im_self.__class__ or ' unbound %s method' % object.im_class.__name__) object = object.im_func
|
def docroutine(self, object, name=None, mod=None, funcs={}, classes={}, methods={}, cl=None): """Produce HTML documentation for a function or method object.""" realname = object.__name__ name = name or realname anchor = (cl and cl.__name__ or '') + '-' + name note = '' skipdocs = 0 if inspect.ismethod(object): if cl: if imclass is not cl: url = '%s.html#%s-%s' % ( imclass.__module__, imclass.__name__, name) note = ' from <a href="%s">%s</a>' % ( url, classname(imclass, mod)) skipdocs = 1 else: note = (object.im_self and ' method of %s instance' + object.im_self.__class__ or ' unbound %s method' % object.im_class.__name__) object = object.im_func
| 6,613
|
def docroutine(self, object, name=None, mod=None, funcs={}, classes={}, methods={}, cl=None): """Produce HTML documentation for a function or method object.""" realname = object.__name__ name = name or realname anchor = (cl and cl.__name__ or '') + '-' + name note = '' skipdocs = 0 if inspect.ismethod(object): if cl: imclass = object.im_class if imclass is not cl: url = '%s.html#%s-%s' % ( imclass.__module__, imclass.__name__, name) note = ' from <a href="%s">%s</a>' % ( url, classname(imclass, mod)) skipdocs = 1 else: note = (object.im_self and ' method of %s instance' + object.im_self.__class__ or ' unbound %s method' % object.im_class.__name__) object = object.im_func
|
def docroutine(self, object, name=None, mod=None, funcs={}, classes={}, methods={}, cl=None): """Produce HTML documentation for a function or method object.""" realname = object.__name__ name = name or realname anchor = (cl and cl.__name__ or '') + '-' + name note = '' skipdocs = 0 if inspect.ismethod(object): if cl: imclass = object.im_class if imclass is not cl: url = '%s.html#%s-%s' % ( imclass.__module__, imclass.__name__, name) note = ' from <a href="%s">%s</a>' % ( url, classname(imclass, mod)) skipdocs = 1 else: inst = object.im_self note = (inst and ' method of %s instance' % classname(inst.__class__, mod) or ' unbound %s method' % classname(imclass, mod)) object = object.im_func
| 6,614
|
def docroutine(self, object, name=None, mod=None, cl=None): """Produce text documentation for a function or method object.""" realname = object.__name__ name = name or realname note = '' skipdocs = 0 if inspect.ismethod(object): imclass = object.im_class if cl: if imclass is not cl: note = ' from ' + classname(imclass, mod) skipdocs = 1 else: note = (object.im_self and ' method of %s instance' + object.im_self.__class__ or ' unbound %s method' % classname(imclass, mod)) object = object.im_func
|
def docroutine(self, object, name=None, mod=None, cl=None): """Produce text documentation for a function or method object.""" realname = object.__name__ name = name or realname note = '' skipdocs = 0 if inspect.ismethod(object): imclass = object.im_class if cl: if imclass is not cl: note = ' from ' + classname(imclass, mod) skipdocs = 1 else: inst = object.im_self note = (inst and ' method of %s instance' % classname(inst.__class__, mod) or ' unbound %s method' % classname(imclass, mod)) object = object.im_func
| 6,615
|
def search(self, event=None): key = self.search_ent.get() self.stop_btn.pack(side='right') self.stop_btn.config(state='normal') self.search_lbl.config(text='Searching for "%s"...' % key) self.search_ent.forget() self.search_lbl.pack(side='left') self.result_lst.delete(0, 'end') self.goto_btn.config(state='disabled') self.expand()
|
def search(self, event=None): key = self.search_ent.get() self.stop_btn.pack(side='right') self.stop_btn.config(state='normal') self.search_lbl.config(text='Searching for "%s"...' % key) self.search_ent.forget() self.search_lbl.pack(side='left') self.result_lst.delete(0, 'end') self.goto_btn.config(state='disabled') self.expand()
| 6,616
|
def output_difference(self, example, got, optionflags): """ Return a string describing the differences between the expected output for a given example (`example`) and the actual output (`got`). `optionflags` is the set of option flags used to compare `want` and `got`. """ want = example.want # If <BLANKLINE>s are being used, then replace blank lines # with <BLANKLINE> in the actual output string. if not (optionflags & DONT_ACCEPT_BLANKLINE): got = re.sub('(?m)^[ ]*(?=\n)', BLANKLINE_MARKER, got)
|
def output_difference(self, example, got, optionflags): """ Return a string describing the differences between the expected output for a given example (`example`) and the actual output (`got`). `optionflags` is the set of option flags used to compare `want` and `got`. """ want = example.want # If <BLANKLINE>s are being used, then replace blank lines # with <BLANKLINE> in the actual output string. if not (optionflags & DONT_ACCEPT_BLANKLINE): got = re.sub('(?m)^[ ]*(?=\n)', BLANKLINE_MARKER, got)
| 6,617
|
def QueueTaskDoneTest(q) try: q.task_done() except ValueError: pass else: raise TestFailed("Did not detect task count going negative")
|
def QueueTaskDoneTest(q): try: q.task_done() except ValueError: pass else: raise TestFailed("Did not detect task count going negative")
| 6,618
|
def translate(text, pre=0): global translate_prog if not translate_prog: url = '\(http\|ftp\|https\)://[^ \t\r\n]*' email = '\<[-a-zA-Z0-9._]+@[-a-zA-Z0-9._]+' translate_prog = prog = regex.compile(url + '\|' + email) else: prog = translate_prog i = 0 list = [] while 1: j = prog.search(text, i) if j < 0: break list.append(escape(text[i:j])) i = j url = prog.group(0) while url[-1] in ');:,.?\'"': url = url[:-1] url = escape(url) if not pre or (pre and PROCESS_PREFORMAT): if ':' in url: repl = '<A HREF="%s">%s</A>' % (url, url) else: repl = '<A HREF="mailto:%s"><%s></A>' % (url, url) else: repl = url list.append(repl) i = i + len(url) j = len(text) list.append(escape(text[i:j])) return string.join(list, '')
|
def translate(text, pre=0): global translate_prog if not translate_prog: url = '\(http\|ftp\|https\)://[^ \t\r\n]*' email = '\<[-a-zA-Z0-9._]+@[-a-zA-Z0-9._]+' translate_prog = prog = regex.compile(url + '\|' + email) else: prog = translate_prog i = 0 list = [] while 1: j = prog.search(text, i) if j < 0: break list.append(escape(text[i:j])) i = j url = prog.group(0) while url[-1] in '();:,.?\'"<>': url = url[:-1] url = escape(url) if not pre or (pre and PROCESS_PREFORMAT): if ':' in url: repl = '<A HREF="%s">%s</A>' % (url, url) else: repl = '<A HREF="mailto:%s"><%s></A>' % (url, url) else: repl = url list.append(repl) i = i + len(url) j = len(text) list.append(escape(text[i:j])) return string.join(list, '')
| 6,619
|
def translate(text, pre=0): global translate_prog if not translate_prog: url = '\(http\|ftp\|https\)://[^ \t\r\n]*' email = '\<[-a-zA-Z0-9._]+@[-a-zA-Z0-9._]+' translate_prog = prog = regex.compile(url + '\|' + email) else: prog = translate_prog i = 0 list = [] while 1: j = prog.search(text, i) if j < 0: break list.append(escape(text[i:j])) i = j url = prog.group(0) while url[-1] in ');:,.?\'"': url = url[:-1] url = escape(url) if not pre or (pre and PROCESS_PREFORMAT): if ':' in url: repl = '<A HREF="%s">%s</A>' % (url, url) else: repl = '<A HREF="mailto:%s"><%s></A>' % (url, url) else: repl = url list.append(repl) i = i + len(url) j = len(text) list.append(escape(text[i:j])) return string.join(list, '')
|
def translate(text, pre=0): global translate_prog if not translate_prog: url = '\(http\|ftp\|https\)://[^ \t\r\n]*' email = '\<[-a-zA-Z0-9._]+@[-a-zA-Z0-9._]+' translate_prog = prog = regex.compile(url + '\|' + email) else: prog = translate_prog i = 0 list = [] while 1: j = prog.search(text, i) if j < 0: break list.append(escape(text[i:j])) i = j url = prog.group(0) while url[-1] in ');:,.?\'"': url = url[:-1] url = escape(url) if not pre or (pre and PROCESS_PREFORMAT): if ':' in url: repl = '<A HREF="%s">%s</A>' % (url, url) else: repl = '<A HREF="mailto:%s"><%s></A>' % (url, url) else: repl = url list.append(repl) j = len(text) list.append(escape(text[i:j])) return string.join(list, '')
| 6,620
|
def test_fixup(s): s2 = u'\ud800\udc01' test_lecmp(s, s2) s2 = u'\ud900\udc01' test_lecmp(s, s2) s2 = u'\uda00\udc01' test_lecmp(s, s2) s2 = u'\udb00\udc01' test_lecmp(s, s2) s2 = u'\ud800\udd01' test_lecmp(s, s2) s2 = u'\ud900\udd01' test_lecmp(s, s2) s2 = u'\uda00\udd01' test_lecmp(s, s2) s2 = u'\udb00\udd01' test_lecmp(s, s2) s2 = u'\ud800\ude01' test_lecmp(s, s2) s2 = u'\ud900\ude01' test_lecmp(s, s2) s2 = u'\uda00\ude01' test_lecmp(s, s2) s2 = u'\udb00\ude01' test_lecmp(s, s2) s2 = u'\ud800\udfff' test_lecmp(s, s2) s2 = u'\ud900\udfff' test_lecmp(s, s2) s2 = u'\uda00\udfff' test_lecmp(s, s2) s2 = u'\udb00\udfff' test_lecmp(s, s2)
|
def test_fixup(s): s2 = u'\ud800\udc01' test_lecmp(s, s2) s2 = u'\ud900\udc01' test_lecmp(s, s2) s2 = u'\uda00\udc01' test_lecmp(s, s2) s2 = u'\udb00\udc01' test_lecmp(s, s2) s2 = u'\ud800\udd01' test_lecmp(s, s2) s2 = u'\ud900\udd01' test_lecmp(s, s2) s2 = u'\uda00\udd01' test_lecmp(s, s2) s2 = u'\udb00\udd01' test_lecmp(s, s2) s2 = u'\ud800\ude01' test_lecmp(s, s2) s2 = u'\ud900\ude01' test_lecmp(s, s2) s2 = u'\uda00\ude01' test_lecmp(s, s2) s2 = u'\udb00\ude01' test_lecmp(s, s2) s2 = u'\ud800\udfff' test_lecmp(s, s2) s2 = u'\ud900\udfff' test_lecmp(s, s2) s2 = u'\uda00\udfff' test_lecmp(s, s2) s2 = u'\udb00\udfff' test_lecmp(s, s2)
| 6,621
|
def test_fixup(s): s2 = u'\ud800\udc01' test_lecmp(s, s2) s2 = u'\ud900\udc01' test_lecmp(s, s2) s2 = u'\uda00\udc01' test_lecmp(s, s2) s2 = u'\udb00\udc01' test_lecmp(s, s2) s2 = u'\ud800\udd01' test_lecmp(s, s2) s2 = u'\ud900\udd01' test_lecmp(s, s2) s2 = u'\uda00\udd01' test_lecmp(s, s2) s2 = u'\udb00\udd01' test_lecmp(s, s2) s2 = u'\ud800\ude01' test_lecmp(s, s2) s2 = u'\ud900\ude01' test_lecmp(s, s2) s2 = u'\uda00\ude01' test_lecmp(s, s2) s2 = u'\udb00\ude01' test_lecmp(s, s2) s2 = u'\ud800\udfff' test_lecmp(s, s2) s2 = u'\ud900\udfff' test_lecmp(s, s2) s2 = u'\uda00\udfff' test_lecmp(s, s2) s2 = u'\udb00\udfff' test_lecmp(s, s2)
|
def test_fixup(s): s2 = u'\ud800\udc01' test_lecmp(s, s2) s2 = u'\ud900\udc01' test_lecmp(s, s2) s2 = u'\uda00\udc01' test_lecmp(s, s2) s2 = u'\udb00\udc01' test_lecmp(s, s2) s2 = u'\ud800\udd01' test_lecmp(s, s2) s2 = u'\ud900\udd01' test_lecmp(s, s2) s2 = u'\uda00\udd01' test_lecmp(s, s2) s2 = u'\udb00\udd01' test_lecmp(s, s2) s2 = u'\ud800\ude01' test_lecmp(s, s2) s2 = u'\ud900\ude01' test_lecmp(s, s2) s2 = u'\uda00\ude01' test_lecmp(s, s2) s2 = u'\udb00\ude01' test_lecmp(s, s2) s2 = u'\ud800\udfff' test_lecmp(s, s2) s2 = u'\ud900\udfff' test_lecmp(s, s2) s2 = u'\uda00\udfff' test_lecmp(s, s2) s2 = u'\udb00\udfff' test_lecmp(s, s2)
| 6,622
|
def test_fixup(s): s2 = u'\ud800\udc01' test_lecmp(s, s2) s2 = u'\ud900\udc01' test_lecmp(s, s2) s2 = u'\uda00\udc01' test_lecmp(s, s2) s2 = u'\udb00\udc01' test_lecmp(s, s2) s2 = u'\ud800\udd01' test_lecmp(s, s2) s2 = u'\ud900\udd01' test_lecmp(s, s2) s2 = u'\uda00\udd01' test_lecmp(s, s2) s2 = u'\udb00\udd01' test_lecmp(s, s2) s2 = u'\ud800\ude01' test_lecmp(s, s2) s2 = u'\ud900\ude01' test_lecmp(s, s2) s2 = u'\uda00\ude01' test_lecmp(s, s2) s2 = u'\udb00\ude01' test_lecmp(s, s2) s2 = u'\ud800\udfff' test_lecmp(s, s2) s2 = u'\ud900\udfff' test_lecmp(s, s2) s2 = u'\uda00\udfff' test_lecmp(s, s2) s2 = u'\udb00\udfff' test_lecmp(s, s2)
|
def test_fixup(s): s2 = u'\ud800\udc01' test_lecmp(s, s2) s2 = u'\ud900\udc01' test_lecmp(s, s2) s2 = u'\uda00\udc01' test_lecmp(s, s2) s2 = u'\udb00\udc01' test_lecmp(s, s2) s2 = u'\ud800\udd01' test_lecmp(s, s2) s2 = u'\ud900\udd01' test_lecmp(s, s2) s2 = u'\uda00\udd01' test_lecmp(s, s2) s2 = u'\udb00\udd01' test_lecmp(s, s2) s2 = u'\ud800\ude01' test_lecmp(s, s2) s2 = u'\ud900\ude01' test_lecmp(s, s2) s2 = u'\uda00\ude01' test_lecmp(s, s2) s2 = u'\udb00\ude01' test_lecmp(s, s2) s2 = u'\ud800\udfff' test_lecmp(s, s2) s2 = u'\ud900\udfff' test_lecmp(s, s2) s2 = u'\uda00\udfff' test_lecmp(s, s2) s2 = u'\udb00\udfff' test_lecmp(s, s2)
| 6,623
|
def testGetSockOpt(self): """Testing getsockopt().""" # We know a socket should start without reuse==0 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) self.assert_(reuse == 0, "Error performing getsockopt.")
|
def testGetSockOpt(self): """Testing getsockopt().""" # We know a socket should start without reuse==0 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) self.assert_(reuse == 0, "Error performing getsockopt.")
| 6,624
|
def testSetSockOpt(self): """Testing setsockopt().""" sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) self.assert_(reuse == 1, "Error performing setsockopt.")
|
def testSetSockOpt(self): """Testing setsockopt().""" sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) reuse = sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) self.assert_(reuse == 1, "Error performing setsockopt.")
| 6,625
|
def poll2 (timeout=0.0, map=None): import poll if map is None: map=socket_map # timeout is in milliseconds timeout = int(timeout*1000) if map: l = [] for fd, obj in map.items(): flags = 0 if obj.readable(): flags = poll.POLLIN if obj.writable(): flags = flags | poll.POLLOUT if flags: l.append ((fd, flags)) r = poll.poll (l, timeout) for fd, flags in r: try: obj = map[fd] try: if (flags & poll.POLLIN): obj.handle_read_event() if (flags & poll.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass
|
def poll2 (timeout=0.0, map=None): import poll if map is None: map=socket_map # timeout is in millisecondsif timeout is not None: timeout = int(timeout*1000) if map: l = [] for fd, obj in map.items(): flags = 0 if obj.readable(): flags = poll.POLLIN if obj.writable(): flags = flags | poll.POLLOUT if flags: l.append ((fd, flags)) r = poll.poll (l, timeout) for fd, flags in r: try: obj = map[fd] try: if (flags & poll.POLLIN): obj.handle_read_event() if (flags & poll.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass
| 6,626
|
def poll3 (timeout=0.0, map=None): # Use the poll() support added to the select module in Python 2.0 if map is None: map=socket_map # timeout is in milliseconds timeout = int(timeout*1000) pollster = select.poll() if map: for fd, obj in map.items(): flags = 0 if obj.readable(): flags = select.POLLIN if obj.writable(): flags = flags | select.POLLOUT if flags: pollster.register(fd, flags) r = pollster.poll (timeout) for fd, flags in r: try: obj = map[fd] try: if (flags & select.POLLIN): obj.handle_read_event() if (flags & select.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass
|
def poll3 (timeout=0.0, map=None): # Use the poll() support added to the select module in Python 2.0 if map is None: map=socket_map # timeout is in millisecondsif timeout is not None: timeout = int(timeout*1000) pollster = select.poll() if map: for fd, obj in map.items(): flags = 0 if obj.readable(): flags = select.POLLIN if obj.writable(): flags = flags | select.POLLOUT if flags: pollster.register(fd, flags) r = pollster.poll (timeout) for fd, flags in r: try: obj = map[fd] try: if (flags & select.POLLIN): obj.handle_read_event() if (flags & select.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass
| 6,627
|
>>> def inorder(t):
|
>>> def inorder(t):
| 6,628
|
def test_main(): test_support.run_unittest(UTF16Test)
|
def test_main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(UTF16Test)) suite.addTest(unittest.makeSuite(EscapeDecodeTest)) test_support.run_suite(suite)
| 6,629
|
def http_error_302(self, req, fp, code, msg, headers): if headers.has_key('location'): newurl = headers['location'] elif headers.has_key('uri'): newurl = headers['uri'] else: return nil = fp.read() fp.close()
|
def http_error_302(self, req, fp, code, msg, headers): if headers.has_key('location'): newurl = headers['location'] elif headers.has_key('uri'): newurl = headers['uri'] else: return nil = fp.read() fp.close()
| 6,630
|
def attr_matches(self, text): """Compute matches when text contains a dot.
|
def attr_matches(self, text): """Compute matches when text contains a dot.
| 6,631
|
def attr_matches(self, text): """Compute matches when text contains a dot.
|
def attr_matches(self, text): """Compute matches when text contains a dot.
| 6,632
|
def draw(self, x, y): # XXX This hard-codes too many geometry constants! self.x, self.y = x, y self.drawicon() self.drawtext() if self.state != 'expanded': return y+17 # draw children if not self.children: sublist = self.item._GetSubList() if not sublist: # _IsExpandable() was mistaken; that's allowed return y+17 for item in sublist: child = TreeNode(self.canvas, self, item) self.children.append(child) cx = x+20 cy = y+17 cylast = 0 for child in self.children: cylast = cy self.canvas.create_line(x+9, cy+7, cx, cy+7, fill="gray50") cy = child.draw(cx, cy) if child.item._IsExpandable(): if child.state == 'expanded': iconname = "minusnode" callback = child.collapse else: iconname = "plusnode" callback = child.expand image = self.geticonimage(iconname) id = self.canvas.create_image(x+9, cylast+7, image=image) # XXX This leaks bindings until canvas is deleted: self.canvas.tag_bind(id, "<1>", callback) self.canvas.tag_bind(id, "<Double-1>", lambda x: None) id = self.canvas.create_line(x+9, y+10, x+9, cylast+7, ##stipple="gray50", # XXX Seems broken in Tk 8.0.x fill="gray50") self.canvas.tag_lower(id) # XXX .lower(id) before Python 1.5.2 return cy
|
def draw(self, x, y): # XXX This hard-codes too many geometry constants! self.x, self.y = x, y self.drawicon() self.drawtext() if self.state != 'expanded': return y+17 # draw children if not self.children: sublist = self.item._GetSubList() if not sublist: # _IsExpandable() was mistaken; that's allowed return y+17 for item in sublist: child = self.__class__(self.canvas, self, item) self.children.append(child) cx = x+20 cy = y+17 cylast = 0 for child in self.children: cylast = cy self.canvas.create_line(x+9, cy+7, cx, cy+7, fill="gray50") cy = child.draw(cx, cy) if child.item._IsExpandable(): if child.state == 'expanded': iconname = "minusnode" callback = child.collapse else: iconname = "plusnode" callback = child.expand image = self.geticonimage(iconname) id = self.canvas.create_image(x+9, cylast+7, image=image) # XXX This leaks bindings until canvas is deleted: self.canvas.tag_bind(id, "<1>", callback) self.canvas.tag_bind(id, "<Double-1>", lambda x: None) id = self.canvas.create_line(x+9, y+10, x+9, cylast+7, ##stipple="gray50", # XXX Seems broken in Tk 8.0.x fill="gray50") self.canvas.tag_lower(id) # XXX .lower(id) before Python 1.5.2 return cy
| 6,633
|
def beginElement(self, element): self.stack.append(element) element = _encode(element) self.writeln("<%s>" % element) self.indentLevel += 1
|
def beginElement(self, element): self.stack.append(element) self.writeln("<%s>" % element) self.indentLevel += 1
| 6,634
|
def simpleElement(self, element, value=None): if value: element = _encode(element) value = _encode(value) self.writeln("<%s>%s</%s>" % (element, value, element)) else: self.writeln("<%s/>" % element)
|
def simpleElement(self, element, value=None): if value: value = _encode(value) self.writeln("<%s>%s</%s>" % (element, value, element)) else: self.writeln("<%s/>" % element)
| 6,635
|
def writeArray(self, array): self.beginElement("array") for value in array: self.writeValue(value) self.endElement("array")
|
def writeArray(self, array): self.beginElement("array") for value in array: self.writeValue(value) self.endElement("array")
| 6,636
|
def __repr__(self): if self: return "True" else: return "False"
|
def __repr__(self): if self: return "True" else: return "False"
| 6,637
|
def finalize_options (self): from distutils import sysconfig
|
def finalize_options (self): from distutils import sysconfig
| 6,638
|
def run (self):
|
def run (self):
| 6,639
|
def __init__(self, display=1, logdir=None, context=5, file=None): self.display = display # send tracebacks to browser if true self.logdir = logdir # log tracebacks to files if not None self.context = context # number of source code lines per frame self.file = file or sys.stdout # place to send the output
|
def __init__(self, display=1, logdir=None, context=5, file=None, format="html"): self.display = display # send tracebacks to browser if true self.logdir = logdir # log tracebacks to files if not None self.context = context # number of source code lines per frame self.file = file or sys.stdout # place to send the output
| 6,640
|
def handle(self, info=None): info = info or sys.exc_info() self.file.write(reset())
|
def handle(self, info=None): info = info or sys.exc_info() self.file.write(reset())
| 6,641
|
def handle(self, info=None): info = info or sys.exc_info() self.file.write(reset())
|
def handle(self, info=None): info = info or sys.exc_info() self.file.write(reset())
| 6,642
|
def handle(self, info=None): info = info or sys.exc_info() self.file.write(reset())
|
def handle(self, info=None): info = info or sys.exc_info() self.file.write(reset())
| 6,643
|
def handle(self, info=None): info = info or sys.exc_info() self.file.write(reset())
|
def handle(self, info=None): info = info or sys.exc_info() self.file.write(reset())
| 6,644
|
def handle(self, info=None): info = info or sys.exc_info() self.file.write(reset())
|
def handle(self, info=None): info = info or sys.exc_info() self.file.write(reset())
| 6,645
|
def display(self): print self
|
def display(self): print self
| 6,646
|
def keys(self): return list(self.keylist)
|
def keys(self): return list(self.keylist)
| 6,647
|
def finalize_options (self):
|
def finalize_options (self):
| 6,648
|
def getctime(filename): """Return the creation time of a file, reported by os.stat().""" return os.stat(filename).st_ctime
|
def getctime(filename): """Return the metadata change time of a file, reported by os.stat().""" return os.stat(filename).st_ctime
| 6,649
|
def find_package_modules(package, mask): import fnmatch if hasattr(package, "__loader__"): path = package.__name__.replace(".", os.path.sep) mask = os.path.join(path, mask) for fnm in package.__loader__._files.iterkeys(): if fnmatch.fnmatchcase(fnm, mask): yield os.path.splitext(fnm)[0].replace(os.path.sep, ".") else: path = package.__path__[0] for fnm in os.listdir(path): if fnmatch.fnmatchcase(fnm, mask): yield "%s.%s" % (package.__name__, os.path.splitext(fnm)[0])
|
def find_package_modules(package, mask): import fnmatch if (hasattr(package, "__loader__") and hasattr(package.__loader__, '_files')): path = package.__name__.replace(".", os.path.sep) mask = os.path.join(path, mask) for fnm in package.__loader__._files.iterkeys(): if fnmatch.fnmatchcase(fnm, mask): yield os.path.splitext(fnm)[0].replace(os.path.sep, ".") else: path = package.__path__[0] for fnm in os.listdir(path): if fnmatch.fnmatchcase(fnm, mask): yield "%s.%s" % (package.__name__, os.path.splitext(fnm)[0])
| 6,650
|
def _format(self, object, stream, indent, allowance, context, level): level = level + 1 objid = _id(object) if objid in context: stream.write(_recursion(object)) self._recursive = True self._readable = False return rep = self._repr(object, context, level - 1) typ = _type(object) sepLines = _len(rep) > (self._width - 1 - indent - allowance) write = stream.write
|
def _format(self, object, stream, indent, allowance, context, level): level = level + 1 objid = _id(object) if objid in context: stream.write(_recursion(object)) self._recursive = True self._readable = False return rep = self._repr(object, context, level - 1) typ = _type(object) sepLines = _len(rep) > (self._width - 1 - indent - allowance) write = stream.write
| 6,651
|
def _format(self, object, stream, indent, allowance, context, level): level = level + 1 objid = _id(object) if objid in context: stream.write(_recursion(object)) self._recursive = True self._readable = False return rep = self._repr(object, context, level - 1) typ = _type(object) sepLines = _len(rep) > (self._width - 1 - indent - allowance) write = stream.write
|
def _format(self, object, stream, indent, allowance, context, level): level = level + 1 objid = _id(object) if objid in context: stream.write(_recursion(object)) self._recursive = True self._readable = False return rep = self._repr(object, context, level - 1) typ = _type(object) sepLines = _len(rep) > (self._width - 1 - indent - allowance) write = stream.write
| 6,652
|
def _format(self, object, stream, indent, allowance, context, level): level = level + 1 objid = _id(object) if objid in context: stream.write(_recursion(object)) self._recursive = True self._readable = False return rep = self._repr(object, context, level - 1) typ = _type(object) sepLines = _len(rep) > (self._width - 1 - indent - allowance) write = stream.write
|
def _format(self, object, stream, indent, allowance, context, level): level = level + 1 objid = _id(object) if objid in context: stream.write(_recursion(object)) self._recursive = True self._readable = False return rep = self._repr(object, context, level - 1) typ = _type(object) sepLines = _len(rep) > (self._width - 1 - indent - allowance) write = stream.write
| 6,653
|
def _safe_repr(object, context, maxlevels, level): typ = _type(object) if typ is str: if 'locale' not in _sys.modules: return `object`, True, False if "'" in object and '"' not in object: closure = '"' quotes = {'"': '\\"'} else: closure = "'" quotes = {"'": "\\'"} qget = quotes.get sio = _StringIO() write = sio.write for char in object: if char.isalpha(): write(char) else: write(qget(char, `char`[1:-1])) return ("%s%s%s" % (closure, sio.getvalue(), closure)), True, False if typ is dict: if not object: return "{}", True, False objid = _id(object) if maxlevels and level > maxlevels: return "{...}", False, objid in context if objid in context: return _recursion(object), False, True context[objid] = 1 readable = True recursive = False components = [] append = components.append level += 1 saferepr = _safe_repr for k, v in object.iteritems(): krepr, kreadable, krecur = saferepr(k, context, maxlevels, level) vrepr, vreadable, vrecur = saferepr(v, context, maxlevels, level) append("%s: %s" % (krepr, vrepr)) readable = readable and kreadable and vreadable if krecur or vrecur: recursive = True del context[objid] return "{%s}" % _commajoin(components), readable, recursive if typ is list or typ is tuple: if typ is list: if not object: return "[]", True, False format = "[%s]" elif _len(object) == 1: format = "(%s,)" else: if not object: return "()", True, False format = "(%s)" objid = _id(object) if maxlevels and level > maxlevels: return format % "...", False, objid in context if objid in context: return _recursion(object), False, True context[objid] = 1 readable = True recursive = False components = [] append = components.append level += 1 for o in object: orepr, oreadable, orecur = _safe_repr(o, context, maxlevels, level) append(orepr) if not oreadable: readable = False if orecur: recursive = True del context[objid] return format % _commajoin(components), readable, recursive rep = `object` return rep, (rep and not rep.startswith('<')), False
|
def _safe_repr(object, context, maxlevels, level): typ = _type(object) if issubclass(typ, basestring): if 'locale' not in _sys.modules: return `object`, True, False if "'" in object and '"' not in object: closure = '"' quotes = {'"': '\\"'} else: closure = "'" quotes = {"'": "\\'"} qget = quotes.get sio = _StringIO() write = sio.write for char in object: if char.isalpha(): write(char) else: write(qget(char, `char`[1:-1])) return ("%s%s%s" % (closure, sio.getvalue(), closure)), True, False if typ is dict: if not object: return "{}", True, False objid = _id(object) if maxlevels and level > maxlevels: return "{...}", False, objid in context if objid in context: return _recursion(object), False, True context[objid] = 1 readable = True recursive = False components = [] append = components.append level += 1 saferepr = _safe_repr for k, v in object.iteritems(): krepr, kreadable, krecur = saferepr(k, context, maxlevels, level) vrepr, vreadable, vrecur = saferepr(v, context, maxlevels, level) append("%s: %s" % (krepr, vrepr)) readable = readable and kreadable and vreadable if krecur or vrecur: recursive = True del context[objid] return "{%s}" % _commajoin(components), readable, recursive if typ is list or typ is tuple: if typ is list: if not object: return "[]", True, False format = "[%s]" elif _len(object) == 1: format = "(%s,)" else: if not object: return "()", True, False format = "(%s)" objid = _id(object) if maxlevels and level > maxlevels: return format % "...", False, objid in context if objid in context: return _recursion(object), False, True context[objid] = 1 readable = True recursive = False components = [] append = components.append level += 1 for o in object: orepr, oreadable, orecur = _safe_repr(o, context, maxlevels, level) append(orepr) if not oreadable: readable = False if orecur: recursive = True del context[objid] return format % _commajoin(components), readable, recursive rep = `object` return rep, (rep and not rep.startswith('<')), False
| 6,654
|
def _safe_repr(object, context, maxlevels, level): typ = _type(object) if typ is str: if 'locale' not in _sys.modules: return `object`, True, False if "'" in object and '"' not in object: closure = '"' quotes = {'"': '\\"'} else: closure = "'" quotes = {"'": "\\'"} qget = quotes.get sio = _StringIO() write = sio.write for char in object: if char.isalpha(): write(char) else: write(qget(char, `char`[1:-1])) return ("%s%s%s" % (closure, sio.getvalue(), closure)), True, False if typ is dict: if not object: return "{}", True, False objid = _id(object) if maxlevels and level > maxlevels: return "{...}", False, objid in context if objid in context: return _recursion(object), False, True context[objid] = 1 readable = True recursive = False components = [] append = components.append level += 1 saferepr = _safe_repr for k, v in object.iteritems(): krepr, kreadable, krecur = saferepr(k, context, maxlevels, level) vrepr, vreadable, vrecur = saferepr(v, context, maxlevels, level) append("%s: %s" % (krepr, vrepr)) readable = readable and kreadable and vreadable if krecur or vrecur: recursive = True del context[objid] return "{%s}" % _commajoin(components), readable, recursive if typ is list or typ is tuple: if typ is list: if not object: return "[]", True, False format = "[%s]" elif _len(object) == 1: format = "(%s,)" else: if not object: return "()", True, False format = "(%s)" objid = _id(object) if maxlevels and level > maxlevels: return format % "...", False, objid in context if objid in context: return _recursion(object), False, True context[objid] = 1 readable = True recursive = False components = [] append = components.append level += 1 for o in object: orepr, oreadable, orecur = _safe_repr(o, context, maxlevels, level) append(orepr) if not oreadable: readable = False if orecur: recursive = True del context[objid] return format % _commajoin(components), readable, recursive rep = `object` return rep, (rep and not rep.startswith('<')), False
|
def _safe_repr(object, context, maxlevels, level): typ = _type(object) if typ is str: if 'locale' not in _sys.modules: return `object`, True, False if "'" in object and '"' not in object: closure = '"' quotes = {'"': '\\"'} else: closure = "'" quotes = {"'": "\\'"} qget = quotes.get sio = _StringIO() write = sio.write for char in object: if char.isalpha(): write(char) else: write(qget(char, `char`[1:-1])) return ("%s%s%s" % (closure, sio.getvalue(), closure)), True, False if issubclass(typ, dict): if not object: return "{}", True, False objid = _id(object) if maxlevels and level > maxlevels: return "{...}", False, objid in context if objid in context: return _recursion(object), False, True context[objid] = 1 readable = True recursive = False components = [] append = components.append level += 1 saferepr = _safe_repr for k, v in object.iteritems(): krepr, kreadable, krecur = saferepr(k, context, maxlevels, level) vrepr, vreadable, vrecur = saferepr(v, context, maxlevels, level) append("%s: %s" % (krepr, vrepr)) readable = readable and kreadable and vreadable if krecur or vrecur: recursive = True del context[objid] return "{%s}" % _commajoin(components), readable, recursive if typ is list or typ is tuple: if typ is list: if not object: return "[]", True, False format = "[%s]" elif _len(object) == 1: format = "(%s,)" else: if not object: return "()", True, False format = "(%s)" objid = _id(object) if maxlevels and level > maxlevels: return format % "...", False, objid in context if objid in context: return _recursion(object), False, True context[objid] = 1 readable = True recursive = False components = [] append = components.append level += 1 for o in object: orepr, oreadable, orecur = _safe_repr(o, context, maxlevels, level) append(orepr) if not oreadable: readable = False if orecur: recursive = True del context[objid] return format % _commajoin(components), readable, recursive rep = `object` return rep, (rep and not rep.startswith('<')), False
| 6,655
|
def _safe_repr(object, context, maxlevels, level): typ = _type(object) if typ is str: if 'locale' not in _sys.modules: return `object`, True, False if "'" in object and '"' not in object: closure = '"' quotes = {'"': '\\"'} else: closure = "'" quotes = {"'": "\\'"} qget = quotes.get sio = _StringIO() write = sio.write for char in object: if char.isalpha(): write(char) else: write(qget(char, `char`[1:-1])) return ("%s%s%s" % (closure, sio.getvalue(), closure)), True, False if typ is dict: if not object: return "{}", True, False objid = _id(object) if maxlevels and level > maxlevels: return "{...}", False, objid in context if objid in context: return _recursion(object), False, True context[objid] = 1 readable = True recursive = False components = [] append = components.append level += 1 saferepr = _safe_repr for k, v in object.iteritems(): krepr, kreadable, krecur = saferepr(k, context, maxlevels, level) vrepr, vreadable, vrecur = saferepr(v, context, maxlevels, level) append("%s: %s" % (krepr, vrepr)) readable = readable and kreadable and vreadable if krecur or vrecur: recursive = True del context[objid] return "{%s}" % _commajoin(components), readable, recursive if typ is list or typ is tuple: if typ is list: if not object: return "[]", True, False format = "[%s]" elif _len(object) == 1: format = "(%s,)" else: if not object: return "()", True, False format = "(%s)" objid = _id(object) if maxlevels and level > maxlevels: return format % "...", False, objid in context if objid in context: return _recursion(object), False, True context[objid] = 1 readable = True recursive = False components = [] append = components.append level += 1 for o in object: orepr, oreadable, orecur = _safe_repr(o, context, maxlevels, level) append(orepr) if not oreadable: readable = False if orecur: recursive = True del context[objid] return format % _commajoin(components), readable, recursive rep = `object` return rep, (rep and not rep.startswith('<')), False
|
def _safe_repr(object, context, maxlevels, level): typ = _type(object) if typ is str: if 'locale' not in _sys.modules: return `object`, True, False if "'" in object and '"' not in object: closure = '"' quotes = {'"': '\\"'} else: closure = "'" quotes = {"'": "\\'"} qget = quotes.get sio = _StringIO() write = sio.write for char in object: if char.isalpha(): write(char) else: write(qget(char, `char`[1:-1])) return ("%s%s%s" % (closure, sio.getvalue(), closure)), True, False if typ is dict: if not object: return "{}", True, False objid = _id(object) if maxlevels and level > maxlevels: return "{...}", False, objid in context if objid in context: return _recursion(object), False, True context[objid] = 1 readable = True recursive = False components = [] append = components.append level += 1 saferepr = _safe_repr for k, v in object.iteritems(): krepr, kreadable, krecur = saferepr(k, context, maxlevels, level) vrepr, vreadable, vrecur = saferepr(v, context, maxlevels, level) append("%s: %s" % (krepr, vrepr)) readable = readable and kreadable and vreadable if krecur or vrecur: recursive = True del context[objid] return "{%s}" % _commajoin(components), readable, recursive if issubclass(typ, list) or issubclass(typ, tuple): if issubclass(typ, list): if not object: return "[]", True, False format = "[%s]" elif _len(object) == 1: format = "(%s,)" else: if not object: return "()", True, False format = "(%s)" objid = _id(object) if maxlevels and level > maxlevels: return format % "...", False, objid in context if objid in context: return _recursion(object), False, True context[objid] = 1 readable = True recursive = False components = [] append = components.append level += 1 for o in object: orepr, oreadable, orecur = _safe_repr(o, context, maxlevels, level) append(orepr) if not oreadable: readable = False if orecur: recursive = True del context[objid] return format % _commajoin(components), readable, recursive rep = `object` return rep, (rep and not rep.startswith('<')), False
| 6,656
|
def readline(self, size=-1): """Read a line with approx. size. If size is negative, read a whole line. readline() and read() must not be mixed up (!). """ if size < 0: size = sys.maxint
|
def readline(self, size=-1): """Read a line with approx. size. If size is negative, read a whole line. readline() and read() must not be mixed up (!). """ if size < 0: size = sys.maxint
| 6,657
|
def readline(self, size=-1): """Read a line with approx. size. If size is negative, read a whole line. readline() and read() must not be mixed up (!). """ if size < 0: size = sys.maxint
|
def readline(self, size=-1): """Read a line with approx. size. If size is negative, read a whole line. readline() and read() must not be mixed up (!). """ if size < 0: size = sys.maxint
| 6,658
|
def getnames(self): return self.parser.names
|
def getnames(self): return self.parser.names
| 6,659
|
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')
|
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')
| 6,660
|
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')
|
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')
| 6,661
|
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')
|
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')
| 6,662
|
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')
|
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')
| 6,663
|
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')
|
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')
| 6,664
|
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')
|
defdef detect_tkinter_darwin(self, inc_dirs, lib_dirs): from os.path import join, exists framework_dirs = [ '/System/Library/Frameworks/', '/Library/Frameworks', join(os.getenv('HOME'), '/Library/Frameworks') ] for F in framework_dirs: for fw in 'Tcl', 'Tk': if not exists(join(F, fw + '.framework')): break else: break else: return 0 include_dirs = [ join(F, fw + '.framework', H) for fw in 'Tcl', 'Tk' for H in 'Headers', 'Versions/Current/PrivateHeaders' ] include_dirs.append('/usr/X11R6/include') frameworks = ['-framework', 'Tcl', '-framework', 'Tk'] ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], define_macros=[('WITH_APPINIT', 1)], include_dirs = include_dirs, libraries = [], extra_compile_args = frameworks, extra_link_args = frameworks, ) self.extensions.append(ext) return 1 detect_modules(self):def detect_tkinter_darwin(self, inc_dirs, lib_dirs): from os.path import join, exists framework_dirs = [ '/System/Library/Frameworks/', '/Library/Frameworks', join(os.getenv('HOME'), '/Library/Frameworks') ] for F in framework_dirs: for fw in 'Tcl', 'Tk': if not exists(join(F, fw + '.framework')): break else: break else: return 0 include_dirs = [ join(F, fw + '.framework', H) for fw in 'Tcl', 'Tk' for H in 'Headers', 'Versions/Current/PrivateHeaders' ] include_dirs.append('/usr/X11R6/include') frameworks = ['-framework', 'Tcl', '-framework', 'Tk'] ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], define_macros=[('WITH_APPINIT', 1)], include_dirs = include_dirs, libraries = [], extra_compile_args = frameworks, extra_link_args = frameworks, ) self.extensions.append(ext) return 1 #def detect_tkinter_darwin(self, inc_dirs, lib_dirs): from os.path import join, exists framework_dirs = [ '/System/Library/Frameworks/', '/Library/Frameworks', join(os.getenv('HOME'), '/Library/Frameworks') ] for F in framework_dirs: for fw in 'Tcl', 'Tk': if not exists(join(F, fw + '.framework')): break else: break else: return 0 include_dirs = [ join(F, fw + '.framework', H) for fw in 'Tcl', 'Tk' for H in 'Headers', 'Versions/Current/PrivateHeaders' ] include_dirs.append('/usr/X11R6/include') frameworks = ['-framework', 'Tcl', '-framework', 'Tk'] ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], define_macros=[('WITH_APPINIT', 1)], include_dirs = include_dirs, libraries = [], extra_compile_args = frameworks, extra_link_args = frameworks, ) self.extensions.append(ext) return 1 Ensuredef detect_tkinter_darwin(self, inc_dirs, lib_dirs): from os.path import join, exists framework_dirs = [ '/System/Library/Frameworks/', '/Library/Frameworks', join(os.getenv('HOME'), '/Library/Frameworks') ] for F in framework_dirs: for fw in 'Tcl', 'Tk': if not exists(join(F, fw + '.framework')): break else: break else: return 0 include_dirs = [ join(F, fw + '.framework', H) for fw in 'Tcl', 'Tk' for H in 'Headers', 'Versions/Current/PrivateHeaders' ] include_dirs.append('/usr/X11R6/include') frameworks = ['-framework', 'Tcl', '-framework', 'Tk'] ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], define_macros=[('WITH_APPINIT', 1)], include_dirs = include_dirs, libraries = [], extra_compile_args = frameworks, extra_link_args = frameworks, ) self.extensions.append(ext) return 1 thatdef detect_tkinter_darwin(self, inc_dirs, lib_dirs): from os.path import join, exists framework_dirs = [ '/System/Library/Frameworks/', '/Library/Frameworks', join(os.getenv('HOME'), '/Library/Frameworks') ] for F in framework_dirs: for fw in 'Tcl', 'Tk': if not exists(join(F, fw + '.framework')): break else: break else: return 0 include_dirs = [ join(F, fw + '.framework', H) for fw in 'Tcl', 'Tk' for H in 'Headers', 'Versions/Current/PrivateHeaders' ] include_dirs.append('/usr/X11R6/include') frameworks = ['-framework', 'Tcl', '-framework', 'Tk'] ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], define_macros=[('WITH_APPINIT', 1)], include_dirs = include_dirs, libraries = [], extra_compile_args = frameworks, extra_link_args = frameworks, ) self.extensions.append(ext) return 1 /usr/localdef detect_tkinter_darwin(self, inc_dirs, lib_dirs): from os.path import join, exists framework_dirs = [ '/System/Library/Frameworks/', '/Library/Frameworks', join(os.getenv('HOME'), '/Library/Frameworks') ] for F in framework_dirs: for fw in 'Tcl', 'Tk': if not exists(join(F, fw + '.framework')): break else: break else: return 0 include_dirs = [ join(F, fw + '.framework', H) for fw in 'Tcl', 'Tk' for H in 'Headers', 'Versions/Current/PrivateHeaders' ] include_dirs.append('/usr/X11R6/include') frameworks = ['-framework', 'Tcl', '-framework', 'Tk'] ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], define_macros=[('WITH_APPINIT', 1)], include_dirs = include_dirs, libraries = [], extra_compile_args = frameworks, extra_link_args = frameworks, ) self.extensions.append(ext) return 1 isdef detect_tkinter_darwin(self, inc_dirs, lib_dirs): from os.path import join, exists framework_dirs = [ '/System/Library/Frameworks/', '/Library/Frameworks', join(os.getenv('HOME'), '/Library/Frameworks') ] for F in framework_dirs: for fw in 'Tcl', 'Tk': if not exists(join(F, fw + '.framework')): break else: break else: return 0 include_dirs = [ join(F, fw + '.framework', H) for fw in 'Tcl', 'Tk' for H in 'Headers', 'Versions/Current/PrivateHeaders' ] include_dirs.append('/usr/X11R6/include') frameworks = ['-framework', 'Tcl', '-framework', 'Tk'] ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], define_macros=[('WITH_APPINIT', 1)], include_dirs = include_dirs, libraries = [], extra_compile_args = frameworks, extra_link_args = frameworks, ) self.extensions.append(ext) return 1 alwaysdef detect_tkinter_darwin(self, inc_dirs, lib_dirs): from os.path import join, exists framework_dirs = [ '/System/Library/Frameworks/', '/Library/Frameworks', join(os.getenv('HOME'), '/Library/Frameworks') ] for F in framework_dirs: for fw in 'Tcl', 'Tk': if not exists(join(F, fw + '.framework')): break else: break else: return 0 include_dirs = [ join(F, fw + '.framework', H) for fw in 'Tcl', 'Tk' for H in 'Headers', 'Versions/Current/PrivateHeaders' ] include_dirs.append('/usr/X11R6/include') frameworks = ['-framework', 'Tcl', '-framework', 'Tk'] ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], define_macros=[('WITH_APPINIT', 1)], include_dirs = include_dirs, libraries = [], extra_compile_args = frameworks, extra_link_args = frameworks, ) self.extensions.append(ext) return 1 useddef detect_tkinter_darwin(self, inc_dirs, lib_dirs): from os.path import join, exists framework_dirs = [ '/System/Library/Frameworks/', '/Library/Frameworks', join(os.getenv('HOME'), '/Library/Frameworks') ] for F in framework_dirs: for fw in 'Tcl', 'Tk': if not exists(join(F, fw + '.framework')): break else: break else: return 0 include_dirs = [ join(F, fw + '.framework', H) for fw in 'Tcl', 'Tk' for H in 'Headers', 'Versions/Current/PrivateHeaders' ] include_dirs.append('/usr/X11R6/include') frameworks = ['-framework', 'Tcl', '-framework', 'Tk'] ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], define_macros=[('WITH_APPINIT', 1)], include_dirs = include_dirs, libraries = [], extra_compile_args = frameworks, extra_link_args = frameworks, ) self.extensions.append(ext) return 1 add_dir_to_list(self.compiler.library_dirs,def detect_tkinter_darwin(self, inc_dirs, lib_dirs): from os.path import join, exists framework_dirs = [ '/System/Library/Frameworks/', '/Library/Frameworks', join(os.getenv('HOME'), '/Library/Frameworks') ] for F in framework_dirs: for fw in 'Tcl', 'Tk': if not exists(join(F, fw + '.framework')): break else: break else: return 0 include_dirs = [ join(F, fw + '.framework', H) for fw in 'Tcl', 'Tk' for H in 'Headers', 'Versions/Current/PrivateHeaders' ] include_dirs.append('/usr/X11R6/include') frameworks = ['-framework', 'Tcl', '-framework', 'Tk'] ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], define_macros=[('WITH_APPINIT', 1)], include_dirs = include_dirs, libraries = [], extra_compile_args = frameworks, extra_link_args = frameworks, ) self.extensions.append(ext) return 1 '/usr/local/lib')def detect_tkinter_darwin(self, inc_dirs, lib_dirs): from os.path import join, exists framework_dirs = [ '/System/Library/Frameworks/', '/Library/Frameworks', join(os.getenv('HOME'), '/Library/Frameworks') ] for F in framework_dirs: for fw in 'Tcl', 'Tk': if not exists(join(F, fw + '.framework')): break else: break else: return 0 include_dirs = [ join(F, fw + '.framework', H) for fw in 'Tcl', 'Tk' for H in 'Headers', 'Versions/Current/PrivateHeaders' ] include_dirs.append('/usr/X11R6/include') frameworks = ['-framework', 'Tcl', '-framework', 'Tk'] ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], define_macros=[('WITH_APPINIT', 1)], include_dirs = include_dirs, libraries = [], extra_compile_args = frameworks, extra_link_args = frameworks, ) self.extensions.append(ext) return 1 add_dir_to_list(self.compiler.include_dirs,def detect_tkinter_darwin(self, inc_dirs, lib_dirs): from os.path import join, exists framework_dirs = [ '/System/Library/Frameworks/', '/Library/Frameworks', join(os.getenv('HOME'), '/Library/Frameworks') ] for F in framework_dirs: for fw in 'Tcl', 'Tk': if not exists(join(F, fw + '.framework')): break else: break else: return 0 include_dirs = [ join(F, fw + '.framework', H) for fw in 'Tcl', 'Tk' for H in 'Headers', 'Versions/Current/PrivateHeaders' ] include_dirs.append('/usr/X11R6/include') frameworks = ['-framework', 'Tcl', '-framework', 'Tk'] ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], define_macros=[('WITH_APPINIT', 1)], include_dirs = include_dirs, libraries = [], extra_compile_args = frameworks, extra_link_args = frameworks, ) self.extensions.append(ext) return 1 '/usr/local/include')
| 6,665
|
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module.
|
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module.
| 6,666
|
def test_chain(self): for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)): for g in (G, I, Ig, S, L, R): self.assertEqual(list(chain(g(s))), list(g(s))) self.assertEqual(list(chain(g(s), g(s))), list(g(s))+list(g(s))) self.assertRaises(TypeError, chain, X(s)) self.assertRaises(TypeError, list, chain(N(s))) self.assertRaises(ZeroDivisionError, list, chain(E(s)))
|
def test_chain(self): for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)): for g in (G, I, Ig, S, L, R): self.assertEqual(list(chain(g(s))), list(g(s))) self.assertEqual(list(chain(g(s), g(s))), list(g(s))+list(g(s))) self.assertRaises(TypeError, chain, X(s)) self.assertRaises(TypeError, chain, N(s)) self.assertRaises(ZeroDivisionError, list, chain(E(s)))
| 6,667
|
def test_cycle(self): for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)): for g in (G, I, Ig, S, L, R): tgtlen = len(s) * 3 expected = list(g(s))*3 actual = list(islice(cycle(g(s)), tgtlen)) self.assertEqual(actual, expected) self.assertRaises(TypeError, cycle, X(s)) self.assertRaises(TypeError, list, cycle(N(s))) self.assertRaises(ZeroDivisionError, list, cycle(E(s)))
|
def test_cycle(self): for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)): for g in (G, I, Ig, S, L, R): tgtlen = len(s) * 3 expected = list(g(s))*3 actual = list(islice(cycle(g(s)), tgtlen)) self.assertEqual(actual, expected) self.assertRaises(TypeError, cycle, X(s)) self.assertRaises(TypeError, cycle, N(s)) self.assertRaises(ZeroDivisionError, list, cycle(E(s)))
| 6,668
|
def test_groupby(self): for s in (range(10), range(0), range(1000), (7,11), xrange(2000,2200,5)): for g in (G, I, Ig, S, L, R): self.assertEqual([k for k, sb in groupby(g(s))], list(g(s))) self.assertRaises(TypeError, groupby, X(s)) self.assertRaises(TypeError, list, groupby(N(s))) self.assertRaises(ZeroDivisionError, list, groupby(E(s)))
|
def test_groupby(self): for s in (range(10), range(0), range(1000), (7,11), xrange(2000,2200,5)): for g in (G, I, Ig, S, L, R): self.assertEqual([k for k, sb in groupby(g(s))], list(g(s))) self.assertRaises(TypeError, groupby, X(s)) self.assertRaises(TypeError, groupby, N(s)) self.assertRaises(ZeroDivisionError, list, groupby(E(s)))
| 6,669
|
def test_ifilter(self): for s in (range(10), range(0), range(1000), (7,11), xrange(2000,2200,5)): for g in (G, I, Ig, S, L, R): self.assertEqual(list(ifilter(isEven, g(s))), filter(isEven, g(s))) self.assertRaises(TypeError, ifilter, isEven, X(s)) self.assertRaises(TypeError, list, ifilter(isEven, N(s))) self.assertRaises(ZeroDivisionError, list, ifilter(isEven, E(s)))
|
def test_ifilter(self): for s in (range(10), range(0), range(1000), (7,11), xrange(2000,2200,5)): for g in (G, I, Ig, S, L, R): self.assertEqual(list(ifilter(isEven, g(s))), filter(isEven, g(s))) self.assertRaises(TypeError, ifilter, isEven, X(s)) self.assertRaises(TypeError, ifilter, isEven, N(s)) self.assertRaises(ZeroDivisionError, list, ifilter(isEven, E(s)))
| 6,670
|
def test_ifilterfalse(self): for s in (range(10), range(0), range(1000), (7,11), xrange(2000,2200,5)): for g in (G, I, Ig, S, L, R): self.assertEqual(list(ifilterfalse(isEven, g(s))), filter(isOdd, g(s))) self.assertRaises(TypeError, ifilterfalse, isEven, X(s)) self.assertRaises(TypeError, list, ifilterfalse(isEven, N(s))) self.assertRaises(ZeroDivisionError, list, ifilterfalse(isEven, E(s)))
|
def test_ifilterfalse(self): for s in (range(10), range(0), range(1000), (7,11), xrange(2000,2200,5)): for g in (G, I, Ig, S, L, R): self.assertEqual(list(ifilterfalse(isEven, g(s))), filter(isOdd, g(s))) self.assertRaises(TypeError, ifilterfalse, isEven, X(s)) self.assertRaises(TypeError, ifilterfalse, isEven, N(s)) self.assertRaises(ZeroDivisionError, list, ifilterfalse(isEven, E(s)))
| 6,671
|
def test_izip(self): for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)): for g in (G, I, Ig, S, L, R): self.assertEqual(list(izip(g(s))), zip(g(s))) self.assertEqual(list(izip(g(s), g(s))), zip(g(s), g(s))) self.assertRaises(TypeError, izip, X(s)) self.assertRaises(TypeError, list, izip(N(s))) self.assertRaises(ZeroDivisionError, list, izip(E(s)))
|
def test_izip(self): for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)): for g in (G, I, Ig, S, L, R): self.assertEqual(list(izip(g(s))), zip(g(s))) self.assertEqual(list(izip(g(s), g(s))), zip(g(s), g(s))) self.assertRaises(TypeError, izip, X(s)) self.assertRaises(TypeError, izip, N(s)) self.assertRaises(ZeroDivisionError, list, izip(E(s)))
| 6,672
|
def test_imap(self): for s in (range(10), range(0), range(100), (7,11), xrange(20,50,5)): for g in (G, I, Ig, S, L, R): self.assertEqual(list(imap(onearg, g(s))), map(onearg, g(s))) self.assertEqual(list(imap(operator.pow, g(s), g(s))), map(operator.pow, g(s), g(s))) self.assertRaises(TypeError, imap, onearg, X(s)) self.assertRaises(TypeError, list, imap(onearg, N(s))) self.assertRaises(ZeroDivisionError, list, imap(onearg, E(s)))
|
def test_imap(self): for s in (range(10), range(0), range(100), (7,11), xrange(20,50,5)): for g in (G, I, Ig, S, L, R): self.assertEqual(list(imap(onearg, g(s))), map(onearg, g(s))) self.assertEqual(list(imap(operator.pow, g(s), g(s))), map(operator.pow, g(s), g(s))) self.assertRaises(TypeError, imap, onearg, X(s)) self.assertRaises(TypeError, imap, onearg, N(s)) self.assertRaises(ZeroDivisionError, list, imap(onearg, E(s)))
| 6,673
|
def test_islice(self): for s in ("12345", "", range(1000), ('do', 1.2), xrange(2000,2200,5)): for g in (G, I, Ig, S, L, R): self.assertEqual(list(islice(g(s),1,None,2)), list(g(s))[1::2]) self.assertRaises(TypeError, islice, X(s), 10) self.assertRaises(TypeError, list, islice(N(s), 10)) self.assertRaises(ZeroDivisionError, list, islice(E(s), 10))
|
def test_islice(self): for s in ("12345", "", range(1000), ('do', 1.2), xrange(2000,2200,5)): for g in (G, I, Ig, S, L, R): self.assertEqual(list(islice(g(s),1,None,2)), list(g(s))[1::2]) self.assertRaises(TypeError, islice, X(s), 10) self.assertRaises(TypeError, islice, N(s), 10) self.assertRaises(ZeroDivisionError, list, islice(E(s), 10))
| 6,674
|
def test_starmap(self): for s in (range(10), range(0), range(100), (7,11), xrange(20,50,5)): for g in (G, I, Ig, S, L, R): ss = zip(s, s) self.assertEqual(list(starmap(operator.pow, g(ss))), map(operator.pow, g(s), g(s))) self.assertRaises(TypeError, starmap, operator.pow, X(ss)) self.assertRaises(TypeError, list, starmap(operator.pow, N(ss))) self.assertRaises(ZeroDivisionError, list, starmap(operator.pow, E(ss)))
|
def test_starmap(self): for s in (range(10), range(0), range(100), (7,11), xrange(20,50,5)): for g in (G, I, Ig, S, L, R): ss = zip(s, s) self.assertEqual(list(starmap(operator.pow, g(ss))), map(operator.pow, g(s), g(s))) self.assertRaises(TypeError, starmap, operator.pow, X(ss)) self.assertRaises(TypeError, starmap, operator.pow, N(ss)) self.assertRaises(ZeroDivisionError, list, starmap(operator.pow, E(ss)))
| 6,675
|
def test_takewhile(self): for s in (range(10), range(0), range(1000), (7,11), xrange(2000,2200,5)): for g in (G, I, Ig, S, L, R): tgt = [] for elem in g(s): if not isEven(elem): break tgt.append(elem) self.assertEqual(list(takewhile(isEven, g(s))), tgt) self.assertRaises(TypeError, takewhile, isEven, X(s)) self.assertRaises(TypeError, list, takewhile(isEven, N(s))) self.assertRaises(ZeroDivisionError, list, takewhile(isEven, E(s)))
|
def test_takewhile(self): for s in (range(10), range(0), range(1000), (7,11), xrange(2000,2200,5)): for g in (G, I, Ig, S, L, R): tgt = [] for elem in g(s): if not isEven(elem): break tgt.append(elem) self.assertEqual(list(takewhile(isEven, g(s))), tgt) self.assertRaises(TypeError, takewhile, isEven, X(s)) self.assertRaises(TypeError, takewhile, isEven, N(s)) self.assertRaises(ZeroDivisionError, list, takewhile(isEven, E(s)))
| 6,676
|
def test_dropwhile(self): for s in (range(10), range(0), range(1000), (7,11), xrange(2000,2200,5)): for g in (G, I, Ig, S, L, R): tgt = [] for elem in g(s): if not tgt and isOdd(elem): continue tgt.append(elem) self.assertEqual(list(dropwhile(isOdd, g(s))), tgt) self.assertRaises(TypeError, dropwhile, isOdd, X(s)) self.assertRaises(TypeError, list, dropwhile(isOdd, N(s))) self.assertRaises(ZeroDivisionError, list, dropwhile(isOdd, E(s)))
|
def test_dropwhile(self): for s in (range(10), range(0), range(1000), (7,11), xrange(2000,2200,5)): for g in (G, I, Ig, S, L, R): tgt = [] for elem in g(s): if not tgt and isOdd(elem): continue tgt.append(elem) self.assertEqual(list(dropwhile(isOdd, g(s))), tgt) self.assertRaises(TypeError, dropwhile, isOdd, X(s)) self.assertRaises(TypeError, dropwhile, isOdd, N(s)) self.assertRaises(ZeroDivisionError, list, dropwhile(isOdd, E(s)))
| 6,677
|
def test_tee(self): for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)): for g in (G, I, Ig, S, L, R): it1, it2 = tee(g(s)) self.assertEqual(list(it1), list(g(s))) self.assertEqual(list(it2), list(g(s))) self.assertRaises(TypeError, tee, X(s)) self.assertRaises(TypeError, list, tee(N(s))[0]) self.assertRaises(ZeroDivisionError, list, tee(E(s))[0])
|
def test_tee(self): for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)): for g in (G, I, Ig, S, L, R): it1, it2 = tee(g(s)) self.assertEqual(list(it1), list(g(s))) self.assertEqual(list(it2), list(g(s))) self.assertRaises(TypeError, tee, X(s)) self.assertRaises(TypeError, tee, N(s)) self.assertRaises(ZeroDivisionError, list, tee(E(s))[0])
| 6,678
|
def open_https(self, url, data=None): """Use HTTPS protocol.""" import httplib user_passwd = None proxy_passwd = None if isinstance(url, str): host, selector = splithost(url) if host: user_passwd, host = splituser(host) host = unquote(host) realhost = host else: host, selector = url # here, we determine, whether the proxy contains authorization information proxy_passwd, host = splituser(host) urltype, rest = splittype(selector) url = rest user_passwd = None if urltype.lower() != 'https': realhost = None else: realhost, rest = splithost(rest) if realhost: user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) #print "proxy via https:", host, selector if not host: raise IOError, ('https error', 'no host given') if proxy_passwd: import base64 proxy_auth = base64.b64encode(proxy_passwd).strip() else: proxy_auth = None if user_passwd: import base64 auth = base64.b64encode(user_passwd).strip() else: auth = None h = httplib.HTTPS(host, 0, key_file=self.key_file, cert_file=self.cert_file) if data is not None: h.putrequest('POST', selector) h.putheader('Content-Type', 'application/x-www-form-urlencoded') h.putheader('Content-Length', '%d' % len(data)) else: h.putrequest('GET', selector) if proxy_auth: h.putheader('Proxy-Authorization: Basic %s' % proxy_auth) if auth: h.putheader('Authorization: Basic %s' % auth) if realhost: h.putheader('Host', realhost) for args in self.addheaders: h.putheader(*args) h.endheaders() if data is not None: h.send(data) errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, "https:" + url) else: if data is None: return self.http_error(url, fp, errcode, errmsg, headers) else: return self.http_error(url, fp, errcode, errmsg, headers, data)
|
def open_https(self, url, data=None): """Use HTTPS protocol.""" import httplib user_passwd = None proxy_passwd = None if isinstance(url, str): host, selector = splithost(url) if host: user_passwd, host = splituser(host) host = unquote(host) realhost = host else: host, selector = url # here, we determine, whether the proxy contains authorization information proxy_passwd, host = splituser(host) urltype, rest = splittype(selector) url = rest user_passwd = None if urltype.lower() != 'https': realhost = None else: realhost, rest = splithost(rest) if realhost: user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) #print "proxy via https:", host, selector if not host: raise IOError, ('https error', 'no host given') if proxy_passwd: import base64 proxy_auth = base64.b64encode(proxy_passwd).strip() else: proxy_auth = None if user_passwd: import base64 auth = base64.b64encode(user_passwd).strip() else: auth = None h = httplib.HTTPS(host, 0, key_file=self.key_file, cert_file=self.cert_file) if data is not None: h.putrequest('POST', selector) h.putheader('Content-Type', 'application/x-www-form-urlencoded') h.putheader('Content-Length', '%d' % len(data)) else: h.putrequest('GET', selector) if proxy_auth: h.putheader('Proxy-Authorization', 'Basic %s' % proxy_auth) if auth: h.putheader('Authorization', 'Basic %s' % auth) if realhost: h.putheader('Host', realhost) for args in self.addheaders: h.putheader(*args) h.endheaders() if data is not None: h.send(data) errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, "https:" + url) else: if data is None: return self.http_error(url, fp, errcode, errmsg, headers) else: return self.http_error(url, fp, errcode, errmsg, headers, data)
| 6,679
|
def missing_ok(str): try: getattr(socket, str) except AttributeError: pass
|
def missing_ok(str): try: getattr(socket, str) except AttributeError: pass
| 6,680
|
def missing_ok(str): try: getattr(socket, str) except AttributeError: pass
|
def missing_ok(str): try: getattr(socket, str) except AttributeError: pass
| 6,681
|
def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ result = '' head = '<br><big><big><strong> %s</strong></big></big>' % name try: file = inspect.getsourcefile(object) filelink = '<a href="file:%s">%s</a>' % (file, file) except TypeError: filelink = '(built-in)' info = [] if hasattr(object, '__version__'): version = str(object.__version__) if version[:11] == '$Revision$': version = version[11:-1] info.append('version: %s' % self.escape(version)) if hasattr(object, '__date__'): info.append(self.escape(str(object.__date__))) if info: head = head + ' (%s)' % join(info, ', ') result = result + self.heading( head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink)
|
def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ result = '' head = '<br><big><big><strong> %s</strong></big></big>' % name try: file = inspect.getsourcefile(object) filelink = '<a href="file:%s">%s</a>' % (file, file) except TypeError: filelink = '(built-in)' info = [] if hasattr(object, '__version__'): version = str(object.__version__) if version[:11] == '$' + 'Revision: ' and version[-1:] == '$': version = strip(version[11:-1]) info.append('version: %s' % self.escape(version)) if hasattr(object, '__date__'): info.append(self.escape(str(object.__date__))) if info: head = head + ' (%s)' % join(info, ', ') result = result + self.heading( head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink)
| 6,682
|
def __init__(self, master=None, value=None, name=None): """Construct a variable
|
def __init__(self, master=None, value=None, name=None): """Construct a variable
| 6,683
|
def _initialize(): global _initialized if _initialized: return macresource.need("DLOG", 260, "dialogs.rsrc", __name__)
|
def def _interact(): """Make sure the application is in the foreground""" AE.AEInteractWithUser(50000000) _initialize(): def _interact(): """Make sure the application is in the foreground""" AE.AEInteractWithUser(50000000) global def _interact(): """Make sure the application is in the foreground""" AE.AEInteractWithUser(50000000) _initialized def _interact(): """Make sure the application is in the foreground""" AE.AEInteractWithUser(50000000) if def _interact(): """Make sure the application is in the foreground""" AE.AEInteractWithUser(50000000) _initialized: def _interact(): """Make sure the application is in the foreground""" AE.AEInteractWithUser(50000000) return def _interact(): """Make sure the application is in the foreground""" AE.AEInteractWithUser(50000000) macresource.need("DLOG", def _interact(): """Make sure the application is in the foreground""" AE.AEInteractWithUser(50000000) 260, def _interact(): """Make sure the application is in the foreground""" AE.AEInteractWithUser(50000000) "dialogs.rsrc", def _interact(): """Make sure the application is in the foreground""" AE.AEInteractWithUser(50000000) __name__) def _interact(): """Make sure the application is in the foreground""" AE.AEInteractWithUser(50000000) def _interact(): """Make sure the application is in the foreground""" AE.AEInteractWithUser(50000000)
| 6,684
|
def parse(self, stream_or_string ):
|
def parse(self, stream_or_string ):
| 6,685
|
def __iter__(self): return self
|
def __iter__(self): return self
| 6,686
|
def __iter__(self): return self
|
def __iter__(self): return self
| 6,687
|
def __iter__(self): return self
|
def __iter__(self): return self
| 6,688
|
def check_module_event(self, event): filename = self.getfilename() if not filename: return if not self.tabnanny(filename): return self.checksyntax(filename)
|
def check_module_event(self, event): filename = self.getfilename() if not filename: return if not self.tabnanny(filename): return self.checksyntax(filename)
| 6,689
|
def tabnanny(self, filename): f = open(filename, 'r') try: tabnanny.process_tokens(tokenize.generate_tokens(f.readline)) except tokenize.TokenError, msg: msgtxt, (lineno, start) = msg self.editwin.gotoline(lineno) self.errorbox("Tabnanny Tokenizing Error", "Token Error: %s" % msgtxt) return False except tabnanny.NannyNag, nag: # The error messages from tabnanny are too confusing... self.editwin.gotoline(nag.get_lineno()) self.errorbox("Tab/space error", indent_message) return False except IndentationError: # From tokenize(), let compile() in checksyntax find it again. pass return True
|
def tabnanny(self, filename): f = open(filename, 'r') try: tabnanny.process_tokens(tokenize.generate_tokens(f.readline)) except tokenize.TokenError, msg: msgtxt, (lineno, start) = msg self.editwin.gotoline(lineno) self.errorbox("Tabnanny Tokenizing Error", "Token Error: %s" % msgtxt) return False except tabnanny.NannyNag, nag: # The error messages from tabnanny are too confusing... self.editwin.gotoline(nag.get_lineno()) self.errorbox("Tab/space error", indent_message) return False except IndentationError: # From tokenize(), let compile() in checksyntax find it again. pass return True
| 6,690
|
def run_module_event(self, event): """Run the module after setting up the environment.
|
def run_module_event(self, event): """Run the module after setting up the environment.
| 6,691
|
def build(self, root, resources=None, **options): """Create a package for some given root folder.
|
def build(self, root, resources=None, **options): """Create a package for some given root folder.
| 6,692
|
def build(self, root, resources=None, **options): """Create a package for some given root folder.
|
def build(self, root, resources=None, **options): """Create a package for some given root folder.
| 6,693
|
def build(self, root, resources=None, **options): """Create a package for some given root folder.
|
defelif not k in ["OutputDir"]: raise Error, "Unknown package option: %s" % k outputdir = options.get("OutputDir", os.getcwd()) packageName = self.packageInfo["Title"] self.PackageRootFolder = os.path.join(outputdir, packageName + ".pkg") build(self,elif not k in ["OutputDir"]: raise Error, "Unknown package option: %s" % k outputdir = options.get("OutputDir", os.getcwd()) packageName = self.packageInfo["Title"] self.PackageRootFolder = os.path.join(outputdir, packageName + ".pkg") root,elif not k in ["OutputDir"]: raise Error, "Unknown package option: %s" % k outputdir = options.get("OutputDir", os.getcwd()) packageName = self.packageInfo["Title"] self.PackageRootFolder = os.path.join(outputdir, packageName + ".pkg") resources=None,elif not k in ["OutputDir"]: raise Error, "Unknown package option: %s" % k outputdir = options.get("OutputDir", os.getcwd()) packageName = self.packageInfo["Title"] self.PackageRootFolder = os.path.join(outputdir, packageName + ".pkg") **options):elif not k in ["OutputDir"]: raise Error, "Unknown package option: %s" % k outputdir = options.get("OutputDir", os.getcwd()) packageName = self.packageInfo["Title"] self.PackageRootFolder = os.path.join(outputdir, packageName + ".pkg") """Createelif not k in ["OutputDir"]: raise Error, "Unknown package option: %s" % k outputdir = options.get("OutputDir", os.getcwd()) packageName = self.packageInfo["Title"] self.PackageRootFolder = os.path.join(outputdir, packageName + ".pkg") aelif not k in ["OutputDir"]: raise Error, "Unknown package option: %s" % k outputdir = options.get("OutputDir", os.getcwd()) packageName = self.packageInfo["Title"] self.PackageRootFolder = os.path.join(outputdir, packageName + ".pkg") packageelif not k in ["OutputDir"]: raise Error, "Unknown package option: %s" % k outputdir = options.get("OutputDir", os.getcwd()) packageName = self.packageInfo["Title"] self.PackageRootFolder = os.path.join(outputdir, packageName + ".pkg") forelif not k in ["OutputDir"]: raise Error, "Unknown package option: %s" % k outputdir = options.get("OutputDir", os.getcwd()) packageName = self.packageInfo["Title"] self.PackageRootFolder = os.path.join(outputdir, packageName + ".pkg") someelif not k in ["OutputDir"]: raise Error, "Unknown package option: %s" % k outputdir = options.get("OutputDir", os.getcwd()) packageName = self.packageInfo["Title"] self.PackageRootFolder = os.path.join(outputdir, packageName + ".pkg") givenelif not k in ["OutputDir"]: raise Error, "Unknown package option: %s" % k outputdir = options.get("OutputDir", os.getcwd()) packageName = self.packageInfo["Title"] self.PackageRootFolder = os.path.join(outputdir, packageName + ".pkg") rootelif not k in ["OutputDir"]: raise Error, "Unknown package option: %s" % k outputdir = options.get("OutputDir", os.getcwd()) packageName = self.packageInfo["Title"] self.PackageRootFolder = os.path.join(outputdir, packageName + ".pkg") folder.
| 6,694
|
def _makeFolders(self): "Create package folder structure."
|
def _makeFolders(self): "Create package folder structure."
| 6,695
|
def _makeFolders(self): "Create package folder structure."
|
def _makeFolders(self): "Create package folder structure."
| 6,696
|
def _addInfo(self): "Write .info file containing installing options."
|
def _addInfo(self): "Write .info file containing installing options."
| 6,697
|
def _addBom(self): "Write .bom file containing 'Bill of Materials'."
|
def _addBom(self): "Write .bom file containing 'Bill of Materials'."
| 6,698
|
def _addArchive(self): "Write .pax.gz file, a compressed archive using pax/gzip."
|
def _addArchive(self): "Write .pax.gz file, a compressed archive using pax/gzip."
| 6,699
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.