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.exit(n) except: traceback.print_exc()
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.exit(n) except: traceback.print_exc()
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 convention before we can actually use them in the filesystem. Raises ValueError if 'pathname' is absolute (starts with '/') or contains local directory separators (unless the local separator is '/', of course). """ if os.sep == '/': return pathname if pathname[0] == '/': raise ValueError, "path '%s' cannot be absolute" % pathname if pathname[-1] == '/': raise ValueError, "path '%s' cannot end with '/'" % pathname paths = string.split(pathname, '/') return apply(os.path.join, paths)
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 convention before we can actually use them in the filesystem. Raises ValueError on non-Unix-ish systems if 'pathname' either starts or ends with a slash. """ if os.sep == '/': return pathname if pathname[0] == '/': raise ValueError, "path '%s' cannot be absolute" % pathname if pathname[-1] == '/': raise ValueError, "path '%s' cannot end with '/'" % pathname paths = string.split(pathname, '/') return apply(os.path.join, paths)
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_vars'. 'os.environ' is first checked/ augmented to guarantee that it contains certain values: see '_check_environ()'. Raise ValueError for any variables not found in either 'local_vars' or 'os.environ'. """ check_environ() 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] return re.sub(r'\$([a-zA-Z_][a-zA-Z_0-9]*)', _subst, str)
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 checked/augmented to guarantee that it contains certain values: see 'check_environ()'. Raise ValueError for any variables not found in either 'local_vars' or 'os.environ'. """ check_environ() 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] return re.sub(r'\$([a-zA-Z_][a-zA-Z_0-9]*)', _subst, str)
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: # continued string if not line: raise TokenError, "EOF within multi-line string" if endprog.search(line) >= 0: pos = end = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr = '' else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, line[:pos], (lnum, 0), (lnum, pos), line) else: # continued statement if not line: raise TokenError, "EOF within multi-line statement" continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos = (lnum, start), (lnum, end) token, initial = line[start:end], line[start] pos = end if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars: # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.search(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog, contstr = endprogs[initial], line[start:] break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], spos, (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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: # continued string if not line: raise TokenError, "EOF within multi-line string" if endprog.search(line) >= 0: pos = end = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr, needcont = '', 0 else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, line[:pos], (lnum, 0), (lnum, pos), line) else: # continued statement if not line: raise TokenError, "EOF within multi-line statement" continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos = (lnum, start), (lnum, end) token, initial = line[start:end], line[start] pos = end if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars: # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.search(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog, contstr = endprogs[initial], line[start:] break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], spos, (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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: # continued string if not line: raise TokenError, "EOF within multi-line string" if endprog.search(line) >= 0: pos = end = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr = '' else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, line[:pos], (lnum, 0), (lnum, pos), line) else: # continued statement if not line: raise TokenError, "EOF within multi-line statement" continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos = (lnum, start), (lnum, end) token, initial = line[start:end], line[start] pos = end if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars: # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.search(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog, contstr = endprogs[initial], line[start:] break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], spos, (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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: # continued string if not line: raise TokenError, ("EOF in multi-line string", strstart) if endprog.match(line) >= 0: pos = end = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr = '' else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, line[:pos], (lnum, 0), (lnum, pos), line) else: # continued statement if not line: raise TokenError, "EOF within multi-line statement" continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos = (lnum, start), (lnum, end) token, initial = line[start:end], line[start] pos = end if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars: # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.search(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog, contstr = endprogs[initial], line[start:] break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], spos, (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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: # continued string if not line: raise TokenError, "EOF within multi-line string" if endprog.search(line) >= 0: pos = end = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr = '' else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, line[:pos], (lnum, 0), (lnum, pos), line) else: # continued statement if not line: raise TokenError, "EOF within multi-line statement" continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos = (lnum, start), (lnum, end) token, initial = line[start:end], line[start] pos = end if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars: # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.search(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog, contstr = endprogs[initial], line[start:] break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], spos, (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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: # continued string if not line: raise TokenError, "EOF within multi-line string" if endprog.search(line) >= 0: pos = end = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr = '' else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, line[:pos], (lnum, 0), (lnum, pos), line) else: # continued statement if not line: raise TokenError, "EOF within multi-line statement" continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos = (lnum, start), (lnum, end) token, initial = line[start:end], line[start] pos = end if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars: # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.search(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog, contstr = endprogs[initial], line[start:] break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], spos, (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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: # continued string if not line: raise TokenError, "EOF within multi-line string" if endprog.search(line) >= 0: pos = end = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr = '' else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, line[:pos], (lnum, 0), (lnum, pos), line) else: # continued statement if not line: raise TokenError, "EOF within multi-line statement" continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos = (lnum, start), (lnum, end) token, initial = line[start:end], line[start] pos = end if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars: # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.search(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog, contstr = endprogs[initial], line[start:] break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], spos, (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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: # continued string if not line: raise TokenError, "EOF within multi-line string" if endprog.search(line) >= 0: pos = end = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr = '' else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, '', (lnum, pos), (lnum, pos), line) else: # continued statement if not line: raise TokenError, "EOF within multi-line statement" continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos = (lnum, start), (lnum, end) token, initial = line[start:end], line[start] pos = end if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars: # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.search(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog, contstr = endprogs[initial], line[start:] break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], spos, (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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: # continued string if not line: raise TokenError, "EOF within multi-line string" if endprog.search(line) >= 0: pos = end = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr = '' else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, line[:pos], (lnum, 0), (lnum, pos), line) else: # continued statement if not line: raise TokenError, "EOF within multi-line statement" continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos = (lnum, start), (lnum, end) token, initial = line[start:end], line[start] pos = end if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars: # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.search(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog, contstr = endprogs[initial], line[start:] break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], spos, (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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: # continued string if not line: raise TokenError, "EOF within multi-line string" if endprog.search(line) >= 0: pos = end = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr = '' else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, line[:pos], (lnum, 0), (lnum, pos), line) else: # continued statement if not line: raise TokenError, ("EOF in multi-line statement", (lnum, 0)) continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos = (lnum, start), (lnum, end) token, initial = line[start:end], line[start] pos = end if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars: # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.search(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog, contstr = endprogs[initial], line[start:] break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], spos, (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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: # continued string if not line: raise TokenError, "EOF within multi-line string" if endprog.search(line) >= 0: pos = end = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr = '' else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, line[:pos], (lnum, 0), (lnum, pos), line) else: # continued statement if not line: raise TokenError, "EOF within multi-line statement" continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos = (lnum, start), (lnum, end) token, initial = line[start:end], line[start] pos = end if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars: # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.search(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog, contstr = endprogs[initial], line[start:] break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], spos, (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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: # continued string if not line: raise TokenError, "EOF within multi-line string" if endprog.search(line) >= 0: pos = end = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr = '' else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, line[:pos], (lnum, 0), (lnum, pos), line) else: # continued statement if not line: raise TokenError, "EOF within multi-line statement" continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos, pos = (lnum, start), (lnum, end), end token, initial = line[start:end], line[start] pos = end if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars: # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.search(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog, contstr = endprogs[initial], line[start:] break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], spos, (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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: # continued string if not line: raise TokenError, "EOF within multi-line string" if endprog.search(line) >= 0: pos = end = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr = '' else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, line[:pos], (lnum, 0), (lnum, pos), line) else: # continued statement if not line: raise TokenError, "EOF within multi-line statement" continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos = (lnum, start), (lnum, end) token, initial = line[start:end], line[start] pos = end if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars: # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.search(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog, contstr = endprogs[initial], line[start:] break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], spos, (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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: # continued string if not line: raise TokenError, "EOF within multi-line string" if endprog.search(line) >= 0: = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr = '' else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, line[:pos], (lnum, 0), (lnum, pos), line) else: # continued statement if not line: raise TokenError, "EOF within multi-line statement" continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos = (lnum, start), (lnum, end) token, initial = line[start:end], line[start] if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars: # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.search(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog, contstr = endprogs[initial], line[start:] break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], spos, (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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: # continued string if not line: raise TokenError, "EOF within multi-line string" if endprog.search(line) >= 0: pos = end = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr = '' else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, line[:pos], (lnum, 0), (lnum, pos), line) else: # continued statement if not line: raise TokenError, "EOF within multi-line statement" continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos = (lnum, start), (lnum, end) token, initial = line[start:end], line[start] pos = end if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars: # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.search(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog, contstr = endprogs[initial], line[start:] break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], spos, (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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: # continued string if not line: raise TokenError, "EOF within multi-line string" if endprog.search(line) >= 0: pos = end = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr = '' else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, line[:pos], (lnum, 0), (lnum, pos), line) else: # continued statement if not line: raise TokenError, "EOF within multi-line statement" continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos = (lnum, start), (lnum, end) token, initial = line[start:end], line[start] pos = end if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars \ or (initial == '.' and token != '.'): # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.search(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog, contstr = endprogs[initial], line[start:] break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], spos, (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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: # continued string if not line: raise TokenError, "EOF within multi-line string" if endprog.search(line) >= 0: pos = end = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr = '' else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, line[:pos], (lnum, 0), (lnum, pos), line) else: # continued statement if not line: raise TokenError, "EOF within multi-line statement" continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos = (lnum, start), (lnum, end) token, initial = line[start:end], line[start] pos = end if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars: # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.search(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog, contstr = endprogs[initial], line[start:] break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], spos, (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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: # continued string if not line: raise TokenError, "EOF within multi-line string" if endprog.search(line) >= 0: pos = end = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr = '' else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, line[:pos], (lnum, 0), (lnum, pos), line) else: # continued statement if not line: raise TokenError, "EOF within multi-line statement" continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos = (lnum, start), (lnum, end) token, initial = line[start:end], line[start] pos = end if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars: # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.match(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog, contstr = endprogs[initial], line[start:] break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], spos, (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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: # continued string if not line: raise TokenError, "EOF within multi-line string" if endprog.search(line) >= 0: pos = end = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr = '' else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, line[:pos], (lnum, 0), (lnum, pos), line) else: # continued statement if not line: raise TokenError, "EOF within multi-line statement" continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos = (lnum, start), (lnum, end) token, initial = line[start:end], line[start] pos = end if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars: # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.search(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog, contstr = endprogs[initial], line[start:] break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], spos, (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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: # continued string if not line: raise TokenError, "EOF within multi-line string" if endprog.search(line) >= 0: pos = end = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr = '' else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, line[:pos], (lnum, 0), (lnum, pos), line) else: # continued statement if not line: raise TokenError, "EOF within multi-line statement" continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos = (lnum, start), (lnum, end) token, initial = line[start:end], line[start] pos = end if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars: # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.search(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog = endprogs[initial] contstr, needcont = line[start:], 1 break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], spos, (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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: # continued string if not line: raise TokenError, "EOF within multi-line string" if endprog.search(line) >= 0: pos = end = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr = '' else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, line[:pos], (lnum, 0), (lnum, pos), line) else: # continued statement if not line: raise TokenError, "EOF within multi-line statement" continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos = (lnum, start), (lnum, end) token, initial = line[start:end], line[start] pos = end if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars: # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.search(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog, contstr = endprogs[initial], line[start:] break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], spos, (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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: # continued string if not line: raise TokenError, "EOF within multi-line string" if endprog.search(line) >= 0: pos = end = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr = '' else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, line[:pos], (lnum, 0), (lnum, pos), line) else: # continued statement if not line: raise TokenError, "EOF within multi-line statement" continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos = (lnum, start), (lnum, end) token, initial = line[start:end], line[start] pos = end if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars: # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.search(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog, contstr = endprogs[initial], line[start:] break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], (lnum, pos), (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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: # continued string if not line: raise TokenError, "EOF within multi-line string" if endprog.search(line) >= 0: pos = end = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr = '' else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, line[:pos], (lnum, 0), (lnum, pos), line) else: # continued statement if not line: raise TokenError, "EOF within multi-line statement" continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos = (lnum, start), (lnum, end) token, initial = line[start:end], line[start] pos = end if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars: # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.search(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog, contstr = endprogs[initial], line[start:] break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], spos, (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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: # continued string if not line: raise TokenError, "EOF within multi-line string" if endprog.search(line) >= 0: pos = end = endprog.regs[0][1] tokeneater(STRING, contstr + line[:end], strstart, (lnum, end), line) contstr = '' else: contstr = contstr + line continue elif parenlev == 0 and not continued: # new statement if not line: break column = 0 while pos < max: # measure leading whitespace if line[pos] == ' ': column = column + 1 elif line[pos] == '\t': column = (column/tabsize + 1)*tabsize elif line[pos] == '\f': column = 0 else: break pos = pos + 1 if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines tokeneater((NEWLINE, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue if column > indents[-1]: # count indents or dedents indents.append(column) tokeneater(INDENT, line[:pos], (lnum, 0), (lnum, pos), line) while column < indents[-1]: indents = indents[:-1] tokeneater(DEDENT, line[:pos], (lnum, 0), (lnum, pos), line) else: # continued statement if not line: raise TokenError, "EOF within multi-line statement" continued = 0 while pos < max: if pseudoprog.match(line, pos) > 0: # scan for tokens start, end = pseudoprog.regs[1] spos, epos = (lnum, start), (lnum, end) token, initial = line[start:end], line[start] pos = end if initial in namechars: # ordinary name tokeneater(NAME, token, spos, epos, line) elif initial in numchars: # ordinary number tokeneater(NUMBER, token, spos, epos, line) elif initial in '\r\n': tokeneater(NEWLINE, token, spos, epos, line) elif initial == '#': tokeneater(COMMENT, token, spos, epos, line) elif initial == '\\': # continued stmt continued = 1 elif token in ('\'\'\'', '"""'): # triple-quoted endprog = endprogs[token] if endprog.search(line, pos) >= 0: # all on one line pos = endprog.regs[0][1] token = line[start:pos] tokeneater(STRING, token, spos, (lnum, pos), line) else: strstart = (lnum, start) # multiple lines contstr = line[start:] break elif initial in '\'"': if token[-1] == '\n': # continued string strstart = (lnum, start) endprog, contstr = endprogs[initial], line[start:] break else: # ordinary string tokeneater(STRING, token, spos, epos, line) else: if initial in '([{': parenlev = parenlev + 1 elif initial in ')]}': parenlev = parenlev - 1 tokeneater(OP, token, spos, epos, line) else: tokeneater(ERRORTOKEN, line[pos], spos, (lnum, pos+1), line) pos = pos + 1 for indent in indents[1:]: # pop remaining indent levels tokeneater(DEDENT, '', (lnum, 0), (lnum, 0), '')
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.FSpCreateResFile(dstfss, srcfinfo.Creator, srcfinfo.Type, -1) h = Res.FSpOpenResFile(dstfss, 3) resource = Res.Resource(alias.data) resource.AddResource('alis', 0, '') Res.CloseResFile(h) dstfinfo = dstfss.GetFInfo() dstfinfo.Flags = dstfinfo.Flags|0x8000 # Alias flag dstfss.SetFInfo(dstfinfo)
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', 'fdrp' else: cr, tp = srcfss.GetCreatorType() Res.FSpCreateResFile(dstfss, cr, tp, -1) h = Res.FSpOpenResFile(dstfss, 3) resource = Res.Resource(alias.data) resource.AddResource('alis', 0, '') Res.CloseResFile(h) dstfinfo = dstfss.GetFInfo() dstfinfo.Flags = dstfinfo.Flags|0x8000 # Alias flag dstfss.SetFInfo(dstfinfo)
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 resp = self.sendcmd('TYPE A') conn = self.transfercmd(cmd) fp = conn.makefile('rb') while 1: line = fp.readline() if self.debugging > 2: print '*retr*', `line` if not line: break if line[-2:] == CRLF: line = line[:-2] elif line[-1:] == '\n': line = line[:-1] callback(line) fp.close() conn.close() return self.voidresp()
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 resp = self.sendcmd('TYPE A') conn = self.transfercmd(cmd) fp = conn.makefile('rb') while 1: line = fp.readline() if self.debugging > 2: print '*retr*', `line` if not line: break if line[-2:] == CRLF: line = line[:-2] elif line[-1:] == '\n': line = line[:-1] callback(line) fp.close() conn.close() return self.voidresp()
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) == type(''): ofile = open(outfile, 'w') else: ofile = outfile nifile = File(ifile, None) mimify_part(nifile, ofile, 0) ofile.flush()
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) == type(''): ofile = open(outfile, 'w') else: ofile = outfile nifile = File(ifile, None) mimify_part(nifile, ofile, 0) ofile.flush()
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 = len(name) childrenname = alogger.name namelen = len(name) ofname = alogger.name namelen = len(name) thename = alogger.name namelen = len(name) placeholdername = alogger.name namelen = len(name) phname = alogger.name namelen = len(name) arename = alogger.name namelen = len(name) connectedname = alogger.name namelen = len(name) toname = alogger.name namelen = len(name) thename = alogger.name namelen = len(name) specifiedname = alogger.name namelen = len(name) logger.name = alogger.name namelen = len(name) """name = alogger.name namelen = len(name) #forname = alogger.name namelen = len(name) cname = alogger.name namelen = len(name) inname = alogger.name namelen = len(name) ph.loggers:name = alogger.name namelen = len(name) forname = alogger.name namelen = len(name) cname = alogger.name namelen = len(name) inname = alogger.name namelen = len(name) ph.loggerMap.keys():name = alogger.name namelen = len(name) ifname = alogger.name namelen = len(name) string.find(c.parent.name,name = alogger.name namelen = len(name) alogger.name)name = alogger.name namelen = len(name) <>name = alogger.name namelen = len(name) 0:name = alogger.name namelen = len(name) alogger.parentname = alogger.name namelen = len(name) =name = alogger.name namelen = len(name) c.parentname = alogger.name namelen = len(name) c.parentname = alogger.name namelen = len(name) =name = alogger.name namelen = len(name) alogger
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(), 5)
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, msg sys.exit(1) section = None fuzzy = 0 # Parse the catalog lno = 0 for l in lines: lno += 1 # If we get a comment line after a msgstr, this is a new entry if l[0] == '#' and section == STR: add(msgid, msgstr, fuzzy) section = None fuzzy = 0 # Record a fuzzy mark if l[:2] == '#,' and l.find('fuzzy'): fuzzy = 1 # Skip comments if l[0] == '#': continue # Now we are in a msgid section, output previous section if l.startswith('msgid'): if section == STR: add(msgid, msgstr, fuzzy) section = ID l = l[5:] msgid = msgstr = '' # Now we are in a msgstr section elif l.startswith('msgstr'): section = STR l = l[6:] # Skip empty lines l = l.strip() if not l: continue # XXX: Does this always follow Python escape semantics? l = eval(l) if section == ID: msgid += l elif section == STR: msgstr += l else: print >> sys.stderr, 'Syntax error on %s:%d' % (infile, lno), \ 'before:' print >> sys.stderr, l sys.exit(1) # Add last entry if section == STR: add(msgid, msgstr, fuzzy) # Compute output output = generate() try: open(outfile,"wb").write(output) except IOError,msg: print >> sys.stderr, msg
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, msg sys.exit(1) section = None fuzzy = 0 # Parse the catalog lno = 0 for l in lines: lno += 1 # If we get a comment line after a msgstr, this is a new entry if l[0] == '#' and section == STR: add(msgid, msgstr, fuzzy) section = None fuzzy = 0 # Record a fuzzy mark if l[:2] == '#,' and l.find('fuzzy'): fuzzy = 1 # Skip comments if l[0] == '#': continue # Now we are in a msgid section, output previous section if l.startswith('msgid'): if section == STR: add(msgid, msgstr, fuzzy) section = ID l = l[5:] msgid = msgstr = '' # Now we are in a msgstr section elif l.startswith('msgstr'): section = STR l = l[6:] # Skip empty lines l = l.strip() if not l: continue # XXX: Does this always follow Python escape semantics? l = eval(l) if section == ID: msgid += l elif section == STR: msgstr += l else: print >> sys.stderr, 'Syntax error on %s:%d' % (infile, lno), \ 'before:' print >> sys.stderr, l sys.exit(1) # Add last entry if section == STR: add(msgid, msgstr, fuzzy) # Compute output output = generate() try: open(outfile,"wb").write(output) except IOError,msg: print >> sys.stderr, msg
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.mode else: mode = 'rb'
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.mode else: mode = 'rb'
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 = line[1:] list.append(line) return resp, list
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] == '..': line = line[1:] list.append(line) return resp, list
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 = line[1:] list.append(line) return resp, list
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: raise NNTPReplyError(resp) list = [] while 1: line = self.getline() if line == '.': break if line[:2] == '..': line = line[1:] if fileHandle: fileHandle.write(line + "\n") else: list.append(line) finally: if openedFile: openedFile.close() return resp, list
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 = "."+erhn if not (dotted_req_host.endswith(domain) or dotted_erhn.endswith(domain)): #debug(" request domain %s does not match cookie domain %s", # req_host, domain) return False
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 if not (dotted_req_host.endswith(domain) or dotted_erhn.endswith(domain)): #debug(" request domain %s does not match cookie domain %s", # req_host, domain) return False
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 = "."+erhn if not (dotted_req_host.endswith(domain) or dotted_erhn.endswith(domain)): #debug(" request domain %s does not match cookie domain %s", # req_host, domain) return False
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 if not (req_host.endswith(domain) or erhn.endswith(domain)): #debug(" request domain %s does not match cookie domain %s", # req_host, domain) return False
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). This list is first processed for "global options" -- options that set attributes of the Distribution instance. Then, it is alternately scanned for Distutils command and options for that command. Each new command terminates the options for the previous command. The allowed options for a command are determined by the 'options' attribute of the command object -- thus, we instantiate (and cache) every command object here, in order to access its 'options' attribute. Any error in that 'options' attribute raises DistutilsGetoptError; any error on the command-line raises DistutilsArgError. If no Distutils commands were found on the command line, raises DistutilsArgError. Return true if command-line successfully parsed and we should carry on with executing commands; false if no errors but we shouldn't execute commands (currently, this only happens if user asks for help)."""
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). This list is first processed for "global options" -- options that set attributes of the Distribution instance. Then, it is alternately scanned for Distutils command and options for that command. Each new command terminates the options for the previous command. The allowed options for a command are determined by the 'options' attribute of the command object -- thus, we instantiate (and cache) every command object here, in order to access its 'options' attribute. Any error in that 'options' attribute raises DistutilsGetoptError; any error on the command-line raises DistutilsArgError. If no Distutils commands were found on the command line, raises DistutilsArgError. Return true if command-line successfully parsed and we should carry on with executing commands; false if no errors but we shouldn't execute commands (currently, this only happens if user asks for help)."""
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, \ self.offset, self.chrompack = stuff
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 = stuff
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\n]*=[ \t\n]*' + '\(\'[^\']*\'\|"[^"]*"\|[-a-zA-Z0-9./:+*%?!()_#]*\)\)?') k = tagfind.match(rawdata, i+1) if k < 0: raise RuntimeError, 'unexpected call to parse_starttag' k = i+1+k tag = string.lower(rawdata[i+1:k]) while k < j: l = attrfind.match(rawdata, k) if l < 0: break attrname, rest, attrvalue = attrfind.group(1, 2, 3) if not rest: attrvalue = attrname elif attrvalue[:1] == '\'' == attrvalue[-1:] or \ attrvalue[:1] == '"' == attrvalue[-1:]: attrvalue = attrvalue[1:-1] attrs.append((string.lower(attrname), attrvalue)) k = k + l j = j+1 try: method = getattr(self, 'start_' + tag) except AttributeError: try: method = getattr(self, 'do_' + tag) except AttributeError: self.unknown_starttag(tag, attrs) return j-i method(attrs) return j-i self.stack.append(tag) method(attrs) return j-i
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\n]*=[ \t\n]*' + '\(\'[^\']*\'\|"[^"]*"\|[-a-zA-Z0-9./:+*%?!()_#]*\)\)?') k = tagfind.match(rawdata, i+1) if k < 0: raise RuntimeError, 'unexpected call to parse_starttag' k = i+1+k tag = string.lower(rawdata[i+1:k]) while k < j: l = attrfind.match(rawdata, k) if l < 0: break attrname, rest, attrvalue = attrfind.group(1, 2, 3) if not rest: attrvalue = attrname elif attrvalue[:1] == '\'' == attrvalue[-1:] or \ attrvalue[:1] == '"' == attrvalue[-1:]: attrvalue = attrvalue[1:-1] attrs.append((string.lower(attrname), attrvalue)) k = k + l j = j+1 try: method = getattr(self, 'start_' + tag) except AttributeError: try: method = getattr(self, 'do_' + tag) except AttributeError: self.unknown_starttag(tag, attrs) return j-i method(attrs) return j-i self.stack.append(tag) method(attrs) return j-i
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\n]*=[ \t\n]*' + '\(\'[^\']*\'\|"[^"]*"\|[-a-zA-Z0-9./:+*%?!()_#]*\)\)?') k = tagfind.match(rawdata, i+1) if k < 0: raise RuntimeError, 'unexpected call to parse_starttag' k = i+1+k tag = string.lower(rawdata[i+1:k]) while k < j: l = attrfind.match(rawdata, k) if l < 0: break attrname, rest, attrvalue = attrfind.group(1, 2, 3) if not rest: attrvalue = attrname elif attrvalue[:1] == '\'' == attrvalue[-1:] or \ attrvalue[:1] == '"' == attrvalue[-1:]: attrvalue = attrvalue[1:-1] attrs.append((string.lower(attrname), attrvalue)) k = k + l j = j+1 try: method = getattr(self, 'start_' + tag) except AttributeError: try: method = getattr(self, 'do_' + tag) except AttributeError: self.unknown_starttag(tag, attrs) return j-i method(attrs) return j-i self.stack.append(tag) method(attrs) return j-i
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\n]*=[ \t\n]*' + '\(\'[^\']*\'\|"[^"]*"\|[-a-zA-Z0-9./:+*%?!()_#]*\)\)?') k = tagfind.match(rawdata, i+1) if k < 0: raise RuntimeError, 'unexpected call to parse_starttag' k = i+1+k tag = string.lower(rawdata[i+1:k]) while k < j: l = attrfind.match(rawdata, k) if l < 0: break attrname, rest, attrvalue = attrfind.group(1, 2, 3) if not rest: attrvalue = attrname elif attrvalue[:1] == '\'' == attrvalue[-1:] or \ attrvalue[:1] == '"' == attrvalue[-1:]: attrvalue = attrvalue[1:-1] attrs.append((string.lower(attrname), attrvalue)) k = k + l j = j+1 try: method = getattr(self, 'start_' + tag) except AttributeError: try: method = getattr(self, 'do_' + tag) except AttributeError: self.unknown_starttag(tag, attrs) return j-i method(attrs) return j-i self.stack.append(tag) method(attrs) return j-i
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 linestart", "insert") if chars == '': if text.compare("insert", ">", "1.0"): # easy: delete preceding newline text.delete("insert-1c") else: text.bell() # at start of buffer return "break" if chars[-1] not in " \t": # easy: delete preceding real char text.delete("insert-1c") return "break" # Ick. It may require *inserting* spaces if we back up over a # tab character! This is written to be clear, not fast. expand, tabwidth = string.expandtabs, self.tabwidth have = len(expand(chars, tabwidth)) assert have > 0 want = int((have - 1) // self.indentwidth) * self.indentwidth ncharsdeleted = 0 while 1: chars = chars[:-1] ncharsdeleted = ncharsdeleted + 1 have = len(expand(chars, tabwidth)) if have <= want or chars[-1] not in " \t": break text.undo_block_start() text.delete("insert-%dc" % ncharsdeleted, "insert") if have < want: text.insert("insert", ' ' * (want - have)) text.undo_block_stop() return "break"
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 linestart", "insert") if chars == '': if text.compare("insert", ">", "1.0"): # easy: delete preceding newline text.delete("insert-1c") else: text.bell() # at start of buffer return "break" if chars[-1] not in " \t": # easy: delete preceding real char text.delete("insert-1c") return "break" # Ick. It may require *inserting* spaces if we back up over a # tab character! This is written to be clear, not fast. expand, tabwidth = string.expandtabs, self.tabwidth have = len(expand(chars, tabwidth)) assert have > 0 want = ((have - 1) // self.indentwidth) * self.indentwidth ncharsdeleted = 0 while 1: chars = chars[:-1] ncharsdeleted = ncharsdeleted + 1 have = len(expand(chars, tabwidth)) if have <= want or chars[-1] not in " \t": break text.undo_block_start() text.delete("insert-%dc" % ncharsdeleted, "insert") if have < want: text.insert("insert", ' ' * (want - have)) text.undo_block_stop() return "break"
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 imported try: module = imp.load_module('__temp__', file, filename, info[1:]) except: return None result = split(module.__doc__ or '', '\n')[0] del sys.modules['__temp__'] else: # text modules can be directly examined line = file.readline() while line[:1] == '#' or not strip(line): line = file.readline() if not line: break line = strip(line) if line[:4] == 'r"""': line = line[1:] if line[:3] == '"""': line = line[3:] if line[-1:] == '\\': line = line[:-1] while not strip(line): line = file.readline() if not line: break result = strip(split(line, '"""')[0]) else: result = None file.close() cache[filename] = (mtime, result) return result
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]: # binary modules have to be imported try: module = imp.load_module('__temp__', file, filename, info[1:]) except: return None result = split(module.__doc__ or '', '\n')[0] del sys.modules['__temp__'] else: # text modules can be directly examined line = file.readline() while line[:1] == '#' or not strip(line): line = file.readline() if not line: break line = strip(line) if line[:4] == 'r"""': line = line[1:] if line[:3] == '"""': line = line[3:] if line[-1:] == '\\': line = line[:-1] while not strip(line): line = file.readline() if not line: break result = strip(split(line, '"""')[0]) else: result = None file.close() cache[filename] = (mtime, result) return result
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 retained as blank strings. The default false value indicates that blank values are to be ignored and treated as if they were not included. strict_parsing: flag indicating what to do with parsing errors. If false (the default), errors are silently ignored. If true, errors raise a ValueError exception. Returns a list, as God intended. """ name_value_pairs = string.splitfields(qs, '&') r=[] for name_value in name_value_pairs: nv = string.splitfields(name_value, '=') if len(nv) != 2: if strict_parsing: raise ValueError, "bad query field: %s" % `name_value` continue name = urllib.unquote(string.replace(nv[0], '+', ' ')) value = urllib.unquote(string.replace(nv[1], '+', ' ')) r.append(name, value) return r
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 retained as blank strings. The default false value indicates that blank values are to be ignored and treated as if they were not included. strict_parsing: flag indicating what to do with parsing errors. If false (the default), errors are silently ignored. If true, errors raise a ValueError exception. Returns a list, as God intended. """ name_value_pairs = string.splitfields(qs, '&') r=[] for name_value in name_value_pairs: nv = string.splitfields(name_value, '=') if len(nv) != 2: if strict_parsing: raise ValueError, "bad query field: %s" % `name_value` continue name = urllib.unquote(string.replace(nv[0], '+', ' ')) value = urllib.unquote(string.replace(nv[1], '+', ' ')) r.append((name, value)) return r
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}' % tixlib) # Load Tix - this should work dynamically or statically # If it's static, lib/tix8.1/pkgIndex.tcl should have 'load {} Tix' # If it's dynamic, it should have 'load libtix8.1.8.2.so Tix' self.tk.eval('package require 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}' % tixlib) # Load Tix - this should work dynamically or statically # If it's static, lib/tix8.1/pkgIndex.tcl should have 'load {} Tix' # If it's dynamic, it should have 'load libtix8.1.8.2.so Tix' self.tk.eval('package require Tix')
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}' % tixlib) # Load Tix - this should work dynamically or statically # If it's static, lib/tix8.1/pkgIndex.tcl should have 'load {} Tix' # If it's dynamic, it should have 'load libtix8.1.8.2.so Tix' self.tk.eval('package require 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}' % tixlib) # Load Tix - this should work dynamically or statically # If it's static, lib/tix8.1/pkgIndex.tcl should have 'load {} Tix' # If it's dynamic, it should have 'load libtix8.1.8.2.so Tix' self.tk.eval('package require 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 widget so that they can be quickly selected again. self.tk.call(self._w,It 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')
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