bugged stringlengths 4 228k | fixed stringlengths 0 96.3M | __index_level_0__ int64 0 481k |
|---|---|---|
def shared_object_filename (self, source_filename): return re.sub (r'\.(c|C|cc|cxx)$', SO) | def shared_object_filename (self, source_filename): return re.sub (r'\.(c|C|cc|cxx)$', SO) | 17,300 |
def library_filename (self, libname): return "lib%s.a" % libname | def library_filename (self, libname): return "lib%s.a" % libname | 17,301 |
def shared_library_filename (self, libname): return "lib%s.so" % libname | def shared_library_filename (self, libname): return "lib%s.so" % libname | 17,302 |
def doTest(self, expected_ext, files, *modules): z = ZipFile(TEMP_ZIP, "w") try: for name, (mtime, data) in files.items(): zinfo = ZipInfo(name, time.localtime(mtime)) zinfo.compress_type = self.compression z.writestr(zinfo, data) z.close() sys.path.insert(0, TEMP_ZIP) | def doTest(self, expected_ext, files, *modules): z = ZipFile(TEMP_ZIP, "w") try: for name, (mtime, data) in files.items(): zinfo = ZipInfo(name, time.localtime(mtime)) zinfo.compress_type = self.compression z.writestr(zinfo, data) z.close() sys.path.insert(0, TEMP_ZIP) | 17,303 |
def failUnlessEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '!=' operator. """ if first != second: raise self.failureException, (msg or '%s != %s' % (first, second)) | def failUnlessEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '!=' operator. """ if first != second: raise self.failureException, (msg or '%s != %s' % (first, second)) | 17,304 |
def failIfEqual(self, first, second, msg=None): """Fail if the two objects are equal as determined by the '==' operator. """ if first == second: raise self.failureException, (msg or '%s == %s' % (first, second)) | def failIfEqual(self, first, second, msg=None): """Fail if the two objects are equal as determined by the '==' operator. """ if first == second: raise self.failureException, (msg or '%s == %s' % (first, second)) | 17,305 |
def addError(self, test, err): TestResult.addError(self, test, err) if self.showAll: self.stream.writeln("ERROR") elif self.dots: self.stream.write('E') if err[0] is KeyboardInterrupt: self.shouldStop = 1 | def addError(self, test, err): TestResult.addError(self, test, err) if self.showAll: self.stream.writeln("ERROR") elif self.dots: self.stream.write('E') if err[0] is KeyboardInterrupt: self.shouldStop = 1 | 17,306 |
def maybe_mutate(): if not mutate: return if random.random() < 0.5: return if random.random() < 0.5: target, keys = dict1, dict1keys else: target, keys = dict2, dict2keys if keys: i = random.randrange(len(keys)) key = keys[i] del target[key] # CAUTION: don't use keys.remove(key) here. Or do <wink>. The # point is th... | def maybe_mutate(): if not mutate: return if random.random() < 0.5: return if random.random() < 0.5: target, keys = dict1, dict1keys else: target, keys = dict2, dict2keys if random.random() < 0.2: mutate = 0 while 1: newkey = Horrid(random.randrange(100)) if newkey not in target: break target[newkey] = Horrid(random.... | 17,307 |
def __init__(self, host, port = NNTP_PORT, user=None, password=None): """Initialize an instance. Arguments: - host: hostname to connect to - port: port to connect to (default the standard NNTP port)""" | def __init__(self, host, port = NNTP_PORT, user=None, password=None): """Initialize an instance. Arguments: - host: hostname to connect to - port: port to connect to (default the standard NNTP port)""" | 17,308 |
def __init__(self, host, port = NNTP_PORT, user=None, password=None): """Initialize an instance. Arguments: - host: hostname to connect to - port: port to connect to (default the standard NNTP port)""" | def __init__(self, host, port = NNTP_PORT, user=None, password=None): """Initialize an instance. Arguments: - host: hostname to connect to - port: port to connect to (default the standard NNTP port)""" | 17,309 |
def __init__(self, host, port = NNTP_PORT, user=None, password=None): """Initialize an instance. Arguments: - host: hostname to connect to - port: port to connect to (default the standard NNTP port)""" | def __init__(self, host, port = NNTP_PORT, user=None, password=None): """Initialize an instance. Arguments: - host: hostname to connect to - port: port to connect to (default the standard NNTP port)""" | 17,310 |
def getresp(self): """Internal: get a response from the server. Raise various errors if the response indicates an error.""" resp = self.getline() if self.debugging: print '*resp*', `resp` c = resp[:1] if c == '4': raise error_temp, resp if c == '5': raise error_perm, resp if c not in '123': raise error_proto, resp retu... | def getresp(self): """Internal: get a response from the server. Raise various errors if the response indicates an error.""" resp = self.getline() if self.debugging: print '*resp*', `resp` c = resp[:1] if c == '4': raise NNTPTemporaryError(resp) if c == '5': raise error_perm, resp if c not in '123': raise error_proto, r... | 17,311 |
def getresp(self): """Internal: get a response from the server. Raise various errors if the response indicates an error.""" resp = self.getline() if self.debugging: print '*resp*', `resp` c = resp[:1] if c == '4': raise error_temp, resp if c == '5': raise error_perm, resp if c not in '123': raise error_proto, resp retu... | def getresp(self): """Internal: get a response from the server. Raise various errors if the response indicates an error.""" resp = self.getline() if self.debugging: print '*resp*', `resp` c = resp[:1] if c == '4': raise error_temp, resp if c == '5': raise NNTPPermanentError(resp) if c not in '123': raise error_proto, r... | 17,312 |
def getresp(self): """Internal: get a response from the server. Raise various errors if the response indicates an error.""" resp = self.getline() if self.debugging: print '*resp*', `resp` c = resp[:1] if c == '4': raise error_temp, resp if c == '5': raise error_perm, resp if c not in '123': raise error_proto, resp retu... | def getresp(self): """Internal: get a response from the server. Raise various errors if the response indicates an error.""" resp = self.getline() if self.debugging: print '*resp*', `resp` c = resp[:1] if c == '4': raise error_temp, resp if c == '5': raise error_perm, resp if c not in '123': raise NNTPProtocolError(resp... | 17,313 |
def getlongresp(self): """Internal: get a response plus following text from the server. Raise various errors if the response indicates an error.""" resp = self.getresp() if resp[:3] not in LONGRESP: raise error_reply, resp list = [] while 1: line = self.getline() if line == '.': break if line[:2] == '..': line = line[1... | def getlongresp(self): """Internal: get a response plus following text from the server. Raise various errors if the response indicates an error.""" resp = self.getresp() if resp[:3] not in LONGRESP: raise NNTPReplyError(resp) list = [] while 1: line = self.getline() if line == '.': break if line[:2] == '..': line = lin... | 17,314 |
def group(self, name): """Process a GROUP command. Argument: - group: the group name Returns: - resp: server response if succesful - count: number of articles (string) - first: first article number (string) - last: last article number (string) - name: the group name""" | def group(self, name): """Process a GROUP command. Argument: - group: the group name Returns: - resp: server response if succesful - count: number of articles (string) - first: first article number (string) - last: last article number (string) - name: the group name""" | 17,315 |
def statparse(self, resp): """Internal: parse the response of a STAT, NEXT or LAST command.""" if resp[:2] <> '22': raise error_reply, resp words = string.split(resp) nr = 0 id = '' n = len(words) if n > 1: nr = words[1] if n > 2: id = words[2] return resp, nr, id | def statparse(self, resp): """Internal: parse the response of a STAT, NEXT or LAST command.""" if resp[:2] <> '22': raise NNTPReplyError(resp) words = string.split(resp) nr = 0 id = '' n = len(words) if n > 1: nr = words[1] if n > 2: id = words[2] return resp, nr, id | 17,316 |
def xover(self,start,end): """Process an XOVER command (optional server extension) Arguments: - start: start of range - end: end of range Returns: - resp: server response if succesful - list: list of (art-nr, subject, poster, date, id, references, size, lines)""" | def xover(self,start,end): """Process an XOVER command (optional server extension) Arguments: - start: start of range - end: end of range Returns: - resp: server response if succesful - list: list of (art-nr, subject, poster, date, id, references, size, lines)""" | 17,317 |
def xpath(self,id): """Process an XPATH command (optional server extension) Arguments: - id: Message id of article Returns: resp: server response if succesful path: directory path to article""" | def xpath(self,id): """Process an XPATH command (optional server extension) Arguments: - id: Message id of article Returns: resp: server response if succesful path: directory path to article""" | 17,318 |
def xpath(self,id): """Process an XPATH command (optional server extension) Arguments: - id: Message id of article Returns: resp: server response if succesful path: directory path to article""" | def xpath(self,id): """Process an XPATH command (optional server extension) Arguments: - id: Message id of article Returns: resp: server response if succesful path: directory path to article""" | 17,319 |
def date (self): """Process the DATE command. Arguments: None Returns: resp: server response if succesful date: Date suitable for newnews/newgroups commands etc. time: Time suitable for newnews/newgroups commands etc.""" | def date (self): """Process the DATE command. Arguments: None Returns: resp: server response if succesful date: Date suitable for newnews/newgroups commands etc. time: Time suitable for newnews/newgroups commands etc.""" | 17,320 |
def date (self): """Process the DATE command. Arguments: None Returns: resp: server response if succesful date: Date suitable for newnews/newgroups commands etc. time: Time suitable for newnews/newgroups commands etc.""" | def date (self): """Process the DATE command. Arguments: None Returns: resp: server response if succesful date: Date suitable for newnews/newgroups commands etc. time: Time suitable for newnews/newgroups commands etc.""" | 17,321 |
def date (self): """Process the DATE command. Arguments: None Returns: resp: server response if succesful date: Date suitable for newnews/newgroups commands etc. time: Time suitable for newnews/newgroups commands etc.""" | def date (self): """Process the DATE command. Arguments: None Returns: resp: server response if succesful date: Date suitable for newnews/newgroups commands etc. time: Time suitable for newnews/newgroups commands etc.""" | 17,322 |
def post(self, f): """Process a POST command. Arguments: - f: file containing the article Returns: - resp: server response if succesful""" | def post(self, f): """Process a POST command. Arguments: - f: file containing the article Returns: - resp: server response if succesful""" | 17,323 |
def ihave(self, id, f): """Process an IHAVE command. Arguments: - id: message-id of the article - f: file containing the article Returns: - resp: server response if succesful Note that if the server refuses the article an exception is raised.""" | def ihave(self, id, f): """Process an IHAVE command. Arguments: - id: message-id of the article - f: file containing the article Returns: - resp: server response if succesful Note that if the server refuses the article an exception is raised.""" | 17,324 |
def _test(): """Minimal test function.""" s = NNTP('news') resp, count, first, last, name = s.group('comp.lang.python') print resp print 'Group', name, 'has', count, 'articles, range', first, 'to', last resp, subs = s.xhdr('subject', first + '-' + last) print resp for item in subs: print "%7s %s" % item resp = s.quit()... | def _test(): """Minimal test function.""" s = NNTP('news', readermode='reader') resp, count, first, last, name = s.group('comp.lang.python') print resp print 'Group', name, 'has', count, 'articles, range', first, 'to', last resp, subs = s.xhdr('subject', first + '-' + last) print resp for item in subs: print "%7s %s" %... | 17,325 |
>>> def inorder(t): | >>> def inorder(t): | 17,326 |
def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (o... | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, leakdebug=0): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look... | 17,327 |
def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (o... | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (o... | 17,328 |
def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (o... | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (o... | 17,329 |
def f(): pass | def f(): pass | 17,330 |
def encode(self, input, final=False): return codecs.mbcs_encode(input,self.errors)[0] | def encode(self, input, final=False): return codecs.mbcs_encode(input,self.errors)[0] | 17,331 |
def format_exception_only(etype, value): """Format the exception part of a traceback. The arguments are the exception type and value such as given by sys.last_type and sys.last_value. The return value is a list of strings, each ending in a newline. Normally, the list contains a single string; however, for SyntaxError... | def format_exception_only(etype, value): """Format the exception part of a traceback. The arguments are the exception type and value such as given by sys.last_type and sys.last_value. The return value is a list of strings, each ending in a newline. Normally, the list contains a single string; however, for SyntaxError... | 17,332 |
def winfo_children(self): """Return a list of all widgets which are children of this widget.""" return map(self._nametowidget, self.tk.splitlist(self.tk.call( 'winfo', 'children', self._w))) | def winfo_children(self): """Return a list of all widgets which are children of this widget.""" return map(self._nametowidget, self.tk.splitlist(self.tk.call( 'winfo', 'children', self._w))) | 17,333 |
def %s(self, *args): return apply(getattr(self.mod, self.name).%s, args) | def %s(self, *args): return apply(getattr(self.mod, self.name).%s, args) | 17,334 |
def __init__(self, mod, name): self.mod = mod self.name = name | def __init__(self, mod, name): self.mod = mod self.name = name | 17,335 |
def __init__(self, *args): | def __init__(self, *args): | 17,336 |
def set_rexec(self, rexec): | def set_rexec(self, rexec): | 17,337 |
def is_builtin(self, name): | def is_builtin(self, name): | 17,338 |
def init_builtin(self, name): | def init_builtin(self, name): | 17,339 |
def load_dynamic(self, name, filename, file): | def load_dynamic(self, name, filename, file): | 17,340 |
def add_module(self, name): | def add_module(self, name): | 17,341 |
def modules_dict(self): | def modules_dict(self): | 17,342 |
def default_path(self): | def default_path(self): | 17,343 |
def reload(self, module, path=None): if path is None and hasattr(module, '__filename__'): head, tail = os.path.split(module.__filename__) path = [os.path.join(head, '')] return ihooks.ModuleImporter.reload(self, module, path) | def reload(self, module, path=None): if path is None and hasattr(module, '__filename__'): head, tail = os.path.split(module.__filename__) path = [os.path.join(head, '')] return ihooks.ModuleImporter.reload(self, module, path) | 17,344 |
def reload(self, module, path=None): if path is None and hasattr(module, '__filename__'): head, tail = os.path.split(module.__filename__) path = [os.path.join(head, '')] return ihooks.ModuleImporter.reload(self, module, path) | def reload(self, module, path=None): if path is None and hasattr(module, '__filename__'): head, tail = os.path.split(module.__filename__) path = [os.path.join(head, '')] return ihooks.ModuleImporter.reload(self, module, path) | 17,345 |
def reload(self, module, path=None): if path is None and hasattr(module, '__filename__'): head, tail = os.path.split(module.__filename__) path = [os.path.join(head, '')] return ihooks.ModuleImporter.reload(self, module, path) | def reload(self, module, path=None): if path is None and hasattr(module, '__filename__'): head, tail = os.path.split(module.__filename__) path = [os.path.join(head, '')] return ihooks.ModuleImporter.reload(self, module, path) | 17,346 |
def reload(self, module, path=None): if path is None and hasattr(module, '__filename__'): head, tail = os.path.split(module.__filename__) path = [os.path.join(head, '')] return ihooks.ModuleImporter.reload(self, module, path) | def reload(self, module, path=None): if path is None and hasattr(module, '__filename__'): head, tail = os.path.split(module.__filename__) path = [os.path.join(head, '')] return ihooks.ModuleImporter.reload(self, module, path) | 17,347 |
def reload(self, module, path=None): if path is None and hasattr(module, '__filename__'): head, tail = os.path.split(module.__filename__) path = [os.path.join(head, '')] return ihooks.ModuleImporter.reload(self, module, path) | def reload(self, module, path=None): if path is None and hasattr(module, '__filename__'): head, tail = os.path.split(module.__filename__) path = [os.path.join(head, '')] return ihooks.ModuleImporter.reload(self, module, path) | 17,348 |
def __init__(self, hooks = None, verbose = 0): | def __init__(self, hooks = None, verbose = 0): | 17,349 |
def set_trusted_path(self): | def set_trusted_path(self): | 17,350 |
def load_dynamic(self, name, filename, file): | def load_dynamic(self, name, filename, file): | 17,351 |
def make_initial_modules(self): | def make_initial_modules(self): | 17,352 |
def is_builtin(self, mname): | def is_builtin(self, mname): | 17,353 |
def make_builtin(self): | def make_builtin(self): | 17,354 |
def make_main(self): | def make_main(self): | 17,355 |
def make_osname(self): | def make_osname(self): | 17,356 |
def make_sys(self): | def make_sys(self): | 17,357 |
def copy_except(self, src, exceptions): | def copy_except(self, src, exceptions): | 17,358 |
def copy_only(self, src, names): | def copy_only(self, src, names): | 17,359 |
def copy_none(self, src): | def copy_none(self, src): | 17,360 |
def add_module(self, mname): | def add_module(self, mname): | 17,361 |
def r_exec(self, code): | def r_exec(self, code): | 17,362 |
def r_eval(self, code): | def r_eval(self, code): | 17,363 |
def r_execfile(self, file): | def r_execfile(self, file): | 17,364 |
def r_import(self, mname, globals={}, locals={}, fromlist=[]): | def r_import(self, mname, globals={}, locals={}, fromlist=[]): | 17,365 |
def make_delegate_files(self): s = self.modules['sys'] | def make_delegate_files(self): s = self.modules['sys'] | 17,366 |
def set_files(self): | def set_files(self): | 17,367 |
def set_files(self): | def set_files(self): | 17,368 |
def reset_files(self): | def reset_files(self): | 17,369 |
def reset_files(self): | def reset_files(self): | 17,370 |
def restore_files(self): | def restore_files(self): | 17,371 |
def s_apply(self, func, args=(), kw=None): | def s_apply(self, func, args=(), kw=None): | 17,372 |
def s_apply(self, func, args=(), kw=None): | def s_apply(self, func, args=(), kw=None): | 17,373 |
def test(): import traceback r = RExec(verbose=('-v' in sys.argv[1:])) print "*** RESTRICTED *** Python", sys.version print sys.copyright while 1: try: try: s = raw_input('>>> ') except EOFError: print break if s and s[0] != '#': s = s + '\n' c = compile(s, '<stdin>', 'single') r.r_exec(c) except SystemExit, n: sys.exi... | def test(): import traceback r = RExec(verbose=('-v' in sys.argv[1:])) print "*** RESTRICTED *** Python", sys.version print sys.copyright while 1: try: try: s = raw_input('>>> ') except EOFError: print break if s and s[0] != '#': s = s + '\n' c = compile(s, '<stdin>', 'single') r.r_exec(c) except SystemExit, n: sys.exi... | 17,374 |
def cmp(f1, f2, shallow=1,use_statcache=0): """Compare two files. Arguments: f1 -- First file name f2 -- Second file name shallow -- Just check stat signature (do not read the files). defaults to 1. use_statcache -- Do not stat() each file directly: go through the statcache module for more efficiency. Return valu... | def cmp(f1, f2, shallow=1,use_statcache=0): """Compare two files. Arguments: f1 -- First file name f2 -- Second file name shallow -- Just check stat signature (do not read the files). defaults to 1. use_statcache -- Do not stat() each file directly: go through the statcache module for more efficiency. Return valu... | 17,375 |
def _sig(st): return (stat.S_IFMT(st[stat.ST_MODE]), st[stat.ST_SIZE], st[stat.ST_MTIME]) | def _sig(st): return (stat.S_IFMT(st[stat.ST_MODE]), st[stat.ST_SIZE], st[stat.ST_MTIME]) | 17,376 |
def setlocale(category, value=None): """ setlocale(integer,string=None) -> string. Activates/queries locale processing. """ if value is not None and value != 'C': raise Error, '_locale emulation only supports "C" locale' return 'C' | def setlocale(category, value=None): """ setlocale(integer,string=None) -> string. Activates/queries locale processing. """ if value not in (None, '', 'C'): raise Error, '_locale emulation only supports "C" locale' return 'C' | 17,377 |
def import_module(name, envLocals=None, envGlobals=None, froms=None, inPkg=None): """Primary service routine implementing 'import' with package nesting.""" # The job is divided into a few distinct steps: # # - Look for either an already loaded module or a file to be loaded. # * if neither loaded module nor prospect ... | def import_module(name, envLocals=None, envGlobals=None, froms=None, inPkg=None): """Primary service routine implementing 'import' with package nesting.""" # The job is divided into a few distinct steps: # # - Look for either an already loaded module or a file to be loaded. # * if neither loaded module nor prospect ... | 17,378 |
def update(self): self.prepare() for file in self.rcsfiles: e = self.preparedetails(file) if e.lsum == e.sum == e.rsum: print '=', file continue if e.sum == e.rsum: if e.rev != e.rrev: print '%s: %s -> %s w/o change' % \ (file, e.rev, e.rrev) e.rev = e.rrev if e.lsum != e.sum: if e.lsum is None: print '%s: file was los... | def update(self): self.prepare() for file in self.rcsfiles: e = self.preparedetails(file) if e.lsum == e.sum == e.rsum: print '=', file continue if e.sum == e.rsum: if e.rev != e.rrev: print '%s: %s -> %s w/o change' % \ (file, e.rev, e.rrev) e.rev = e.rrev if e.lsum != e.sum: if e.lsum is None: print '%s: file was los... | 17,379 |
def update(self): self.prepare() for file in self.rcsfiles: e = self.preparedetails(file) if e.lsum == e.sum == e.rsum: print '=', file continue if e.sum == e.rsum: if e.rev != e.rrev: print '%s: %s -> %s w/o change' % \ (file, e.rev, e.rrev) e.rev = e.rrev if e.lsum != e.sum: if e.lsum is None: print '%s: file was los... | def update(self): self.prepare() for file in self.rcsfiles: e = self.preparedetails(file) if e.lsum == e.sum == e.rsum: print '=', file continue if e.sum == e.rsum: if e.rev != e.rrev: print '%s: %s -> %s w/o change' % \ (file, e.rev, e.rrev) e.rev = e.rrev if e.lsum != e.sum: if e.lsum is None: print '%s: file was los... | 17,380 |
def parse_starttag(self, i): rawdata = self.rawdata try: j = string.index(rawdata, '>', i) except string.index_error: return -1 # Now parse the data between i+1 and j into a tag and attrs attrs = [] tagfind = regex.compile('[a-zA-Z][a-zA-Z0-9]*') attrfind = regex.compile( '[ \t\n]+\([a-zA-Z_][a-zA-Z_0-9]*\)' + '\([ \t\... | def parse_starttag(self, i): rawdata = self.rawdata try: j = string.index(rawdata, '>', i) except string.index_error: return -1 # Now parse the data between i+1 and j into a tag and attrs attrs = [] tagfind = regex.compile('[a-zA-Z][a-zA-Z0-9]*') attrfind = regex.compile( '[ \t\n]+\([a-zA-Z_][a-zA-Z_0-9]*\)' + '\([ \t\... | 17,381 |
def parse_starttag(self, i): rawdata = self.rawdata try: j = string.index(rawdata, '>', i) except string.index_error: return -1 # Now parse the data between i+1 and j into a tag and attrs attrs = [] tagfind = regex.compile('[a-zA-Z][a-zA-Z0-9]*') attrfind = regex.compile( '[ \t\n]+\([a-zA-Z_][a-zA-Z_0-9]*\)' + '\([ \t\... | def parse_starttag(self, i): rawdata = self.rawdata try: j = string.index(rawdata, '>', i) except string.index_error: return -1 # Now parse the data between i+1 and j into a tag and attrs attrs = [] tagfind = regex.compile('[a-zA-Z][a-zA-Z0-9]*') attrfind = regex.compile( '[ \t\n]+\([a-zA-Z_][a-zA-Z_0-9]*\)' + '\([ \t\... | 17,382 |
def test(): file = 'test.html' f = open(file, 'r') x = TestSGML() while 1: line = f.readline() if not line: x.close() break x.feed(line) | def test(): file = 'test.html' if file == '-': f = sys.stdin else: try: f = open(file, 'r') except IOError, msg: print file, ":", msg sys.exit(1) data = f.read() if f is not sys.stdin: f.close() x = klass() for c in data: x.feed(c) x.close() | 17,383 |
def test(): file = 'test.html' f = open(file, 'r') x = TestSGML() while 1: line = f.readline() if not line: x.close() break x.feed(line) | def test(): file = 'test.html' f = open(file, 'r') x = TestSGML() while 1: line = f.readline() if not line: x.close() break x.feed(line) | 17,384 |
def get_config_h_filename(): """Return full pathname of installed config.h file.""" inc_dir = get_python_inc(plat_specific=1) return os.path.join(inc_dir, "config.h") | def get_config_h_filename(): """Return full pathname of installed config.h file.""" if python_build: inc_dir = '.' else: inc_dir = get_python_inc(plat_specific=1) return os.path.join(inc_dir, "config.h") | 17,385 |
def getpage(self, url_pair): # Incoming argument name is a (URL, fragment) pair. # The page may have been cached in the name_table variable. url, fragment = url_pair if self.name_table.has_key(url): return self.name_table[url] | def getpage(self, url_pair): # Incoming argument name is a (URL, fragment) pair. # The page may have been cached in the name_table variable. url, fragment = url_pair if self.name_table.has_key(url): return self.name_table[url] | 17,386 |
def timeit(self, number=default_number): """Time 'number' executions of the main statement. | def timeit(self, number=default_number): """Time 'number' executions of the main statement. | 17,387 |
def _remote(self, action): assert "'" not in action cmd = "kfmclient '%s' >/dev/null 2>&1" % action rc = os.system(cmd) if rc: import time if self.basename == "konqueror": os.system(self.name + " --silent &") else: os.system(self.name + " -d &") time.sleep(PROCESS_CREATION_DELAY) rc = os.system(cmd) return not rc | def _remote(self, action): cmd = "kfmclient %s >/dev/null 2>&1" % action rc = os.system(cmd) if rc: import time if self.basename == "konqueror": os.system(self.name + " --silent &") else: os.system(self.name + " -d &") time.sleep(PROCESS_CREATION_DELAY) rc = os.system(cmd) return not rc | 17,388 |
def get(self, key, default): try: ref = self.data[key] except KeyError: return default else: o = ref() if o is None: # This should only happen return default else: return o | def get(self, key, default=None): try: ref = self.data[key] except KeyError: return default else: o = ref() if o is None: # This should only happen return default else: return o | 17,389 |
def remove(o, data=d, key=key): del data[key] | def remove(o, data=d, key=key): del data[key] | 17,390 |
def get(self, key, default): return self.data.get(ref(key),default) | def get(self, key, default=None): return self.data.get(ref(key),default) | 17,391 |
def update(self, dict): d = self.data L = [] for key, value in dict.items(): L.append(ref(key, self._remove), value) for key, r in L: d[key] = r | def update(self, dict): d = self.data L = [] for key, value in dict.items(): L.append((ref(key, self._remove), value)) for key, r in L: d[key] = r | 17,392 |
def reset(self): if self._namespaces: self._parser = expat.ParserCreate(None, " ") self._parser.StartElementHandler = self.start_element_ns self._parser.EndElementHandler = self.end_element_ns else: self._parser = expat.ParserCreate() self._parser.StartElementHandler = self.start_element self._parser.EndElementHandler ... | def reset(self): if self._namespaces: self._parser = expat.ParserCreate(None, " ") self._parser.StartElementHandler = self.start_element_ns self._parser.EndElementHandler = self.end_element_ns else: self._parser = expat.ParserCreate() self._parser.StartElementHandler = self.start_element self._parser.EndElementHandler ... | 17,393 |
def try_stmt(self, nodelist): # 'try' ':' suite (except_clause ':' suite)+ ['else' ':' suite] # | 'try' ':' suite 'finally' ':' suite if nodelist[3][0] != symbol.except_clause: return self.com_try_finally(nodelist) | def try_stmt(self, nodelist): # 'try' ':' suite (except_clause ':' suite)+ ['else' ':' suite] # | 'try' ':' suite 'finally' ':' suite if nodelist[3][0] != symbol.except_clause: return self.com_try_finally(nodelist) | 17,394 |
def com_try_finally(self, nodelist): # try_fin_stmt: "try" ":" suite "finally" ":" suite return TryFinally(self.com_node(nodelist[2]), self.com_node(nodelist[5]), lineno=nodelist[0][2]) | def com_try_finally(self, nodelist): # try_fin_stmt: "try" ":" suite "finally" ":" suite return TryFinally(self.com_node(nodelist[2]), self.com_node(nodelist[5]), lineno=nodelist[0][2]) | 17,395 |
def com_try_except(self, nodelist): # try_except: 'try' ':' suite (except_clause ':' suite)* ['else' suite] #tryexcept: [TryNode, [except_clauses], elseNode)] stmt = self.com_node(nodelist[2]) clauses = [] elseNode = None for i in range(3, len(nodelist), 3): node = nodelist[i] if node[0] == symbol.except_clause: # exc... | def com_try_except(self, nodelist): # try_except: 'try' ':' suite (except_clause ':' suite)* ['else' suite] #tryexcept: [TryNode, [except_clauses], elseNode)] clauses = [] elseNode = None for i in range(3, len(nodelist), 3): node = nodelist[i] if node[0] == symbol.except_clause: # except_clause: 'except' [expr [',' ex... | 17,396 |
def com_try_except(self, nodelist): # try_except: 'try' ':' suite (except_clause ':' suite)* ['else' suite] #tryexcept: [TryNode, [except_clauses], elseNode)] stmt = self.com_node(nodelist[2]) clauses = [] elseNode = None for i in range(3, len(nodelist), 3): node = nodelist[i] if node[0] == symbol.except_clause: # exc... | def com_try_except(self, nodelist): # try_except: 'try' ':' suite (except_clause ':' suite)* ['else' suite] #tryexcept: [TryNode, [except_clauses], elseNode)] stmt = self.com_node(nodelist[2]) clauses = [] elseNode = None for i in range(3, len(nodelist), 3): node = nodelist[i] if node[0] == symbol.except_clause: # exc... | 17,397 |
def test_main(): test_support.run_unittest( TemporaryFileTests, StatAttributeTests, EnvironTests, WalkTests ) | def test_main(): test_support.run_unittest( TemporaryFileTests, StatAttributeTests, EnvironTests, WalkTests, MakedirTests, ) | 17,398 |
def test_title(self): self.checkmethod('title', u' hello ', u' Hello ') self.checkmethod('title', u'Hello ', u'Hello ') self.checkmethod('title', u'hello ', u'Hello ') self.checkmethod('title', u"fOrMaT thIs aS titLe String", u'Format This As Title String') self.checkmethod('title', u"fOrMaT,thIs-aS*titLe;String", u'Fo... | def test_title(self): self.checkmethod('title', u' hello ', u' Hello ') self.checkmethod('title', u'Hello ', u'Hello ') self.checkmethod('title', u'hello ', u'Hello ') self.checkmethod('title', u"fOrMaT thIs aS titLe String", u'Format This As Title String') self.checkmethod('title', u"fOrMaT,thIs-aS*titLe;String", u'Fo... | 17,399 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.