bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def _wrap_chunks(self, chunks): """_wrap_chunks(chunks : [string]) -> [string]
def _wrap_chunks(self, chunks): """_wrap_chunks(chunks : [string]) -> [string]
7,300
def _wrap_chunks(self, chunks): """_wrap_chunks(chunks : [string]) -> [string]
def _wrap_chunks(self, chunks): """_wrap_chunks(chunks : [string]) -> [string]
7,301
def _wrap_chunks(self, chunks): """_wrap_chunks(chunks : [string]) -> [string]
def _wrap_chunks(self, chunks): """_wrap_chunks(chunks : [string]) -> [string]
7,302
def _wrap_chunks(self, chunks): """_wrap_chunks(chunks : [string]) -> [string]
def _wrap_chunks(self, chunks): """_wrap_chunks(chunks : [string]) -> [string]
7,303
def read(self, length = None): if self.pos >= self.stop: return '' remaining = self.stop - self.pos if length is None or length < 0: length = remaining elif length > remaining: length = remaining self.fp.seek(self.pos) self.pos = self.pos + length return self.fp.read(length)
def read(self, length = None): if self.pos >= self.stop: return '' remaining = self.stop - self.pos if length is None or length < 0: length = remaining elif length > remaining: length = remaining self.fp.seek(self.pos) self.pos = self.pos + length return self.fp.read(length)
7,304
def readline(self, length = None): if self.pos >= self.stop: return '' if length is None: length = self.stop - self.pos self.fp.seek(self.pos) data = self.fp.readline(length) if len(data) < length: length = len(data) self.pos = self.pos + length return data
def readline(self, length = None): if self.pos >= self.stop: return '' if length is None: length = self.stop - self.pos self.fp.seek(self.pos) data = self.fp.readline(length) self.pos = self.fp.tell() return data
7,305
def close(self): pass
def close(self): pass
7,306
def deletecommand(self, name): #print '- Tkinter: deleted command', name self.tk.deletecommand(name) index = self._tclCommands.index(name) del self._tclCommands[index]
def deletecommand(self, name): #print '- Tkinter: deleted command', name self.tk.deletecommand(name) index = self._tclCommands.index(name) del self._tclCommands[index]
7,307
def _bind(self, what, sequence, func, add): if func: cmd = ("%sset _tkinter_break [%s %s]\n" 'if {"$_tkinter_break" == "break"} break\n') \ % (add and '+' or '', self._register(func, self._substitute), _string.join(self._subst_format)) apply(self.tk.call, what + (sequence, cmd)) elif func == '': apply(self.tk.call, what + (sequence, func)) else: return apply(self.tk.call, what + (sequence,))
def _bind(self, what, sequence, func, add, needcleanup=1): if func: cmd = ("%sset _tkinter_break [%s %s]\n" 'if {"$_tkinter_break" == "break"} break\n') \ % (add and '+' or '', self._register(func, self._substitute), _string.join(self._subst_format)) apply(self.tk.call, what + (sequence, cmd)) elif func == '': apply(self.tk.call, what + (sequence, func)) else: return apply(self.tk.call, what + (sequence,))
7,308
def _bind(self, what, sequence, func, add): if func: cmd = ("%sset _tkinter_break [%s %s]\n" 'if {"$_tkinter_break" == "break"} break\n') \ % (add and '+' or '', self._register(func, self._substitute), _string.join(self._subst_format)) apply(self.tk.call, what + (sequence, cmd)) elif func == '': apply(self.tk.call, what + (sequence, func)) else: return apply(self.tk.call, what + (sequence,))
def _bind(self, what, sequence, func, add): if func: cmd = ("%sset _tkinter_break [%s %s]\n" 'if {"$_tkinter_break" == "break"} break\n') \ % (add and '+' or '', self._register(func, self._substitute, needcleanup), _string.join(self._subst_format)) apply(self.tk.call, what + (sequence, cmd)) elif func == '': apply(self.tk.call, what + (sequence, func)) else: return apply(self.tk.call, what + (sequence,))
7,309
def bind_all(self, sequence=None, func=None, add=None): return self._bind(('bind', 'all'), sequence, func, add)
def bind_all(self, sequence=None, func=None, add=None): return self._bind(('bind', 'all'), sequence, func, add)
7,310
def bind_class(self, className, sequence=None, func=None, add=None): return self._bind(('bind', className), sequence, func, add)
def bind_class(self, className, sequence=None, func=None, add=None): return self._bind(('bind', className), sequence, func, add)
7,311
def _register(self, func, subst=None): f = CallWrapper(func, subst, self).__call__ name = `id(f)` try: func = func.im_func except AttributeError: pass try: name = name + func.__name__ except AttributeError: pass self.tk.createcommand(name, f) if self._tclCommands is None: self._tclCommands = [] self._tclCommands.append(name) #print '+ Tkinter created command', name return name
def _register(self, func, subst=None, needcleanup=1): f = CallWrapper(func, subst, self).__call__ name = `id(f)` try: func = func.im_func except AttributeError: pass try: name = name + func.__name__ except AttributeError: pass self.tk.createcommand(name, f) if self._tclCommands is None: self._tclCommands = [] self._tclCommands.append(name) #print '+ Tkinter created command', name return name
7,312
def _register(self, func, subst=None): f = CallWrapper(func, subst, self).__call__ name = `id(f)` try: func = func.im_func except AttributeError: pass try: name = name + func.__name__ except AttributeError: pass self.tk.createcommand(name, f) if self._tclCommands is None: self._tclCommands = [] self._tclCommands.append(name) #print '+ Tkinter created command', name return name
def _register(self, func, subst=None): f = CallWrapper(func, subst, self).__call__ name = `id(f)` try: func = func.im_func except AttributeError: pass try: name = name + func.__name__ except AttributeError: pass self.tk.createcommand(name, f) if needcleanup: if self._tclCommands is None: self._tclCommands = [] self._tclCommands.append(name) #print '+ Tkinter created command', name return name
7,313
def change_root (new_root, pathname): """Return 'pathname' with 'new_root' prepended. If 'pathname' is relative, this is equivalent to "os.path.join(new_root,pathname)". Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS.""" if not abspath (pathname): return os.path.join (new_root, pathname) elif os.name == 'posix': return os.path.join (new_root, pathname[1:]) elif os.name == 'nt': (root_drive, root_path) = os.path.splitdrive (new_root) (drive, path) = os.path.splitdrive (pathname) raise RuntimeError, "I give up -- not sure how to do this on Windows" elif os.name == 'mac': raise RuntimeError, "no clue how to do this on Mac OS" else: raise DistutilsPlatformError, \ "nothing known about platform '%s'" % os.name
defchange_root(new_root,pathname):"""Return'pathname'with'new_root'prepended.If'pathname'isrelative,thisisequivalentto"os.path.join(new_root,pathname)".Otherwise,itrequiresmaking'pathname'relativeandthenjoiningthetwo,whichistrickyonDOS/WindowsandMacOS."""ifnotabspath(pathname):returnos.path.join(new_root,pathname)elifos.name=='posix':returnos.path.join(new_root,pathname[1:])elifos.name=='nt':(root_drive,root_path)=os.path.splitdrive(new_root)(drive,path)=os.path.splitdrive(pathname)raiseRuntimeError,"Igiveup--notsurehowtodothisonWindows"elifos.name=='mac':raiseRuntimeError,"nocluehowtodothisonMacOS"else:raiseDistutilsPlatformError,\"nothingknownaboutplatform'%s'"%os.name
7,314
def change_root (new_root, pathname): """Return 'pathname' with 'new_root' prepended. If 'pathname' is relative, this is equivalent to "os.path.join(new_root,pathname)". Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS.""" if not abspath (pathname): return os.path.join (new_root, pathname) elif os.name == 'posix': return os.path.join (new_root, pathname[1:]) elif os.name == 'nt': (root_drive, root_path) = os.path.splitdrive (new_root) (drive, path) = os.path.splitdrive (pathname) raise RuntimeError, "I give up -- not sure how to do this on Windows" elif os.name == 'mac': raise RuntimeError, "no clue how to do this on Mac OS" else: raise DistutilsPlatformError, \ "nothing known about platform '%s'" % os.name
def change_root (new_root, pathname): """Return 'pathname' with 'new_root' prepended. If 'pathname' is relative, this is equivalent to "os.path.join(new_root,pathname)". Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS. """ if os.name == 'posix': if not os.path.isabs (pathname): return os.path.join (new_root, pathname) else: return os.path.join (new_root, pathname[1:]) elif os.name == 'nt': (root_drive, root_path) = os.path.splitdrive (new_root) (drive, path) = os.path.splitdrive (pathname) raise RuntimeError, "I give up -- not sure how to do this on Windows" elif os.name == 'mac': raise RuntimeError, "no clue how to do this on Mac OS" else: raise DistutilsPlatformError, \ "nothing known about platform '%s'" % os.name
7,315
def change_root (new_root, pathname): """Return 'pathname' with 'new_root' prepended. If 'pathname' is relative, this is equivalent to "os.path.join(new_root,pathname)". Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS.""" if not abspath (pathname): return os.path.join (new_root, pathname) elif os.name == 'posix': return os.path.join (new_root, pathname[1:]) elif os.name == 'nt': (root_drive, root_path) = os.path.splitdrive (new_root) (drive, path) = os.path.splitdrive (pathname) raise RuntimeError, "I give up -- not sure how to do this on Windows" elif os.name == 'mac': raise RuntimeError, "no clue how to do this on Mac OS" else: raise DistutilsPlatformError, \ "nothing known about platform '%s'" % os.name
def change_root (new_root, pathname): """Return 'pathname' with 'new_root' prepended. If 'pathname' is relative, this is equivalent to "os.path.join(new_root,pathname)". Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS.""" if not abspath (pathname): return os.path.join (new_root, pathname) elif os.name == 'posix': return os.path.join (new_root, pathname[1:]) elif os.name == 'nt': (drive, path) = os.path.splitdrive (pathname) raise RuntimeError, "I give up -- not sure how to do this on Windows" elif os.name == 'mac': raise RuntimeError, "no clue how to do this on Mac OS" else: raise DistutilsPlatformError, \ "nothing known about platform '%s'" % os.name
7,316
def change_root (new_root, pathname): """Return 'pathname' with 'new_root' prepended. If 'pathname' is relative, this is equivalent to "os.path.join(new_root,pathname)". Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS.""" if not abspath (pathname): return os.path.join (new_root, pathname) elif os.name == 'posix': return os.path.join (new_root, pathname[1:]) elif os.name == 'nt': (root_drive, root_path) = os.path.splitdrive (new_root) (drive, path) = os.path.splitdrive (pathname) raise RuntimeError, "I give up -- not sure how to do this on Windows" elif os.name == 'mac': raise RuntimeError, "no clue how to do this on Mac OS" else: raise DistutilsPlatformError, \ "nothing known about platform '%s'" % os.name
def change_root (new_root, pathname): """Return 'pathname' with 'new_root' prepended. If 'pathname' is relative, this is equivalent to "os.path.join(new_root,pathname)". Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS.""" if not abspath (pathname): return os.path.join (new_root, pathname) elif os.name == 'posix': return os.path.join (new_root, pathname[1:]) elif os.name == 'nt': (root_drive, root_path) = os.path.splitdrive (new_root) (drive, path) = os.path.splitdrive (pathname) if path[0] == '\\': path = path[1:] return os.path.join (new_root, path) elif os.name == 'mac': raise RuntimeError, "no clue how to do this on Mac OS" else: raise DistutilsPlatformError, \ "nothing known about platform '%s'" % os.name
7,317
def help_dialog(self, event=None): try: helpfile = os.path.join(os.path.dirname(__file__), self.helpfile) except NameError: helpfile = self.helpfile if self.flist: self.flist.open(helpfile) else: self.io.loadfile(helpfile)
def help_dialog(self, event=None): try: helpfile = os.path.join(os.path.dirname(__file__), self.helpfile) except NameError: helpfile = self.helpfile if self.flist: self.flist.open(helpfile) else: self.io.loadfile(helpfile)
7,318
def python_docs(self, event=None): webbrowser.open(self.help_url)
def python_docs(self, event=None): webbrowser.open(self.help_url)
7,319
def install_opener(opener): global _opener _opener = opener
def install_opener(opener): global _opener _opener = opener
7,320
def main(): global debug, looping, magnify, mindelta, nowait, quiet, regen, speed global threading, xoff, yoff # Parse command line try: opts, args = getopt.getopt(sys.argv[1:], 'M:dlm:nqr:s:tx:y:') except getopt.error, msg: sys.stdout = sys.stderr print 'Error:', msg, '\n' help() sys.exit(2) # Interpret options try: for opt, arg in opts: if opt == '-M': magnify = float(eval(arg)) if opt == '-d': debug = debug + 1 if opt == '-l': looping = 1 if opt == '-m': mindelta = string.atoi(arg) if opt == '-n': nowait = 1 if opt == '-q': quiet = 1 if opt == '-r': regen = string.atoi(arg) if opt == '-s': try: speed = float(eval(arg)) except: sys.stdout = sys.stderr print 'Option -s needs float argument' sys.exit(2) if opt == '-t': try: import thread threading = 1 except ImportError: print 'Sorry, this version of Python', print 'does not support threads:', print '-t ignored' if opt == '-x': xoff = string.atoi(arg) if opt == '-y': yoff = string.atoi(arg) except string.atoi_error: sys.stdout = sys.stderr print 'Option', opt, 'require integer argument' sys.exit(2) # Check validity of certain options combinations if nowait and looping: print 'Warning: -n and -l are mutually exclusive; -n ignored' nowait = 0 if xoff <> None and yoff == None: print 'Warning: -x without -y ignored' if xoff == None and yoff <> None: print 'Warning: -y without -x ignored' # Process all files if not args: args = ['film.video'] sts = 0 for filename in args: sts = (process(filename) or sts) # Exit with proper exit status sys.exit(sts)
def main(): global debug, looping, magnify, mindelta, nowait, quiet, regen, speed global threading, xoff, yoff # Parse command line try: opts, args = getopt.getopt(sys.argv[1:], 'M:dlm:nqr:s:tx:y:') except getopt.error, msg: sys.stdout = sys.stderr print 'Error:', msg, '\n' help() sys.exit(2) # Interpret options try: for opt, arg in opts: if opt == '-M': magnify = float(eval(arg)) if opt == '-d': debug = debug + 1 if opt == '-l': looping = 1 if opt == '-m': mindelta = string.atoi(arg) if opt == '-n': nowait = 1 if opt == '-q': quiet = 1 if opt == '-r': regen = string.atoi(arg) if opt == '-s': try: speed = float(eval(arg)) except: sys.stdout = sys.stderr print 'Option -s needs float argument' sys.exit(2) if opt == '-t': try: import thread threading = 1 except ImportError: print 'Sorry, this version of Python', print 'does not support threads:', print '-t ignored' if opt == '-x': xoff = string.atoi(arg) if opt == '-y': yoff = string.atoi(arg) except string.atoi_error: sys.stdout = sys.stderr print 'Option', opt, 'requires integer argument' sys.exit(2) # Check validity of certain options combinations if nowait and looping: print 'Warning: -n and -l are mutually exclusive; -n ignored' nowait = 0 if xoff <> None and yoff == None: print 'Warning: -x without -y ignored' if xoff == None and yoff <> None: print 'Warning: -y without -x ignored' # Process all files if not args: args = ['film.video'] sts = 0 for filename in args: sts = (process(filename) or sts) # Exit with proper exit status sys.exit(sts)
7,321
def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite): """Execute program (MS Windows version)"""
def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite): """Execute program (MS Windows version)"""
7,322
def normcase(s): """Normalize case of pathname. Makes all characters lowercase and all
def normcase(s): """Normalize case of pathname. Makes all characters lowercase and all
7,323
def _test(): import doctest doctest.testmod()
def _test(): import doctest doctest.testmod()
7,324
def test_mixed_compare(self): our = self.theclass(2000, 4, 5) self.assertRaises(TypeError, cmp, our, 1) self.assertRaises(TypeError, cmp, 1, our)
def test_mixed_compare(self): our = self.theclass(2000, 4, 5) self.assertRaises(TypeError, cmp, our, 1) self.assertRaises(TypeError, cmp, 1, our)
7,325
def __cmp__(self, other): # Return "equal" so calling this can't be confused with # compare-by-address (which never says "equal" for distinct # objects). return 0
def __cmp__(self, other): # Return "equal" so calling this can't be confused with # compare-by-address (which never says "equal" for distinct # objects). return 0
7,326
def test_bug_1028306(self): # Trying to compare a date to a datetime should act like a mixed- # type comparison, despite that datetime is a subclass of date. as_date = date.today() as_datetime = datetime.combine(as_date, time()) self.assert_(as_date != as_datetime) self.assert_(as_datetime != as_date) self.assert_(not as_date == as_datetime) self.assert_(not as_datetime == as_date) self.assertRaises(TypeError, lambda: as_date < as_datetime) self.assertRaises(TypeError, lambda: as_datetime < as_date) self.assertRaises(TypeError, lambda: as_date <= as_datetime) self.assertRaises(TypeError, lambda: as_datetime <= as_date) self.assertRaises(TypeError, lambda: as_date > as_datetime) self.assertRaises(TypeError, lambda: as_datetime > as_date) self.assertRaises(TypeError, lambda: as_date >= as_datetime) self.assertRaises(TypeError, lambda: as_datetime >= as_date)
def test_bug_1028306(self): # Trying to compare a date to a datetime should act like a mixed- # type comparison, despite that datetime is a subclass of date. as_date = date.today() as_datetime = datetime.combine(as_date, time()) self.assert_(as_date != as_datetime) self.assert_(as_datetime != as_date) self.assert_(not as_date == as_datetime) self.assert_(not as_datetime == as_date) self.assertRaises(TypeError, lambda: as_date < as_datetime) self.assertRaises(TypeError, lambda: as_datetime < as_date) self.assertRaises(TypeError, lambda: as_date <= as_datetime) self.assertRaises(TypeError, lambda: as_datetime <= as_date) self.assertRaises(TypeError, lambda: as_date > as_datetime) self.assertRaises(TypeError, lambda: as_datetime > as_date) self.assertRaises(TypeError, lambda: as_date >= as_datetime) self.assertRaises(TypeError, lambda: as_datetime >= as_date)
7,327
def test_bug_1028306(self): # Trying to compare a date to a datetime should act like a mixed- # type comparison, despite that datetime is a subclass of date. as_date = date.today() as_datetime = datetime.combine(as_date, time()) self.assert_(as_date != as_datetime) self.assert_(as_datetime != as_date) self.assert_(not as_date == as_datetime) self.assert_(not as_datetime == as_date) self.assertRaises(TypeError, lambda: as_date < as_datetime) self.assertRaises(TypeError, lambda: as_datetime < as_date) self.assertRaises(TypeError, lambda: as_date <= as_datetime) self.assertRaises(TypeError, lambda: as_datetime <= as_date) self.assertRaises(TypeError, lambda: as_date > as_datetime) self.assertRaises(TypeError, lambda: as_datetime > as_date) self.assertRaises(TypeError, lambda: as_date >= as_datetime) self.assertRaises(TypeError, lambda: as_datetime >= as_date)
def test_bug_1028306(self): # Trying to compare a date to a datetime should act like a mixed- # type comparison, despite that datetime is a subclass of date. as_date = date.today() as_datetime = datetime.combine(as_date, time()) self.assert_(as_date != as_datetime) self.assert_(as_datetime != as_date) self.assert_(not as_date == as_datetime) self.assert_(not as_datetime == as_date) self.assertRaises(TypeError, lambda: as_date < as_datetime) self.assertRaises(TypeError, lambda: as_datetime < as_date) self.assertRaises(TypeError, lambda: as_date <= as_datetime) self.assertRaises(TypeError, lambda: as_datetime <= as_date) self.assertRaises(TypeError, lambda: as_date > as_datetime) self.assertRaises(TypeError, lambda: as_datetime > as_date) self.assertRaises(TypeError, lambda: as_date >= as_datetime) self.assertRaises(TypeError, lambda: as_datetime >= as_date)
7,328
def test(openmethod, what): if verbose: print '\nTesting: ', what fname = tempfile.mktemp() f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print word f.close() try: os.remove(fname) except os.error: pass
def test(openmethod, what, ondisk=1): if verbose: print '\nTesting: ', what fname = tempfile.mktemp() f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print word f.close() try: os.remove(fname) except os.error: pass
7,329
def test(openmethod, what): if verbose: print '\nTesting: ', what fname = tempfile.mktemp() f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print word f.close() try: os.remove(fname) except os.error: pass
def test(openmethod, what): if verbose: print '\nTesting: ', what, (ondisk and "on disk" or "in memory") fname = tempfile.mktemp() f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print word f.close() try: os.remove(fname) except os.error: pass
7,330
def test(openmethod, what): if verbose: print '\nTesting: ', what fname = tempfile.mktemp() f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print word f.close() try: os.remove(fname) except os.error: pass
def test(openmethod, what): if verbose: print '\nTesting: ', what if ondisk: fname = tempfile.mktemp() else: fname = None f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print word f.close() try: os.remove(fname) except os.error: pass
7,331
def test(openmethod, what): if verbose: print '\nTesting: ', what fname = tempfile.mktemp() f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print word f.close() try: os.remove(fname) except os.error: pass
def test(openmethod, what): if verbose: print '\nTesting: ', what fname = tempfile.mktemp() f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if ondisk: if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print word f.close() try: os.remove(fname) except os.error: pass
7,332
def test(openmethod, what): if verbose: print '\nTesting: ', what fname = tempfile.mktemp() f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print word f.close() try: os.remove(fname) except os.error: pass
def test(openmethod, what): if verbose: print '\nTesting: ', what fname = tempfile.mktemp() f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print word f.close() try: os.remove(fname) except os.error: pass
7,333
def test(openmethod, what): if verbose: print '\nTesting: ', what fname = tempfile.mktemp() f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print word f.close() try: os.remove(fname) except os.error: pass
def test(openmethod, what): if verbose: print '\nTesting: ', what fname = tempfile.mktemp() f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print word f.close() try: os.remove(fname) except os.error: pass
7,334
def test(openmethod, what): if verbose: print '\nTesting: ', what fname = tempfile.mktemp() f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print word f.close() try: os.remove(fname) except os.error: pass
def test(openmethod, what): if verbose: print '\nTesting: ', what fname = tempfile.mktemp() f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print word f.close() try: os.remove(fname) except os.error: pass
7,335
def test(openmethod, what): if verbose: print '\nTesting: ', what fname = tempfile.mktemp() f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print word f.close() try: os.remove(fname) except os.error: pass
def test(openmethod, what): if verbose: print '\nTesting: ', what fname = tempfile.mktemp() f = openmethod(fname, 'c') verify(f.keys() == []) if verbose: print 'creation...' f['0'] = '' f['a'] = 'Guido' f['b'] = 'van' f['c'] = 'Rossum' f['d'] = 'invented' f['f'] = 'Python' if verbose: print '%s %s %s' % (f['a'], f['b'], f['c']) if what == 'BTree' : if verbose: print 'key ordering...' f.set_location(f.first()[0]) while 1: try: rec = f.next() except KeyError: if rec != f.last(): print 'Error, last != last!' f.previous() break if verbose: print rec if not f.has_key('a'): print 'Error, missing key!' f.sync() f.close() if verbose: print 'modification...' f = openmethod(fname, 'w') f['d'] = 'discovered' if verbose: print 'access...' for key in f.keys(): word = f[key] if verbose: print word f.close() try: os.remove(fname) except os.error: pass
7,336
def prompt(prompt): sys.stdout.write(prompt + ": ") return sys.stdin.readline().strip()
def prompt(prompt): sys.stdout.write(prompt + ": ") return sys.stdin.readline().strip()
7,337
>>> def f(None=1):
>>> def f(None=1):
7,338
>>> def f(x, y=1, z):
>>> def f(x, y=1, z):
7,339
>>> def f(x, None):
>>> def f(x, None):
7,340
>>> def f(*None):
>>> def f(*None):
7,341
>>> def f(**None):
>>> def f(**None):
7,342
>>> def None(x):
>>> def None(x):
7,343
>>> def f(it, *varargs):
>>> def f(it, *varargs):
7,344
>>> def f(it, *varargs):
>>> def f(it, *varargs):
7,345
>>> def f(it, *varargs):
>>> def f(it, *varargs):
7,346
>>> def f(it, *varargs):
>>> def f(it, *varargs):
7,347
>>> def f(it, *varargs):
>>> def f(it, *varargs):
7,348
>>> def f(it, *varargs):
>>> def f(it, *varargs):
7,349
>>> def f(it, *varargs):
>>> def f(it, *varargs):
7,350
>>> def f(it, *varargs):
>>> def f(it, *varargs):
7,351
>>> def f(it, *varargs):
>>> def f(it, *varargs):
7,352
>>> def f(it, *varargs):
>>> def f(it, *varargs):
7,353
def select(self, _object, _attributes={}, **_arguments): """select: Select the specified object(s) Required argument: the object to select Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'misc' _subcode = 'slct'
def select(self, _object, _attributes={}, **_arguments): """select: Select the specified object(s) Required argument: the object to select Keyword argument _attributes: AppleEvent attribute dictionary """ _code = 'misc' _subcode = 'slct'
7,354
def finalize_package_data (self): self.ensure_string('group', "Development/Libraries") self.ensure_string('vendor', "%s <%s>" % (self.distribution.get_contact(), self.distribution.get_contact_email())) self.ensure_string('packager') self.ensure_string_list('doc_files') if type(self.doc_files) is ListType: for readme in ('README', 'README.txt'): if os.path.exists(readme) and readme not in self.doc_files: self.doc.append(readme)
def finalize_package_data (self): self.ensure_string('group', "Development/Libraries") self.ensure_string('vendor', "%s <%s>" % (self.distribution.get_contact(), self.distribution.get_contact_email())) self.ensure_string('packager') self.ensure_string_list('doc_files') if type(self.doc_files) is ListType: for readme in ('README', 'README.txt'): if os.path.exists(readme) and readme not in self.doc_files: self.doc.append(readme)
7,355
def decode(in_file, out_file=None, mode=None): """Decode uuencoded file""" # # Open the input file, if needed. # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): in_file = open(in_file) # # Read until a begin is encountered or we've exhausted the file # while 1: hdr = in_file.readline() if not hdr: raise Error, 'No valid begin line found in input file' if hdr[:5] != 'begin': continue hdrfields = string.split(hdr) if len(hdrfields) == 3 and hdrfields[0] == 'begin': try: string.atoi(hdrfields[1], 8) break except ValueError: pass if out_file == None: out_file = hdrfields[2] if mode == None: mode = string.atoi(hdrfields[1], 8) # # Open the output file # if out_file == '-': out_file = sys.stdout elif type(out_file) == type(''): fp = open(out_file, 'wb') try: os.path.chmod(out_file, mode) except AttributeError: pass out_file = fp # # Main decoding loop # str = in_file.readline() while str and str != 'end\n': out_file.write(binascii.a2b_uu(str)) str = in_file.readline() if not str: raise Error, 'Truncated input file'
def decode(in_file, out_file=None, mode=None): """Decode uuencoded file""" # # Open the input file, if needed. # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): in_file = open(in_file) # # Read until a begin is encountered or we've exhausted the file # while 1: hdr = in_file.readline() if not hdr: raise Error, 'No valid begin line found in input file' if hdr[:5] != 'begin': continue hdrfields = string.split(hdr) if len(hdrfields) == 3 and hdrfields[0] == 'begin': try: string.atoi(hdrfields[1], 8) break except ValueError: pass if out_file == None: out_file = hdrfields[2] if mode == None: mode = string.atoi(hdrfields[1], 8) # # Open the output file # if out_file == '-': out_file = sys.stdout elif type(out_file) == type(''): fp = open(out_file, 'wb') try: os.path.chmod(out_file, mode) except AttributeError: pass out_file = fp # # Main decoding loop # s = in_file.readline() while s and s != 'end\n': try: data = binascii.a2b_uu(s) except binascii.Error, v: nbytes = (((ord(s[0])-32) & 63) * 4 + 5) / 3 data = binascii.a2b_uu(s[:nbytes]) sys.stderr.write("Warning: %s\n" % str(v)) out_file.write(data) s = in_file.readline() if not str: raise Error, 'Truncated input file'
7,356
def translation(domain, localedir=None, languages=None, class_=None): if class_ is None: class_ = GNUTranslations mofile = find(domain, localedir, languages) if mofile is None: raise IOError(ENOENT, 'No translation file found for domain', domain) key = os.path.abspath(mofile) # TBD: do we need to worry about the file pointer getting collected? # Avoid opening, reading, and parsing the .mo file after it's been done # once. t = _translations.get(key) if t is None: t = _translations.setdefault(key, class_(open(mofile, 'rb'))) return t
def translation(domain, localedir=None, languages=None, class_=None, fallback=0): if class_ is None: class_ = GNUTranslations mofile = find(domain, localedir, languages) if mofile is None: raise IOError(ENOENT, 'No translation file found for domain', domain) key = os.path.abspath(mofile) # TBD: do we need to worry about the file pointer getting collected? # Avoid opening, reading, and parsing the .mo file after it's been done # once. t = _translations.get(key) if t is None: t = _translations.setdefault(key, class_(open(mofile, 'rb'))) return t
7,357
def install(domain, localedir=None, unicode=0): translation(domain, localedir).install(unicode)
def install(domain, localedir=None, unicode=0): translation(domain, localedir, fallback=1).install(unicode)
7,358
def _init_posix(): """Initialize the module as appropriate for POSIX systems.""" g = {} # load the installed Makefile: try: filename = get_makefile_filename() parse_makefile(filename, g) except IOError, msg: my_msg = "invalid Python installation: unable to open %s" % filename if hasattr(msg, "strerror"): my_msg = my_msg + " (%s)" % msg.strerror raise DistutilsPlatformError, my_msg # On AIX, there are wrong paths to the linker scripts in the Makefile # -- these paths are relative to the Python source, but when installed # the scripts are in another directory. if sys.platform == 'aix4': # what about AIX 3.x ? # Linker script is in the config directory, not in Modules as the # Makefile says. python_lib = get_python_lib(standard_lib=1) ld_so_aix = os.path.join(python_lib, 'config', 'ld_so_aix') python_exp = os.path.join(python_lib, 'config', 'python.exp') g['LDSHARED'] = "%s %s -bI:%s" % (ld_so_aix, g['CC'], python_exp) elif sys.platform == 'beos': # Linker script is in the config directory. In the Makefile it is # relative to the srcdir, which after installation no longer makes # sense. python_lib = get_python_lib(standard_lib=1) linkerscript_name = os.path.basename(string.split(g['LDSHARED'])[0]) linkerscript = os.path.join(python_lib, 'config', linkerscript_name) # XXX this isn't the right place to do this: adding the Python # library to the link, if needed, should be in the "build_ext" # command. (It's also needed for non-MS compilers on Windows, and # it's taken care of for them by the 'build_ext.get_libraries()' # method.) g['LDSHARED'] = ("%s -L%s/lib -lpython%s" % (linkerscript, PREFIX, sys.version[0:3])) global _config_vars _config_vars = g
def _init_posix(): """Initialize the module as appropriate for POSIX systems.""" g = {} # load the installed Makefile: try: filename = get_makefile_filename() parse_makefile(filename, g) except IOError, msg: my_msg = "invalid Python installation: unable to open %s" % filename if hasattr(msg, "strerror"): my_msg = my_msg + " (%s)" % msg.strerror raise DistutilsPlatformError, my_msg # On AIX, there are wrong paths to the linker scripts in the Makefile # -- these paths are relative to the Python source, but when installed # the scripts are in another directory. if sys.platform == 'aix4': # what about AIX 3.x ? # Linker script is in the config directory, not in Modules as the # Makefile says. python_lib = get_python_lib(standard_lib=1) ld_so_aix = os.path.join(python_lib, 'config', 'ld_so_aix') python_exp = os.path.join(python_lib, 'config', 'python.exp') g['LDSHARED'] = "%s %s -bI:%s" % (ld_so_aix, g['CC'], python_exp) elif sys.platform == 'beos': # Linker script is in the config directory. In the Makefile it is # relative to the srcdir, which after installation no longer makes # sense. python_lib = get_python_lib(standard_lib=1) linkerscript_name = os.path.basename(string.split(g['LDSHARED'])[0]) linkerscript = os.path.join(python_lib, 'config', linkerscript_name) # XXX this isn't the right place to do this: adding the Python # library to the link, if needed, should be in the "build_ext" # command. (It's also needed for non-MS compilers on Windows, and # it's taken care of for them by the 'build_ext.get_libraries()' # method.) g['LDSHARED'] = ("%s -L%s/lib -lpython%s" % (linkerscript, PREFIX, sys.version[0:3])) global _config_vars _config_vars = g
7,359
def getdomainliteral(self): """Parse an RFC-822 domain-literal.""" return self.getdelimited('[', ']\r', 0)
def getdomainliteral(self): """Parse an RFC-822 domain-literal.""" return '[%s]' % self.getdelimited('[', ']\r', 0)
7,360
def _msgobj(self, filename): fp = openfile(findfile(filename)) try: msg = email.message_from_file(fp) finally: fp.close() return msg
def _msgobj(self, filename, strict=False): fp = openfile(findfile(filename)) try: msg = email.message_from_file(fp) finally: fp.close() return msg
7,361
def _msgobj(self, filename): fp = openfile(findfile(filename)) try: msg = email.message_from_file(fp) finally: fp.close() return msg
def _msgobj(self, filename): fp = openfile(findfile(filename)) try: msg = email.message_from_file(fp, strict=strict) finally: fp.close() return msg
7,362
def test_get_decoded_payload(self): eq = self.assertEqual msg = self._msgobj('msg_10.txt') # The outer message is a multipart eq(msg.get_payload(decode=1), None) # Subpart 1 is 7bit encoded eq(msg.get_payload(0).get_payload(decode=1), 'This is a 7bit encoded message.\n') # Subpart 2 is quopri eq(msg.get_payload(1).get_payload(decode=1), '\xa1This is a Quoted Printable encoded message!\n') # Subpart 3 is base64 eq(msg.get_payload(2).get_payload(decode=1), 'This is a Base64 encoded message.') # Subpart 4 has no Content-Transfer-Encoding: header. eq(msg.get_payload(3).get_payload(decode=1), 'This has no Content-Transfer-Encoding: header.\n')
def test_get_decoded_payload(self): eq = self.assertEqual msg = self._msgobj('msg_10.txt') # The outer message is a multipart eq(msg.get_payload(decode=True), None) # Subpart 1 is 7bit encoded eq(msg.get_payload(0).get_payload(decode=1), 'This is a 7bit encoded message.\n') # Subpart 2 is quopri eq(msg.get_payload(1).get_payload(decode=1), '\xa1This is a Quoted Printable encoded message!\n') # Subpart 3 is base64 eq(msg.get_payload(2).get_payload(decode=1), 'This is a Base64 encoded message.') # Subpart 4 has no Content-Transfer-Encoding: header. eq(msg.get_payload(3).get_payload(decode=1), 'This has no Content-Transfer-Encoding: header.\n')
7,363
def test_get_decoded_payload(self): eq = self.assertEqual msg = self._msgobj('msg_10.txt') # The outer message is a multipart eq(msg.get_payload(decode=1), None) # Subpart 1 is 7bit encoded eq(msg.get_payload(0).get_payload(decode=1), 'This is a 7bit encoded message.\n') # Subpart 2 is quopri eq(msg.get_payload(1).get_payload(decode=1), '\xa1This is a Quoted Printable encoded message!\n') # Subpart 3 is base64 eq(msg.get_payload(2).get_payload(decode=1), 'This is a Base64 encoded message.') # Subpart 4 has no Content-Transfer-Encoding: header. eq(msg.get_payload(3).get_payload(decode=1), 'This has no Content-Transfer-Encoding: header.\n')
def test_get_decoded_payload(self): eq = self.assertEqual msg = self._msgobj('msg_10.txt') # The outer message is a multipart eq(msg.get_payload(decode=1), None) # Subpart 1 is 7bit encoded eq(msg.get_payload(0).get_payload(decode=True), 'This is a 7bit encoded message.\n') # Subpart 2 is quopri eq(msg.get_payload(1).get_payload(decode=1), '\xa1This is a Quoted Printable encoded message!\n') # Subpart 3 is base64 eq(msg.get_payload(2).get_payload(decode=1), 'This is a Base64 encoded message.') # Subpart 4 has no Content-Transfer-Encoding: header. eq(msg.get_payload(3).get_payload(decode=1), 'This has no Content-Transfer-Encoding: header.\n')
7,364
def test_get_decoded_payload(self): eq = self.assertEqual msg = self._msgobj('msg_10.txt') # The outer message is a multipart eq(msg.get_payload(decode=1), None) # Subpart 1 is 7bit encoded eq(msg.get_payload(0).get_payload(decode=1), 'This is a 7bit encoded message.\n') # Subpart 2 is quopri eq(msg.get_payload(1).get_payload(decode=1), '\xa1This is a Quoted Printable encoded message!\n') # Subpart 3 is base64 eq(msg.get_payload(2).get_payload(decode=1), 'This is a Base64 encoded message.') # Subpart 4 has no Content-Transfer-Encoding: header. eq(msg.get_payload(3).get_payload(decode=1), 'This has no Content-Transfer-Encoding: header.\n')
def test_get_decoded_payload(self): eq = self.assertEqual msg = self._msgobj('msg_10.txt') # The outer message is a multipart eq(msg.get_payload(decode=1), None) # Subpart 1 is 7bit encoded eq(msg.get_payload(0).get_payload(decode=1), 'This is a 7bit encoded message.\n') # Subpart 2 is quopri eq(msg.get_payload(1).get_payload(decode=True), '\xa1This is a Quoted Printable encoded message!\n') # Subpart 3 is base64 eq(msg.get_payload(2).get_payload(decode=1), 'This is a Base64 encoded message.') # Subpart 4 has no Content-Transfer-Encoding: header. eq(msg.get_payload(3).get_payload(decode=1), 'This has no Content-Transfer-Encoding: header.\n')
7,365
def test_get_decoded_payload(self): eq = self.assertEqual msg = self._msgobj('msg_10.txt') # The outer message is a multipart eq(msg.get_payload(decode=1), None) # Subpart 1 is 7bit encoded eq(msg.get_payload(0).get_payload(decode=1), 'This is a 7bit encoded message.\n') # Subpart 2 is quopri eq(msg.get_payload(1).get_payload(decode=1), '\xa1This is a Quoted Printable encoded message!\n') # Subpart 3 is base64 eq(msg.get_payload(2).get_payload(decode=1), 'This is a Base64 encoded message.') # Subpart 4 has no Content-Transfer-Encoding: header. eq(msg.get_payload(3).get_payload(decode=1), 'This has no Content-Transfer-Encoding: header.\n')
def test_get_decoded_payload(self): eq = self.assertEqual msg = self._msgobj('msg_10.txt') # The outer message is a multipart eq(msg.get_payload(decode=1), None) # Subpart 1 is 7bit encoded eq(msg.get_payload(0).get_payload(decode=1), 'This is a 7bit encoded message.\n') # Subpart 2 is quopri eq(msg.get_payload(1).get_payload(decode=1), '\xa1This is a Quoted Printable encoded message!\n') # Subpart 3 is base64 eq(msg.get_payload(2).get_payload(decode=True), 'This is a Base64 encoded message.') # Subpart 4 has no Content-Transfer-Encoding: header. eq(msg.get_payload(3).get_payload(decode=1), 'This has no Content-Transfer-Encoding: header.\n')
7,366
def test_get_decoded_payload(self): eq = self.assertEqual msg = self._msgobj('msg_10.txt') # The outer message is a multipart eq(msg.get_payload(decode=1), None) # Subpart 1 is 7bit encoded eq(msg.get_payload(0).get_payload(decode=1), 'This is a 7bit encoded message.\n') # Subpart 2 is quopri eq(msg.get_payload(1).get_payload(decode=1), '\xa1This is a Quoted Printable encoded message!\n') # Subpart 3 is base64 eq(msg.get_payload(2).get_payload(decode=1), 'This is a Base64 encoded message.') # Subpart 4 has no Content-Transfer-Encoding: header. eq(msg.get_payload(3).get_payload(decode=1), 'This has no Content-Transfer-Encoding: header.\n')
def test_get_decoded_payload(self): eq = self.assertEqual msg = self._msgobj('msg_10.txt') # The outer message is a multipart eq(msg.get_payload(decode=1), None) # Subpart 1 is 7bit encoded eq(msg.get_payload(0).get_payload(decode=1), 'This is a 7bit encoded message.\n') # Subpart 2 is quopri eq(msg.get_payload(1).get_payload(decode=1), '\xa1This is a Quoted Printable encoded message!\n') # Subpart 3 is base64 eq(msg.get_payload(2).get_payload(decode=1), 'This is a Base64 encoded message.') # Subpart 4 has no Content-Transfer-Encoding: header. eq(msg.get_payload(3).get_payload(decode=True), 'This has no Content-Transfer-Encoding: header.\n')
7,367
def test_set_param(self): eq = self.assertEqual msg = Message() msg.set_param('charset', 'iso-2022-jp') eq(msg.get_param('charset'), 'iso-2022-jp') msg.set_param('importance', 'high value') eq(msg.get_param('importance'), 'high value') eq(msg.get_param('importance', unquote=0), '"high value"') eq(msg.get_params(), [('text/plain', ''), ('charset', 'iso-2022-jp'), ('importance', 'high value')]) eq(msg.get_params(unquote=0), [('text/plain', ''), ('charset', '"iso-2022-jp"'), ('importance', '"high value"')]) msg.set_param('charset', 'iso-9999-xx', header='X-Jimmy') eq(msg.get_param('charset', header='X-Jimmy'), 'iso-9999-xx')
def test_set_param(self): eq = self.assertEqual msg = Message() msg.set_param('charset', 'iso-2022-jp') eq(msg.get_param('charset'), 'iso-2022-jp') msg.set_param('importance', 'high value') eq(msg.get_param('importance'), 'high value') eq(msg.get_param('importance', unquote=False), '"high value"') eq(msg.get_params(), [('text/plain', ''), ('charset', 'iso-2022-jp'), ('importance', 'high value')]) eq(msg.get_params(unquote=0), [('text/plain', ''), ('charset', '"iso-2022-jp"'), ('importance', '"high value"')]) msg.set_param('charset', 'iso-9999-xx', header='X-Jimmy') eq(msg.get_param('charset', header='X-Jimmy'), 'iso-9999-xx')
7,368
def test_set_param(self): eq = self.assertEqual msg = Message() msg.set_param('charset', 'iso-2022-jp') eq(msg.get_param('charset'), 'iso-2022-jp') msg.set_param('importance', 'high value') eq(msg.get_param('importance'), 'high value') eq(msg.get_param('importance', unquote=0), '"high value"') eq(msg.get_params(), [('text/plain', ''), ('charset', 'iso-2022-jp'), ('importance', 'high value')]) eq(msg.get_params(unquote=0), [('text/plain', ''), ('charset', '"iso-2022-jp"'), ('importance', '"high value"')]) msg.set_param('charset', 'iso-9999-xx', header='X-Jimmy') eq(msg.get_param('charset', header='X-Jimmy'), 'iso-9999-xx')
def test_set_param(self): eq = self.assertEqual msg = Message() msg.set_param('charset', 'iso-2022-jp') eq(msg.get_param('charset'), 'iso-2022-jp') msg.set_param('importance', 'high value') eq(msg.get_param('importance'), 'high value') eq(msg.get_param('importance', unquote=0), '"high value"') eq(msg.get_params(), [('text/plain', ''), ('charset', 'iso-2022-jp'), ('importance', 'high value')]) eq(msg.get_params(unquote=False), [('text/plain', ''), ('charset', '"iso-2022-jp"'), ('importance', '"high value"')]) msg.set_param('charset', 'iso-9999-xx', header='X-Jimmy') eq(msg.get_param('charset', header='X-Jimmy'), 'iso-9999-xx')
7,369
def test_mangled_from(self): s = StringIO() g = Generator(s, mangle_from_=1) g.flatten(self.msg) self.assertEqual(s.getvalue(), """\
def test_mangled_from(self): s = StringIO() g = Generator(s, mangle_from_=True) g.flatten(self.msg) self.assertEqual(s.getvalue(), """\
7,370
def test_dont_mangle_from(self): s = StringIO() g = Generator(s, mangle_from_=0) g.flatten(self.msg) self.assertEqual(s.getvalue(), """\
def test_dont_mangle_from(self): s = StringIO() g = Generator(s, mangle_from_=False) g.flatten(self.msg) self.assertEqual(s.getvalue(), """\
7,371
def test_bogus_boundary(self): fp = openfile(findfile('msg_15.txt')) try: data = fp.read() finally: fp.close() p = Parser(strict=1) # Note, under a future non-strict parsing mode, this would parse the # message into the intended message tree. self.assertRaises(Errors.BoundaryError, p.parsestr, data)
def test_bogus_boundary(self): fp = openfile(findfile('msg_15.txt')) try: data = fp.read() finally: fp.close() p = Parser(strict=True) # Note, under a future non-strict parsing mode, this would parse the # message into the intended message tree. self.assertRaises(Errors.BoundaryError, p.parsestr, data)
7,372
def test_formatdate_localtime(self): now = time.time() self.assertEqual( Utils.parsedate(Utils.formatdate(now, localtime=1))[:6], time.localtime(now)[:6])
def test_formatdate_localtime(self): now = time.time() self.assertEqual( Utils.parsedate(Utils.formatdate(now, localtime=True))[:6], time.localtime(now)[:6])
7,373
def test_header_encode(self): eq = self.assertEqual he = base64MIME.header_encode eq(he('hello'), '=?iso-8859-1?b?aGVsbG8=?=') eq(he('hello\nworld'), '=?iso-8859-1?b?aGVsbG8NCndvcmxk?=') # Test the charset option eq(he('hello', charset='iso-8859-2'), '=?iso-8859-2?b?aGVsbG8=?=') # Test the keep_eols flag eq(he('hello\nworld', keep_eols=1), '=?iso-8859-1?b?aGVsbG8Kd29ybGQ=?=') # Test the maxlinelen argument eq(he('xxxx ' * 20, maxlinelen=40), """\
def test_header_encode(self): eq = self.assertEqual he = base64MIME.header_encode eq(he('hello'), '=?iso-8859-1?b?aGVsbG8=?=') eq(he('hello\nworld'), '=?iso-8859-1?b?aGVsbG8NCndvcmxk?=') # Test the charset option eq(he('hello', charset='iso-8859-2'), '=?iso-8859-2?b?aGVsbG8=?=') # Test the keep_eols flag eq(he('hello\nworld', keep_eols=True), '=?iso-8859-1?b?aGVsbG8Kd29ybGQ=?=') # Test the maxlinelen argument eq(he('xxxx ' * 20, maxlinelen=40), """\
7,374
def test_header_encode(self): eq = self.assertEqual he = quopriMIME.header_encode eq(he('hello'), '=?iso-8859-1?q?hello?=') eq(he('hello\nworld'), '=?iso-8859-1?q?hello=0D=0Aworld?=') # Test the charset option eq(he('hello', charset='iso-8859-2'), '=?iso-8859-2?q?hello?=') # Test the keep_eols flag eq(he('hello\nworld', keep_eols=1), '=?iso-8859-1?q?hello=0Aworld?=') # Test a non-ASCII character eq(he('hello\xc7there'), '=?iso-8859-1?q?hello=C7there?=') # Test the maxlinelen argument eq(he('xxxx ' * 20, maxlinelen=40), """\
def test_header_encode(self): eq = self.assertEqual he = quopriMIME.header_encode eq(he('hello'), '=?iso-8859-1?q?hello?=') eq(he('hello\nworld'), '=?iso-8859-1?q?hello=0D=0Aworld?=') # Test the charset option eq(he('hello', charset='iso-8859-2'), '=?iso-8859-2?q?hello?=') # Test the keep_eols flag eq(he('hello\nworld', keep_eols=True), '=?iso-8859-1?q?hello=0Aworld?=') # Test a non-ASCII character eq(he('hello\xc7there'), '=?iso-8859-1?q?hello=C7there?=') # Test the maxlinelen argument eq(he('xxxx ' * 20, maxlinelen=40), """\
7,375
def test_get_param(self): eq = self.assertEqual msg = self._msgobj('msg_29.txt') eq(msg.get_param('title'), ('us-ascii', 'en', 'This is even more ***fun*** isn\'t it!')) eq(msg.get_param('title', unquote=0), ('us-ascii', 'en', '"This is even more ***fun*** isn\'t it!"'))
def test_get_param(self): eq = self.assertEqual msg = self._msgobj('msg_29.txt') eq(msg.get_param('title'), ('us-ascii', 'en', 'This is even more ***fun*** isn\'t it!')) eq(msg.get_param('title', unquote=False), ('us-ascii', 'en', '"This is even more ***fun*** isn\'t it!"'))
7,376
def __init__(self, initfile): self.__initfile = initfile self.__colordb = None self.__optiondb = {} self.__views = [] self.__red = 0 self.__green = 0 self.__blue = 0 self.__canceled = 0 # read the initialization file fp = None if initfile: try: try: fp = open(initfile) self.__optiondb = marshal.load(fp) if type(self.__optiondb) <> DictType: print >> sys.stderr, \ 'Problem reading options from file:', initfile self.__optiondb = {} except (IOError, EOFError, ValueError): pass finally: if fp: fp.close()
def __init__(self, initfile): self.__initfile = initfile self.__colordb = None self.__optiondb = {} self.__views = [] self.__red = 0 self.__green = 0 self.__blue = 0 self.__canceled = 0 # read the initialization file fp = None if initfile: try: try: fp = open(initfile) self.__optiondb = marshal.load(fp) if not isinstance(self.__optiondb, DictType): print >> sys.stderr, \ 'Problem reading options from file:', initfile self.__optiondb = {} except (IOError, EOFError, ValueError): pass finally: if fp: fp.close()
7,377
def NodeList(): return []
def NodeList(): return []
7,378
def getElementsByTagName(self, name): return _getElementsByTagNameHelper(self, name, [])
def getElementsByTagName(self, name): return _getElementsByTagNameHelper(self, name, [])
7,379
def getElementsByTagNameNS(self, namespaceURI, localName): return _getElementsByTagNameNSHelper(self, namespaceURI, localName, [])
def getElementsByTagNameNS(self, namespaceURI, localName): return _getElementsByTagNameNSHelper(self, namespaceURI, localName, [])
7,380
def getElementsByTagName(self, name): return _getElementsByTagNameHelper(self, name, [])
def getElementsByTagName(self, name): return _getElementsByTagNameHelper(self, name, [])
7,381
def getElementsByTagNameNS(self, namespaceURI, localName): return _getElementsByTagNameNSHelper(self, namespaceURI, localName, [])
def getElementsByTagNameNS(self, namespaceURI, localName): return _getElementsByTagNameNSHelper(self, namespaceURI, localName, [])
7,382
def open_https(self, url): """Use HTTPS protocol.""" import httplib if type(url) is type(""): host, selector = splithost(url) user_passwd, host = splituser(host) else: host, selector = url urltype, rest = splittype(selector) if string.lower(urltype) == 'https': realhost, rest = splithost(rest) 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 user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd)) else: auth = None h = httplib.HTTPS(host, 0, key_file=self.key_file, cert_file=self.cert_file) h.putrequest('GET', selector) if auth: h.putheader('Authorization: Basic %s' % auth) for args in self.addheaders: apply(h.putheader, args) h.endheaders() errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, url) else: return self.http_error(url, fp, errcode, errmsg, headers)
def open_https(self, url, data=None): """Use HTTPS protocol.""" import httplib if type(url) is type(""): host, selector = splithost(url) user_passwd, host = splituser(host) else: host, selector = url urltype, rest = splittype(selector) if string.lower(urltype) == 'https': realhost, rest = splithost(rest) 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 user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd)) else: auth = None h = httplib.HTTPS(host, 0, key_file=self.key_file, cert_file=self.cert_file) h.putrequest('GET', selector) if auth: h.putheader('Authorization: Basic %s' % auth) for args in self.addheaders: apply(h.putheader, args) h.endheaders() errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, url) else: return self.http_error(url, fp, errcode, errmsg, headers)
7,383
def open_https(self, url): """Use HTTPS protocol.""" import httplib if type(url) is type(""): host, selector = splithost(url) user_passwd, host = splituser(host) else: host, selector = url urltype, rest = splittype(selector) if string.lower(urltype) == 'https': realhost, rest = splithost(rest) 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 user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd)) else: auth = None h = httplib.HTTPS(host, 0, key_file=self.key_file, cert_file=self.cert_file) h.putrequest('GET', selector) if auth: h.putheader('Authorization: Basic %s' % auth) for args in self.addheaders: apply(h.putheader, args) h.endheaders() errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, url) else: return self.http_error(url, fp, errcode, errmsg, headers)
def open_https(self, url): """Use HTTPS protocol.""" import httplib if type(url) is type(""): host, selector = splithost(url) user_passwd, host = splituser(host) else: host, selector = url urltype, rest = splittype(selector) if string.lower(urltype) == 'https': realhost, rest = splithost(rest) 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 user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd)) 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 auth: h.putheader('Authorization: Basic %s' % auth) for args in self.addheaders: apply(h.putheader, args) h.endheaders() errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, url) else: return self.http_error(url, fp, errcode, errmsg, headers)
7,384
def parseaddr(address): import string str = '' email = '' comment = '' backslash = 0 dquote = 0 space = 0 paren = 0 bracket = 0 seen_bracket = 0 for c in address: if backslash: str = str + c backslash = 0 continue if c == '\\': backslash = 1 continue if dquote: if c == '"': dquote = 0 else: str = str + c continue if c == '"': dquote = 1 continue if c in string.whitespace: space = 1 continue if space: str = str + ' ' space = 0 if paren: if c == '(': paren = paren + 1 str = str + c continue if c == ')': paren = paren - 1 if paren == 0: comment = comment + str str = '' continue if c == '(': paren = paren + 1 if bracket: email = email + str str = '' elif not seen_bracket: email = email + str str = '' continue if bracket: if c == '>': bracket = 0 email = email + str str = '' continue if c == '<': bracket = 1 seen_bracket = 1 comment = comment + str str = '' email = '' continue if c == '#' and not bracket and not paren: # rest is comment break str = str + c if str: if seen_bracket: if bracket: email = str else: comment = comment + str else: if paren: comment = comment + str else: email = email + str return string.strip(comment), string.strip(email)
def parseaddr(address): token = [] tokens = [] backslash = 0 dquote = 0 space = 0 paren = 0 bracket = 0 seen_bracket = 0 for c in address: if backslash: str = str + c backslash = 0 continue if c == '\\': backslash = 1 continue if dquote: if c == '"': dquote = 0 else: str = str + c continue if c == '"': dquote = 1 continue if c in string.whitespace: space = 1 continue if space: str = str + ' ' space = 0 if paren: if c == '(': paren = paren + 1 str = str + c continue if c == ')': paren = paren - 1 if paren == 0: comment = comment + str str = '' continue if c == '(': paren = paren + 1 if bracket: email = email + str str = '' elif not seen_bracket: email = email + str str = '' continue if bracket: if c == '>': bracket = 0 email = email + str str = '' continue if c == '<': bracket = 1 seen_bracket = 1 comment = comment + str str = '' email = '' continue if c == '#' and not bracket and not paren: # rest is comment break str = str + c if str: if seen_bracket: if bracket: email = str else: comment = comment + str else: if paren: comment = comment + str else: email = email + str return string.strip(comment), string.strip(email)
7,385
def parseaddr(address): import string str = '' email = '' comment = '' backslash = 0 dquote = 0 space = 0 paren = 0 bracket = 0 seen_bracket = 0 for c in address: if backslash: str = str + c backslash = 0 continue if c == '\\': backslash = 1 continue if dquote: if c == '"': dquote = 0 else: str = str + c continue if c == '"': dquote = 1 continue if c in string.whitespace: space = 1 continue if space: str = str + ' ' space = 0 if paren: if c == '(': paren = paren + 1 str = str + c continue if c == ')': paren = paren - 1 if paren == 0: comment = comment + str str = '' continue if c == '(': paren = paren + 1 if bracket: email = email + str str = '' elif not seen_bracket: email = email + str str = '' continue if bracket: if c == '>': bracket = 0 email = email + str str = '' continue if c == '<': bracket = 1 seen_bracket = 1 comment = comment + str str = '' email = '' continue if c == '#' and not bracket and not paren: # rest is comment break str = str + c if str: if seen_bracket: if bracket: email = str else: comment = comment + str else: if paren: comment = comment + str else: email = email + str return string.strip(comment), string.strip(email)
def parseaddr(address): import string str = '' email = '' comment = '' backslash = 0 dquote = 0 space = 0 paren = 0 for c in address: if backslash: str = str + c backslash = 0 continue if c == '\\': backslash = 1 continue if dquote: if c == '"': dquote = 0 else: str = str + c continue if c == '"': dquote = 1 continue if c in string.whitespace: space = 1 continue if space: str = str + ' ' space = 0 if paren: if c == '(': paren = paren + 1 str = str + c continue if c == ')': paren = paren - 1 if paren == 0: comment = comment + str str = '' continue if c == '(': paren = paren + 1 if bracket: email = email + str str = '' elif not seen_bracket: email = email + str str = '' continue if bracket: if c == '>': bracket = 0 email = email + str str = '' continue if c == '<': bracket = 1 seen_bracket = 1 comment = comment + str str = '' email = '' continue if c == '#' and not bracket and not paren: # rest is comment break str = str + c if str: if seen_bracket: if bracket: email = str else: comment = comment + str else: if paren: comment = comment + str else: email = email + str return string.strip(comment), string.strip(email)
7,386
def parseaddr(address): import string str = '' email = '' comment = '' backslash = 0 dquote = 0 space = 0 paren = 0 bracket = 0 seen_bracket = 0 for c in address: if backslash: str = str + c backslash = 0 continue if c == '\\': backslash = 1 continue if dquote: if c == '"': dquote = 0 else: str = str + c continue if c == '"': dquote = 1 continue if c in string.whitespace: space = 1 continue if space: str = str + ' ' space = 0 if paren: if c == '(': paren = paren + 1 str = str + c continue if c == ')': paren = paren - 1 if paren == 0: comment = comment + str str = '' continue if c == '(': paren = paren + 1 if bracket: email = email + str str = '' elif not seen_bracket: email = email + str str = '' continue if bracket: if c == '>': bracket = 0 email = email + str str = '' continue if c == '<': bracket = 1 seen_bracket = 1 comment = comment + str str = '' email = '' continue if c == '#' and not bracket and not paren: # rest is comment break str = str + c if str: if seen_bracket: if bracket: email = str else: comment = comment + str else: if paren: comment = comment + str else: email = email + str return string.strip(comment), string.strip(email)
def parseaddr(address): import string str = '' email = '' comment = '' backslash = 0 dquote = 0 space = 0 paren = 0 bracket = 0 seen_bracket = 0 for c in address: if backslash: token.append(c) backslash = 0 continue if c == '\\': backslash = 1 continue if dquote: if c == '"': dquote = 0 else: token.append(c) continue if c == '"': dquote = 1 continue if c in string.whitespace: space = 1 continue if space: str = str + ' ' space = 0 if paren: if c == '(': paren = paren + 1 token.append(c) continue if c == ')': paren = paren - 1 if paren == 0: comment = comment + str str = '' continue if c == '(': paren = paren + 1 if bracket: email = email + str str = '' elif not seen_bracket: email = email + str str = '' continue if bracket: if c == '>': bracket = 0 email = email + str str = '' continue if c == '<': bracket = 1 seen_bracket = 1 comment = comment + str str = '' email = '' continue if c == '#' and not bracket and not paren: # rest is comment break token.append(c) if str: if seen_bracket: if bracket: email = str else: comment = comment + str else: if paren: comment = comment + str else: email = email + str return string.strip(comment), string.strip(email)
7,387
def parseaddr(address): import string str = '' email = '' comment = '' backslash = 0 dquote = 0 space = 0 paren = 0 bracket = 0 seen_bracket = 0 for c in address: if backslash: str = str + c backslash = 0 continue if c == '\\': backslash = 1 continue if dquote: if c == '"': dquote = 0 else: str = str + c continue if c == '"': dquote = 1 continue if c in string.whitespace: space = 1 continue if space: str = str + ' ' space = 0 if paren: if c == '(': paren = paren + 1 str = str + c continue if c == ')': paren = paren - 1 if paren == 0: comment = comment + str str = '' continue if c == '(': paren = paren + 1 if bracket: email = email + str str = '' elif not seen_bracket: email = email + str str = '' continue if bracket: if c == '>': bracket = 0 email = email + str str = '' continue if c == '<': bracket = 1 seen_bracket = 1 comment = comment + str str = '' email = '' continue if c == '#' and not bracket and not paren: # rest is comment break str = str + c if str: if seen_bracket: if bracket: email = str else: comment = comment + str else: if paren: comment = comment + str else: email = email + str return string.strip(comment), string.strip(email)
def parseaddr(address): import string str = '' email = '' comment = '' backslash = 0 dquote = 0 space = 0 paren = 0 bracket = 0 seen_bracket = 0 for c in address: if backslash: str = str + c backslash = 0 if c == '\\': backslash = 1 if dquote: if c == '"': dquote = 0 else: str = str + c if c == '"': dquote = 1 if c in string.whitespace: space = 1 if space: str = str + ' ' space = 0 if paren: if c == '(': paren = paren + 1 str = str + c if c == ')': paren = paren - 1 if paren == 0: comment = comment + str str = '' if c == '(': paren = paren + 1 if bracket: email = email + str str = '' elif not seen_bracket: email = email + str str = '' if bracket: if c == '>': bracket = 0 email = email + str str = '' if c == '<': bracket = 1 seen_bracket = 1 comment = comment + str str = '' email = '' if c == '#' and not bracket and not paren: # rest is comment break str = str + c if str: if seen_bracket: if bracket: email = str else: comment = comment + str else: if paren: comment = comment + str else: email = email + str return string.strip(comment), string.strip(email)
7,388
def parseaddr(address): import string str = '' email = '' comment = '' backslash = 0 dquote = 0 space = 0 paren = 0 bracket = 0 seen_bracket = 0 for c in address: if backslash: str = str + c backslash = 0 continue if c == '\\': backslash = 1 continue if dquote: if c == '"': dquote = 0 else: str = str + c continue if c == '"': dquote = 1 continue if c in string.whitespace: space = 1 continue if space: str = str + ' ' space = 0 if paren: if c == '(': paren = paren + 1 str = str + c continue if c == ')': paren = paren - 1 if paren == 0: comment = comment + str str = '' continue if c == '(': paren = paren + 1 if bracket: email = email + str str = '' elif not seen_bracket: email = email + str str = '' continue if bracket: if c == '>': bracket = 0 email = email + str str = '' continue if c == '<': bracket = 1 seen_bracket = 1 comment = comment + str str = '' email = '' continue if c == '#' and not bracket and not paren: # rest is comment break str = str + c if str: if seen_bracket: if bracket: email = str else: comment = comment + str else: if paren: comment = comment + str else: email = email + str return string.strip(comment), string.strip(email)
def parseaddr(address): import string str = '' email = '' comment = '' backslash = 0 dquote = 0 space = 0 paren = 0 bracket = 0 seen_bracket = 0 for c in address: if backslash: token.append(c) backslash = 0 continue if c == '\\': backslash = 1 continue if dquote: if c == '"': dquote = 0 else: token.append(c) continue if c == '"': dquote = 1 continue if c in string.whitespace: space = 1 continue if space: str = str + ' ' space = 0 if paren: if c == '(': paren = paren + 1 token.append(c) continue if c == ')': paren = paren - 1 if paren == 0: comment = comment + str str = '' continue if c == '(': paren = paren + 1 if bracket: email = email + str str = '' elif not seen_bracket: email = email + str str = '' continue if bracket: if c == '>': bracket = 0 email = email + str str = '' continue if c == '<': bracket = 1 seen_bracket = 1 comment = comment + str str = '' email = '' continue if c == '#' and not bracket and not paren: # rest is comment break token.append(c) if str: if seen_bracket: if bracket: email = str else: comment = comment + str else: if paren: comment = comment + str else: email = email + str return string.strip(comment), string.strip(email)
7,389
def parseaddr(address): import string str = '' email = '' comment = '' backslash = 0 dquote = 0 space = 0 paren = 0 bracket = 0 seen_bracket = 0 for c in address: if backslash: str = str + c backslash = 0 continue if c == '\\': backslash = 1 continue if dquote: if c == '"': dquote = 0 else: str = str + c continue if c == '"': dquote = 1 continue if c in string.whitespace: space = 1 continue if space: str = str + ' ' space = 0 if paren: if c == '(': paren = paren + 1 str = str + c continue if c == ')': paren = paren - 1 if paren == 0: comment = comment + str str = '' continue if c == '(': paren = paren + 1 if bracket: email = email + str str = '' elif not seen_bracket: email = email + str str = '' continue if bracket: if c == '>': bracket = 0 email = email + str str = '' continue if c == '<': bracket = 1 seen_bracket = 1 comment = comment + str str = '' email = '' continue if c == '#' and not bracket and not paren: # rest is comment break str = str + c if str: if seen_bracket: if bracket: email = str else: comment = comment + str else: if paren: comment = comment + str else: email = email + str return string.strip(comment), string.strip(email)
def parseaddr(address): import string str = '' email = '' comment = '' backslash = 0 dquote = 0 space = 0 paren = 0 bracket = 0 seen_bracket = 0 for c in address: if backslash: str = str + c backslash = 0 continue if c == '\\': backslash = 1 continue if dquote: if c == '"': dquote = 0 else: str = str + c continue if c == '"': dquote = 1 was_quoted = 1 continue if paren: if c == '(': paren = paren + 1 str = str + c continue if c == ')': paren = paren - 1 if paren == 0: comment = comment + str str = '' continue if c == '(': paren = paren + 1 if bracket: email = email + str str = '' elif not seen_bracket: email = email + str str = '' continue if bracket: if c == '>': bracket = 0 email = email + str str = '' continue if c == '<': bracket = 1 seen_bracket = 1 comment = comment + str str = '' email = '' continue if c == '#' and not bracket and not paren: # rest is comment break str = str + c if str: if seen_bracket: if bracket: email = str else: comment = comment + str else: if paren: comment = comment + str else: email = email + str return string.strip(comment), string.strip(email)
7,390
def parseaddr(address): import string str = '' email = '' comment = '' backslash = 0 dquote = 0 space = 0 paren = 0 bracket = 0 seen_bracket = 0 for c in address: if backslash: str = str + c backslash = 0 continue if c == '\\': backslash = 1 continue if dquote: if c == '"': dquote = 0 else: str = str + c continue if c == '"': dquote = 1 continue if c in string.whitespace: space = 1 continue if space: str = str + ' ' space = 0 if paren: if c == '(': paren = paren + 1 str = str + c continue if c == ')': paren = paren - 1 if paren == 0: comment = comment + str str = '' continue if c == '(': paren = paren + 1 if bracket: email = email + str str = '' elif not seen_bracket: email = email + str str = '' continue if bracket: if c == '>': bracket = 0 email = email + str str = '' continue if c == '<': bracket = 1 seen_bracket = 1 comment = comment + str str = '' email = '' continue if c == '#' and not bracket and not paren: # rest is comment break str = str + c if str: if seen_bracket: if bracket: email = str else: comment = comment + str else: if paren: comment = comment + str else: email = email + str return string.strip(comment), string.strip(email)
def parseaddr(address): import string str = '' email = '' comment = '' backslash = 0 dquote = 0 space = 0 paren = 0 bracket = 0 seen_bracket = 0 for c in address: if backslash: str = str + c backslash = 0 continue if c == '\\': backslash = 1 continue if dquote: if c == '"': dquote = 0 else: str = str + c continue if c == '"': dquote = 1 continue if c in string.whitespace: space = 1 continue if space: str = str + ' ' space = 0 if paren: if c == '(': paren = paren + 1 elif c == ')': paren = paren - 1 if paren == 0: comment = comment + str str = '' continue if c == '(': paren = paren + 1 if bracket: email = email + str str = '' elif not seen_bracket: email = email + str str = '' continue if bracket: if c == '>': bracket = 0 email = email + str str = '' continue if c == '<': bracket = 1 seen_bracket = 1 comment = comment + str str = '' email = '' continue if c == '#' and not bracket and not paren: # rest is comment break str = str + c if str: if seen_bracket: if bracket: email = str else: comment = comment + str else: if paren: comment = comment + str else: email = email + str return string.strip(comment), string.strip(email)
7,391
def parseaddr(address): import string str = '' email = '' comment = '' backslash = 0 dquote = 0 space = 0 paren = 0 bracket = 0 seen_bracket = 0 for c in address: if backslash: str = str + c backslash = 0 continue if c == '\\': backslash = 1 continue if dquote: if c == '"': dquote = 0 else: str = str + c continue if c == '"': dquote = 1 continue if c in string.whitespace: space = 1 continue if space: str = str + ' ' space = 0 if paren: if c == '(': paren = paren + 1 str = str + c continue if c == ')': paren = paren - 1 if paren == 0: comment = comment + str str = '' continue if c == '(': paren = paren + 1 if bracket: email = email + str str = '' elif not seen_bracket: email = email + str str = '' continue if bracket: if c == '>': bracket = 0 email = email + str str = '' continue if c == '<': bracket = 1 seen_bracket = 1 comment = comment + str str = '' email = '' continue if c == '#' and not bracket and not paren: # rest is comment break str = str + c if str: if seen_bracket: if bracket: email = str else: comment = comment + str else: if paren: comment = comment + str else: email = email + str return string.strip(comment), string.strip(email)
def parseaddr(address): import string str = '' email = '' comment = '' backslash = 0 dquote = 0 space = 0 paren = 0 bracket = 0 seen_bracket = 0 for c in address: if backslash: str = str + c backslash = 0 continue if c == '\\': backslash = 1 continue if dquote: if c == '"': dquote = 0 else: str = str + c continue if c == '"': dquote = 1 continue if c in string.whitespace: space = 1 continue if space: str = str + ' ' space = 0 if paren: if c == '(': paren = paren + 1 str = str + c continue if c == ')': paren = paren - 1 if paren == 0: token = string.join(token, '') tokens.append((2, token)) token = [] continue if c == '(': paren = paren + 1 if bracket: email = email + str str = '' elif not seen_bracket: email = email + str str = '' continue if bracket: if c == '>': bracket = 0 email = email + str str = '' continue if c == '<': bracket = 1 seen_bracket = 1 token = string.join(token, '') tokens.append((2, token)) token = [] email = '' continue if c == '#' and not bracket and not paren: # rest is comment break str = str + c if str: if seen_bracket: if bracket: email = str else: comment = comment + str else: if paren: comment = comment + str else: email = email + str return string.strip(comment), string.strip(email)
7,392
def parseaddr(address): import string str = '' email = '' comment = '' backslash = 0 dquote = 0 space = 0 paren = 0 bracket = 0 seen_bracket = 0 for c in address: if backslash: str = str + c backslash = 0 continue if c == '\\': backslash = 1 continue if dquote: if c == '"': dquote = 0 else: str = str + c continue if c == '"': dquote = 1 continue if c in string.whitespace: space = 1 continue if space: str = str + ' ' space = 0 if paren: if c == '(': paren = paren + 1 str = str + c continue if c == ')': paren = paren - 1 if paren == 0: comment = comment + str str = '' continue if c == '(': paren = paren + 1 if bracket: email = email + str str = '' elif not seen_bracket: email = email + str str = '' continue if bracket: if c == '>': bracket = 0 email = email + str str = '' continue if c == '<': bracket = 1 seen_bracket = 1 comment = comment + str str = '' email = '' continue if c == '#' and not bracket and not paren: # rest is comment break str = str + c if str: if seen_bracket: if bracket: email = str else: comment = comment + str else: if paren: comment = comment + str else: email = email + str return string.strip(comment), string.strip(email)
def parseaddr(address): import string str = '' email = '' comment = '' backslash = 0 dquote = 0 space = 0 paren = 0 bracket = 0 seen_bracket = 0 for c in address: if backslash: str = str + c backslash = 0 continue if c == '\\': backslash = 1 continue if dquote: if c == '"': dquote = 0 else: str = str + c continue if c == '"': dquote = 1 continue if c in string.whitespace: space = 1 continue if space: str = str + ' ' space = 0 if paren: if c == '(': paren = paren + 1 str = str + c continue if c == ')': paren = paren - 1 if paren == 0: comment = comment + str str = '' continue if c == '(': paren = 1 token = string.join(token, '') tokens.append((was_quoted, token)) was_quoted = 0 token = [] continue if c in string.whitespace: space = 1 continue if c in '<>@,;:.[]': token = string.join(token, '') tokens.append((was_quoted, token)) was_quoted = 0 token = [] tokens.append((0, c)) space = 0 continue if space: token = string.join(token, '') tokens.append((was_quoted, token)) was_quoted = 0 token = [] space = 0 token.append(c) token = string.join(token, '') tokens.append((was_quoted, token)) if (0, '<') in tokens: name = [] addr = [] cur = name for token in tokens: if token[1] == '': continue if c == '<': bracket = 1 seen_bracket = 1 comment = comment + str str = '' email = '' continue if c == '#' and not bracket and not paren: # rest is comment break str = str + c if str: if seen_bracket: if bracket: email = str else: comment = comment + str else: if paren: comment = comment + str else: email = email + str return string.strip(comment), string.strip(email)
7,393
def parseaddr(address): import string str = '' email = '' comment = '' backslash = 0 dquote = 0 space = 0 paren = 0 bracket = 0 seen_bracket = 0 for c in address: if backslash: str = str + c backslash = 0 continue if c == '\\': backslash = 1 continue if dquote: if c == '"': dquote = 0 else: str = str + c continue if c == '"': dquote = 1 continue if c in string.whitespace: space = 1 continue if space: str = str + ' ' space = 0 if paren: if c == '(': paren = paren + 1 str = str + c continue if c == ')': paren = paren - 1 if paren == 0: comment = comment + str str = '' continue if c == '(': paren = paren + 1 if bracket: email = email + str str = '' elif not seen_bracket: email = email + str str = '' continue if bracket: if c == '>': bracket = 0 email = email + str str = '' continue if c == '<': bracket = 1 seen_bracket = 1 comment = comment + str str = '' email = '' continue if c == '#' and not bracket and not paren: # rest is comment break str = str + c if str: if seen_bracket: if bracket: email = str else: comment = comment + str else: if paren: comment = comment + str else: email = email + str return string.strip(comment), string.strip(email)
def parseaddr(address): import string str = '' email = '' comment = '' backslash = 0 dquote = 0 space = 0 paren = 0 bracket = 0 seen_bracket = 0 for c in address: if backslash: str = str + c backslash = 0 continue if c == '\\': backslash = 1 continue if dquote: if c == '"': dquote = 0 else: str = str + c continue if c == '"': dquote = 1 continue if c in string.whitespace: space = 1 continue if space: str = str + ' ' space = 0 if paren: if c == '(': paren = paren + 1 str = str + c continue if c == ')': paren = paren - 1 if paren == 0: comment = comment + str str = '' continue if c == '(': paren = paren + 1 if bracket: email = email + str str = '' elif not seen_bracket: email = email + str str = '' continue if bracket: if c == '>': bracket = 0 email = email + str str = '' continue if c == '<': bracket = 1 seen_bracket = 1 comment = comment + str str = '' email = '' continue if c == '#' and not bracket and not paren: # rest is comment break str = str + c if str: if seen_bracket: if bracket: email = str else: comment = comment + str else: if paren: comment = comment + str else: email = email + str return string.strip(comment), string.strip(email)
7,394
def parseaddr(address): import string str = '' email = '' comment = '' backslash = 0 dquote = 0 space = 0 paren = 0 bracket = 0 seen_bracket = 0 for c in address: if backslash: str = str + c backslash = 0 continue if c == '\\': backslash = 1 continue if dquote: if c == '"': dquote = 0 else: str = str + c continue if c == '"': dquote = 1 continue if c in string.whitespace: space = 1 continue if space: str = str + ' ' space = 0 if paren: if c == '(': paren = paren + 1 str = str + c continue if c == ')': paren = paren - 1 if paren == 0: comment = comment + str str = '' continue if c == '(': paren = paren + 1 if bracket: email = email + str str = '' elif not seen_bracket: email = email + str str = '' continue if bracket: if c == '>': bracket = 0 email = email + str str = '' continue if c == '<': bracket = 1 seen_bracket = 1 comment = comment + str str = '' email = '' continue if c == '#' and not bracket and not paren: # rest is comment break str = str + c if str: if seen_bracket: if bracket: email = str else: comment = comment + str else: if paren: comment = comment + str else: email = email + str return string.strip(comment), string.strip(email)
def parseaddr(address): import string str = '' email = '' comment = '' backslash = 0 dquote = 0 space = 0 paren = 0 bracket = 0 seen_bracket = 0 for c in address: if backslash: str = str + c backslash = 0 continue if c == '\\': backslash = 1 continue if dquote: if c == '"': dquote = 0 else: str = str + c continue if c == '"': dquote = 1 continue if c in string.whitespace: space = 1 continue if space: str = str + ' ' space = 0 if paren: if c == '(': paren = paren + 1 str = str + c continue if c == ')': paren = paren - 1 if paren == 0: comment = comment + str str = '' continue if c == '(': paren = paren + 1 if bracket: email = email + str str = '' elif not seen_bracket: email = email + str str = '' continue if bracket: if c == '>': bracket = 0 email = email + str str = '' continue if c == '<': bracket = 1 seen_bracket = 1 comment = comment + str str = '' email = '' continue if c == '#' and not bracket and not paren: # rest is comment break str = str + c if str: if seen_bracket: if bracket: email = str else: cur.append(token[1]) else: name = [] addr = [] for token in tokens: if token[1] == '': continue if token[0] == 2: name.append(token[1]) elif token[0] == 1: if specials.search(token[1]) >= 0: addr.append(quote(token[1])) else: addr.append(token[1]) else: email = email + str return string.strip(comment), string.strip(email)
7,395
def parseaddr(address): import string str = '' email = '' comment = '' backslash = 0 dquote = 0 space = 0 paren = 0 bracket = 0 seen_bracket = 0 for c in address: if backslash: str = str + c backslash = 0 continue if c == '\\': backslash = 1 continue if dquote: if c == '"': dquote = 0 else: str = str + c continue if c == '"': dquote = 1 continue if c in string.whitespace: space = 1 continue if space: str = str + ' ' space = 0 if paren: if c == '(': paren = paren + 1 str = str + c continue if c == ')': paren = paren - 1 if paren == 0: comment = comment + str str = '' continue if c == '(': paren = paren + 1 if bracket: email = email + str str = '' elif not seen_bracket: email = email + str str = '' continue if bracket: if c == '>': bracket = 0 email = email + str str = '' continue if c == '<': bracket = 1 seen_bracket = 1 comment = comment + str str = '' email = '' continue if c == '#' and not bracket and not paren: # rest is comment break str = str + c if str: if seen_bracket: if bracket: email = str else: comment = comment + str else: if paren: comment = comment + str else: email = email + str return string.strip(comment), string.strip(email)
def parseaddr(address): import string str = '' email = '' comment = '' backslash = 0 dquote = 0 space = 0 paren = 0 bracket = 0 seen_bracket = 0 for c in address: if backslash: str = str + c backslash = 0 continue if c == '\\': backslash = 1 continue if dquote: if c == '"': dquote = 0 else: str = str + c continue if c == '"': dquote = 1 continue if c in string.whitespace: space = 1 continue if space: str = str + ' ' space = 0 if paren: if c == '(': paren = paren + 1 str = str + c continue if c == ')': paren = paren - 1 if paren == 0: comment = comment + str str = '' continue if c == '(': paren = paren + 1 if bracket: email = email + str str = '' elif not seen_bracket: email = email + str str = '' continue if bracket: if c == '>': bracket = 0 email = email + str str = '' continue if c == '<': bracket = 1 seen_bracket = 1 comment = comment + str str = '' email = '' continue if c == '#' and not bracket and not paren: # rest is comment break str = str + c if str: if seen_bracket: if bracket: email = str else: comment = comment + str else: if paren: comment = comment + str else: addr.append(token[1]) return string.join(name, ' '), string.join(addr, '')
7,396
def __init__(self, filename, when='h', interval=1, backupCount=0, encoding=None): BaseRotatingHandler.__init__(self, filename, 'a', encoding) self.when = string.upper(when) self.backupCount = backupCount # Calculate the real rollover interval, which is just the number of # seconds between rollovers. Also set the filename suffix used when # a rollover occurs. Current 'when' events supported: # S - Seconds # M - Minutes # H - Hours # D - Days # midnight - roll over at midnight # W{0-6} - roll over on a certain day; 0 - Monday # # Case of the 'when' specifier is not important; lower or upper case # will work. currentTime = int(time.time()) if self.when == 'S': self.interval = 1 # one second self.suffix = "%Y-%m-%d_%H-%M-%S" elif self.when == 'M': self.interval = 60 # one minute self.suffix = "%Y-%m-%d_%H-%M" elif self.when == 'H': self.interval = 60 * 60 # one hour self.suffix = "%Y-%m-%d_%H" elif self.when == 'D' or self.when == 'MIDNIGHT': self.interval = 60 * 60 * 24 # one day self.suffix = "%Y-%m-%d" elif self.when.startswith('W'): self.interval = 60 * 60 * 24 * 7 # one week if len(self.when) != 2: raise ValueError("You must specify a day for weekly rollover from 0 to 6 (0 is Monday): %s" % self.when) if self.when[1] < '0' or self.when[1] > '6': raise ValueError("Invalid day specified for weekly rollover: %s" % self.when) self.dayOfWeek = int(self.when[1]) self.suffix = "%Y-%m-%d" else: raise ValueError("Invalid rollover interval specified: %s" % self.when)
def __init__(self, filename, when='h', interval=1, backupCount=0, encoding=None): BaseRotatingHandler.__init__(self, filename, 'a', encoding) self.when = string.upper(when) self.backupCount = backupCount # Calculate the real rollover interval, which is just the number of # seconds between rollovers. Also set the filename suffix used when # a rollover occurs. Current 'when' events supported: # S - Seconds # M - Minutes # H - Hours # D - Days # midnight - roll over at midnight # W{0-6} - roll over on a certain day; 0 - Monday # # Case of the 'when' specifier is not important; lower or upper case # will work. currentTime = int(time.time()) if self.when == 'S': self.interval = 1 # one second self.suffix = "%Y-%m-%d_%H-%M-%S" elif self.when == 'M': self.interval = 60 # one minute self.suffix = "%Y-%m-%d_%H-%M" elif self.when == 'H': self.interval = 60 * 60 # one hour self.suffix = "%Y-%m-%d_%H" elif self.when == 'D' or self.when == 'MIDNIGHT': self.interval = 60 * 60 * 24 # one day self.suffix = "%Y-%m-%d" elif self.when.startswith('W'): self.interval = 60 * 60 * 24 * 7 # one week if len(self.when) != 2: raise ValueError("You must specify a day for weekly rollover from 0 to 6 (0 is Monday): %s" % self.when) if self.when[1] < '0' or self.when[1] > '6': raise ValueError("Invalid day specified for weekly rollover: %s" % self.when) self.dayOfWeek = int(self.when[1]) self.suffix = "%Y-%m-%d" else: raise ValueError("Invalid rollover interval specified: %s" % self.when)
7,397
def get(self, section, option, raw=0): """Get an option value for a given section.
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section.
7,398
def get(self, section, option, raw=0): """Get an option value for a given section.
def get(self, section, option, raw=0): """Get an option value for a given section.
7,399