bugged stringlengths 4 228k | fixed stringlengths 0 96.3M | __index_level_0__ int64 0 481k |
|---|---|---|
def s_apply(self, func, args=(), kw=None): | def s_apply(self, func, args=(), kw=None): | 13,100 |
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... | 13,101 |
def convert_path (pathname): """Return 'pathname' as a name that will work on the native filesystem, i.e. split it on '/' and put it back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local conventio... | def convert_path (pathname): """Return 'pathname' as a name that will work on the native filesystem, i.e. split it on '/' and put it back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local conventio... | 13,102 |
def subst_vars (str, local_vars): """Perform shell/Perl-style variable substitution on 'string'. Every occurrence of '$' followed by a name, or a name enclosed in braces, is considered a variable. Every variable is substituted by the value found in the 'local_vars' dictionary, or in 'os.environ' if it's not in 'local... | def subst_vars (str, local_vars): """Perform shell/Perl-style variable substitution on 'string'. Every occurrence of '$' followed by a name is considered a variable, and variable is substituted by the value found in the 'local_vars' dictionary, or in 'os.environ' if it's not in 'local_vars'. 'os.environ' is first chec... | 13,103 |
def _subst (match, local_vars=local_vars): var_name = match.group(1) if local_vars.has_key(var_name): return str(local_vars[var_name]) else: return os.environ[var_name] | def _subst (match, local_vars=local_vars): var_name = match.group(1) if local_vars.has_key(var_name): return str(local_vars[var_name]) else: return os.environ[var_name] | 13,104 |
def group(*choices): return '\(' + string.join(choices, '\|') + '\)' | def group(*choices): return '\(' + string.join(choices, '\|') + '\)' | 13,105 |
def group(*choices): return '\(' + string.join(choices, '\|') + '\)' | def group(*choices): return '\(' + string.join(choices, '\|') + '\)' | 13,106 |
def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr = '' indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr, needcont = '', 0 indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | 13,107 |
def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr = '' indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr = '' indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | 13,108 |
def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr = '' indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr = '' indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | 13,109 |
def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr = '' indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr = '' indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | 13,110 |
def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr = '' indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr = '' indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | 13,111 |
def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr = '' indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr = '' indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | 13,112 |
def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr = '' indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr = '' indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | 13,113 |
def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr = '' indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr = '' indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | 13,114 |
def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr = '' indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr = '' indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | 13,115 |
def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr = '' indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr = '' indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | 13,116 |
def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr = '' indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr = '' indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | 13,117 |
def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr = '' indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | def tokenize(readline, tokeneater=printtoken): lnum = parenlev = continued = 0 namechars, numchars = string.letters + '_', string.digits contstr = '' indents = [0] while 1: # loop over lines in stream line = readline() lnum = lnum + 1 pos, max = 0, len(line) if contstr: ... | 13,118 |
def check_iters(self, dict): # item iterator: items = dict.items() for item in dict.iteritems(): items.remove(item) self.assert_(len(items) == 0, "iterator did not touch all items") | def check_iters(self, dict): # item iterator: items = dict.items() for item in dict.iteritems(): items.remove(item) self.assert_(len(items) == 0, "iterator did not touch all items") | 13,119 |
def check_iters(self, dict): # item iterator: items = dict.items() for item in dict.iteritems(): items.remove(item) self.assert_(len(items) == 0, "iterator did not touch all items") | def check_iters(self, dict): # item iterator: items = dict.items() for item in dict.iteritems(): items.remove(item) self.assert_(len(items) == 0, "iterator did not touch all items") | 13,120 |
def check_iters(self, dict): # item iterator: items = dict.items() for item in dict.iteritems(): items.remove(item) self.assert_(len(items) == 0, "iterator did not touch all items") | def check_iters(self, dict): # item iterator: items = dict.items() for item in dict.iteritems(): items.remove(item) self.assert_(len(items) == 0, "iterator did not touch all items") | 13,121 |
def mkalias(src, dst, relative=None): """Create a finder alias""" srcfss = macfs.FSSpec(src) dstfss = macfs.FSSpec(dst) if relative: relativefss = macfs.FSSpec(relative) # ik mag er geen None in stoppen :-( alias = srcfss.NewAlias(relativefss) else: alias = srcfss.NewAlias() srcfinfo = srcfss.GetFInfo() Res.FSpCreateR... | def mkalias(src, dst, relative=None): """Create a finder alias""" srcfss = macfs.FSSpec(src) dstfss = macfs.FSSpec(dst) if relative: relativefss = macfs.FSSpec(relative) # ik mag er geen None in stoppen :-( alias = srcfss.NewAlias(relativefss) else: alias = srcfss.NewAlias() if os.path.isdir(src): cr, tp = 'MACS', 'fd... | 13,122 |
def retrlines(self, cmd, callback = None): '''Retrieve data in line mode. The argument is a RETR or LIST command. The callback function (2nd argument) is called for each line, with trailing CRLF stripped. This creates a new port for you. print_lines is the default callback.''' if not callback: callback = print_line re... | def retrlines(self, cmd, callback = None): '''Retrieve data in line mode. The argument is a RETR or LIST command. The callback function (2nd argument) is called for each line, with trailing CRLF stripped. This creates a new port for you. print_line() is the default callback.''' if not callback: callback = print_line r... | 13,123 |
def mimify(infile, outfile): """Convert 8bit parts of a MIME mail message to quoted-printable.""" if type(infile) == type(''): ifile = open(infile) if type(outfile) == type('') and infile == outfile: import os d, f = os.path.split(infile) os.rename(infile, os.path.join(d, ',' + f)) else: ifile = infile if type(outfile)... | def mimify(infile, outfile): """Convert 8bit parts of a MIME mail message to quoted-printable.""" if type(infile) == type(''): ifile = open(infile) if type(outfile) == type('') and infile == outfile: import os d, f = os.path.split(infile) os.rename(infile, os.path.join(d, ',' + f)) else: ifile = infile if type(outfile)... | 13,124 |
def _fixupChildren(self, ph, alogger): """ Ensure that children of the placeholder ph are connected to the specified logger. """ #for c in ph.loggers: for c in ph.loggerMap.keys(): if string.find(c.parent.name, alogger.name) <> 0: alogger.parent = c.parent c.parent = alogger | defname = alogger.name namelen = len(name) _fixupChildren(self,name = alogger.name namelen = len(name) ph,name = alogger.name namelen = len(name) alogger):name = alogger.name namelen = len(name) """name = alogger.name namelen = len(name) Ensurename = alogger.name namelen = len(name) thatname = alogger.name namelen = le... | 13,125 |
def _fixupChildren(self, ph, alogger): """ Ensure that children of the placeholder ph are connected to the specified logger. """ #for c in ph.loggers: for c in ph.loggerMap.keys(): if string.find(c.parent.name, alogger.name) <> 0: alogger.parent = c.parent c.parent = alogger | def _fixupChildren(self, ph, alogger): """ Ensure that children of the placeholder ph are connected to the specified logger. """ #for c in ph.loggers: for c in ph.loggerMap.keys(): if c.parent.name[:namelen] != name: alogger.parent = c.parent c.parent = alogger | 13,126 |
def get_version(self): return self.version or "???" | def get_version(self): return self.version or "???" | 13,127 |
def testCompileLibrary(self): # A simple but large test. Compile all the code in the # standard library and its test suite. This doesn't verify # that any of the code is correct, merely the compiler is able # to generate some kind of code for it. | def testCompileLibrary(self): # A simple but large test. Compile all the code in the # standard library and its test suite. This doesn't verify # that any of the code is correct, merely the compiler is able # to generate some kind of code for it. | 13,128 |
def checkit(self): if self.returntype.__class__ != OSErrType: OutLbrace() Output("OSErr _err = ResError();") Output("if (_err != noErr) return PyMac_Error(_err);") OutRbrace() FunctionGenerator.checkit(self) # XXX | def checkit(self): if self.returntype.__class__ != OSErrType: OutLbrace() Output("OSErr _err = ResError();") Output("if (_err != noErr) return PyMac_Error(_err);") OutRbrace() FunctionGenerator.checkit(self) # XXX | 13,129 |
def test_wide(self): self.assertEqual(u''.width(), 0) self.assertEqual(u'abcd'.width(), 4) self.assertEqual(u'\u0187\u01c9'.width(), 2) self.assertEqual(u'\u2460\u2329'.width(), 3) self.assertEqual(u'\u2329\u2460'.width(), 3) self.assertEqual(u'\ud55c\uae00'.width(), 4) self.assertEqual(u'\ud55c\u2606\uae00'.width(), 5... | def test_width(self): self.assertEqual(u''.width(), 0) self.assertEqual(u'abcd'.width(), 4) self.assertEqual(u'\u0187\u01c9'.width(), 2) self.assertEqual(u'\u2460\u2329'.width(), 3) self.assertEqual(u'\u2329\u2460'.width(), 3) self.assertEqual(u'\ud55c\uae00'.width(), 4) self.assertEqual(u'\ud55c\u2606\uae00'.width(), ... | 13,130 |
def make(filename, outfile): ID = 1 STR = 2 # Compute .mo name from .po name and arguments if filename.endswith('.po'): infile = filename else: infile = filename + '.po' if outfile is None: outfile = os.path.splitext(infile)[0] + '.mo' try: lines = open(infile).readlines() except IOError, msg: print >> sys.stderr, ms... | def make(filename, outfile): ID = 1 STR = 2 # Compute .mo name from .po name and arguments if filename.endswith('.po'): infile = filename else: infile = filename + '.po' if outfile is None: outfile = os.path.splitext(infile)[0] + '.mo' try: lines = open(infile).readlines() except IOError, msg: print >> sys.stderr, ms... | 13,131 |
def ignorableWhitespace(self, whitespace): """Receive notification of ignorable whitespace in element content. | def ignorableWhitespace(self, whitespace): """Receive notification of ignorable whitespace in element content. | 13,132 |
def __init__(self, filename=None, mode=None, compresslevel=9, fileobj=None): if fileobj is None: fileobj = self.myfileobj = __builtin__.open(filename, mode or 'rb') if filename is None: if hasattr(fileobj, 'name'): filename = fileobj.name else: filename = '' if mode is None: if hasattr(fileobj, 'mode'): mode = fileobj.... | def __init__(self, filename=None, mode=None, compresslevel=9, fileobj=None): if fileobj is None: fileobj = self.myfileobj = __builtin__.open(filename, mode or 'rb') if filename is None: if hasattr(fileobj, 'name'): filename = fileobj.name else: filename = '' if mode is None: if hasattr(fileobj, 'mode'): mode = fileobj.... | 13,133 |
def handle_entityref(self, name): """Handle entity references, no need to override.""" replacement = convert_entityref(name) if replacement is None: self.unknown_entityref(name) else: self.handle_data(convert_entityref(name)) | def handle_entityref(self, name): """Handle entity references, no need to override.""" replacement = self.convert_entityref(name) if replacement is None: self.unknown_entityref(name) else: self.handle_data(convert_entityref(name)) | 13,134 |
def handle_entityref(self, name): """Handle entity references, no need to override.""" replacement = convert_entityref(name) if replacement is None: self.unknown_entityref(name) else: self.handle_data(convert_entityref(name)) | def handle_entityref(self, name): """Handle entity references, no need to override.""" replacement = convert_entityref(name) if replacement is None: self.unknown_entityref(name) else: self.handle_data(convert_entityref(name)) | 13,135 |
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... | def getlongresp(self,fileHandle=None): """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] == ... | 13,136 |
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... | def getlongresp(self): """Internal: get a response plus following text from the server. Raise various errors if the response indicates an error.""" openedFile = None try: if isinstance(fileHandle, types.StringType): openedFile = fileHandle = open(fileHandle, "w") resp = self.getresp() if resp[:3] not in LONGRESP: ra... | 13,137 |
def longcmd(self, line): """Internal: send a command and get the response plus following text.""" self.putcmd(line) return self.getlongresp() | def longcmd(self, line, fileHandle=None): """Internal: send a command and get the response plus following text.""" self.putcmd(line) return self.getlongresp() | 13,138 |
def longcmd(self, line): """Internal: send a command and get the response plus following text.""" self.putcmd(line) return self.getlongresp() | def longcmd(self, line): """Internal: send a command and get the response plus following text.""" self.putcmd(line) return self.getlongresp() | 13,139 |
def artcmd(self, line): """Internal: process a HEAD, BODY or ARTICLE command.""" resp, list = self.longcmd(line) resp, nr, id = self.statparse(resp) return resp, nr, id, list | def artcmd(self, line, fileHandle=None): """Internal: process a HEAD, BODY or ARTICLE command.""" resp, list = self.longcmd(line) resp, nr, id = self.statparse(resp) return resp, nr, id, list | 13,140 |
def artcmd(self, line): """Internal: process a HEAD, BODY or ARTICLE command.""" resp, list = self.longcmd(line) resp, nr, id = self.statparse(resp) return resp, nr, id, list | def artcmd(self, line): """Internal: process a HEAD, BODY or ARTICLE command.""" resp, list = self.longcmd(line,fileHandle) resp, nr, id = self.statparse(resp) return resp, nr, id, list | 13,141 |
def body(self, id): """Process a BODY command. Argument: - id: article number or message id Returns: - resp: server response if successful - nr: article number - id: message id - list: the lines of the article's body""" | def body(self, id, fileHandle=None): """Process a BODY command. Argument: - id: article number or message id Returns: - resp: server response if successful - nr: article number - id: message id - list: the lines of the article's body""" | 13,142 |
def body(self, id): """Process a BODY command. Argument: - id: article number or message id Returns: - resp: server response if successful - nr: article number - id: message id - list: the lines of the article's body""" | def body(self, id): """Process a BODY command. Argument: - id: article number or message id Returns: - resp: server response if successful - nr: article number - id: message id - list: the lines of the article's body""" | 13,143 |
def domain_return_ok(self, domain, request): # Liberal check of. This is here as an optimization to avoid # having to load lots of MSIE cookie files unless necessary. req_host, erhn = eff_request_host(request) if not req_host.startswith("."): dotted_req_host = "."+req_host if not erhn.startswith("."): dotted_erhn = ".... | def domain_return_ok(self, domain, request): # Liberal check of. This is here as an optimization to avoid # having to load lots of MSIE cookie files unless necessary. req_host, erhn = eff_request_host(request) if not req_host.startswith("."): req_host = "."+req_host if not erhn.startswith("."): dotted_erhn = "."+erhn ... | 13,144 |
def domain_return_ok(self, domain, request): # Liberal check of. This is here as an optimization to avoid # having to load lots of MSIE cookie files unless necessary. req_host, erhn = eff_request_host(request) if not req_host.startswith("."): dotted_req_host = "."+req_host if not erhn.startswith("."): dotted_erhn = ".... | def domain_return_ok(self, domain, request): # Liberal check of. This is here as an optimization to avoid # having to load lots of MSIE cookie files unless necessary. req_host, erhn = eff_request_host(request) if not req_host.startswith("."): dotted_req_host = "."+req_host if not erhn.startswith("."): erhn = "."+erhn ... | 13,145 |
def parse_command_line (self, args): """Parse the setup script's command line: set any Distribution attributes tied to command-line options, create all command objects, and set their options from the command-line. 'args' must be a list of command-line arguments, most likely 'sys.argv[1:]' (see the 'setup()' function).... | def parse_command_line (self, args): """Parse the setup script's command line: set any Distribution attributes tied to command-line options, create all command objects, and set their options from the command-line. 'args' must be a list of command-line arguments, most likely 'sys.argv[1:]' (see the 'setup()' function).... | 13,146 |
def setcmapinfo(self): stuff = 0, 0, 0, 0, 0 if self.format in ('rgb8', 'grey'): stuff = 8, 0, 0, 0, 0 if self.format == 'grey4': stuff = 4, 0, 0, 0, 0 if self.format == 'grey2': stuff = 2, 0, 0, 0, 0 if self.format == 'mono': stuff = 1, 0, 0, 0, 0 print 'setcmapinfo:', stuff self.c0bits, self.c1bits, self.c2bits, \ se... | def setcmapinfo(self): stuff = 0, 0, 0, 0, 0 if self.format in ('rgb8', 'grey'): stuff = 8, 0, 0, 0, 0 if self.format == 'grey4': stuff = 4, 0, 0, 0, 0 if self.format == 'grey2': stuff = 2, 0, 0, 0, 0 if self.format == 'mono': stuff = 1, 0, 0, 0, 0 self.c0bits, self.c1bits, self.c2bits, \ self.offset, self.chrompack = ... | 13,147 |
def handle(self): """Handle a single HTTP request. | def handle(self): """Handle a single HTTP request. | 13,148 |
def add_header(self, _name, _value, **_params): """Extended header setting. | defadd_header(self,_name,_value,**_params):"""Extendedheadersetting. | 13,149 |
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\... | 13,150 |
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\... | 13,151 |
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() | 13,152 |
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) | 13,153 |
def remove_option(section, option): """Remove an option.""" if not section or section == "DEFAULT": sectdict = self.__defaults else: try: sectdict = self.__sections[section] except KeyError: raise NoSectionError(section) existed = sectdict.has_key(key) if existed: del sectdict[key] return existed | def remove_option(self, section, option): """Remove an option.""" if not section or section == "DEFAULT": sectdict = self.__defaults else: try: sectdict = self.__sections[section] except KeyError: raise NoSectionError(section) existed = sectdict.has_key(key) if existed: del sectdict[key] return existed | 13,154 |
def remove_section(section): """Remove a file section.""" if self.__sections.has_key(section): del self.__sections[section] return 1 else: return 0 | def remove_section(self, section): """Remove a file section.""" if self.__sections.has_key(section): del self.__sections[section] return 1 else: return 0 | 13,155 |
def __init__(self, text): self.text = text | def __init__(self, text, fileclass=StringIO.StringIO): self.text = text | 13,156 |
def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise httplib.UnimplementedFileMode() return StringIO.StringIO(self.text) | def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise httplib.UnimplementedFileMode() return StringIO.StringIO(self.text) | 13,157 |
def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise httplib.UnimplementedFileMode() return StringIO.StringIO(self.text) | def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': raise httplib.UnimplementedFileMode() return StringIO.StringIO(self.text) | 13,158 |
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. | 13,159 |
def smart_backspace_event(self, event): text = self.text first, last = self.editwin.get_selection_indices() if first and last: text.delete(first, last) text.mark_set("insert", first) return "break" # Delete whitespace left, until hitting a real char or closest # preceding virtual tab stop. chars = text.get("insert line... | def smart_backspace_event(self, event): text = self.text first, last = self.editwin.get_selection_indices() if first and last: text.delete(first, last) text.mark_set("insert", first) return "break" # Delete whitespace left, until hitting a real char or closest # preceding virtual tab stop. chars = text.get("insert line... | 13,160 |
def synopsis(filename, cache={}): """Get the one-line summary out of a module file.""" mtime = os.stat(filename).st_mtime lastupdate, result = cache.get(filename, (0, None)) if lastupdate < mtime: info = inspect.getmoduleinfo(filename) file = open(filename) if info and 'b' in info[2]: # binary modules have to be import... | def synopsis(filename, cache={}): """Get the one-line summary out of a module file.""" mtime = os.stat(filename).st_mtime lastupdate, result = cache.get(filename, (0, None)) if lastupdate < mtime: info = inspect.getmoduleinfo(filename) try: file = open(filename) except IOError: return None if info and 'b' in info[2]: ... | 13,161 |
def tempfilepager(text, cmd): """Page through text by invoking a program on a temporary file.""" import tempfile (fd, filename) = tempfile.mkstemp() file = os.fdopen(fd, 'w') file.write(text) file.close() try: os.system(cmd + ' ' + filename) finally: os.unlink(filename) | def tempfilepager(text, cmd): """Page through text by invoking a program on a temporary file.""" import tempfile filename = tempfile.mktemp() file = open(filename, 'w') file.write(text) file.close() try: os.system(cmd + ' ' + filename) finally: os.unlink(filename) | 13,162 |
def parse_qsl(qs, keep_blank_values=0, strict_parsing=0): """Parse a query given as a string argument. Arguments: qs: URL-encoded query string to be parsed keep_blank_values: flag indicating whether blank values in URL encoded queries should be treated as blank strings. A true value inicates that blanks should be re... | def parse_qsl(qs, keep_blank_values=0, strict_parsing=0): """Parse a query given as a string argument. Arguments: qs: URL-encoded query string to be parsed keep_blank_values: flag indicating whether blank values in URL encoded queries should be treated as blank strings. A true value inicates that blanks should be re... | 13,163 |
def test_one(self, x, pack=struct.pack, unpack=struct.unpack, unhexlify=binascii.unhexlify): if verbose: print "trying std", self.formatpair, "on", x, "==", hex(x) | def test_one(self, x, pack=struct.pack, unpack=struct.unpack, unhexlify=binascii.unhexlify): if verbose: print "trying std", self.formatpair, "on", x, "==", hex(x) | 13,164 |
def __init__(self, screenName=None, baseName=None, className='Tk'): Tkinter.Tk.__init__(self, screenName, baseName, className) tixlib = os.environ.get('TIX_LIBRARY') if tixlib is not None: self.tk.eval('global auto_path; lappend auto_path {%s}' % tixlib) self.tk.eval('global tcl_pkgPath; lappend tcl_pkgPath {%s}' % tix... | def __init__(self, screenName=None, baseName=None, className='Tix'): Tkinter.Tk.__init__(self, screenName, baseName, className) tixlib = os.environ.get('TIX_LIBRARY') if tixlib is not None: self.tk.eval('global auto_path; lappend auto_path {%s}' % tixlib) self.tk.eval('global tcl_pkgPath; lappend tcl_pkgPath {%s}' % ti... | 13,165 |
def __init__(self, screenName=None, baseName=None, className='Tk'): Tkinter.Tk.__init__(self, screenName, baseName, className) tixlib = os.environ.get('TIX_LIBRARY') if tixlib is not None: self.tk.eval('global auto_path; lappend auto_path {%s}' % tixlib) self.tk.eval('global tcl_pkgPath; lappend tcl_pkgPath {%s}' % tix... | def __init__(self, screenName=None, baseName=None, className='Tk'): Tkinter.Tk.__init__(self, screenName, baseName, className) tixlib = os.environ.get('TIX_LIBRARY') if tixlib is not None: self.tk.eval('global auto_path; lappend auto_path {%s}' % tixlib) self.tk.eval('global tcl_pkgPath; lappend tcl_pkgPath {%s}' % tix... | 13,166 |
def slaves(self): return map(self._nametowidget, self.tk.splitlist( self.tk.call( 'tixForm', 'slaves', self._w))) | def slaves(self): return map(self._nametowidget, self.tk.splitlist( self.tk.call( 'tixForm', 'slaves', self._w))) | 13,167 |
def slaves(self): return map(self._nametowidget, self.tk.splitlist( self.tk.call( 'tixForm', 'slaves', self._w))) | def slaves(self): return map(self._nametowidget, self.tk.splitlist( self.tk.call( 'tixForm', 'slaves', self._w))) | 13,168 |
def __getattr__(self, name): if self.subwidget_list.has_key(name): return self.subwidget_list[name] raise AttributeError, name | def__getattr__(self,name):ifself.subwidget_list.has_key(name):returnself.subwidget_list[name]raiseAttributeError,name | 13,169 |
def set_silent(self, value): self.tk.call('tixSetSilent', self._w, value) | def set_silent(self, value): self.tk.call('tixSetSilent', self._w, value) | 13,170 |
def subwidget(self, name): n = self._subwidget_name(name) if not n: raise TclError, "Subwidget " + name + " not child of " + self._name # Remove header of name and leading dot n = n[len(self._w)+1:] return self._nametowidget(n) | defsubwidget(self,name):n=self._subwidget_name(name)ifnotn:raiseTclError,"Subwidget"+name+"notchildof"+self._name#Removeheaderofnameandleadingdotn=n[len(self._w)+1:]returnself._nametowidget(n) | 13,171 |
def subwidgets_all(self): names = self._subwidget_names() if not names: return [] retlist = [] for name in names: name = name[len(self._w)+1:] try: retlist.append(self._nametowidget(name)) except: # some of the widgets are unknown e.g. border in LabelFrame pass return retlist | defsubwidgets_all(self):names=self._subwidget_names()ifnotnames:return[]retlist=[]fornameinnames:name=name[len(self._w)+1:]try:retlist.append(self._nametowidget(name))except:#someofthewidgetsareunknowne.g.borderinLabelFramepassreturnretlist | 13,172 |
def _subwidget_name(self,name): try: return self.tk.call(self._w, 'subwidget', name) except TclError: return None | def_subwidget_name(self,name):try:returnself.tk.call(self._w,'subwidget',name)exceptTclError:returnNone | 13,173 |
def _subwidget_names(self): try: x = self.tk.call(self._w, 'subwidgets', '-all') return self.tk.split(x) except TclError: return None | def_subwidget_names(self):try:x=self.tk.call(self._w,'subwidgets','-all')returnself.tk.split(x)exceptTclError:returnNone | 13,174 |
def unbind_widget(self, widget): self.tk.call(self._w, 'unbind', widget._w) | def unbind_widget(self, widget): self.tk.call(self._w, 'unbind', widget._w) | 13,175 |
def invoke(self, name): if self.subwidget_list.has_key(name): self.tk.call(self._w, 'invoke', name) | def invoke(self, name): if self.subwidget_list.has_key(name): self.tk.call(self._w, 'invoke', name) | 13,176 |
def invoke(self, name): if self.subwidget_list.has_key(name): self.tk.call(self._w, 'invoke', name) | def invoke(self, name): if self.subwidget_list.has_key(name): self.tk.call(self._w, 'invoke', name) | 13,177 |
def pick(self, index): self.tk.call(self._w, 'pick', index) | def pick(self, index): self.tk.call(self._w, 'pick', index) | 13,178 |
def update(self): self.tk.call(self._w, 'update') | def update(self): self.tk.call(self._w, 'update') | 13,179 |
def chdir(self, dir): self.tk.call(self._w, 'chdir', dir) | def chdir(self, dir): self.tk.call(self._w, 'chdir', dir) | 13,180 |
def popdown(self): self.tk.call(self._w, 'popdown') | defIt is generally used for the user to choose a file. FileSelectBox stores the files mostly recently selected into a ComboBox widget so that they can be quickly selected again. popdown(self):It is generally used for the user to choose a file. FileSelectBox stores the files mostly recently selected into a ComboBox wid... | 13,181 |
def popdown(self): self.tk.call(self._w, 'popdown') | def popdown(self): self.tk.call(self._w, 'popdown') | 13,182 |
def file_dialog(self): # XXX return python object pass | def file_dialog(self): # XXX return python object pass | 13,183 |
def __init__ (self,master=None,cnf={}, **kw): TixWidget.__init__(self, master, 'tixInputOnly', None, cnf, kw) | def __init__ (self,master=None,cnf={}, **kw): TixWidget.__init__(self, master, 'tixInputOnly', None, cnf, kw) | 13,184 |
def __init__ (self,master=None,cnf={}, **kw): TixWidget.__init__(self, master, 'tixLabelEntry', ['labelside','options'], cnf, kw) self.subwidget_list['label'] = _dummyLabel(self, 'label') self.subwidget_list['entry'] = _dummyEntry(self, 'entry') | def __init__ (self,master=None,cnf={}, **kw): TixWidget.__init__(self, master, 'tixLabelEntry', ['labelside','options'], cnf, kw) self.subwidget_list['label'] = _dummyLabel(self, 'label') self.subwidget_list['entry'] = _dummyEntry(self, 'entry') | 13,185 |
def __init__ (self,master=None,cnf={}, **kw): TixWidget.__init__(self, master, 'tixLabelFrame', ['labelside','options'], cnf, kw) self.subwidget_list['label'] = _dummyLabel(self, 'label') self.subwidget_list['frame'] = _dummyFrame(self, 'frame') | def __init__ (self,master=None,cnf={}, **kw): TixWidget.__init__(self, master, 'tixLabelFrame', ['labelside','options'], cnf, kw) self.subwidget_list['label'] = _dummyLabel(self, 'label') self.subwidget_list['frame'] = _dummyFrame(self, 'frame') | 13,186 |
def raised(self): return self.tk.call(self._w, 'raised') | def raised(self): return self.tk.call(self._w, 'raised') | 13,187 |
def enable(self, name): self.tk.call(self._w, 'enable', name) | def enable(self, name): self.tk.call(self._w, 'enable', name) | 13,188 |
def enable(self, name): self.tk.call(self._w, 'enable', name) | def enable(self, name): self.tk.call(self._w, 'enable', name) | 13,189 |
def panes(self): names = self.tk.call(self._w, 'panes') ret = [] for x in names: ret.append(self.subwidget(x)) return ret | def panes(self): names = self.tk.call(self._w, 'panes') ret = [] for x in names: ret.append(self.subwidget(x)) return ret | 13,190 |
def post_widget(self, widget, x, y): self.tk.call(self._w, 'post', widget._w, x, y) | def post_widget(self, widget, x, y): self.tk.call(self._w, 'post', widget._w, x, y) | 13,191 |
def attach_widget(self, widget): self.tk.call(self._w, 'attachwidget', widget._w) | def attach_widget(self, widget): self.tk.call(self._w, 'attachwidget', widget._w) | 13,192 |
def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixScrolledHList', ['options'], cnf, kw) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') | def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixScrolledHList', ['options'], cnf, kw) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') | 13,193 |
def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixScrolledListBox', ['options'], cnf, kw) self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') | def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixScrolledListBox', ['options'], cnf, kw) self.subwidget_list['listbox'] = _dummyListbox(self, 'listbox') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') | 13,194 |
def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixScrolledText', ['options'], cnf, kw) self.subwidget_list['text'] = _dummyText(self, 'text') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') | def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixScrolledText', ['options'], cnf, kw) self.subwidget_list['text'] = _dummyText(self, 'text') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') | 13,195 |
def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixScrolledTList', ['options'], cnf, kw) self.subwidget_list['tlist'] = _dummyTList(self, 'tlist') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') | def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixScrolledTList', ['options'], cnf, kw) self.subwidget_list['tlist'] = _dummyTList(self, 'tlist') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') | 13,196 |
def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixScrolledWindow', ['options'], cnf, kw) self.subwidget_list['window'] = _dummyFrame(self, 'window') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') | def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixScrolledWindow', ['options'], cnf, kw) self.subwidget_list['window'] = _dummyFrame(self, 'window') self.subwidget_list['vsb'] = _dummyScrollbar(self, 'vsb') self.subwidget_list['hsb'] = _dummyScrollbar(self, 'hsb') | 13,197 |
def invoke(self, name): if self.subwidget_list.has_key(name): self.tk.call(self._w, 'invoke', name) | def invoke(self, name): if self.subwidget_list.has_key(name): self.tk.call(self._w, 'invoke', name) | 13,198 |
def yview(self, *args): apply(self.tk.call, (self._w, 'yview') + args) | def yview(self, *args): apply(self.tk.call, (self._w, 'yview') + args) | 13,199 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.