bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
|---|---|---|
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
|
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
| 8,300
|
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
|
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
| 8,301
|
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
|
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
| 8,302
|
def gather(self): "Collect and return the contents of the window." result = "" for y in range(self.maxy+1): self.win.move(y, 0) stop = self._end_of_line(y) #sys.stderr.write("y=%d, _end_of_line(y)=%d\n" % (y, stop)) if stop == 0 and self.stripspaces: continue for x in range(self.maxx+1): if self.stripspaces and x == stop: break result = result + chr(ascii.ascii(self.win.inch(y, x))) if self.maxy > 0: result = result + "\n" return result
|
defgather(self):"Collectandreturnthecontentsofthewindow."result=""foryinrange(self.maxy+1):self.win.move(y,0)stop=self._end_of_line(y)#sys.stderr.write("y=%d,_end_of_line(y)=%d\n"%(y,stop))ifstop==0andself.stripspaces:continueforxinrange(self.maxx+1):ifself.stripspacesandx==stop:breakresult=result+chr(ascii.ascii(self.win.inch(y,x)))ifself.maxy>0:result=result+"\n"returnresult
| 8,303
|
def main(): if len(sys.argv) > 1: for filename in sys.argv[1:]: processfile(filename) else: filename = EasyDialogs.AskFileForOpen(message='Select file with aeut/aete resource:') if not filename: sys.exit(0) processfile(filename)
|
def main(): if len(sys.argv) > 1: for filename in sys.argv[1:]: processfile(filename) else: filename = EasyDialogs.AskFileForOpen( message='Select scriptable application', dialogOptionFlags=0x1056) if not filename: sys.exit(0) processfile(filename)
| 8,304
|
def main(): if len(sys.argv) > 1: for filename in sys.argv[1:]: processfile(filename) else: filename = EasyDialogs.AskFileForOpen(message='Select file with aeut/aete resource:') if not filename: sys.exit(0) processfile(filename)
|
def main(): if len(sys.argv) > 1: for filename in sys.argv[1:]: processfile(filename) else: filename = EasyDialogs.AskFileForOpen(message='Select file with aeut/aete resource:') if not filename: sys.exit(0) processfile(filename)
| 8,305
|
def compileaete(aete, resinfo, fname): """Generate code for a full aete resource. fname passed for doc purposes""" [version, language, script, suites] = aete major, minor = divmod(version, 256) creatorsignature, dummy = MacOS.GetCreatorAndType(fname) packagename = identify(os.path.splitext(os.path.basename(fname))[0]) if language: packagename = packagename+'_lang%d'%language if script: packagename = packagename+'_script%d'%script if len(packagename) > 27: packagename = packagename[:27] pathname = EasyDialogs.AskFolder(message='Create and select package folder for %s'%packagename, defaultLocation=DEFAULT_PACKAGEFOLDER) if not pathname: return packagename = os.path.split(os.path.normpath(pathname))[1] basepkgname = EasyDialogs.AskFolder(message='Package folder for base suite (usually StdSuites)', defaultLocation=DEFAULT_PACKAGEFOLDER) if basepkgname: dirname, basepkgname = os.path.split(os.path.normpath(basepkgname)) if not dirname in sys.path: sys.path.insert(0, dirname) basepackage = __import__(basepkgname) else: basepackage = None suitelist = [] allprecompinfo = [] allsuites = [] for suite in suites: code, suite, pathname, modname, precompinfo = precompilesuite(suite, basepackage) if not code: continue allprecompinfo = allprecompinfo + precompinfo suiteinfo = suite, pathname, modname suitelist.append((code, modname)) allsuites.append(suiteinfo) for suiteinfo in allsuites: compilesuite(suiteinfo, major, minor, language, script, fname, basepackage, allprecompinfo) initfilename = EasyDialogs.AskFileForSave(message='Package module', savedFileName='__init__.py') if not initfilename: return fp = open(initfilename, 'w') MacOS.SetCreatorAndType(initfilename, 'Pyth', 'TEXT') fp.write('"""\n') fp.write("Package generated from %s\n"%fname) if resinfo: fp.write("Resource %s resid %d %s\n"%(ascii(resinfo[1]), resinfo[0], ascii(resinfo[2]))) fp.write('"""\n') fp.write('import aetools\n') fp.write('Error = aetools.Error\n') for code, modname in suitelist: fp.write("import %s\n" % modname) fp.write("\n\n_code_to_module = {\n") for code, modname in suitelist: fp.write("\t'%s' : %s,\n"%(ascii(code), modname)) fp.write("}\n\n") fp.write("\n\n_code_to_fullname = {\n") for code, modname in suitelist: fp.write("\t'%s' : ('%s.%s', '%s'),\n"%(ascii(code), packagename, modname, modname)) fp.write("}\n\n") for code, modname in suitelist: fp.write("from %s import *\n"%modname) # Generate property dicts and element dicts for all types declared in this module fp.write("def getbaseclasses(v):\n") fp.write("\tif hasattr(v, '_superclassnames') and not hasattr(v, '_propdict'):\n") fp.write("\t\tv._propdict = {}\n") fp.write("\t\tv._elemdict = {}\n") fp.write("\t\tfor superclass in v._superclassnames:\n")
|
def compileaete(aete, resinfo, fname): """Generate code for a full aete resource. fname passed for doc purposes""" [version, language, script, suites] = aete major, minor = divmod(version, 256) creatorsignature, dummy = MacOS.GetCreatorAndType(fname) packagename = identify(os.path.splitext(os.path.basename(fname))[0]) if language: packagename = packagename+'_lang%d'%language if script: packagename = packagename+'_script%d'%script if len(packagename) > 27: packagename = packagename[:27] pathname = EasyDialogs.AskFolder(message='Create and select package folder for %s'%packagename, defaultLocation=DEFAULT_USER_PACKAGEFOLDER) if not pathname: return packagename = os.path.split(os.path.normpath(pathname))[1] basepkgname = EasyDialogs.AskFolder(message='Package folder for base suite (usually StdSuites)', defaultLocation=DEFAULT_USER_PACKAGEFOLDER) if basepkgname: dirname, basepkgname = os.path.split(os.path.normpath(basepkgname)) if not dirname in sys.path: sys.path.insert(0, dirname) basepackage = __import__(basepkgname) else: basepackage = None suitelist = [] allprecompinfo = [] allsuites = [] for suite in suites: code, suite, pathname, modname, precompinfo = precompilesuite(suite, basepackage) if not code: continue allprecompinfo = allprecompinfo + precompinfo suiteinfo = suite, pathname, modname suitelist.append((code, modname)) allsuites.append(suiteinfo) for suiteinfo in allsuites: compilesuite(suiteinfo, major, minor, language, script, fname, basepackage, allprecompinfo) initfilename = EasyDialogs.AskFileForSave(message='Package module', savedFileName='__init__.py') if not initfilename: return fp = open(initfilename, 'w') MacOS.SetCreatorAndType(initfilename, 'Pyth', 'TEXT') fp.write('"""\n') fp.write("Package generated from %s\n"%fname) if resinfo: fp.write("Resource %s resid %d %s\n"%(ascii(resinfo[1]), resinfo[0], ascii(resinfo[2]))) fp.write('"""\n') fp.write('import aetools\n') fp.write('Error = aetools.Error\n') for code, modname in suitelist: fp.write("import %s\n" % modname) fp.write("\n\n_code_to_module = {\n") for code, modname in suitelist: fp.write("\t'%s' : %s,\n"%(ascii(code), modname)) fp.write("}\n\n") fp.write("\n\n_code_to_fullname = {\n") for code, modname in suitelist: fp.write("\t'%s' : ('%s.%s', '%s'),\n"%(ascii(code), packagename, modname, modname)) fp.write("}\n\n") for code, modname in suitelist: fp.write("from %s import *\n"%modname) # Generate property dicts and element dicts for all types declared in this module fp.write("def getbaseclasses(v):\n") fp.write("\tif hasattr(v, '_superclassnames') and not hasattr(v, '_propdict'):\n") fp.write("\t\tv._propdict = {}\n") fp.write("\t\tv._elemdict = {}\n") fp.write("\t\tfor superclass in v._superclassnames:\n")
| 8,306
|
def compileaete(aete, resinfo, fname): """Generate code for a full aete resource. fname passed for doc purposes""" [version, language, script, suites] = aete major, minor = divmod(version, 256) creatorsignature, dummy = MacOS.GetCreatorAndType(fname) packagename = identify(os.path.splitext(os.path.basename(fname))[0]) if language: packagename = packagename+'_lang%d'%language if script: packagename = packagename+'_script%d'%script if len(packagename) > 27: packagename = packagename[:27] pathname = EasyDialogs.AskFolder(message='Create and select package folder for %s'%packagename, defaultLocation=DEFAULT_PACKAGEFOLDER) if not pathname: return packagename = os.path.split(os.path.normpath(pathname))[1] basepkgname = EasyDialogs.AskFolder(message='Package folder for base suite (usually StdSuites)', defaultLocation=DEFAULT_PACKAGEFOLDER) if basepkgname: dirname, basepkgname = os.path.split(os.path.normpath(basepkgname)) if not dirname in sys.path: sys.path.insert(0, dirname) basepackage = __import__(basepkgname) else: basepackage = None suitelist = [] allprecompinfo = [] allsuites = [] for suite in suites: code, suite, pathname, modname, precompinfo = precompilesuite(suite, basepackage) if not code: continue allprecompinfo = allprecompinfo + precompinfo suiteinfo = suite, pathname, modname suitelist.append((code, modname)) allsuites.append(suiteinfo) for suiteinfo in allsuites: compilesuite(suiteinfo, major, minor, language, script, fname, basepackage, allprecompinfo) initfilename = EasyDialogs.AskFileForSave(message='Package module', savedFileName='__init__.py') if not initfilename: return fp = open(initfilename, 'w') MacOS.SetCreatorAndType(initfilename, 'Pyth', 'TEXT') fp.write('"""\n') fp.write("Package generated from %s\n"%fname) if resinfo: fp.write("Resource %s resid %d %s\n"%(ascii(resinfo[1]), resinfo[0], ascii(resinfo[2]))) fp.write('"""\n') fp.write('import aetools\n') fp.write('Error = aetools.Error\n') for code, modname in suitelist: fp.write("import %s\n" % modname) fp.write("\n\n_code_to_module = {\n") for code, modname in suitelist: fp.write("\t'%s' : %s,\n"%(ascii(code), modname)) fp.write("}\n\n") fp.write("\n\n_code_to_fullname = {\n") for code, modname in suitelist: fp.write("\t'%s' : ('%s.%s', '%s'),\n"%(ascii(code), packagename, modname, modname)) fp.write("}\n\n") for code, modname in suitelist: fp.write("from %s import *\n"%modname) # Generate property dicts and element dicts for all types declared in this module fp.write("def getbaseclasses(v):\n") fp.write("\tif hasattr(v, '_superclassnames') and not hasattr(v, '_propdict'):\n") fp.write("\t\tv._propdict = {}\n") fp.write("\t\tv._elemdict = {}\n") fp.write("\t\tfor superclass in v._superclassnames:\n")
|
def compileaete(aete, resinfo, fname): """Generate code for a full aete resource. fname passed for doc purposes""" [version, language, script, suites] = aete major, minor = divmod(version, 256) creatorsignature, dummy = MacOS.GetCreatorAndType(fname) packagename = identify(os.path.splitext(os.path.basename(fname))[0]) if language: packagename = packagename+'_lang%d'%language if script: packagename = packagename+'_script%d'%script if len(packagename) > 27: packagename = packagename[:27] pathname = EasyDialogs.AskFolder(message='Create and select package folder for %s'%packagename, defaultLocation=DEFAULT_STANDARD_PACKAGEFOLDER) if not pathname: return packagename = os.path.split(os.path.normpath(pathname))[1] basepkgname = EasyDialogs.AskFolder(message='Package folder for base suite (usually StdSuites)', defaultLocation=DEFAULT_STANDARD_PACKAGEFOLDER) if basepkgname: dirname, basepkgname = os.path.split(os.path.normpath(basepkgname)) if not dirname in sys.path: sys.path.insert(0, dirname) basepackage = __import__(basepkgname) else: basepackage = None suitelist = [] allprecompinfo = [] allsuites = [] for suite in suites: code, suite, pathname, modname, precompinfo = precompilesuite(suite, basepackage) if not code: continue allprecompinfo = allprecompinfo + precompinfo suiteinfo = suite, pathname, modname suitelist.append((code, modname)) allsuites.append(suiteinfo) for suiteinfo in allsuites: compilesuite(suiteinfo, major, minor, language, script, fname, basepackage, allprecompinfo) initfilename = EasyDialogs.AskFileForSave(message='Package module', savedFileName='__init__.py') if not initfilename: return fp = open(initfilename, 'w') MacOS.SetCreatorAndType(initfilename, 'Pyth', 'TEXT') fp.write('"""\n') fp.write("Package generated from %s\n"%fname) if resinfo: fp.write("Resource %s resid %d %s\n"%(ascii(resinfo[1]), resinfo[0], ascii(resinfo[2]))) fp.write('"""\n') fp.write('import aetools\n') fp.write('Error = aetools.Error\n') for code, modname in suitelist: fp.write("import %s\n" % modname) fp.write("\n\n_code_to_module = {\n") for code, modname in suitelist: fp.write("\t'%s' : %s,\n"%(ascii(code), modname)) fp.write("}\n\n") fp.write("\n\n_code_to_fullname = {\n") for code, modname in suitelist: fp.write("\t'%s' : ('%s.%s', '%s'),\n"%(ascii(code), packagename, modname, modname)) fp.write("}\n\n") for code, modname in suitelist: fp.write("from %s import *\n"%modname) # Generate property dicts and element dicts for all types declared in this module fp.write("def getbaseclasses(v):\n") fp.write("\tif hasattr(v, '_superclassnames') and not hasattr(v, '_propdict'):\n") fp.write("\t\tv._propdict = {}\n") fp.write("\t\tv._elemdict = {}\n") fp.write("\t\tfor superclass in v._superclassnames:\n")
| 8,307
|
def identify(str): """Turn any string into an identifier: - replace space by _ - replace other illegal chars by _xx_ (hex code) - prepend _ if the result is a python keyword """ if not str: return "empty_ae_name_" rv = '' ok = string.ascii_letters + '_' ok2 = ok + string.digits for c in str: if c in ok: rv = rv + c elif c == ' ': rv = rv + '_' else: rv = rv + '_%02.2x_'%ord(c) ok = ok2 if keyword.iskeyword(rv): rv = rv + '_' return rv
|
def identify(str): """Turn any string into an identifier: - replace space by _ - replace other illegal chars by _xx_ (hex code) - prepend _ if the result is a python keyword """ if not str: return "empty_ae_name_" rv = '' ok = string.ascii_letters + '_' ok2 = ok + string.digits for c in str: if c in ok: rv = rv + c elif c == ' ': rv = rv + '_' else: rv = rv + '_%02.2x_'%ord(c) ok = ok2 if keyword.iskeyword(rv): rv = rv + '_' return rv
| 8,308
|
def test_charset(self): eq = self.assertEqual msg = MIMEText('hello there', _charset='us-ascii') eq(msg.get_charset().input_charset, 'us-ascii') eq(msg['content-type'], 'text/plain; charset="us-ascii"')
|
def test_charset(self): eq = self.assertEqual msg = MIMEText('hello there', _charset='us-ascii') eq(msg.get_charset().input_charset, 'us-ascii') eq(msg['content-type'], 'text/plain; charset="us-ascii"')
| 8,309
|
def __init__(self, host = '', port = 0): """Initialize a new instance.
|
def __init__(self, host = '', port = 0): """Initialize a new instance.
| 8,310
|
def __init__(self, host = '', port = 0): """Initialize a new instance.
|
def __init__(self, host = '', port = 0): """Initialize a new instance.
| 8,311
|
def connect(self, host='localhost', port = 0): """Connect to a host on a given port.
|
def connect(self, host='localhost', port = 0): """Connect to a host on a given port.
| 8,312
|
def getreply(self): """Get a reply from the server. Returns a tuple consisting of:
|
def getreply(self): """Get a reply from the server. Returns a tuple consisting of:
| 8,313
|
def getreply(self): """Get a reply from the server. Returns a tuple consisting of:
|
def getreply(self): """Get a reply from the server. Returns a tuple consisting of:
| 8,314
|
def getreply(self): """Get a reply from the server. Returns a tuple consisting of:
|
def getreply(self): """Get a reply from the server. Returns a tuple consisting of:
| 8,315
|
def docmd(self, cmd, args=""): """Send a command, and return its response code.""" self.putcmd(cmd,args) (code,msg)=self.getreply() return code
|
def docmd(self, cmd, args=""): """Send a command, and return its response code.""" self.putcmd(cmd,args) (code,msg)=self.getreply() return code
| 8,316
|
def helo(self, name=''): """SMTP 'helo' command. Hostname to send for this command defaults to the FQDN of the local host. """ name=string.strip(name) if len(name)==0: name=socket.gethostbyaddr(socket.gethostname())[0] self.putcmd("helo",name) (code,msg)=self.getreply() self.helo_resp=msg return code
|
def helo(self, name=''): """SMTP 'helo' command. Hostname to send for this command defaults to the FQDN of the local host. """ name=string.strip(name) if len(name)==0: name=socket.gethostbyaddr(socket.gethostname())[0] self.putcmd("helo",name) (code,msg)=self.getreply() self.helo_resp=msg return code
| 8,317
|
def ehlo(self, name=''): """ SMTP 'ehlo' command. Hostname to send for this command defaults to the FQDN of the local host. """ name=string.strip(name) if len(name)==0: name=socket.gethostbyaddr(socket.gethostname())[0] self.putcmd("ehlo",name) (code,msg)=self.getreply() # According to RFC1869 some (badly written) # MTA's will disconnect on an ehlo. Toss an exception if # that happens -ddm if code == -1 and len(msg) == 0: raise SMTPServerDisconnected("Server not connected") self.ehlo_resp=msg if code<>250: return code self.does_esmtp=1 #parse the ehlo responce -ddm resp=string.split(self.ehlo_resp,'\n') del resp[0] for each in resp: m=re.match(r'(?P<feature>[A-Za-z0-9][A-Za-z0-9\-]*)',each) if m: feature=string.lower(m.group("feature")) params=string.strip(m.string[m.end("feature"):]) self.esmtp_features[feature]=params return code
|
def ehlo(self, name=''): """ SMTP 'ehlo' command. Hostname to send for this command defaults to the FQDN of the local host. """ name=string.strip(name) if len(name)==0: name=socket.gethostbyaddr(socket.gethostname())[0] self.putcmd("ehlo",name) (code,msg)=self.getreply() # According to RFC1869 some (badly written) # MTA's will disconnect on an ehlo. Toss an exception if # that happens -ddm if code == -1 and len(msg) == 0: raise SMTPServerDisconnected("Server not connected") self.ehlo_resp=msg if code<>250: return (code,msg) self.does_esmtp=1 #parse the ehlo responce -ddm resp=string.split(self.ehlo_resp,'\n') del resp[0] for each in resp: m=re.match(r'(?P<feature>[A-Za-z0-9][A-Za-z0-9\-]*)',each) if m: feature=string.lower(m.group("feature")) params=string.strip(m.string[m.end("feature"):]) self.esmtp_features[feature]=params return code
| 8,318
|
def ehlo(self, name=''): """ SMTP 'ehlo' command. Hostname to send for this command defaults to the FQDN of the local host. """ name=string.strip(name) if len(name)==0: name=socket.gethostbyaddr(socket.gethostname())[0] self.putcmd("ehlo",name) (code,msg)=self.getreply() # According to RFC1869 some (badly written) # MTA's will disconnect on an ehlo. Toss an exception if # that happens -ddm if code == -1 and len(msg) == 0: raise SMTPServerDisconnected("Server not connected") self.ehlo_resp=msg if code<>250: return code self.does_esmtp=1 #parse the ehlo responce -ddm resp=string.split(self.ehlo_resp,'\n') del resp[0] for each in resp: m=re.match(r'(?P<feature>[A-Za-z0-9][A-Za-z0-9\-]*)',each) if m: feature=string.lower(m.group("feature")) params=string.strip(m.string[m.end("feature"):]) self.esmtp_features[feature]=params return code
|
def ehlo(self, name=''): """ SMTP 'ehlo' command. Hostname to send for this command defaults to the FQDN of the local host. """ name=string.strip(name) if len(name)==0: name=socket.gethostbyaddr(socket.gethostname())[0] self.putcmd("ehlo",name) (code,msg)=self.getreply() # According to RFC1869 some (badly written) # MTA's will disconnect on an ehlo. Toss an exception if # that happens -ddm if code == -1 and len(msg) == 0: raise SMTPServerDisconnected("Server not connected") self.ehlo_resp=msg if code<>250: return (code,msg) self.does_esmtp=1 #parse the ehlo responce -ddm resp=string.split(self.ehlo_resp,'\n') del resp[0] for each in resp: m=re.match(r'(?P<feature>[A-Za-z0-9][A-Za-z0-9\-]*)',each) if m: feature=string.lower(m.group("feature")) params=string.strip(m.string[m.end("feature"):]) self.esmtp_features[feature]=params return code
| 8,319
|
def help(self, args=''): """SMTP 'help' command. Returns help text from server.""" self.putcmd("help", args) (code,msg)=self.getreply() return msg
|
def help(self, args=''): """SMTP 'help' command. Returns help text from server.""" self.putcmd("help", args) (code,msg)=self.getreply() return msg
| 8,320
|
def rset(self): """SMTP 'rset' command -- resets session.""" code=self.docmd("rset") return code
|
def rset(self): """SMTP 'rset' command -- resets session.""" code=self.docmd("rset") return code
| 8,321
|
def noop(self): """SMTP 'noop' command -- doesn't do anything :>""" code=self.docmd("noop") return code
|
def noop(self): """SMTP 'noop' command -- doesn't do anything :>""" code=self.docmd("noop") return code
| 8,322
|
def data(self,msg): """SMTP 'DATA' command -- sends message data to server. Automatically quotes lines beginning with a period per rfc821. """ self.putcmd("data") (code,repl)=self.getreply() if self.debuglevel >0 : print "data:", (code,repl) if code <> 354: return -1 else: self.send(quotedata(msg)) self.send("%s.%s" % (CRLF, CRLF)) (code,msg)=self.getreply() if self.debuglevel >0 : print "data:", (code,msg) return code
|
def data(self,msg): """SMTP 'DATA' command -- sends message data to server. Automatically quotes lines beginning with a period per rfc821. """ self.putcmd("data") (code,repl)=self.getreply() if self.debuglevel >0 : print "data:", (code,repl) if code <> 354: raise SMTPDataError(code,repl) else: self.send(quotedata(msg)) self.send("%s.%s" % (CRLF, CRLF)) (code,msg)=self.getreply() if self.debuglevel >0 : print "data:", (code,msg) return code
| 8,323
|
def data(self,msg): """SMTP 'DATA' command -- sends message data to server. Automatically quotes lines beginning with a period per rfc821. """ self.putcmd("data") (code,repl)=self.getreply() if self.debuglevel >0 : print "data:", (code,repl) if code <> 354: return -1 else: self.send(quotedata(msg)) self.send("%s.%s" % (CRLF, CRLF)) (code,msg)=self.getreply() if self.debuglevel >0 : print "data:", (code,msg) return code
|
def data(self,msg): """SMTP 'DATA' command -- sends message data to server. Automatically quotes lines beginning with a period per rfc821. """ self.putcmd("data") (code,repl)=self.getreply() if self.debuglevel >0 : print "data:", (code,repl) if code <> 354: return -1 else: self.send(quotedata(msg)) self.send("%s.%s" % (CRLF, CRLF)) (code,msg)=self.getreply() if self.debuglevel >0 : print "data:", (code,msg) return code
| 8,324
|
def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction.
|
def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction.
| 8,325
|
def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction.
|
def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction.
| 8,326
|
def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction.
|
def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction.
| 8,327
|
def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction.
|
def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction.
| 8,328
|
def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction.
|
def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction.
| 8,329
|
def decompress(self, data): return bz2.decompress(data)
|
def decompress(self, data): return bz2.decompress(data)
| 8,330
|
def normpath(s): """Normalize a pathname. Will return the same result for equivalent paths.""" if ":" not in s: return ":"+s comps = s.split(":") i = 1 while i < len(comps)-1: if comps[i] == "" and comps[i-1] != "": if i > 1: del comps[i-1:i+1] i = i - 1 else: # best way to handle this is to raise an exception raise norm_error, 'Cannot use :: immedeately after volume name' else: i = i + 1 s = ":".join(comps) # remove trailing ":" except for ":" and "Volume:" if s[-1] == ":" and len(comps) > 2 and s != ":"*len(s): s = s[:-1] return s
|
def normpath(s): """Normalize a pathname. Will return the same result for equivalent paths.""" if ":" not in s: return ":"+s comps = s.split(":") i = 1 while i < len(comps)-1: if comps[i] == "" and comps[i-1] != "": if i > 1: del comps[i-1:i+1] i = i - 1 else: # best way to handle this is to raise an exception raise norm_error, 'Cannot use :: immediately after volume name' else: i = i + 1 s = ":".join(comps) # remove trailing ":" except for ":" and "Volume:" if s[-1] == ":" and len(comps) > 2 and s != ":"*len(s): s = s[:-1] return s
| 8,331
|
def connect(self, host = '', port = 0): '''Connect to host. Arguments are: - host: hostname to connect to (string, default previous host) - port: port to connect to (integer, default previous port)''' if host: self.host = host if port: self.port = port self.passiveserver = 0 msg = "getaddrinfo returns an empty list" for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM): af, socktype, proto, canonname, sa = res try: self.sock = socket.socket(af, socktype, proto) self.sock.connect(sa) except socket.error, msg: if self.sock: self.sock.close() self.sock = None continue break if not self.sock: raise socket.error, msg self.af = af self.file = self.sock.makefile('rb') self.welcome = self.getresp() return self.welcome
|
def connect(self, host = '', port = 0): '''Connect to host. Arguments are: - host: hostname to connect to (string, default previous host) - port: port to connect to (integer, default previous port)''' if host: self.host = host if port: self.port = port msg = "getaddrinfo returns an empty list" for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM): af, socktype, proto, canonname, sa = res try: self.sock = socket.socket(af, socktype, proto) self.sock.connect(sa) except socket.error, msg: if self.sock: self.sock.close() self.sock = None continue break if not self.sock: raise socket.error, msg self.af = af self.file = self.sock.makefile('rb') self.welcome = self.getresp() return self.welcome
| 8,332
|
def poll (timeout=0.0, map=None): global DEBUG if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.items(): if obj.readable(): r.append (fd) if obj.writable(): w.append (fd) r,w,e = select.select (r,w,e, timeout) if DEBUG: print r,w,e for fd in r: try: obj = map[fd] try: obj.handle_read_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass for fd in w: try: obj = map[fd] try: obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass
|
def poll (timeout=0.0, map=None): global DEBUG if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.items(): if obj.readable(): r.append (fd) if obj.writable(): w.append (fd) r,w,e = select.select (r,w,e, timeout) if DEBUG: print r,w,e for fd in r: try: obj = map[fd] except KeyError: pass for fd in w: try: obj = map[fd] try: obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass
| 8,333
|
def poll (timeout=0.0, map=None): global DEBUG if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.items(): if obj.readable(): r.append (fd) if obj.writable(): w.append (fd) r,w,e = select.select (r,w,e, timeout) if DEBUG: print r,w,e for fd in r: try: obj = map[fd] try: obj.handle_read_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass for fd in w: try: obj = map[fd] try: obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass
|
def poll (timeout=0.0, map=None): global DEBUG if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.items(): if obj.readable(): r.append (fd) if obj.writable(): w.append (fd) r,w,e = select.select (r,w,e, timeout) if DEBUG: print r,w,e for fd in r: try: obj = map[fd] try: obj.handle_read_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: continue try: obj.handle_read_event() except ExitNow: raise ExitNow except: obj.handle_error() for fd in w: try: obj = map[fd] try: obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: continue try: obj.handle_read_event() except ExitNow: raise ExitNow except: obj.handle_error()
| 8,334
|
def poll (timeout=0.0, map=None): global DEBUG if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.items(): if obj.readable(): r.append (fd) if obj.writable(): w.append (fd) r,w,e = select.select (r,w,e, timeout) if DEBUG: print r,w,e for fd in r: try: obj = map[fd] try: obj.handle_read_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass for fd in w: try: obj = map[fd] try: obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass
|
def poll (timeout=0.0, map=None): global DEBUG if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.items(): if obj.readable(): r.append (fd) if obj.writable(): w.append (fd) r,w,e = select.select (r,w,e, timeout) if DEBUG: print r,w,e for fd in r: try: obj = map[fd] try: obj.handle_read_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass for fd in w: try: obj = map[fd] except KeyError: pass
| 8,335
|
def poll (timeout=0.0, map=None): global DEBUG if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.items(): if obj.readable(): r.append (fd) if obj.writable(): w.append (fd) r,w,e = select.select (r,w,e, timeout) if DEBUG: print r,w,e for fd in r: try: obj = map[fd] try: obj.handle_read_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass for fd in w: try: obj = map[fd] try: obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass
|
def poll (timeout=0.0, map=None): global DEBUG if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.items(): if obj.readable(): r.append (fd) if obj.writable(): w.append (fd) r,w,e = select.select (r,w,e, timeout) if DEBUG: print r,w,e for fd in r: try: obj = map[fd] try: obj.handle_read_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: continue try: obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() for fd in w: try: obj = map[fd] try: obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: continue try: obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error()
| 8,336
|
def poll2 (timeout=0.0, map=None): import poll if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) if map: l = [] for fd, obj in map.items(): flags = 0 if obj.readable(): flags = poll.POLLIN if obj.writable(): flags = flags | poll.POLLOUT if flags: l.append ((fd, flags)) r = poll.poll (l, timeout) for fd, flags in r: try: obj = map[fd] try: if (flags & poll.POLLIN): obj.handle_read_event() if (flags & poll.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass
|
def poll2 (timeout=0.0, map=None): import poll if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) if map: l = [] for fd, obj in map.items(): flags = 0 if obj.readable(): flags = poll.POLLIN if obj.writable(): flags = flags | poll.POLLOUT if flags: l.append ((fd, flags)) r = poll.poll (l, timeout) for fd, flags in r: try: obj = map[fd] except KeyError: pass
| 8,337
|
def poll2 (timeout=0.0, map=None): import poll if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) if map: l = [] for fd, obj in map.items(): flags = 0 if obj.readable(): flags = poll.POLLIN if obj.writable(): flags = flags | poll.POLLOUT if flags: l.append ((fd, flags)) r = poll.poll (l, timeout) for fd, flags in r: try: obj = map[fd] try: if (flags & poll.POLLIN): obj.handle_read_event() if (flags & poll.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass
|
def poll2 (timeout=0.0, map=None): import poll if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) if map: l = [] for fd, obj in map.items(): flags = 0 if obj.readable(): flags = poll.POLLIN if obj.writable(): flags = flags | poll.POLLOUT if flags: l.append ((fd, flags)) r = poll.poll (l, timeout) for fd, flags in r: try: obj = map[fd] try: if (flags & poll.POLLIN): obj.handle_read_event() if (flags & poll.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: continue try: if (flags & poll.POLLIN): obj.handle_read_event() if (flags & poll.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error()
| 8,338
|
def poll3 (timeout=0.0, map=None): # Use the poll() support added to the select module in Python 2.0 if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) pollster = select.poll() if map: for fd, obj in map.items(): flags = 0 if obj.readable(): flags = select.POLLIN if obj.writable(): flags = flags | select.POLLOUT if flags: pollster.register(fd, flags) r = pollster.poll (timeout) for fd, flags in r: try: obj = map[fd] try: if (flags & select.POLLIN): obj.handle_read_event() if (flags & select.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass
|
def poll3 (timeout=0.0, map=None): # Use the poll() support added to the select module in Python 2.0 if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) pollster = select.poll() if map: for fd, obj in map.items(): flags = 0 if obj.readable(): flags = select.POLLIN if obj.writable(): flags = flags | select.POLLOUT if flags: pollster.register(fd, flags) r = pollster.poll (timeout) for fd, flags in r: try: obj = map[fd] except KeyError: pass
| 8,339
|
def poll3 (timeout=0.0, map=None): # Use the poll() support added to the select module in Python 2.0 if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) pollster = select.poll() if map: for fd, obj in map.items(): flags = 0 if obj.readable(): flags = select.POLLIN if obj.writable(): flags = flags | select.POLLOUT if flags: pollster.register(fd, flags) r = pollster.poll (timeout) for fd, flags in r: try: obj = map[fd] try: if (flags & select.POLLIN): obj.handle_read_event() if (flags & select.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: pass
|
def poll3 (timeout=0.0, map=None): # Use the poll() support added to the select module in Python 2.0 if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) pollster = select.poll() if map: for fd, obj in map.items(): flags = 0 if obj.readable(): flags = select.POLLIN if obj.writable(): flags = flags | select.POLLOUT if flags: pollster.register(fd, flags) r = pollster.poll (timeout) for fd, flags in r: try: obj = map[fd] try: if (flags & select.POLLIN): obj.handle_read_event() if (flags & select.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() except KeyError: continue try: if (flags & select.POLLIN): obj.handle_read_event() if (flags & select.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error()
| 8,340
|
def __init__ (self, dist): """Create and initialize a new Command object. Most importantly, invokes the 'initialize_options()' method, which is the real initializer and depends on the actual command being instantiated. """ # late import because of mutual dependence between these classes from distutils.dist import Distribution
|
def __init__ (self, dist): """Create and initialize a new Command object. Most importantly, invokes the 'initialize_options()' method, which is the real initializer and depends on the actual command being instantiated. """ # late import because of mutual dependence between these classes from distutils.dist import Distribution
| 8,341
|
def interesting_lines(self, firstline): """Generator which yields context lines, starting at firstline.""" # The indentation level we are currently in: lastindent = INFINITY # For a line to be interesting, it must begin with a block opening # keyword, and have less indentation than lastindent. for line_index in xrange(firstline, -1, -1): indent, text, opener = self.get_line_info(line_index) if indent < lastindent: lastindent = indent if opener == "else" or "elif": # We also show the if statement lastindent += 1 if opener and line_index < firstline: yield line_index, text
|
def interesting_lines(self, firstline): """Generator which yields context lines, starting at firstline.""" # The indentation level we are currently in: lastindent = INFINITY # For a line to be interesting, it must begin with a block opening # keyword, and have less indentation than lastindent. for line_index in xrange(firstline, -1, -1): indent, text, opener = self.get_line_info(line_index) if indent < lastindent: lastindent = indent if opener in ("else", "elif"): # We also show the if statement lastindent += 1 if opener and line_index < firstline: yield line_index, text
| 8,342
|
def splittype(url): """splittype('type:opaquestring') --> 'type', 'opaquestring'.""" global _typeprog if _typeprog is None: import re _typeprog = re.compile('^([^/:]+):') match = _typeprog.match(url) if match: scheme = match.group(1) return scheme, url[len(scheme) + 1:] return None, url
|
def splittype(url): """splittype('type:opaquestring') --> 'type', 'opaquestring'.""" global _typeprog if _typeprog is None: import re _typeprog = re.compile('^([^/:]+):') match = _typeprog.match(url) if match: scheme = match.group(1) return scheme.lower(), url[len(scheme) + 1:] return None, url
| 8,343
|
def test_formatdate(self): now = 1005327232.109884 epoch = time.gmtime(0)[0] # When does the epoch start? if epoch == 1970: # traditional Unix epoch matchdate = 'Fri, 09 Nov 2001 17:33:52 -0000' elif epoch == 1904: # Mac epoch matchdate = 'Sat, 09 Nov 1935 16:33:52 -0000' else: matchdate = "I don't understand your epoch" gdate = Utils.formatdate(now) self.assertEqual(gdate, matchdate)
|
def test_formatdate(self): now = 1005327232.109884 gm_epoch = time.gmtime(0)[0:3] loc_epoch = time.localtime(0)[0:3] # When does the epoch start? if epoch == 1970: # traditional Unix epoch matchdate = 'Fri, 09 Nov 2001 17:33:52 -0000' elif epoch == 1904: # Mac epoch matchdate = 'Sat, 09 Nov 1935 16:33:52 -0000' else: matchdate = "I don't understand your epoch" gdate = Utils.formatdate(now) self.assertEqual(gdate, matchdate)
| 8,344
|
def test_formatdate(self): now = 1005327232.109884 epoch = time.gmtime(0)[0] # When does the epoch start? if epoch == 1970: # traditional Unix epoch matchdate = 'Fri, 09 Nov 2001 17:33:52 -0000' elif epoch == 1904: # Mac epoch matchdate = 'Sat, 09 Nov 1935 16:33:52 -0000' else: matchdate = "I don't understand your epoch" gdate = Utils.formatdate(now) self.assertEqual(gdate, matchdate)
|
def test_formatdate(self): now = 1005327232.109884 epoch = time.gmtime(0)[0] # When does the epoch start? if gm_epoch == (1970, 1, 1): # traditional Unix epoch matchdate = 'Fri, 09 Nov 2001 17:33:52 -0000' elif epoch == 1904: # Mac epoch matchdate = 'Sat, 09 Nov 1935 16:33:52 -0000' else: matchdate = "I don't understand your epoch" gdate = Utils.formatdate(now) self.assertEqual(gdate, matchdate)
| 8,345
|
def test_formatdate(self): now = 1005327232.109884 epoch = time.gmtime(0)[0] # When does the epoch start? if epoch == 1970: # traditional Unix epoch matchdate = 'Fri, 09 Nov 2001 17:33:52 -0000' elif epoch == 1904: # Mac epoch matchdate = 'Sat, 09 Nov 1935 16:33:52 -0000' else: matchdate = "I don't understand your epoch" gdate = Utils.formatdate(now) self.assertEqual(gdate, matchdate)
|
def test_formatdate(self): now = 1005327232.109884 epoch = time.gmtime(0)[0] # When does the epoch start? if epoch == 1970: # traditional Unix epoch matchdate = 'Fri, 09 Nov 2001 17:33:52 -0000' elif loc_epoch == (1904, 1, 1): # Mac epoch matchdate = 'Sat, 09 Nov 1935 16:33:52 -0000' else: matchdate = "I don't understand your epoch" gdate = Utils.formatdate(now) self.assertEqual(gdate, matchdate)
| 8,346
|
def setcontext(context, _local=local): """Set this thread's context to context.""" if context in (DefaultContext, BasicContext, ExtendedContext): context = context.copy() context.clear_flags() _local.__decimal_context__ = context
|
def setcontext(context, _local=local): """Set this thread's context to context.""" if context in (DefaultContext, BasicContext, ExtendedContext): context = context.copy() context.clear_flags() _local.__decimal_context__ = context
| 8,347
|
def __init__(self, value="0", context=None): """Create a decimal point instance.
|
def __init__(self, value="0", context=None): """Create a decimal point instance.
| 8,348
|
def __init__(self, value="0", context=None): """Create a decimal point instance.
|
def __init__(self, value="0", context=None): """Create a decimal point instance.
| 8,349
|
def __init__(self, value="0", context=None): """Create a decimal point instance.
|
def __init__(self, value="0", context=None): """Create a decimal point instance.
| 8,350
|
def __init__(self, value="0", context=None): """Create a decimal point instance.
|
def __init__(self, value="0", context=None): """Create a decimal point instance.
| 8,351
|
def _isnan(self): """Returns whether the number is not actually one.
|
def _isnan(self): """Returns whether the number is not actually one.
| 8,352
|
def _check_nans(self, other = None, context=None): """Returns whether the number is not actually one.
|
def _check_nans(self, other = None, context=None): """Returns whether the number is not actually one.
| 8,353
|
def __nonzero__(self): """Is the number non-zero?
|
def __nonzero__(self): """Is the number non-zero?
| 8,354
|
def __nonzero__(self): """Is the number non-zero?
|
def __nonzero__(self): """Is the number non-zero?
| 8,355
|
def __cmp__(self, other, context=None): if context is None: context = getcontext() other = self._convert_other(other)
|
def __cmp__(self, other, context=None): if context is None: context = getcontext() other = self._convert_other(other)
| 8,356
|
def __cmp__(self, other, context=None): if context is None: context = getcontext() other = self._convert_other(other)
|
def __cmp__(self, other, context=None): if context is None: context = getcontext() other = self._convert_other(other)
| 8,357
|
def __cmp__(self, other, context=None): if context is None: context = getcontext() other = self._convert_other(other)
|
def __cmp__(self, other, context=None): if context is None: context = getcontext() other = self._convert_other(other)
| 8,358
|
def __cmp__(self, other, context=None): if context is None: context = getcontext() other = self._convert_other(other)
|
def __cmp__(self, other, context=None): if context is None: context = getcontext() other = self._convert_other(other)
| 8,359
|
def compare(self, other, context=None): """Compares one to another.
|
def compare(self, other, context=None): """Compares one to another.
| 8,360
|
def compare(self, other, context=None): """Compares one to another.
|
def compare(self, other, context=None): """Compares one to another.
| 8,361
|
def to_eng_string(self, context=None): """Convert to engineering-type string.
|
def to_eng_string(self, context=None): """Convert to engineering-type string.
| 8,362
|
def __neg__(self, context=None): """Returns a copy with the sign switched.
|
def __neg__(self, context=None): """Returns a copy with the sign switched.
| 8,363
|
def __pos__(self, context=None): """Returns a copy, unless it is a sNaN.
|
def __pos__(self, context=None): """Returns a copy, unless it is a sNaN.
| 8,364
|
def __abs__(self, round=1, context=None): """Returns the absolute value of self.
|
def __abs__(self, round=1, context=None): """Returns the absolute value of self.
| 8,365
|
def __add__(self, other, context=None): """Returns self + other.
|
def __add__(self, other, context=None): """Returns self + other.
| 8,366
|
def __add__(self, other, context=None): """Returns self + other.
|
def __add__(self, other, context=None): """Returns self + other.
| 8,367
|
def __add__(self, other, context=None): """Returns self + other.
|
def __add__(self, other, context=None): """Returns self + other.
| 8,368
|
def __add__(self, other, context=None): """Returns self + other.
|
def __add__(self, other, context=None): """Returns self + other.
| 8,369
|
def __sub__(self, other, context=None): """Return self + (-other)""" if context is None: context = getcontext() other = self._convert_other(other)
|
def __sub__(self, other, context=None): """Return self + (-other)""" if context is None: context = getcontext() other = self._convert_other(other)
| 8,370
|
def __rsub__(self, other, context=None): """Return other + (-self)""" if context is None: context = getcontext() other = self._convert_other(other)
|
def __rsub__(self, other, context=None): """Return other + (-self)""" if context is None: context = getcontext() other = self._convert_other(other)
| 8,371
|
def _increment(self, round=1, context=None): """Special case of add, adding 1eExponent
|
def _increment(self, round=1, context=None): """Special case of add, adding 1eExponent
| 8,372
|
def __mul__(self, other, context=None): """Return self * other.
|
def __mul__(self, other, context=None): """Return self * other.
| 8,373
|
def __mul__(self, other, context=None): """Return self * other.
|
def __mul__(self, other, context=None): """Return self * other.
| 8,374
|
def __mul__(self, other, context=None): """Return self * other.
|
def __mul__(self, other, context=None): """Return self * other.
| 8,375
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
| 8,376
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
| 8,377
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
| 8,378
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
| 8,379
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
| 8,380
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
| 8,381
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
| 8,382
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
| 8,383
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
| 8,384
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
| 8,385
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
| 8,386
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
| 8,387
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
| 8,388
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
| 8,389
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
|
def _divide(self, other, divmod = 0, context=None): """Return a / b, to context.prec precision.
| 8,390
|
def __rdiv__(self, other, context=None): """Swaps self/other and returns __div__.""" other = self._convert_other(other) return other.__div__(self, context=context)
|
def __rdiv__(self, other, context=None): """Swaps self/other and returns __div__.""" other = _convert_other(other) return other.__div__(self, context=context)
| 8,391
|
def __rdivmod__(self, other, context=None): """Swaps self/other and returns __divmod__.""" other = self._convert_other(other) return other.__divmod__(self, context=context)
|
def __rdivmod__(self, other, context=None): """Swaps self/other and returns __divmod__.""" other = _convert_other(other) return other.__divmod__(self, context=context)
| 8,392
|
def __mod__(self, other, context=None): """ self % other """ if context is None: context = getcontext() other = self._convert_other(other)
|
def __mod__(self, other, context=None): """ self % other """ if context is None: context = getcontext() other = self._convert_other(other)
| 8,393
|
def __rfloordiv__(self, other, context=None): """Swaps self/other and returns __floordiv__.""" other = self._convert_other(other) return other.__floordiv__(self, context=context)
|
def __rfloordiv__(self, other, context=None): """Swaps self/other and returns __floordiv__.""" other = _convert_other(other) return other.__floordiv__(self, context=context)
| 8,394
|
def __int__(self): """Converts self to a int, truncating if necessary.""" if self._isnan(): context = getcontext() return context._raise_error(InvalidContext) elif self._isinfinity(): raise OverflowError, "Cannot convert infinity to long" if not self: return 0 sign = '-'*self._sign if self._exp >= 0: s = sign + ''.join(map(str, self._int)) + '0'*self._exp return int(s) s = sign + ''.join(map(str, self._int))[:self._exp] return int(s) tmp = list(self._int) tmp.reverse() val = 0 while tmp: val *= 10 val += tmp.pop() return int(((-1) ** self._sign) * val * 10.**int(self._exp))
|
def __int__(self): """Converts self to a int, truncating if necessary.""" if self._is_special: if self._isnan(): context = getcontext() return context._raise_error(InvalidContext) elif self._isinfinity(): raise OverflowError, "Cannot convert infinity to long" if not self: return 0 sign = '-'*self._sign if self._exp >= 0: s = sign + ''.join(map(str, self._int)) + '0'*self._exp return int(s) s = sign + ''.join(map(str, self._int))[:self._exp] return int(s) tmp = list(self._int) tmp.reverse() val = 0 while tmp: val *= 10 val += tmp.pop() return int(((-1) ** self._sign) * val * 10.**int(self._exp))
| 8,395
|
def __int__(self): """Converts self to a int, truncating if necessary.""" if self._isnan(): context = getcontext() return context._raise_error(InvalidContext) elif self._isinfinity(): raise OverflowError, "Cannot convert infinity to long" if not self: return 0 sign = '-'*self._sign if self._exp >= 0: s = sign + ''.join(map(str, self._int)) + '0'*self._exp return int(s) s = sign + ''.join(map(str, self._int))[:self._exp] return int(s) tmp = list(self._int) tmp.reverse() val = 0 while tmp: val *= 10 val += tmp.pop() return int(((-1) ** self._sign) * val * 10.**int(self._exp))
|
def __int__(self): """Converts self to a int, truncating if necessary.""" if self._isnan(): context = getcontext() return context._raise_error(InvalidContext) elif self._isinfinity(): raise OverflowError, "Cannot convert infinity to long" if not self: return 0 sign = '-'*self._sign if self._exp >= 0: s = sign + ''.join(map(str, self._int)) + '0'*self._exp return int(s) s = sign + ''.join(map(str, self._int))[:self._exp] return int(s) tmp = list(self._int) tmp.reverse() val = 0 while tmp: val *= 10 val += tmp.pop() return int(((-1) ** self._sign) * val * 10.**int(self._exp))
| 8,396
|
def _fix(self, prec=None, rounding=None, folddown=None, context=None): """Round if it is necessary to keep self within prec precision.
|
def _fix(self, prec=None, rounding=None, folddown=None, context=None): """Round if it is necessary to keep self within prec precision.
| 8,397
|
def _fix(self, prec=None, rounding=None, folddown=None, context=None): """Round if it is necessary to keep self within prec precision.
|
def _fix(self, prec=None, rounding=None, folddown=None, context=None): """Round if it is necessary to keep self within prec precision.
| 8,398
|
def _fixexponents(self, prec=None, rounding=None, folddown=None, context=None): """Fix the exponents and return a copy with the exponent in bounds.""" if self._isinfinity(): return self if context is None: context = getcontext() if prec is None: prec = context.prec if folddown is None: folddown = context._clamp Emin, Emax = context.Emin, context.Emax Etop = context.Etop() ans = Decimal(self) if ans.adjusted() < Emin: Etiny = context.Etiny() if ans._exp < Etiny: if not ans: ans._exp = Etiny context._raise_error(Clamped) return ans ans = ans._rescale(Etiny, context=context) #It isn't zero, and exp < Emin => subnormal context._raise_error(Subnormal) if context.flags[Inexact]: context._raise_error(Underflow) else: if ans: #Only raise subnormal if non-zero. context._raise_error(Subnormal) elif folddown and ans._exp > Etop: context._raise_error(Clamped) ans = ans._rescale(Etop, context=context) elif ans.adjusted() > Emax: if not ans: ans._exp = Emax context._raise_error(Clamped) return ans context._raise_error(Inexact) context._raise_error(Rounded) return context._raise_error(Overflow, 'above Emax', ans._sign) return ans
|
def _fixexponents(self, prec=None, rounding=None, folddown=None, context=None): """Fix the exponents and return a copy with the exponent in bounds.""" if self._is_special: return self if context is None: context = getcontext() if prec is None: prec = context.prec if folddown is None: folddown = context._clamp Emin, Emax = context.Emin, context.Emax Etop = context.Etop() ans = Decimal(self) if ans.adjusted() < Emin: Etiny = context.Etiny() if ans._exp < Etiny: if not ans: ans._exp = Etiny context._raise_error(Clamped) return ans ans = ans._rescale(Etiny, context=context) #It isn't zero, and exp < Emin => subnormal context._raise_error(Subnormal) if context.flags[Inexact]: context._raise_error(Underflow) else: if ans: #Only raise subnormal if non-zero. context._raise_error(Subnormal) elif folddown and ans._exp > Etop: context._raise_error(Clamped) ans = ans._rescale(Etop, context=context) elif ans.adjusted() > Emax: if not ans: ans._exp = Emax context._raise_error(Clamped) return ans context._raise_error(Inexact) context._raise_error(Rounded) return context._raise_error(Overflow, 'above Emax', ans._sign) return ans
| 8,399
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.