bugged stringlengths 4 228k | fixed stringlengths 0 96.3M | __index_level_0__ int64 0 481k |
|---|---|---|
def _checkcrc(self): | def _checkcrc(self): | 24,500 |
def _readheader(self): | def _readheader(self): | 24,501 |
def _readheader(self): | def _readheader(self): | 24,502 |
def read(self, *n): | def read(self, *n): | 24,503 |
def close_data(self): if self.state != _DID_HEADER: raise Error, 'close_data at wrong time' if self.dlen: | def close_data(self): if self.state != _DID_HEADER: raise Error, 'close_data at wrong time' if self.dlen: | 24,504 |
def close_data(self): if self.state != _DID_HEADER: raise Error, 'close_data at wrong time' if self.dlen: | def close_data(self): if self.state != _DID_HEADER: raise Error, 'close_data at wrong time' if self.dlen: | 24,505 |
def hexbin(inp, out): """(infilename, outfilename) - Decode binhexed file""" ifp = HexBin(inp) finfo = ifp.FInfo if not out: out = ifp.FName if os.name == 'mac': ofss = macfs.FSSpec(out) out = ofss.as_pathname() ofp = open(out, 'wb') # XXXX Do translation on non-mac systems d = ifp.read() ofp.write(d) ofp.close() ifp.... | def hexbin(inp, out): """(infilename, outfilename) - Decode binhexed file""" ifp = HexBin(inp) finfo = ifp.FInfo if not out: out = ifp.FName if os.name == 'mac': ofss = macfs.FSSpec(out) out = ofss.as_pathname() ofp = open(out, 'wb') # XXXX Do translation on non-mac systems while 1: d = ifp.read(128000) if not d: brea... | 24,506 |
def hexbin(inp, out): """(infilename, outfilename) - Decode binhexed file""" ifp = HexBin(inp) finfo = ifp.FInfo if not out: out = ifp.FName if os.name == 'mac': ofss = macfs.FSSpec(out) out = ofss.as_pathname() ofp = open(out, 'wb') # XXXX Do translation on non-mac systems d = ifp.read() ofp.write(d) ofp.close() ifp.... | def hexbin(inp, out): """(infilename, outfilename) - Decode binhexed file""" ifp = HexBin(inp) finfo = ifp.FInfo if not out: out = ifp.FName if os.name == 'mac': ofss = macfs.FSSpec(out) out = ofss.as_pathname() ofp = open(out, 'wb') # XXXX Do translation on non-mac systems d = ifp.read() ofp.write(d) ofp.close() ifp.... | 24,507 |
def _test(): if os.name == 'mac': fss, ok = macfs.PromptGetFile('File to convert:') if not ok: sys.exit(0) fname = fss.as_pathname() else: fname = sys.argv[1] #binhex(fname, fname+'.hqx') #hexbin(fname+'.hqx', fname+'.viahqx') hexbin(fname, fname+'.unpacked') sys.exit(1) | def_test():ifos.name=='mac':fss,ok=macfs.PromptGetFile('Filetoconvert:')ifnotok:sys.exit(0)fname=fss.as_pathname()else:fname=sys.argv[1]#binhex(fname,fname+'.hqx')#hexbin(fname+'.hqx',fname+'.viahqx')hexbin(fname,fname+'.unpacked')sys.exit(1) | 24,508 |
... def g(): | ... def g(): | 24,509 |
... def f(self): | ... def f(self): | 24,510 |
def draw(self, x, y): # XXX This hard-codes too many geometry constants! self.x, self.y = x, y self.drawicon() self.drawtext() if self.state != 'expanded': return y+17 # draw children if not self.children: sublist = self.item._GetSubList() if not sublist: # _IsExpandable() was mistaken; that's allowed return y+17 for i... | def draw(self, x, y): # XXX This hard-codes too many geometry constants! self.x, self.y = x, y self.drawicon() self.drawtext() if self.state != 'expanded': return y+17 # draw children if not self.children: sublist = self.item._GetSubList() if not sublist: # _IsExpandable() was mistaken; that's allowed return y+17 for i... | 24,511 |
def test_b(self): from _testcapi import getargs_b # b returns 'unsigned char', and does range checking (0 ... UCHAR_MAX) self.failUnlessEqual(3, getargs_b(3.14)) self.failUnlessEqual(99, getargs_b(Long())) self.failUnlessEqual(99, getargs_b(Int())) | def test_b(self): from _testcapi import getargs_b # b returns 'unsigned char', and does range checking (0 ... UCHAR_MAX) self.assertRaises(TypeError, getargs_b, 3.14) self.failUnlessEqual(99, getargs_b(Long())) self.failUnlessEqual(99, getargs_b(Int())) | 24,512 |
def test_B(self): from _testcapi import getargs_B # B returns 'unsigned char', no range checking self.failUnlessEqual(3, getargs_B(3.14)) self.failUnlessEqual(99, getargs_B(Long())) self.failUnlessEqual(99, getargs_B(Int())) | def test_B(self): from _testcapi import getargs_B # B returns 'unsigned char', no range checking self.assertRaises(TypeError, getargs_B, 3.14) self.failUnlessEqual(99, getargs_B(Long())) self.failUnlessEqual(99, getargs_B(Int())) | 24,513 |
def test_H(self): from _testcapi import getargs_H # H returns 'unsigned short', no range checking self.failUnlessEqual(3, getargs_H(3.14)) self.failUnlessEqual(99, getargs_H(Long())) self.failUnlessEqual(99, getargs_H(Int())) | def test_H(self): from _testcapi import getargs_H # H returns 'unsigned short', no range checking self.assertRaises(TypeError, getargs_H, 3.14) self.failUnlessEqual(99, getargs_H(Long())) self.failUnlessEqual(99, getargs_H(Int())) | 24,514 |
def test_I(self): from _testcapi import getargs_I # I returns 'unsigned int', no range checking self.failUnlessEqual(3, getargs_I(3.14)) self.failUnlessEqual(99, getargs_I(Long())) self.failUnlessEqual(99, getargs_I(Int())) | def test_I(self): from _testcapi import getargs_I # I returns 'unsigned int', no range checking self.assertRaises(TypeError, getargs_I, 3.14) self.failUnlessEqual(99, getargs_I(Long())) self.failUnlessEqual(99, getargs_I(Int())) | 24,515 |
def test_i(self): from _testcapi import getargs_i # i returns 'int', and does range checking (INT_MIN ... INT_MAX) self.failUnlessEqual(3, getargs_i(3.14)) self.failUnlessEqual(99, getargs_i(Long())) self.failUnlessEqual(99, getargs_i(Int())) | def test_i(self): from _testcapi import getargs_i # i returns 'int', and does range checking (INT_MIN ... INT_MAX) self.assertRaises(TypeError, getargs_i, 3.14) self.failUnlessEqual(99, getargs_i(Long())) self.failUnlessEqual(99, getargs_i(Int())) | 24,516 |
def test_l(self): from _testcapi import getargs_l # l returns 'long', and does range checking (LONG_MIN ... LONG_MAX) self.failUnlessEqual(3, getargs_l(3.14)) self.failUnlessEqual(99, getargs_l(Long())) self.failUnlessEqual(99, getargs_l(Int())) | def test_l(self): from _testcapi import getargs_l # l returns 'long', and does range checking (LONG_MIN ... LONG_MAX) self.assertRaises(TypeError, getargs_l, 3.14) self.failUnlessEqual(99, getargs_l(Long())) self.failUnlessEqual(99, getargs_l(Int())) | 24,517 |
def __del__(self): """Call the "close()" method in case the user forgot.""" if self.fp and not self._filePassed: self.fp.close() self.fp = None | def __del__(self): """Call the "close()" method in case the user forgot.""" if self.fp and not self._filePassed: self.fp.close() self.fp = None | 24,518 |
check_syntax("def f(): global time; import ") | 24,519 | |
def recolorize_main(self): next = "1.0" was_ok = is_ok = 0 while 1: item = self.tag_nextrange("TODO", next) if not item: break head, tail = item self.tag_remove("SYNC", head, tail) item = self.tag_prevrange("SYNC", head) if item: head = item[1] else: head = "1.0" | def recolorize_main(self): next = "1.0" was_ok = is_ok = 0 while 1: item = self.tag_nextrange("TODO", next) if not item: break head, tail = item self.tag_remove("SYNC", head, tail) item = self.tag_prevrange("SYNC", head) if item: head = item[1] else: head = "1.0" | 24,520 |
def create_static_lib (self, objects, output_libname, output_dir=None, debug=0, extra_preargs=None, extra_postargs=None): | def create_static_lib (self, objects, output_libname, output_dir=None, debug=0, extra_preargs=None, extra_postargs=None): | 24,521 |
def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, debug=0, extra_preargs=None, extra_postargs=None): | def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, debug=0, extra_preargs=None, extra_postargs=None): | 24,522 |
def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, debug=0, extra_preargs=None, extra_postargs=None): | def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, debug=0, extra_preargs=None, extra_postargs=None): | 24,523 |
def main(): global app initialcolor = (128, 128, 128) try: opts, args = getopt.getopt(sys.argv[1:], 'hc:', ['color=', 'help']) except getopt.error, msg: usage(1, msg) if args: usage(1) for opt, arg in opts: if opt in ('-h', '--help'): usage(0) elif opt in ('-c', '--color'): initialcolor = arg # create the windows a... | def main(): global app initialcolor = 'grey50' try: opts, args = getopt.getopt(sys.argv[1:], 'hc:', ['color=', 'help']) except getopt.error, msg: usage(1, msg) if args: usage(1) for opt, arg in opts: if opt in ('-h', '--help'): usage(0) elif opt in ('-c', '--color'): initialcolor = arg # create the windows and go f... | 24,524 |
def _bytecode_filenames (self, py_filenames): bytecode_files = [] for py_file in py_filenames: if self.compile: bytecode_files.append(py_file + "c") if self.optmize > 0: bytecode_files.append(py_file + "o") | def _bytecode_filenames (self, py_filenames): bytecode_files = [] for py_file in py_filenames: if self.compile: bytecode_files.append(py_file + "c") if self.optimize > 0: bytecode_files.append(py_file + "o") | 24,525 |
def do_updateEvt(self, event): (what, message, when, where, modifiers) = event wid = Win.WhichWindow(message) if wid and self._windows.has_key(wid): window = self._windows[wid] window.do_rawupdate(wid, event) else: if wid: wid.HideWindow() import sys sys.stderr.write("XXX killed unknown (crashed?) Python window.\n") el... | def do_updateEvt(self, event): (what, message, when, where, modifiers) = event wid = Win.WhichWindow(message) if wid and self._windows.has_key(wid): window = self._windows[wid] window.do_rawupdate(wid, event) else: if KILLUNKNOWNWINDOWS and wid: wid.HideWindow() import sys sys.stderr.write("XXX killed unknown (crashed?... | 24,526 |
def _setup_compile(self, outdir, macros, incdirs, sources, depends, extra): """Process arguments and decide which source files to compile. | def _setup_compile(self, outdir, macros, incdirs, sources, depends, extra): """Process arguments and decide which source files to compile. | 24,527 |
def _prep_compile(self, sources, output_dir, depends=None): """Decide which souce files must be recompiled. | def _prep_compile(self, sources, output_dir, depends=None): """Decide which souce files must be recompiled. | 24,528 |
def open(self, url, new=0): os.system(self.command % url) | def open(self, url, new=0, autoraise=1): os.system(self.command % url) | 24,529 |
def open(self, url, new=1): # XXX Currently I know no way to prevent KFM from opening a new win. self._remote("openURL %s" % url) | def open(self, url, new=1, autoraise=1): # XXX Currently I know no way to prevent KFM from opening a new win. self._remote("openURL %s" % url) | 24,530 |
def open(self, url, new=0): if new: self._remote("LOADNEW " + url) else: self._remote("LOAD " + url) | def open(self, url, new=0, autoraise=1): if new: self._remote("LOADNEW " + url) else: self._remote("LOAD " + url) | 24,531 |
def open(self, url, new=0): os.startfile(url) | def open(self, url, new=0, autoraise=1): os.startfile(url) | 24,532 |
def open(self, url, new=0): ic.launchurl(url) | def open(self, url, new=0, autoraise=1): ic.launchurl(url) | 24,533 |
def get_version(self): return self.version or "???" | def get_version(self): return self.version or "???" | 24,534 |
def makepath(*paths): dir = os.path.abspath(os.path.join(*paths)) return dir, os.path.normcase(dir) | def makepath(*paths): dir = os.path.abspath(os.path.join(*paths)) return dir, os.path.normcase(dir) | 24,535 |
def makepath(*paths): dir = os.path.abspath(os.path.join(*paths)) return dir, os.path.normcase(dir) | def makepath(*paths): dir = os.path.abspath(os.path.join(*paths)) return dir, os.path.normcase(dir) | 24,536 |
def break_yolks(self): self.yolks = self.yolks - 2 | def break_yolks(self): self.yolks = self.yolks - 2 | 24,537 |
def upload_file(self, command, pyversion, filename): # Sign if requested if self.sign: spawn(("gpg", "--detach-sign", "-a", filename), dry_run=self.dry_run) | def upload_file(self, command, pyversion, filename): # Sign if requested if self.sign: spawn(("gpg", "--detach-sign", "-a", filename), dry_run=self.dry_run) | 24,538 |
def upload_file(self, command, pyversion, filename): # Sign if requested if self.sign: spawn(("gpg", "--detach-sign", "-a", filename), dry_run=self.dry_run) | def upload_file(self, command, pyversion, filename): # Sign if requested if self.sign: spawn(("gpg", "--detach-sign", "-a", filename), dry_run=self.dry_run) | 24,539 |
def test_load(self): if os.name == "nt": name = "msvcrt" elif os.name == "ce": name = "coredll" elif sys.platform == "darwin": name = "libc.dylib" elif sys.platform.startswith("freebsd"): name = "libc.so" elif sys.platform == "sunos5": name = "libc.so" elif sys.platform.startswith("netbsd"): name = "libc.so" else: name... | def test_load(self): if os.name == "nt": name = "msvcrt" elif os.name == "ce": name = "coredll" elif sys.platform == "darwin": name = "libc.dylib" elif sys.platform.startswith("freebsd"): name = "libc.so" elif sys.platform == "sunos5": name = "libc.so" elif sys.platform.startswith("netbsd") or sys.platform.startswith("... | 24,540 |
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') | 24,541 |
def test_xrange(self): self.assertEqual(list(xrange(3)), [0, 1, 2]) self.assertEqual(list(xrange(1, 5)), [1, 2, 3, 4]) self.assertEqual(list(xrange(0)), []) self.assertEqual(list(xrange(-3)), []) self.assertEqual(list(xrange(1, 10, 3)), [1, 4, 7]) self.assertEqual(list(xrange(5, -5, -3)), [5, 2, -1, -4]) | def test_xrange(self): self.assertEqual(list(xrange(3)), [0, 1, 2]) self.assertEqual(list(xrange(1, 5)), [1, 2, 3, 4]) self.assertEqual(list(xrange(0)), []) self.assertEqual(list(xrange(-3)), []) self.assertEqual(list(xrange(1, 10, 3)), [1, 4, 7]) self.assertEqual(list(xrange(5, -5, -3)), [5, 2, -1, -4]) | 24,542 |
def _get_fqdn_hostname(name): name = string.strip(name) if len(name) == 0: name = socket.gethostname() try: hostname, aliases, ipaddrs = socket.gethostbyaddr(name) except socket.error: pass else: aliases.insert(0, hostname) for name in aliases: if '.' in name: break else: name = hostname return name | def make_fqdn(name = ''): """Get fully qualified domain name from name. An empty argument is interpreted as meaning the local host. First the hostname returned by socket.gethostbyaddr() is checked, then possibly existing aliases. In case no FQDN is available, hostname is returned. """ name = string.strip(name) if len... | 24,543 |
def _get_fqdn_hostname(name): name = string.strip(name) if len(name) == 0: name = socket.gethostname() try: hostname, aliases, ipaddrs = socket.gethostbyaddr(name) except socket.error: pass else: aliases.insert(0, hostname) for name in aliases: if '.' in name: break else: name = hostname return name | def _get_fqdn_hostname(name): name = string.strip(name) if len(name) == 0: name = socket.gethostname() try: hostname, aliases, ipaddrs = socket.gethostbyaddr(name) except socket.error: pass else: aliases.insert(0, hostname) for name in aliases: if '.' in name: break else: aliases.insert(0, hostname) for name in aliases... | 24,544 |
def _get_fqdn_hostname(name): name = string.strip(name) if len(name) == 0: name = socket.gethostname() try: hostname, aliases, ipaddrs = socket.gethostbyaddr(name) except socket.error: pass else: aliases.insert(0, hostname) for name in aliases: if '.' in name: break else: name = hostname return name | def _get_fqdn_hostname(name): name = string.strip(name) if len(name) == 0: name = socket.gethostname() try: hostname, aliases, ipaddrs = socket.gethostbyaddr(name) except socket.error: pass else: name = hostname return name | 24,545 |
def helo(self, name=''): """SMTP 'helo' command. Hostname to send for this command defaults to the FQDN of the local host. """ self.putcmd("helo", _get_fqdn_hostname(name)) (code,msg)=self.getreply() self.helo_resp=msg return (code,msg) | def helo(self, name=''): """SMTP 'helo' command. Hostname to send for this command defaults to the FQDN of the local host. """ if name: self.putcmd("helo", name) else: self.putcmd("helo", make_fqdn()) (code,msg)=self.getreply() self.helo_resp=msg return (code,msg) | 24,546 |
def ehlo(self, name=''): """ SMTP 'ehlo' command. Hostname to send for this command defaults to the FQDN of the local host. """ self.putcmd("ehlo", _get_fqdn_hostname(name)) (code,msg)=self.getreply() # According to RFC1869 some (badly written) # MTA's will disconnect on an ehlo. Toss an exception if # that happens -dd... | def ehlo(self, name=''): """ SMTP 'ehlo' command. Hostname to send for this command defaults to the FQDN of the local host. """ if name: self.putcmd("ehlo", name) else: self.putcmd("ehlo", make_fqdn()) (code,msg)=self.getreply() # According to RFC1869 some (badly written) # MTA's will disconnect on an ehlo. Toss an exc... | 24,547 |
def startElementNS(self, name, tagName , attrs): uri, localname = name if uri: # When using namespaces, the reader may or may not # provide us with the original name. If not, create # *a* valid tagName from the current context. if tagName is None: tagName = self._current_context[uri] + ":" + localname node = self.docum... | def startElementNS(self, name, tagName , attrs): uri, localname = name if uri: # When using namespaces, the reader may or may not # provide us with the original name. If not, create # *a* valid tagName from the current context. if tagName is None: prefix = self._current_context[uri] if prefix: tagName = prefix + ":" + ... | 24,548 |
def startElementNS(self, name, tagName , attrs): uri, localname = name if uri: # When using namespaces, the reader may or may not # provide us with the original name. If not, create # *a* valid tagName from the current context. if tagName is None: tagName = self._current_context[uri] + ":" + localname node = self.docum... | def startElementNS(self, name, tagName , attrs): uri, localname = name if uri: # When using namespaces, the reader may or may not # provide us with the original name. If not, create # *a* valid tagName from the current context. if tagName is None: tagName = self._current_context[uri] + ":" + localname node = self.docum... | 24,549 |
def nobody_uid(): """Internal routine to get nobody's uid""" global nobody if nobody: return nobody import pwd try: nobody = pwd.getpwnam('nobody')[2] except pwd.error: nobody = 1 + max(map(lambda x: x[2], pwd.getpwall())) return nobody | def nobody_uid(): """Internal routine to get nobody's uid""" global nobody if nobody: return nobody import pwd try: nobody = pwd.getpwnam('nobody')[2] except KeyError: nobody = 1 + max(map(lambda x: x[2], pwd.getpwall())) return nobody | 24,550 |
def force_test_exit(): # Sigh, both imports seem necessary to avoid errors. import os fork_pid = os.fork() if fork_pid: # In parent. return fork_pid # In child. import os, time try: # Wait 5 seconds longer than the expected alarm to give enough # time for the normal sequence of events to occur. This is # just a stop-... | def force_test_exit(): # Sigh, both imports seem necessary to avoid errors. import os fork_pid = os.fork() if fork_pid: # In parent. return fork_pid # In child. import os, time try: # Wait 5 seconds longer than the expected alarm to give enough # time for the normal sequence of events to occur. This is # just a stop-... | 24,551 |
def output_tp_init(self): if self.output_tp_initBody: Output("static int %s_init(PyObject *self, PyObject *args, PyObject *kwds)", self.prefix) OutLbrace() self.output_tp_initBody() OutRbrace() else: Output("#define %s_tp_init 0", self.prefix) Output() | def output_tp_init(self): if self.output_tp_initBody: Output("static int %s_tp_init(PyObject *self, PyObject *args, PyObject *kwds)", self.prefix) OutLbrace() self.output_tp_initBody() OutRbrace() else: Output("#define %s_tp_init 0", self.prefix) Output() | 24,552 |
def close(self): if self.closehook: apply(self.closehook, self.hookargs) self.closehook = None self.hookargs = None addbase.close(self) | def close(self): if self.closehook: apply(self.closehook, self.hookargs) self.closehook = None self.hookargs = None addbase.close(self) | 24,553 |
def test_tuple_reuse(self): # Tests an implementation detail where tuple is reused # whenever nothing else holds a reference to it self.assertEqual(len(Set(map(id, list(self.seq)))), len(self.seq)) self.assertEqual(len(Set(map(id, enumerate(self.seq)))), min(1,len(self.seq))) | def test_tuple_reuse(self): # Tests an implementation detail where tuple is reused # whenever nothing else holds a reference to it self.assertEqual(len(Set(map(id, list(enumerate(self.seq))))), len(self.seq)) self.assertEqual(len(Set(map(id, enumerate(self.seq)))), min(1,len(self.seq))) | 24,554 |
def getproxies_environment(): """Return a dictionary of scheme -> proxy server URL mappings. Scan the environment for variables named <scheme>_proxy; this seems to be the standard convention. If you need a different way, you can pass a proxies dictionary to the [Fancy]URLopener constructor. """ proxies = {} for name... | def getproxies_environment(): """Return a dictionary of scheme -> proxy server URL mappings. Scan the environment for variables named <scheme>_proxy; this seems to be the standard convention. If you need a different way, you can pass a proxies dictionary to the [Fancy]URLopener constructor. """ proxies = {} for name... | 24,555 |
def mkpath (name, mode=0777, verbose=0, dry_run=0): """Create a directory and any missing ancestor directories. If the directory already exists (or if 'name' is the empty string, which means the current directory, which of course exists), then do nothing. Raise DistutilsFileError if unable to create some directory al... | def mkpath (name, mode=0777, verbose=0, dry_run=0): """Create a directory and any missing ancestor directories. If the directory already exists (or if 'name' is the empty string, which means the current directory, which of course exists), then do nothing. Raise DistutilsFileError if unable to create some directory al... | 24,556 |
def get_host_info(self, host): | def get_host_info(self, host): | 24,557 |
def visiblename(name, all=None): """Decide whether to show documentation on a variable.""" # Certain special names are redundant. if name in ['__builtins__', '__doc__', '__file__', '__path__', '__module__', '__name__']: return 0 # Private names are hidden, but special names are displayed. if name.startswith('__') and n... | def visiblename(name, all=None): """Decide whether to show documentation on a variable.""" # Certain special names are redundant. if name in ['__builtins__', '__doc__', '__file__', '__path__', '__module__', '__name__', '__slots__']: return 0 # Private names are hidden, but special names are displayed. if name.startswit... | 24,558 |
def spillproperties(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: push(self._docproperty(name, value, mod)) return attrs | def spilldescriptors(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: push(self._docproperty(name, value, mod)) return attrs | 24,559 |
def spillproperties(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: push(self._docproperty(name, value, mod)) return attrs | def spillproperties(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: push(self._docdescriptor(name, value, mod)) return attrs | 24,560 |
def spilldata(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: base = self.docother(getattr(object, name), name, mod) if callable(value) or inspect.isdatadescriptor(value): doc = getattr(value, "__doc__", None) else: doc = None if doc is... | def spilldata(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: base = self.docother(getattr(object, name), name, mod) if callable(value) or inspect.isdatadescriptor(value): doc = getattr(value, "__doc__", None) else: doc = None if doc is... | 24,561 |
def spilldata(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: base = self.docother(getattr(object, name), name, mod) if callable(value) or inspect.isdatadescriptor(value): doc = getattr(value, "__doc__", None) else: doc = None if doc is... | def spilldata(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: base = self.docother(getattr(object, name), name, mod) if callable(value) or inspect.isdatadescriptor(value): doc = getattr(value, "__doc__", None) else: doc = None if doc is... | 24,562 |
def _docproperty(self, name, value, mod): results = [] push = results.append | def _docdescriptor(self, name, value, mod): results = [] push = results.append | 24,563 |
def _docproperty(self, name, value, mod): results = [] push = results.append | def _docproperty(self, name, value, mod): results = [] push = results.append | 24,564 |
def docproperty(self, object, name=None, mod=None, cl=None): """Produce html documentation for a property.""" return self._docproperty(name, object, mod) | def docproperty(self, object, name=None, mod=None, cl=None): """Produce html documentation for a property.""" return self._docproperty(name, object, mod) | 24,565 |
def spillproperties(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: push(self._docproperty(name, value, mod)) return attrs | def spilldescriptors(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: push(self._docproperty(name, value, mod)) return attrs | 24,566 |
def spillproperties(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: push(self._docproperty(name, value, mod)) return attrs | def spillproperties(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: push(self._docdescriptor(name, value, mod)) return attrs | 24,567 |
def spilldata(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: if callable(value) or inspect.isdatadescriptor(value): doc = getattr(value, "__doc__", None) else: doc = None push(self.docother(getattr(object, name), name, mod, 70, doc) + ... | def spilldata(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: if callable(value) or inspect.isdatadescriptor(value): doc = getattr(value, "__doc__", None) else: doc = None push(self.docother(getattr(object, name), name, mod, 70, doc) + ... | 24,568 |
def spilldata(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: if callable(value) or inspect.isdatadescriptor(value): doc = getattr(value, "__doc__", None) else: doc = None push(self.docother(getattr(object, name), name, mod, 70, doc) + ... | def spilldata(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: if callable(value) or inspect.isdatadescriptor(value): doc = getattr(value, "__doc__", None) else: doc = None push(self.docother(getattr(object, name), name, mod, 70, doc) + ... | 24,569 |
def _docproperty(self, name, value, mod): results = [] push = results.append | def _docdescriptor(self, name, value, mod): results = [] push = results.append | 24,570 |
def _docproperty(self, name, value, mod): results = [] push = results.append | def _docproperty(self, name, value, mod): results = [] push = results.append | 24,571 |
def _docproperty(self, name, value, mod): results = [] push = results.append | def _docproperty(self, name, value, mod): results = [] push = results.append | 24,572 |
def docproperty(self, object, name=None, mod=None, cl=None): """Produce text documentation for a property.""" return self._docproperty(name, object, mod) | def docproperty(self, object, name=None, mod=None, cl=None): """Produce text documentation for a property.""" return self._docproperty(name, object, mod) | 24,573 |
def _sync_flush(f): """Ensure changes to file f are physically on disk.""" f.flush() os.fsync(f.fileno()) | def _sync_flush(f): """Ensure changes to file f are physically on disk.""" f.flush() if hasattr(os, 'fsync'): os.fsync(f.fileno()) | 24,574 |
def __hash__(self, *args): print "__hash__:", args return id(self) | def __hash__(self, *args): print "__hash__:", args return id(self) | 24,575 |
def strftest(now): if verbose: print "strftime test for", time.ctime(now) nowsecs = int(now) gmt = time.gmtime(now) now = time.localtime(now) if now[3] < 12: ampm='AM' else: ampm='PM' jan1 = time.localtime(time.mktime((now[0], 1, 1) + (0,)*6)) if now[8]: tz = time.tzname[1] else: tz = time.tzname[0] if now[3] > 12:... | def strftest(now): if verbose: print "strftime test for", time.ctime(now) nowsecs = int(now) gmt = time.gmtime(now) now = time.localtime(now) if now[3] < 12: ampm='AM' else: ampm='PM' jan1 = time.localtime(time.mktime((now[0], 1, 1) + (0,)*6)) if now[8]: tz = time.tzname[1] else: tz = time.tzname[0] if now[3] > 12:... | 24,576 |
def __init__(self, address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER): """ Initialize a handler. | def __init__(self, address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER): """ Initialize a handler. | 24,577 |
def __init__(self, address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER): """ Initialize a handler. | def __init__(self, address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER): """ Initialize a handler. | 24,578 |
def copy_scripts (self): """Copy each script listed in 'self.scripts'; if it's marked as a Python script in the Unix way (first line matches 'first_line_re', ie. starts with "\#!" and contains "python"), then adjust the first line to refer to the current Python interpreter as we copy. """ self.mkpath(self.build_dir) fo... | def copy_scripts (self): """Copy each script listed in 'self.scripts'; if it's marked as a Python script in the Unix way (first line matches 'first_line_re', ie. starts with "\#!" and contains "python"), then adjust the first line to refer to the current Python interpreter as we copy. """ self.mkpath(self.build_dir) fo... | 24,579 |
def getentry(self, which): self._check() if which == 'in': cmd = IN_ENTRY_SENSE elif which == 'out': cmd = OUT_ENTRY_SENSE self.replycmd(cmd) h = self._getnumber(2) print 'h=',h m = self._getnumber(2) print 'm=',m s = self._getnumber(2) print 's=',s f = self._getnumber(2) print 'f=',f return (h, m, s, f) | def getentry(self, which): self._check() if which == 'in': cmd = IN_ENTRY_SENSE elif which == 'out': cmd = OUT_ENTRY_SENSE self.replycmd(cmd) h = self._getnumber(2) m = self._getnumber(2) print 'm=',m s = self._getnumber(2) print 's=',s f = self._getnumber(2) print 'f=',f return (h, m, s, f) | 24,580 |
def getentry(self, which): self._check() if which == 'in': cmd = IN_ENTRY_SENSE elif which == 'out': cmd = OUT_ENTRY_SENSE self.replycmd(cmd) h = self._getnumber(2) print 'h=',h m = self._getnumber(2) print 'm=',m s = self._getnumber(2) print 's=',s f = self._getnumber(2) print 'f=',f return (h, m, s, f) | def getentry(self, which): self._check() if which == 'in': cmd = IN_ENTRY_SENSE elif which == 'out': cmd = OUT_ENTRY_SENSE self.replycmd(cmd) h = self._getnumber(2) print 'h=',h m = self._getnumber(2) s = self._getnumber(2) print 's=',s f = self._getnumber(2) print 'f=',f return (h, m, s, f) | 24,581 |
def getentry(self, which): self._check() if which == 'in': cmd = IN_ENTRY_SENSE elif which == 'out': cmd = OUT_ENTRY_SENSE self.replycmd(cmd) h = self._getnumber(2) print 'h=',h m = self._getnumber(2) print 'm=',m s = self._getnumber(2) print 's=',s f = self._getnumber(2) print 'f=',f return (h, m, s, f) | def getentry(self, which): self._check() if which == 'in': cmd = IN_ENTRY_SENSE elif which == 'out': cmd = OUT_ENTRY_SENSE self.replycmd(cmd) h = self._getnumber(2) print 'h=',h m = self._getnumber(2) print 'm=',m s = self._getnumber(2) f = self._getnumber(2) print 'f=',f return (h, m, s, f) | 24,582 |
def getentry(self, which): self._check() if which == 'in': cmd = IN_ENTRY_SENSE elif which == 'out': cmd = OUT_ENTRY_SENSE self.replycmd(cmd) h = self._getnumber(2) print 'h=',h m = self._getnumber(2) print 'm=',m s = self._getnumber(2) print 's=',s f = self._getnumber(2) print 'f=',f return (h, m, s, f) | def getentry(self, which): self._check() if which == 'in': cmd = IN_ENTRY_SENSE elif which == 'out': cmd = OUT_ENTRY_SENSE self.replycmd(cmd) h = self._getnumber(2) print 'h=',h m = self._getnumber(2) print 'm=',m s = self._getnumber(2) print 's=',s f = self._getnumber(2) return (h, m, s, f) | 24,583 |
def __init__(self, msg, filename=None, lineno=None): self.filename = file self.lineno = lineno self.msg = msg Exception.__init__(self, msg) | def __init__(self, msg, filename=None, lineno=None): self.filename = filename self.lineno = lineno self.msg = msg Exception.__init__(self, msg) | 24,584 |
def test_pickling(self): p = pickle.dumps(self.set) print repr(p) copy = pickle.loads(p) repr(copy) self.assertEqual(self.set, copy, "%s != %s" % (self.set, copy)) | def test_pickling(self): p = pickle.dumps(self.set) copy = pickle.loads(p) repr(copy) self.assertEqual(self.set, copy, "%s != %s" % (self.set, copy)) | 24,585 |
def test_pickling(self): p = pickle.dumps(self.set) print repr(p) copy = pickle.loads(p) repr(copy) self.assertEqual(self.set, copy, "%s != %s" % (self.set, copy)) | def test_pickling(self): p = pickle.dumps(self.set) print repr(p) copy = pickle.loads(p) self.assertEqual(self.set, copy, "%s != %s" % (self.set, copy)) | 24,586 |
def read(self): import httplib tries = 0 while tries<5: connection = httplib.HTTP(self.host) connection.putrequest("GET", self.path) connection.putheader("Host", self.host) connection.endheaders() status, text, mime = connection.getreply() if status in [301,302] and mime: tries = tries + 1 newurl = mime.get("Location",... | def read(self): opener = URLopener() f = opener.open(self.url) lines = f.readlines() self.errcode = opener.errcode if self.errcode == 401 or self.errcode == 403: self.disallow_all = 1 elif status>=400: self.allow_all = 1 else: # status < 400 self.parse(connection.getfile().readlines()) | 24,587 |
def read(self): import httplib tries = 0 while tries<5: connection = httplib.HTTP(self.host) connection.putrequest("GET", self.path) connection.putheader("Host", self.host) connection.endheaders() status, text, mime = connection.getreply() if status in [301,302] and mime: tries = tries + 1 newurl = mime.get("Location",... | def read(self): import httplib tries = 0 while tries<5: connection = httplib.HTTP(self.host) connection.putrequest("GET", self.path) connection.putheader("Host", self.host) connection.endheaders() status, text, mime = connection.getreply() if status in [301,302] and mime: tries = tries + 1 newurl = mime.get("Location",... | 24,588 |
def read(self): import httplib tries = 0 while tries<5: connection = httplib.HTTP(self.host) connection.putrequest("GET", self.path) connection.putheader("Host", self.host) connection.endheaders() status, text, mime = connection.getreply() if status in [301,302] and mime: tries = tries + 1 newurl = mime.get("Location",... | def read(self): import httplib tries = 0 while tries<5: connection = httplib.HTTP(self.host) connection.putrequest("GET", self.path) connection.putheader("Host", self.host) connection.endheaders() status, text, mime = connection.getreply() if status in [301,302] and mime: tries = tries + 1 newurl = mime.get("Location",... | 24,589 |
def can_fetch(self, useragent, url): """using the parsed robots.txt decide if useragent can fetch url""" _debug("Checking robot.txt allowance for\n%s\n%s" % (useragent, url)) if self.disallow_all: return 0 if self.allow_all: return 1 # search for given user agent matches # the first match counts useragent = useragent.l... | def can_fetch(self, useragent, url): """using the parsed robots.txt decide if useragent can fetch url""" _debug("Checking robot.txt allowance for:\n user agent: %s\n url: %s" % (useragent, url)) if self.disallow_all: return 0 if self.allow_all: return 1 # search for given user agent matches # the first match counts u... | 24,590 |
def can_fetch(self, useragent, url): """using the parsed robots.txt decide if useragent can fetch url""" _debug("Checking robot.txt allowance for\n%s\n%s" % (useragent, url)) if self.disallow_all: return 0 if self.allow_all: return 1 # search for given user agent matches # the first match counts useragent = useragent.l... | def can_fetch(self, useragent, url): """using the parsed robots.txt decide if useragent can fetch url""" _debug("Checking robot.txt allowance for\n%s\n%s" % (useragent, url)) if self.disallow_all: return 0 if self.allow_all: return 1 # search for given user agent matches # the first match counts url = urllib.quote(urlp... | 24,591 |
def applies_to(self, useragent): "check if this entry applies to the specified agent" for agent in self.useragents: if agent=="*": return 1 if re.match(agent, useragent): return 1 return 0 | def applies_to(self, useragent): """check if this entry applies to the specified agent""" useragent = useragent.split("/")[0].lower() for agent in self.useragents: if agent=="*": return 1 if re.match(agent, useragent): return 1 return 0 | 24,592 |
def applies_to(self, useragent): "check if this entry applies to the specified agent" for agent in self.useragents: if agent=="*": return 1 if re.match(agent, useragent): return 1 return 0 | def applies_to(self, useragent): "check if this entry applies to the specified agent" for agent in self.useragents: if agent=='*': return 1 if re.match(agent, useragent): return 1 return 0 | 24,593 |
def applies_to(self, useragent): "check if this entry applies to the specified agent" for agent in self.useragents: if agent=="*": return 1 if re.match(agent, useragent): return 1 return 0 | def applies_to(self, useragent): "check if this entry applies to the specified agent" for agent in self.useragents: if agent=="*": return 1 agent = agent.lower() if re.search(re.escape(useragent), agent): return 1 return 0 | 24,594 |
def _test(): global debug import sys rp = RobotFileParser() debug = 1 if len(sys.argv) <= 1: rp.set_url('http://www.musi-cal.com/robots.txt') rp.read() else: rp.parse(open(sys.argv[1]).readlines()) print rp.can_fetch('*', 'http://www.musi-cal.com/') print rp.can_fetch('Musi-Cal-Robot/1.0', 'http://www.musi-cal.com/cgi-... | def _test(): global debug import sys rp = RobotFileParser() debug = 1 rp.set_url('http://www.musi-cal.com/robots.txt') rp.read() _check(rp.can_fetch('*', 'http://www.musi-cal.com/'), 1) _check(rp.can_fetch('', 'http://www.musi-cal.com/'), 0) _check(rp.can_fetch('CherryPickerSE', 'http://www.musi-cal.com/cgi-bin/e... | 24,595 |
def _test(): global debug import sys rp = RobotFileParser() debug = 1 if len(sys.argv) <= 1: rp.set_url('http://www.musi-cal.com/robots.txt') rp.read() else: rp.parse(open(sys.argv[1]).readlines()) print rp.can_fetch('*', 'http://www.musi-cal.com/') print rp.can_fetch('Musi-Cal-Robot/1.0', 'http://www.musi-cal.com/cgi-... | def _test(): global debug import sys rp = RobotFileParser() debug = 1 if len(sys.argv) <= 1: rp.set_url('http://www.musi-cal.com/robots.txt') rp.read() else: rp.parse(open(sys.argv[1]).readlines()) print rp.can_fetch('*', 'http://www.musi-cal.com/') print rp.can_fetch('Musi-Cal-Robot/1.0', 'http://www.musi-cal.com/cgi-... | 24,596 |
def addpackage(sitedir, name): fullname = os.path.join(sitedir, name) try: f = open(fullname) except IOError: return while 1: dir = f.readline() if not dir: break if dir[0] == '#': continue if dir.startswith("import"): exec dir continue if dir[-1] == '\n': dir = dir[:-1] dir, dircase = makepath(sitedir, dir) if not dir... | def addpackage(sitedir, name): fullname = os.path.join(sitedir, name) try: f = open(fullname) except IOError: return while 1: dir = f.readline() if not dir: break if dir[0] == '#': continue if dir.startswith("import"): exec dir continue if dir[-1] == '\n': dir = dir[:-1] dir, dircase = makepath(sitedir, dir) if not dir... | 24,597 |
def addpackage(sitedir, name): fullname = os.path.join(sitedir, name) try: f = open(fullname) except IOError: return while 1: dir = f.readline() if not dir: break if dir[0] == '#': continue if dir.startswith("import"): exec dir continue if dir[-1] == '\n': dir = dir[:-1] dir, dircase = makepath(sitedir, dir) if not dir... | def addpackage(sitedir, name): fullname = os.path.join(sitedir, name) try: f = open(fullname) except IOError: return while 1: dir = f.readline() if not dir: break if dir[0] == '#': continue if dir.startswith("import"): exec dir continue if dir[-1] == '\n': dir = dir[:-1] dir, dircase = makepath(sitedir, dir) if not dir... | 24,598 |
def _format_final_exc_line(etype, value): """Return a list of a single line -- normal case for format_exception_only""" try: printable = value is None or not str(value) except: printable = False if printable: line = "%s\n" % etype else: line = "%s: %s\n" % (etype, _some_str(value)) return line | def _format_final_exc_line(etype, value): """Return a list of a single line -- normal case for format_exception_only""" valuestr = _some_str(value) if value is None or not valuestr: line = "%s\n" % etype else: line = "%s: %s\n" % (etype, _some_str(value)) return line | 24,599 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.