bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def check_missing_spaces_before(tokens, lines, warnings): "Check for missing spaces before }" operators = '}', for i, t in enumerate(tokens): if t.typ != Token.punct or t.string not in operators: continue prec = tokens[i-1] if prec.line == t.line and prec.end == t.col: w = 'Missing space before `%s\' (col %d): %s' warnings.append((t.line, w % (t.string, t.col, lines[t.line])))
def check_missing_spaces_before(tokens, lines, warnings): "Check for missing spaces before }" operators = '}', for i, t in enumerate(tokens): if t.typ != Token.punct or t.string not in operators: continue if t.prec.line == t.line and t.prec.end == t.col: w = 'Missing space before `%s\' (col %d): %s' warnings.append((t.line, w % (t.string, t.col, lines[t.line])))
6,000
def check_singlular_opening_braces(tokens, lines, warnings): "Check for inappropriate { on a separate line" for i, t in enumerate(tokens): if t.bracelevel == 0 or t.typ != Token.punct or t.string != '{': continue prec = tokens[i-1] if t.line > prec.line and prec.typ == Token.punct \ and prec.string == ')': w = 'Opening brace on a separate line (col %d)' warnings.append((t.line, w % t.col))
def check_singlular_opening_braces(tokens, lines, warnings): "Check for inappropriate { on a separate line" for t in tokens: if t.bracelevel == 0 or t.typ != Token.punct or t.string != '{': continue prec = tokens[i-1] if t.line > prec.line and prec.typ == Token.punct \ and prec.string == ')': w = 'Opening brace on a separate line (col %d)' warnings.append((t.line, w % t.col))
6,001
def check_singlular_opening_braces(tokens, lines, warnings): "Check for inappropriate { on a separate line" for i, t in enumerate(tokens): if t.bracelevel == 0 or t.typ != Token.punct or t.string != '{': continue prec = tokens[i-1] if t.line > prec.line and prec.typ == Token.punct \ and prec.string == ')': w = 'Opening brace on a separate line (col %d)' warnings.append((t.line, w % t.col))
def check_singlular_opening_braces(tokens, lines, warnings): "Check for inappropriate { on a separate line" for i, t in enumerate(tokens): if t.bracelevel == 0 or t.typ != Token.punct or t.string != '{': continue if t.line > t.prec.line and t.prec.typ == Token.punct \ and t.prec.string == ')': w = 'Opening brace on a separate line (col %d)' warnings.append((t.line, w % t.col))
6,002
def check_keyword_spacing(tokens, lines, warnings): "Check for missing spaces after for, while, etc." keywlist = 'if', 'for', 'while', 'switch' keywords = dict([(x, 1) for x in keywlist]) for i, t in enumerate(tokens): if t.typ != Token.ident or t.string not in keywords: continue succ = tokens[i+1] if succ.line == t.line and t.end == succ.col: w = 'Missing space after `%s\' (col %d): %s' warnings.append((t.line, w % (t.string, t.col, lines[t.line])))
def check_keyword_spacing(tokens, lines, warnings): "Check for missing spaces after for, while, etc." keywlist = 'if', 'for', 'while', 'switch' keywords = dict([(x, 1) for x in keywlist]) for t in tokens: if t.typ != Token.ident or t.string not in keywords: continue succ = tokens[i+1] if succ.line == t.line and t.end == succ.col: w = 'Missing space after `%s\' (col %d): %s' warnings.append((t.line, w % (t.string, t.col, lines[t.line])))
6,003
def check_keyword_spacing(tokens, lines, warnings): "Check for missing spaces after for, while, etc." keywlist = 'if', 'for', 'while', 'switch' keywords = dict([(x, 1) for x in keywlist]) for i, t in enumerate(tokens): if t.typ != Token.ident or t.string not in keywords: continue succ = tokens[i+1] if succ.line == t.line and t.end == succ.col: w = 'Missing space after `%s\' (col %d): %s' warnings.append((t.line, w % (t.string, t.col, lines[t.line])))
def check_keyword_spacing(tokens, lines, warnings): "Check for missing spaces after for, while, etc." keywlist = 'if', 'for', 'while', 'switch' keywords = dict([(x, 1) for x in keywlist]) for i, t in enumerate(tokens): if t.typ != Token.ident or t.string not in keywords: continue if t.succ.line == t.line and t.end == t.succ.col: w = 'Missing space after `%s\' (col %d): %s' warnings.append((t.line, w % (t.string, t.col, lines[t.line])))
6,004
def check_multistatements(tokens, lines, warnings): "Check for more than one statemen on one line" for i, t in enumerate(tokens): if t.typ != Token.punct or t.string != ';' or t.parenlevel > 0: continue try: succ = tokens[i+1] except IndexError: break if succ.line == t.line: w = 'More than one statement on a line (col %d): %s' warnings.append((t.line, w % (succ.col, lines[t.line])))
def check_multistatements(tokens, lines, warnings): "Check for more than one statemen on one line" for t in tokens: if t.typ != Token.punct or t.string != ';' or t.parenlevel > 0: continue try: succ = tokens[i+1] except IndexError: break if succ.line == t.line: w = 'More than one statement on a line (col %d): %s' warnings.append((t.line, w % (succ.col, lines[t.line])))
6,005
def check_multistatements(tokens, lines, warnings): "Check for more than one statemen on one line" for i, t in enumerate(tokens): if t.typ != Token.punct or t.string != ';' or t.parenlevel > 0: continue try: succ = tokens[i+1] except IndexError: break if succ.line == t.line: w = 'More than one statement on a line (col %d): %s' warnings.append((t.line, w % (succ.col, lines[t.line])))
def check_multistatements(tokens, lines, warnings): "Check for more than one statemen on one line" for i, t in enumerate(tokens): if t.typ != Token.punct or t.string != ';' or t.parenlevel > 0: continue if t.succ.line == t.line: w = 'More than one statement on a line (col %d): %s' warnings.append((t.line, w % (succ.col, lines[t.line])))
6,006
def check_multistatements(tokens, lines, warnings): "Check for more than one statemen on one line" for i, t in enumerate(tokens): if t.typ != Token.punct or t.string != ';' or t.parenlevel > 0: continue try: succ = tokens[i+1] except IndexError: break if succ.line == t.line: w = 'More than one statement on a line (col %d): %s' warnings.append((t.line, w % (succ.col, lines[t.line])))
def check_multistatements(tokens, lines, warnings): "Check for more than one statemen on one line" for i, t in enumerate(tokens): if t.typ != Token.punct or t.string != ';' or t.parenlevel > 0: continue try: succ = tokens[i+1] except IndexError: break if succ.line == t.line: w = 'More than one statement on a line (col %d): %s' warnings.append((t.line, w % (t.succ.col, lines[t.line])))
6,007
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for i, t in enumerate(tokens): if t.typ != Token.ident: continue if t.string == 'else': succ = tokens[i+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[i+2] if succ.line > t.line: continue if succ.typ == Token.ident and succ.string == 'if': continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue if t.string in ('for', 'while', 'if'): # catch do-while if t.string == 'while': prec = tokens[i-1] if prec.typ == Token.punct and prec.string == '}': prec = tokens[prec.matching-1] if prec.typ == Token.ident and prec.string == 'do': continue succ = tokens[i+1] assert succ.typ == Token.punct and succ.string == '(' m = succ.matching succ = tokens[m+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[m+2] if succ.line > tokens[m].line: continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for t in tokens: if t.typ != Token.ident: continue if t.string == 'else': succ = tokens[i+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[i+2] if succ.line > t.line: continue if succ.typ == Token.ident and succ.string == 'if': continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue if t.string in ('for', 'while', 'if'): # catch do-while if t.string == 'while': prec = tokens[i-1] if prec.typ == Token.punct and prec.string == '}': prec = tokens[prec.matching-1] if prec.typ == Token.ident and prec.string == 'do': continue succ = tokens[i+1] assert succ.typ == Token.punct and succ.string == '(' m = succ.matching succ = tokens[m+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[m+2] if succ.line > tokens[m].line: continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue
6,008
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for i, t in enumerate(tokens): if t.typ != Token.ident: continue if t.string == 'else': succ = tokens[i+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[i+2] if succ.line > t.line: continue if succ.typ == Token.ident and succ.string == 'if': continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue if t.string in ('for', 'while', 'if'): # catch do-while if t.string == 'while': prec = tokens[i-1] if prec.typ == Token.punct and prec.string == '}': prec = tokens[prec.matching-1] if prec.typ == Token.ident and prec.string == 'do': continue succ = tokens[i+1] assert succ.typ == Token.punct and succ.string == '(' m = succ.matching succ = tokens[m+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[m+2] if succ.line > tokens[m].line: continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for i, t in enumerate(tokens): if t.typ != Token.ident: continue if t.string == 'else': succ = t.succ if succ.typ == Token.punct and succ.string == '{': succ = tokens[i+2] if succ.line > t.line: continue if succ.typ == Token.ident and succ.string == 'if': continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue if t.string in ('for', 'while', 'if'): # catch do-while if t.string == 'while': prec = tokens[i-1] if prec.typ == Token.punct and prec.string == '}': prec = tokens[prec.matching-1] if prec.typ == Token.ident and prec.string == 'do': continue succ = t.succ assert succ.typ == Token.punct and succ.string == '(' m = succ.matching succ = tokens[m+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[m+2] if succ.line > tokens[m].line: continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue
6,009
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for i, t in enumerate(tokens): if t.typ != Token.ident: continue if t.string == 'else': succ = tokens[i+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[i+2] if succ.line > t.line: continue if succ.typ == Token.ident and succ.string == 'if': continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue if t.string in ('for', 'while', 'if'): # catch do-while if t.string == 'while': prec = tokens[i-1] if prec.typ == Token.punct and prec.string == '}': prec = tokens[prec.matching-1] if prec.typ == Token.ident and prec.string == 'do': continue succ = tokens[i+1] assert succ.typ == Token.punct and succ.string == '(' m = succ.matching succ = tokens[m+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[m+2] if succ.line > tokens[m].line: continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for i, t in enumerate(tokens): if t.typ != Token.ident: continue if t.string == 'else': succ = tokens[i+1] if succ.typ == Token.punct and succ.string == '{': succ = succ.succ if succ.line > t.line: continue if succ.typ == Token.ident and succ.string == 'if': continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue if t.string in ('for', 'while', 'if'): # catch do-while if t.string == 'while': prec = tokens[i-1] if prec.typ == Token.punct and prec.string == '}': prec = tokens[prec.matching-1] if prec.typ == Token.ident and prec.string == 'do': continue succ = tokens[i+1] assert succ.typ == Token.punct and succ.string == '(' m = succ.matching succ = tokens[m+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[m+2] if succ.line > tokens[m].line: continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue
6,010
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for i, t in enumerate(tokens): if t.typ != Token.ident: continue if t.string == 'else': succ = tokens[i+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[i+2] if succ.line > t.line: continue if succ.typ == Token.ident and succ.string == 'if': continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue if t.string in ('for', 'while', 'if'): # catch do-while if t.string == 'while': prec = tokens[i-1] if prec.typ == Token.punct and prec.string == '}': prec = tokens[prec.matching-1] if prec.typ == Token.ident and prec.string == 'do': continue succ = tokens[i+1] assert succ.typ == Token.punct and succ.string == '(' m = succ.matching succ = tokens[m+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[m+2] if succ.line > tokens[m].line: continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for i, t in enumerate(tokens): if t.typ != Token.ident: continue if t.string == 'else': succ = tokens[i+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[i+2] if succ.line > t.line: continue if succ.typ == Token.ident and succ.string == 'if': continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue if t.string in ('for', 'while', 'if'): # catch do-while if t.string == 'while': prec = t.prec if prec.typ == Token.punct and prec.string == '}': prec = tokens[prec.matching-1] if prec.typ == Token.ident and prec.string == 'do': continue succ = tokens[i+1] assert succ.typ == Token.punct and succ.string == '(' m = succ.matching succ = tokens[m+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[m+2] if succ.line > tokens[m].line: continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue
6,011
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for i, t in enumerate(tokens): if t.typ != Token.ident: continue if t.string == 'else': succ = tokens[i+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[i+2] if succ.line > t.line: continue if succ.typ == Token.ident and succ.string == 'if': continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue if t.string in ('for', 'while', 'if'): # catch do-while if t.string == 'while': prec = tokens[i-1] if prec.typ == Token.punct and prec.string == '}': prec = tokens[prec.matching-1] if prec.typ == Token.ident and prec.string == 'do': continue succ = tokens[i+1] assert succ.typ == Token.punct and succ.string == '(' m = succ.matching succ = tokens[m+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[m+2] if succ.line > tokens[m].line: continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for i, t in enumerate(tokens): if t.typ != Token.ident: continue if t.string == 'else': succ = tokens[i+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[i+2] if succ.line > t.line: continue if succ.typ == Token.ident and succ.string == 'if': continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue if t.string in ('for', 'while', 'if'): # catch do-while if t.string == 'while': prec = tokens[i-1] if prec.typ == Token.punct and prec.string == '}': prec = prec.matching.prec if prec.typ == Token.ident and prec.string == 'do': continue succ = tokens[i+1] assert succ.typ == Token.punct and succ.string == '(' m = succ.matching succ = tokens[m+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[m+2] if succ.line > tokens[m].line: continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue
6,012
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for i, t in enumerate(tokens): if t.typ != Token.ident: continue if t.string == 'else': succ = tokens[i+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[i+2] if succ.line > t.line: continue if succ.typ == Token.ident and succ.string == 'if': continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue if t.string in ('for', 'while', 'if'): # catch do-while if t.string == 'while': prec = tokens[i-1] if prec.typ == Token.punct and prec.string == '}': prec = tokens[prec.matching-1] if prec.typ == Token.ident and prec.string == 'do': continue succ = tokens[i+1] assert succ.typ == Token.punct and succ.string == '(' m = succ.matching succ = tokens[m+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[m+2] if succ.line > tokens[m].line: continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for i, t in enumerate(tokens): if t.typ != Token.ident: continue if t.string == 'else': succ = tokens[i+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[i+2] if succ.line > t.line: continue if succ.typ == Token.ident and succ.string == 'if': continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue if t.string in ('for', 'while', 'if'): # catch do-while if t.string == 'while': prec = tokens[i-1] if prec.typ == Token.punct and prec.string == '}': prec = tokens[prec.matching-1] if prec.typ == Token.ident and prec.string == 'do': continue succ = t.succ if succ.typ != Token.punct or succ.string != '(': continue m = succ.matching succ = tokens[m+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[m+2] if succ.line > tokens[m].line: continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue
6,013
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for i, t in enumerate(tokens): if t.typ != Token.ident: continue if t.string == 'else': succ = tokens[i+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[i+2] if succ.line > t.line: continue if succ.typ == Token.ident and succ.string == 'if': continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue if t.string in ('for', 'while', 'if'): # catch do-while if t.string == 'while': prec = tokens[i-1] if prec.typ == Token.punct and prec.string == '}': prec = tokens[prec.matching-1] if prec.typ == Token.ident and prec.string == 'do': continue succ = tokens[i+1] assert succ.typ == Token.punct and succ.string == '(' m = succ.matching succ = tokens[m+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[m+2] if succ.line > tokens[m].line: continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for i, t in enumerate(tokens): if t.typ != Token.ident: continue if t.string == 'else': succ = tokens[i+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[i+2] if succ.line > t.line: continue if succ.typ == Token.ident and succ.string == 'if': continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue if t.string in ('for', 'while', 'if'): # catch do-while if t.string == 'while': prec = tokens[i-1] if prec.typ == Token.punct and prec.string == '}': prec = tokens[prec.matching-1] if prec.typ == Token.ident and prec.string == 'do': continue succ = tokens[i+1] assert succ.typ == Token.punct and succ.string == '(' m = succ.matching succ = m.succ if succ.typ == Token.punct and succ.string == '{': succ = tokens[m+2] if succ.line > tokens[m].line: continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue
6,014
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for i, t in enumerate(tokens): if t.typ != Token.ident: continue if t.string == 'else': succ = tokens[i+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[i+2] if succ.line > t.line: continue if succ.typ == Token.ident and succ.string == 'if': continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue if t.string in ('for', 'while', 'if'): # catch do-while if t.string == 'while': prec = tokens[i-1] if prec.typ == Token.punct and prec.string == '}': prec = tokens[prec.matching-1] if prec.typ == Token.ident and prec.string == 'do': continue succ = tokens[i+1] assert succ.typ == Token.punct and succ.string == '(' m = succ.matching succ = tokens[m+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[m+2] if succ.line > tokens[m].line: continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue
def check_oneliners(tokens, lines, warnings): "Check for if, else, statements on the same line." for i, t in enumerate(tokens): if t.typ != Token.ident: continue if t.string == 'else': succ = tokens[i+1] if succ.typ == Token.punct and succ.string == '{': succ = tokens[i+2] if succ.line > t.line: continue if succ.typ == Token.ident and succ.string == 'if': continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue if t.string in ('for', 'while', 'if'): # catch do-while if t.string == 'while': prec = tokens[i-1] if prec.typ == Token.punct and prec.string == '}': prec = tokens[prec.matching-1] if prec.typ == Token.ident and prec.string == 'do': continue succ = tokens[i+1] assert succ.typ == Token.punct and succ.string == '(' m = succ.matching succ = tokens[m+1] if succ.typ == Token.punct and succ.string == '{': succ = succ.succ if succ.line > m.line: continue w = 'Statement for `%s\' on the same line (col %d): %s' warnings.append((succ.line, w % (t.string, succ.col, lines[succ.line]))) continue
6,015
def check_eol_operators(tokens, lines, warnings): "Check for operators on the end of line." # XXX: don't check `=', not always sure about the style oplist = '&&', '||', '+', '-', '*', '/', '%', '|', '&', '^', \ '==', '!=', '<', '>', '<=', '>=', '?' #, '=' operators = dict([(x, 1) for x in oplist]) for i, t in enumerate(tokens): if t.bracelevel == 0: continue if t.typ != Token.punct or t.string not in operators: continue if t.line == tokens[i+1].line: continue w = 'Line ends with an operator `%s\' (col %d): %s' warnings.append((t.line, w % (t.string, t.col, lines[t.line])))
def check_eol_operators(tokens, lines, warnings): "Check for operators on the end of line." # XXX: don't check `=', not always sure about the style oplist = '&&', '||', '+', '-', '*', '/', '%', '|', '&', '^', \ '==', '!=', '<', '>', '<=', '>=', '?' #, '=' operators = dict([(x, 1) for x in oplist]) for t in tokens: if t.bracelevel == 0: continue if t.typ != Token.punct or t.string not in operators: continue if t.line == tokens[i+1].line: continue w = 'Line ends with an operator `%s\' (col %d): %s' warnings.append((t.line, w % (t.string, t.col, lines[t.line])))
6,016
def check_eol_operators(tokens, lines, warnings): "Check for operators on the end of line." # XXX: don't check `=', not always sure about the style oplist = '&&', '||', '+', '-', '*', '/', '%', '|', '&', '^', \ '==', '!=', '<', '>', '<=', '>=', '?' #, '=' operators = dict([(x, 1) for x in oplist]) for i, t in enumerate(tokens): if t.bracelevel == 0: continue if t.typ != Token.punct or t.string not in operators: continue if t.line == tokens[i+1].line: continue w = 'Line ends with an operator `%s\' (col %d): %s' warnings.append((t.line, w % (t.string, t.col, lines[t.line])))
def check_eol_operators(tokens, lines, warnings): "Check for operators on the end of line." # XXX: don't check `=', not always sure about the style oplist = '&&', '||', '+', '-', '*', '/', '%', '|', '&', '^', \ '==', '!=', '<', '>', '<=', '>=', '?' #, '=' operators = dict([(x, 1) for x in oplist]) for i, t in enumerate(tokens): if t.bracelevel == 0: continue if t.typ != Token.punct or t.string not in operators: continue if t.line == t.succ.line: continue w = 'Line ends with an operator `%s\' (col %d): %s' warnings.append((t.line, w % (t.string, t.col, lines[t.line])))
6,017
def check_function_call_spaces(tokens, lines, warnings): "Check for function calls having the silly GNU spaces before (." keywlist = 'if', 'for', 'while', 'switch', 'return', 'case', 'goto' keywords = dict([(x, 1) for x in keywlist]) for i, t in enumerate(tokens): if t.bracelevel == 0: continue if t.typ != Token.punct or t.string != '(': continue prec = tokens[i-1] if prec.typ != Token.ident or prec.string in keywords: continue if prec.line == t.line and prec.end == t.col: continue m = t.matching if tokens[m+1].typ == Token.punct and tokens[m+1].string == '(': continue w = 'Space between function name and parenthesis (col %d): %s' warnings.append((t.line, w % (t.col, lines[t.line])))
def check_function_call_spaces(tokens, lines, warnings): "Check for function calls having the silly GNU spaces before (." keywlist = 'if', 'for', 'while', 'switch', 'return', 'case', 'goto' keywords = dict([(x, 1) for x in keywlist]) for t in tokens: if t.bracelevel == 0: continue if t.typ != Token.punct or t.string != '(': continue prec = tokens[i-1] if prec.typ != Token.ident or prec.string in keywords: continue if prec.line == t.line and prec.end == t.col: continue m = t.matching if tokens[m+1].typ == Token.punct and tokens[m+1].string == '(': continue w = 'Space between function name and parenthesis (col %d): %s' warnings.append((t.line, w % (t.col, lines[t.line])))
6,018
def check_function_call_spaces(tokens, lines, warnings): "Check for function calls having the silly GNU spaces before (." keywlist = 'if', 'for', 'while', 'switch', 'return', 'case', 'goto' keywords = dict([(x, 1) for x in keywlist]) for i, t in enumerate(tokens): if t.bracelevel == 0: continue if t.typ != Token.punct or t.string != '(': continue prec = tokens[i-1] if prec.typ != Token.ident or prec.string in keywords: continue if prec.line == t.line and prec.end == t.col: continue m = t.matching if tokens[m+1].typ == Token.punct and tokens[m+1].string == '(': continue w = 'Space between function name and parenthesis (col %d): %s' warnings.append((t.line, w % (t.col, lines[t.line])))
def check_function_call_spaces(tokens, lines, warnings): "Check for function calls having the silly GNU spaces before (." keywlist = 'if', 'for', 'while', 'switch', 'return', 'case', 'goto' keywords = dict([(x, 1) for x in keywlist]) for i, t in enumerate(tokens): if t.bracelevel == 0: continue if t.typ != Token.punct or t.string != '(': continue prec = t.prec if prec.typ != Token.ident or prec.string in keywords: continue if prec.line == t.line and prec.end == t.col: continue m = t.matching if tokens[m+1].typ == Token.punct and tokens[m+1].string == '(': continue w = 'Space between function name and parenthesis (col %d): %s' warnings.append((t.line, w % (t.col, lines[t.line])))
6,019
def check_function_call_spaces(tokens, lines, warnings): "Check for function calls having the silly GNU spaces before (." keywlist = 'if', 'for', 'while', 'switch', 'return', 'case', 'goto' keywords = dict([(x, 1) for x in keywlist]) for i, t in enumerate(tokens): if t.bracelevel == 0: continue if t.typ != Token.punct or t.string != '(': continue prec = tokens[i-1] if prec.typ != Token.ident or prec.string in keywords: continue if prec.line == t.line and prec.end == t.col: continue m = t.matching if tokens[m+1].typ == Token.punct and tokens[m+1].string == '(': continue w = 'Space between function name and parenthesis (col %d): %s' warnings.append((t.line, w % (t.col, lines[t.line])))
def check_function_call_spaces(tokens, lines, warnings): "Check for function calls having the silly GNU spaces before (." keywlist = 'if', 'for', 'while', 'switch', 'return', 'case', 'goto' keywords = dict([(x, 1) for x in keywlist]) for i, t in enumerate(tokens): if t.bracelevel == 0: continue if t.typ != Token.punct or t.string != '(': continue prec = tokens[i-1] if prec.typ != Token.ident or prec.string in keywords: continue if prec.line == t.line and prec.end == t.col or prec.line < t.line: continue m = t.matching.succ if m.typ == Token.punct and m.string == '(': continue w = 'Space between function name and parenthesis (col %d): %s' warnings.append((t.line, w % (t.col, lines[t.line])))
6,020
def check_return_case_parentheses(tokens, lines, warnings): keywlist = 'return', 'case', 'goto' keywords = dict([(x, 1) for x in keywlist]) for i, t in enumerate(tokens): if t.typ != Token.punct or t.string != '(': continue if not i or tokens[i-1].string not in keywords: continue w = 'Extra return/case/goto parentheses (col %d)' warnings.append((t.line, w % (t.col)))
def check_return_case_parentheses(tokens, lines, warnings): keywlist = 'return', 'case', 'goto' keywords = dict([(x, 1) for x in keywlist]) for t in tokens: if t.typ != Token.punct or t.string != '(': continue if not i or tokens[i-1].string not in keywords: continue w = 'Extra return/case/goto parentheses (col %d)' warnings.append((t.line, w % (t.col)))
6,021
def check_return_case_parentheses(tokens, lines, warnings): keywlist = 'return', 'case', 'goto' keywords = dict([(x, 1) for x in keywlist]) for i, t in enumerate(tokens): if t.typ != Token.punct or t.string != '(': continue if not i or tokens[i-1].string not in keywords: continue w = 'Extra return/case/goto parentheses (col %d)' warnings.append((t.line, w % (t.col)))
def check_return_case_parentheses(tokens, lines, warnings): keywlist = 'return', 'case', 'goto' keywords = dict([(x, 1) for x in keywlist]) for i, t in enumerate(tokens): if t.typ != Token.punct or t.string != '(': continue if t.prec.string not in keywords: continue if t.matching.succ.typ != Token.punct or t.matching.succ.string != ';': continue w = 'Extra return/case/goto parentheses (col %d)' warnings.append((t.line, w % (t.col)))
6,022
def check_boolean_comparisons(tokens, lines, warnings): keywlist = 'TRUE', 'FALSE' keywords = dict([(x, 1) for x in keywlist]) for i, t in enumerate(tokens): if not i or tokens[i].string not in keywords: continue if tokens[i-1].typ != Token.punct or (tokens[i-1].string != '!=' and tokens[i-1].string != '=='): continue w = 'Comparison to TRUE or FALSE (col %d)' warnings.append((t.line, w % (t.col)))
def check_boolean_comparisons(tokens, lines, warnings): keywlist = 'TRUE', 'FALSE' keywords = dict([(x, 1) for x in keywlist]) for t in tokens: if t.string not in keywords: continue prec = t.prec if prec.typ != Token.punct or (prec.string != '!=' and prec.string != '=='): continue w = 'Comparison to TRUE or FALSE (col %d)' warnings.append((t.line, w % (t.col)))
6,023
def find_matching_parentheses(tokens): "Add `matching' attribute to each token that is a parenthesis." pairs = {'}': '{', ')': '(', ']': '['} stacks = {'{': [], '(': [], '[': []} for i, t in enumerate(tokens): if t.string in pairs: p = stacks[pairs[t.string]].pop() t.matching = p tokens[p].matching = i t.parenlevel = len(stacks['(']) t.bracelevel = len(stacks['{']) if t.string in stacks: stacks[t.string].append(i)
def find_matching_parentheses(tokens): "Add `matching' attribute to each token that is a parenthesis." pairs = {'}': '{', ')': '(', ']': '['} stacks = {'{': [], '(': [], '[': []} for i, t in enumerate(tokens): if t.string in pairs: p = stacks[pairs[t.string]].pop() t.matching = p p.matching = t t.parenlevel = len(stacks['(']) t.bracelevel = len(stacks['{']) if t.string in stacks: stacks[t.string].append(i)
6,024
def find_matching_parentheses(tokens): "Add `matching' attribute to each token that is a parenthesis." pairs = {'}': '{', ')': '(', ']': '['} stacks = {'{': [], '(': [], '[': []} for i, t in enumerate(tokens): if t.string in pairs: p = stacks[pairs[t.string]].pop() t.matching = p tokens[p].matching = i t.parenlevel = len(stacks['(']) t.bracelevel = len(stacks['{']) if t.string in stacks: stacks[t.string].append(i)
def find_matching_parentheses(tokens): "Add `matching' attribute to each token that is a parenthesis." pairs = {'}': '{', ')': '(', ']': '['} stacks = {'{': [], '(': [], '[': []} for i, t in enumerate(tokens): if t.string in pairs: p = stacks[pairs[t.string]].pop() t.matching = p tokens[p].matching = i t.parenlevel = len(stacks['(']) t.bracelevel = len(stacks['{']) if t.string in stacks: stacks[t.string].append(t)
6,025
def tokenize(lines): "`Parse' a C file returning a sequence of Tokens" re_com = re.compile(r'/\*.*?\*/|//.*') re_mac = re.compile(r'#.*') re_str = re.compile(r'"([^\\"]+|\\"|\\[^"])*"') re_chr = re.compile(r'\'(?:.|\\.|\\[0-7]{3}|\\x[0-9a-f]{2})\'') re_id = re.compile(r'\b[A-Za-z_]\w*\b') # this eats some integers too re_dbl = re.compile(r'\b(\d*\.\d+|\d+\.?)(?:[Ee][-+]?\d+)?\b') re_int = re.compile(r'\b(?:0[xX][a-fA-F0-9]+|0[0-7]+|[-+]?\d+)[LU]*\b') re_eq = re.compile(r'(?:[-+*%/&|!<>=^]|&&|>>|<<|\|\|)?=') re_grp = re.compile(r'&&|<<|>>|->|::|\.\*|->\*|\|\|') re_sin = re.compile(r'[][(){};:?,.+~!%^&*|/^<>]|-') re_tokens = re_com, re_str, re_chr, re_id, re_dbl, re_int, \ re_eq, re_grp, re_sin token_ids = { re_com: 0, re_str: Token.string, re_chr: Token.char, re_id: Token.ident, re_dbl: Token.double, re_int: Token.integer, re_eq: Token.punct, re_grp: Token.punct, re_sin: Token.punct } tokens = [] in_comment = False in_macro = False for i, l in enumerate(lines): l, col = blstrip(l, 0) # special processing when we are inside a multiline comment or macro if in_comment: base = l.find('*/') if base == -1: continue l = l[base+2:] col += base+2 l, col = blstrip(l, col) in_comment = False elif in_macro: in_macro = l.endswith('\\') continue elif l.startswith('#'): if l.endswith('\\'): in_macro = True continue while l: if l.startswith('/*') and l.find('*/') == -1: in_comment = True break for r in re_tokens: m = r.match(l) if m: if token_ids[r]: tokens.append(Token(i, col, token_ids[r], m.group())) col += m.end() l, col = blstrip(l[m.end():], col) break if not m: sys.stderr.write('*** ERROR: Completely ugly code ' + '(trying to sync): %s\n' % l) l = '' return tokens
def tokenize(lines): "`Parse' a C file returning a sequence of Tokens" re_com = re.compile(r'/\*.*?\*/|//.*') re_mac = re.compile(r'#.*') re_str = re.compile(r'"([^\\"]+|\\"|\\[^"])*"') re_chr = re.compile(r'\'(?:.|\\.|\\[0-7]{3}|\\x[0-9a-f]{2})\'') re_id = re.compile(r'\b[A-Za-z_]\w*\b') # this eats some integers too re_dbl = re.compile(r'\b(\d*\.\d+|\d+\.?)(?:[Ee][-+]?\d+)?[FfLl]?\b') re_int = re.compile(r'\b(?:0[xX][a-fA-F0-9]+|0[0-7]+|[-+]?\d+)[LlUu]*\b') re_eq = re.compile(r'(?:[-+*%/&|!<>=^]|&&|>>|<<|\|\|)?=') re_grp = re.compile(r'&&|<<|>>|->|::|\.\*|->\*|\|\|') re_sin = re.compile(r'[][(){};:?,.+~!%^&*|/^<>]|-') re_tokens = re_com, re_str, re_chr, re_id, re_dbl, re_int, \ re_eq, re_grp, re_sin token_ids = { re_com: 0, re_str: Token.string, re_chr: Token.char, re_id: Token.ident, re_dbl: Token.double, re_int: Token.integer, re_eq: Token.punct, re_grp: Token.punct, re_sin: Token.punct } tokens = [] in_comment = False in_macro = False for i, l in enumerate(lines): l, col = blstrip(l, 0) # special processing when we are inside a multiline comment or macro if in_comment: base = l.find('*/') if base == -1: continue l = l[base+2:] col += base+2 l, col = blstrip(l, col) in_comment = False elif in_macro: in_macro = l.endswith('\\') continue elif l.startswith('#'): if l.endswith('\\'): in_macro = True continue while l: if l.startswith('/*') and l.find('*/') == -1: in_comment = True break for r in re_tokens: m = r.match(l) if m: if token_ids[r]: tokens.append(Token(i, col, token_ids[r], m.group())) col += m.end() l, col = blstrip(l[m.end():], col) break if not m: sys.stderr.write('*** ERROR: Completely ugly code ' + '(trying to sync): %s\n' % l) l = '' return tokens
6,026
def check_multistatements(tokens, lines, warnings): "Check for more than one statemen on one line" for t in tokens: if t.typ != Token.punct or t.string != ';' or t.parenlevel > 0: continue if t.succ.line == t.line: w = 'More than one statement on a line (col %d): %s' warnings.append((t.line, w % (t.succ.col, lines[t.line])))
def check_multistatements(tokens, lines, warnings): "Check for more than one statemen on one line" for t in tokens: if t.typ != Token.punct or t.string != ';' or t.parenlevel > 0: continue if t.succ and t.succ.line == t.line: w = 'More than one statement on a line (col %d): %s' warnings.append((t.line, w % (t.succ.col, lines[t.line])))
6,027
def update_documentation(images): """Update `documentation' in C source to list all stock icons.""" # Format documentation entries # Note the `../' in image path. It is here to undo the effect of content # files being XIncluded from xml/ subdirectory, therefore straight paths # get xml/ prepended to be relative to the driver file (as of 1.66.1 # stylesheets) -- which is exactly what we do NOT need. cfile = base + '.c' template = ('/**\n' ' * GWY_STOCK_%s\n' ' *\n' ' * The "%s" stock icon.\n' ' * <inlinegraphic fileref="../gwy_%s-%d.png" format="PNG"/>\n' ' **/\n' '\n') docs = [] for k, v in images.items(): k = re.sub(r'_1_1', '_1:1', k) words = k.split('_') for i in range(len(words)): # Heuristics: words without wovels are abbreviations if not re.search(r'[aeiouy]', words[i]): words[i] = words[i].upper() else: words[i] = words[i].title() human_name = '-'.join(words) if 24 in v: size = 24 else: size = max(v) docs.append(template % (k.upper(), human_name, k, size)) docs.sort() docs = ''.join(docs) replace_file(cfile, docs)
def update_documentation(images): """Update `documentation' in C source to list all stock icons.""" # Format documentation entries # Note the `../' in image path. It is here to undo the effect of content # files being XIncluded from xml/ subdirectory, therefore straight paths # get xml/ prepended to be relative to the driver file (as of 1.66.1 # stylesheets) -- which is exactly what we do NOT need. cfile = base + '.c' template = ('/**\n' ' * GWY_STOCK_%s\n' ' *\n' ' * The "%s" stock icon.\n' ' * <inlinegraphic fileref="../gwy_%s-%d.png" format="PNG"/>\n' ' **/\n' '\n') docs = [] for k, v in images.items(): words = re.sub(r'_1_1', '_1:1', k).split('_') for i in range(len(words)): # Heuristics: words without wovels are abbreviations if not re.search(r'[aeiouy]', words[i]): words[i] = words[i].upper() else: words[i] = words[i].title() human_name = '-'.join(words) if 24 in v: size = 24 else: size = max(v) docs.append(template % (k.upper(), human_name, k, size)) docs.sort() docs = ''.join(docs) replace_file(cfile, docs)
6,028
command -nargs=+ HiLink hi def link <args>
command -nargs=+ HiLink hi def link <args>
6,029
def _read_dfield(fh, data, base): c = fh.read(1) assert c == '[' dfield = {} _dmove(data, base + '/xres', dfield, 'xres', int) _dmove(data, base + '/yres', dfield, 'yres', int) _dmove(data, base + '/xreal', dfield, 'xreal', float) _dmove(data, base + '/yreal', dfield, 'yreal', float) _dmove(data, base + '/unit-xy', dfield, 'unit-xy') _dmove(data, base + '/unit-z', dfield, 'unit-z') a = _array.array('d') a.fromfile(fh, dfield['xres']*dfield['yres']) c = fh.readline() assert c == ']]\n' dfield['data'] = a data[base] = dfield
def _read_dfield(fh, data, base): c = fh.read(1) if not c: return False if c != '[': fh.seek(-1, 1) return False dfield = {} _dmove(data, base + '/xres', dfield, 'xres', int) _dmove(data, base + '/yres', dfield, 'yres', int) _dmove(data, base + '/xreal', dfield, 'xreal', float) _dmove(data, base + '/yreal', dfield, 'yreal', float) _dmove(data, base + '/unit-xy', dfield, 'unit-xy') _dmove(data, base + '/unit-z', dfield, 'unit-z') a = _array.array('d') a.fromfile(fh, dfield['xres']*dfield['yres']) c = fh.readline() assert c == ']]\n' dfield['data'] = a data[base] = dfield
6,030
def read(filename): """Read a Gwyddion plug-in proxy dump file. The file is returned as a dictionary of dump key, value pairs. Data fields are packed into dictionaries with following keys (not all has to be present): `xres', x-resolution (number of samples), `yres', y-resolution (number of samples), `xreal', real x size (in base SI units), `yreal', real y size (in base SI units), `unit-xy', lateral units (base SI, like `m'), `unit-z', value units (base SI, like `m' or `A'), `data', the data field data itself (array of floats). The `data' member is a raw array of floats (please see array module documentation). Exceptions, caused by fatal errors, are not handled -- it is up to caller to eventually handle them.""" line_re = _re.compile(r'^(?P<key>[^=]+)=(?P<val>.*)\n') field_re = _re.compile(r'^(?P<key>[^=]+)=\[\n') fh = file(filename, 'rb') data = {} while True: line = fh.readline() if not line: break m = field_re.match(line) if m: _read_dfield(fh, data, m.group('key')) continue m = line_re.match(line) if m: data[m.group('key')] = m.group('val') continue raise 'Can\'t understand input' fh.close() return data
def read(filename): """Read a Gwyddion plug-in proxy dump file. The file is returned as a dictionary of dump key, value pairs. Data fields are packed into dictionaries with following keys (not all has to be present): `xres', x-resolution (number of samples), `yres', y-resolution (number of samples), `xreal', real x size (in base SI units), `yreal', real y size (in base SI units), `unit-xy', lateral units (base SI, like `m'), `unit-z', value units (base SI, like `m' or `A'), `data', the data field data itself (array of floats). The `data' member is a raw array of floats (please see array module documentation). Exceptions, caused by fatal errors, are not handled -- it is up to caller to eventually handle them.""" line_re = _re.compile(r'^(?P<key>[^=]+)=(?P<val>.*)\n') field_re = _re.compile(r'^(?P<key>[^=]+)=\[\n') fh = file(filename, 'rb') data = {} while True: line = fh.readline() if not line: break m = field_re.match(line) if m and _read_dfield(fh, data, m.group('key')): continue m = line_re.match(line) if m: data[m.group('key')] = m.group('val') continue raise 'Can\'t understand input' fh.close() return data
6,031
def expand_template(makefile, name, supplementary=None): """Get expansion of specified template, taking information from Makefile. SELF: defines TOP_SRCDIR, LIBRARY, LIBDIR DATA: install-data rule, created from foo_DATA LIB_HEADERS: this variable, filled from lib_LTLIBRARIES, fooinclude_HEADERS LIB_OBJECTS: this variable, filled from lib_LTLIBRARIES, foo_SOURCES LIB_OBJ_RULES: .c -> .obj rules, filled from lib_LTLIBRARIES, foo_SOURCES PRG_OBJECTS: this variable, filled from bin_PROGRAMS, foo_SOURCES PRG_OBJ_RULES: .c -> .obj rules, filled from bin_PROGRAMS, foo_SOURCES MODULES: this variable, filled from foo_LTLIBRARIES MOD_OBJ_RULES: .c -> .obj rules, filled from foo_LTLIBRARIES, foo_SOURCES MOD_DLL_RULES: .obj -> .dll rules, filled from foo_LTLIBRARIES MO_INSTALL_RULES: installdirs and install-mo rules, filled from LINGUAS""" if name == 'SELF': if srcpath: srcdir = '\\'.join(['..'] * len(srcpath)) s = ['TOP_SRCDIR = ' + srcdir] else: s = ['TOP_SRCDIR = .'] libraries = fix_suffixes(get_list(makefile, 'lib_LTLIBRARIES'), '.la') if libraries: assert len(libraries) == 1 s.append('LIBDIR = ' + srcpath[-1]) l = libraries[0] s.append('LIBRARY = ' + l) return '\n'.join(s) elif name == 'DATA': lst = get_list(makefile, '\w+_DATA') list_part = name + ' =' + format_list(lst) inst_part = [('$(INSTALL) %s "$(DEST_DIR)\$(DATA_TYPE)"' % x) for x in lst] inst_part = '\n\t'.join(['install-data: data'] + inst_part) return list_part + '\n\n' + inst_part elif name == 'LIB_HEADERS': libraries = fix_suffixes(get_list(makefile, 'lib_LTLIBRARIES'), '.la') lst = [] for l in libraries: ul = underscorize(l) lst += get_list(makefile, '%sinclude_HEADERS' % ul) return name + ' =' + format_list(lst) elif name == 'LIB_OBJECTS': libraries = get_list(makefile, 'lib_LTLIBRARIES') lst = [] for l in libraries: ul = underscorize(l) lst += fix_suffixes(get_list(makefile, '%s_SOURCES' % ul), '.c', '.obj') return name + ' =' + format_list(lst) elif name == 'LIB_OBJ_RULES': libraries = get_list(makefile, 'lib_LTLIBRARIES') lst = [] for l in libraries: ul = underscorize(l) for x in fix_suffixes(get_list(makefile, '%s_SOURCES' % ul), '.c'): deps = format_list(get_file_deps(x, ul)) lst.append(object_rule % (x, deps, 'LIB', x)) return '\n'.join(lst) elif name == 'PRG_OBJECTS': programs = get_list(makefile, 'bin_PROGRAMS') lst = [] for p in programs: up = underscorize(p) lst += fix_suffixes(get_list(makefile, '%s_SOURCES' % up), '.c', '.obj') return name + ' =' + format_list(lst) elif name == 'PRG_OBJ_RULES': programs = get_list(makefile, 'bin_PROGRAMS') lst = [] for p in programs: up = underscorize(p) for x in fix_suffixes(get_list(makefile, '%s_SOURCES' % up), '.c'): deps = format_list(get_file_deps(x)) lst.append(object_rule % (x, deps, 'PRG', x)) return '\n'.join(lst) elif name == 'MODULES': mods = get_list(makefile, r'\w+_LTLIBRARIES') mods = expand_make_vars(mods, supplementary) mods = fix_suffixes(fix_suffixes(mods, '.la', '.dll'), ')', ').dll') return name + ' =' + format_list(mods) elif name == 'MOD_OBJ_RULES': mods = get_list(makefile, r'\w+_LTLIBRARIES') mods = expand_make_vars(mods, supplementary) lst = [] for m in mods: um = underscorize(m) for x in get_list(makefile, '%s_SOURCES' % um): # Ignore header files in SOURCES if not x.endswith('.c'): continue x = x[:-2] deps = format_list(get_file_deps(x, um)) lst.append(object_rule % (x, deps, 'MOD', x)) return '\n'.join(lst) elif name == 'MOD_DLL_RULES': mods = get_list(makefile, r'\w+_LTLIBRARIES') mods = expand_make_vars(mods, supplementary) mods = fix_suffixes(mods, '.la') lst = [] for m in mods: lst.append(mod_dll_rule % (m, m, m, m, m)) return '\n'.join(lst) elif name == 'MO_INSTALL_RULES': pos = [l.strip() for l in file('LINGUAS')] pos = [l for l in pos if l and not l.strip().startswith('#')] assert len(pos) == 1 pos = re.split(r'\s+', pos[0]) if not pos: return lst = ['installdirs:', '\t-@mkdir "$(DEST_DIR)\\locale"'] for p in pos: lst.append('\t-@mkdir "$(DEST_DIR)\\locale\\%s"' % p) lst.append('\t-@mkdir "$(DEST_DIR)\\locale\\%s\\LC_MESSAGES"' % p) lst.append('') lst.append('install-mo:') for p in pos: lst.append(mo_inst_rule % (p, p)) return '\n'.join(lst) print 'WARNING: Unknown template %s' % name return ''
def expand_template(makefile, name, supplementary=None): """Get expansion of specified template, taking information from Makefile. SELF: defines TOP_SRCDIR, LIBRARY, LIBDIR DATA: install-data rule, created from foo_DATA LIB_HEADERS: install rules, filled from lib_LTLIBRARIES, fooinclude_HEADERS LIB_OBJECTS: this variable, filled from lib_LTLIBRARIES, foo_SOURCES LIB_OBJ_RULES: .c -> .obj rules, filled from lib_LTLIBRARIES, foo_SOURCES PRG_OBJECTS: this variable, filled from bin_PROGRAMS, foo_SOURCES PRG_OBJ_RULES: .c -> .obj rules, filled from bin_PROGRAMS, foo_SOURCES MODULES: this variable, filled from foo_LTLIBRARIES MOD_OBJ_RULES: .c -> .obj rules, filled from foo_LTLIBRARIES, foo_SOURCES MOD_DLL_RULES: .obj -> .dll rules, filled from foo_LTLIBRARIES MO_INSTALL_RULES: installdirs and install-mo rules, filled from LINGUAS""" if name == 'SELF': if srcpath: srcdir = '\\'.join(['..'] * len(srcpath)) s = ['TOP_SRCDIR = ' + srcdir] else: s = ['TOP_SRCDIR = .'] libraries = fix_suffixes(get_list(makefile, 'lib_LTLIBRARIES'), '.la') if libraries: assert len(libraries) == 1 s.append('LIBDIR = ' + srcpath[-1]) l = libraries[0] s.append('LIBRARY = ' + l) return '\n'.join(s) elif name == 'DATA': lst = get_list(makefile, '\w+_DATA') list_part = name + ' =' + format_list(lst) inst_part = [('$(INSTALL) %s "$(DEST_DIR)\$(DATA_TYPE)"' % x) for x in lst] inst_part = '\n\t'.join(['install-data: data'] + inst_part) return list_part + '\n\n' + inst_part elif name == 'LIB_HEADERS': libraries = fix_suffixes(get_list(makefile, 'lib_LTLIBRARIES'), '.la') lst = [] for l in libraries: ul = underscorize(l) lst += get_list(makefile, '%sinclude_HEADERS' % ul) return name + ' =' + format_list(lst) elif name == 'LIB_OBJECTS': libraries = get_list(makefile, 'lib_LTLIBRARIES') lst = [] for l in libraries: ul = underscorize(l) lst += fix_suffixes(get_list(makefile, '%s_SOURCES' % ul), '.c', '.obj') return name + ' =' + format_list(lst) elif name == 'LIB_OBJ_RULES': libraries = get_list(makefile, 'lib_LTLIBRARIES') lst = [] for l in libraries: ul = underscorize(l) for x in fix_suffixes(get_list(makefile, '%s_SOURCES' % ul), '.c'): deps = format_list(get_file_deps(x, ul)) lst.append(object_rule % (x, deps, 'LIB', x)) return '\n'.join(lst) elif name == 'PRG_OBJECTS': programs = get_list(makefile, 'bin_PROGRAMS') lst = [] for p in programs: up = underscorize(p) lst += fix_suffixes(get_list(makefile, '%s_SOURCES' % up), '.c', '.obj') return name + ' =' + format_list(lst) elif name == 'PRG_OBJ_RULES': programs = get_list(makefile, 'bin_PROGRAMS') lst = [] for p in programs: up = underscorize(p) for x in fix_suffixes(get_list(makefile, '%s_SOURCES' % up), '.c'): deps = format_list(get_file_deps(x)) lst.append(object_rule % (x, deps, 'PRG', x)) return '\n'.join(lst) elif name == 'MODULES': mods = get_list(makefile, r'\w+_LTLIBRARIES') mods = expand_make_vars(mods, supplementary) mods = fix_suffixes(fix_suffixes(mods, '.la', '.dll'), ')', ').dll') return name + ' =' + format_list(mods) elif name == 'MOD_OBJ_RULES': mods = get_list(makefile, r'\w+_LTLIBRARIES') mods = expand_make_vars(mods, supplementary) lst = [] for m in mods: um = underscorize(m) for x in get_list(makefile, '%s_SOURCES' % um): # Ignore header files in SOURCES if not x.endswith('.c'): continue x = x[:-2] deps = format_list(get_file_deps(x, um)) lst.append(object_rule % (x, deps, 'MOD', x)) return '\n'.join(lst) elif name == 'MOD_DLL_RULES': mods = get_list(makefile, r'\w+_LTLIBRARIES') mods = expand_make_vars(mods, supplementary) mods = fix_suffixes(mods, '.la') lst = [] for m in mods: lst.append(mod_dll_rule % (m, m, m, m, m)) return '\n'.join(lst) elif name == 'MO_INSTALL_RULES': pos = [l.strip() for l in file('LINGUAS')] pos = [l for l in pos if l and not l.strip().startswith('#')] assert len(pos) == 1 pos = re.split(r'\s+', pos[0]) if not pos: return lst = ['installdirs:', '\t-@mkdir "$(DEST_DIR)\\locale"'] for p in pos: lst.append('\t-@mkdir "$(DEST_DIR)\\locale\\%s"' % p) lst.append('\t-@mkdir "$(DEST_DIR)\\locale\\%s\\LC_MESSAGES"' % p) lst.append('') lst.append('install-mo:') for p in pos: lst.append(mo_inst_rule % (p, p)) return '\n'.join(lst) print 'WARNING: Unknown template %s' % name return ''
6,032
def expand_template(makefile, name, supplementary=None): """Get expansion of specified template, taking information from Makefile. SELF: defines TOP_SRCDIR, LIBRARY, LIBDIR DATA: install-data rule, created from foo_DATA LIB_HEADERS: this variable, filled from lib_LTLIBRARIES, fooinclude_HEADERS LIB_OBJECTS: this variable, filled from lib_LTLIBRARIES, foo_SOURCES LIB_OBJ_RULES: .c -> .obj rules, filled from lib_LTLIBRARIES, foo_SOURCES PRG_OBJECTS: this variable, filled from bin_PROGRAMS, foo_SOURCES PRG_OBJ_RULES: .c -> .obj rules, filled from bin_PROGRAMS, foo_SOURCES MODULES: this variable, filled from foo_LTLIBRARIES MOD_OBJ_RULES: .c -> .obj rules, filled from foo_LTLIBRARIES, foo_SOURCES MOD_DLL_RULES: .obj -> .dll rules, filled from foo_LTLIBRARIES MO_INSTALL_RULES: installdirs and install-mo rules, filled from LINGUAS""" if name == 'SELF': if srcpath: srcdir = '\\'.join(['..'] * len(srcpath)) s = ['TOP_SRCDIR = ' + srcdir] else: s = ['TOP_SRCDIR = .'] libraries = fix_suffixes(get_list(makefile, 'lib_LTLIBRARIES'), '.la') if libraries: assert len(libraries) == 1 s.append('LIBDIR = ' + srcpath[-1]) l = libraries[0] s.append('LIBRARY = ' + l) return '\n'.join(s) elif name == 'DATA': lst = get_list(makefile, '\w+_DATA') list_part = name + ' =' + format_list(lst) inst_part = [('$(INSTALL) %s "$(DEST_DIR)\$(DATA_TYPE)"' % x) for x in lst] inst_part = '\n\t'.join(['install-data: data'] + inst_part) return list_part + '\n\n' + inst_part elif name == 'LIB_HEADERS': libraries = fix_suffixes(get_list(makefile, 'lib_LTLIBRARIES'), '.la') lst = [] for l in libraries: ul = underscorize(l) lst += get_list(makefile, '%sinclude_HEADERS' % ul) return name + ' =' + format_list(lst) elif name == 'LIB_OBJECTS': libraries = get_list(makefile, 'lib_LTLIBRARIES') lst = [] for l in libraries: ul = underscorize(l) lst += fix_suffixes(get_list(makefile, '%s_SOURCES' % ul), '.c', '.obj') return name + ' =' + format_list(lst) elif name == 'LIB_OBJ_RULES': libraries = get_list(makefile, 'lib_LTLIBRARIES') lst = [] for l in libraries: ul = underscorize(l) for x in fix_suffixes(get_list(makefile, '%s_SOURCES' % ul), '.c'): deps = format_list(get_file_deps(x, ul)) lst.append(object_rule % (x, deps, 'LIB', x)) return '\n'.join(lst) elif name == 'PRG_OBJECTS': programs = get_list(makefile, 'bin_PROGRAMS') lst = [] for p in programs: up = underscorize(p) lst += fix_suffixes(get_list(makefile, '%s_SOURCES' % up), '.c', '.obj') return name + ' =' + format_list(lst) elif name == 'PRG_OBJ_RULES': programs = get_list(makefile, 'bin_PROGRAMS') lst = [] for p in programs: up = underscorize(p) for x in fix_suffixes(get_list(makefile, '%s_SOURCES' % up), '.c'): deps = format_list(get_file_deps(x)) lst.append(object_rule % (x, deps, 'PRG', x)) return '\n'.join(lst) elif name == 'MODULES': mods = get_list(makefile, r'\w+_LTLIBRARIES') mods = expand_make_vars(mods, supplementary) mods = fix_suffixes(fix_suffixes(mods, '.la', '.dll'), ')', ').dll') return name + ' =' + format_list(mods) elif name == 'MOD_OBJ_RULES': mods = get_list(makefile, r'\w+_LTLIBRARIES') mods = expand_make_vars(mods, supplementary) lst = [] for m in mods: um = underscorize(m) for x in get_list(makefile, '%s_SOURCES' % um): # Ignore header files in SOURCES if not x.endswith('.c'): continue x = x[:-2] deps = format_list(get_file_deps(x, um)) lst.append(object_rule % (x, deps, 'MOD', x)) return '\n'.join(lst) elif name == 'MOD_DLL_RULES': mods = get_list(makefile, r'\w+_LTLIBRARIES') mods = expand_make_vars(mods, supplementary) mods = fix_suffixes(mods, '.la') lst = [] for m in mods: lst.append(mod_dll_rule % (m, m, m, m, m)) return '\n'.join(lst) elif name == 'MO_INSTALL_RULES': pos = [l.strip() for l in file('LINGUAS')] pos = [l for l in pos if l and not l.strip().startswith('#')] assert len(pos) == 1 pos = re.split(r'\s+', pos[0]) if not pos: return lst = ['installdirs:', '\t-@mkdir "$(DEST_DIR)\\locale"'] for p in pos: lst.append('\t-@mkdir "$(DEST_DIR)\\locale\\%s"' % p) lst.append('\t-@mkdir "$(DEST_DIR)\\locale\\%s\\LC_MESSAGES"' % p) lst.append('') lst.append('install-mo:') for p in pos: lst.append(mo_inst_rule % (p, p)) return '\n'.join(lst) print 'WARNING: Unknown template %s' % name return ''
def expand_template(makefile, name, supplementary=None): """Get expansion of specified template, taking information from Makefile. SELF: defines TOP_SRCDIR, LIBRARY, LIBDIR DATA: install-data rule, created from foo_DATA LIB_HEADERS: this variable, filled from lib_LTLIBRARIES, fooinclude_HEADERS LIB_OBJECTS: this variable, filled from lib_LTLIBRARIES, foo_SOURCES LIB_OBJ_RULES: .c -> .obj rules, filled from lib_LTLIBRARIES, foo_SOURCES PRG_OBJECTS: this variable, filled from bin_PROGRAMS, foo_SOURCES PRG_OBJ_RULES: .c -> .obj rules, filled from bin_PROGRAMS, foo_SOURCES MODULES: this variable, filled from foo_LTLIBRARIES MOD_OBJ_RULES: .c -> .obj rules, filled from foo_LTLIBRARIES, foo_SOURCES MOD_DLL_RULES: .obj -> .dll rules, filled from foo_LTLIBRARIES MO_INSTALL_RULES: installdirs and install-mo rules, filled from LINGUAS""" if name == 'SELF': if srcpath: srcdir = '\\'.join(['..'] * len(srcpath)) s = ['TOP_SRCDIR = ' + srcdir] else: s = ['TOP_SRCDIR = .'] libraries = fix_suffixes(get_list(makefile, 'lib_LTLIBRARIES'), '.la') if libraries: assert len(libraries) == 1 s.append('LIBDIR = ' + srcpath[-1]) l = libraries[0] s.append('LIBRARY = ' + l) return '\n'.join(s) elif name == 'DATA': lst = get_list(makefile, '\w+_DATA') list_part = name + ' =' + format_list(lst) inst_part = [('$(INSTALL) %s "$(DEST_DIR)\$(DATA_TYPE)"' % x) for x in lst] inst_part = '\n\t'.join(['install-data: data'] + inst_part) return list_part + '\n\n' + inst_part elif name == 'LIB_HEADERS': libraries = fix_suffixes(get_list(makefile, 'lib_LTLIBRARIES'), '.la') lst = [] for l in libraries: ul = underscorize(l) lst += get_list(makefile, '%sinclude_HEADERS' % ul) list_part = name + ' =' + format_list(lst) inst_part = [('$(INSTALL) %s "$(DEST_DIR)\include\$(LIBDIR)"' % x) for x in lst] inst_part = '\n\t'.join(['install-headers:'] + inst_part) return list_part + '\n\n' + inst_part elif name == 'LIB_OBJECTS': libraries = get_list(makefile, 'lib_LTLIBRARIES') lst = [] for l in libraries: ul = underscorize(l) lst += fix_suffixes(get_list(makefile, '%s_SOURCES' % ul), '.c', '.obj') list_part = name + ' =' + format_list(lst) inst_part = [('$(INSTALL) %s "$(DEST_DIR)\include\$(LIBDIR)"' % x) for x in lst] inst_part = '\n\t'.join(['install-headers:'] + inst_part) return list_part + '\n\n' + inst_part elif name == 'LIB_OBJ_RULES': libraries = get_list(makefile, 'lib_LTLIBRARIES') lst = [] for l in libraries: ul = underscorize(l) for x in fix_suffixes(get_list(makefile, '%s_SOURCES' % ul), '.c'): deps = format_list(get_file_deps(x, ul)) lst.append(object_rule % (x, deps, 'LIB', x)) return '\n'.join(lst) elif name == 'PRG_OBJECTS': programs = get_list(makefile, 'bin_PROGRAMS') lst = [] for p in programs: up = underscorize(p) lst += fix_suffixes(get_list(makefile, '%s_SOURCES' % up), '.c', '.obj') list_part = name + ' =' + format_list(lst) inst_part = [('$(INSTALL) %s "$(DEST_DIR)\include\$(LIBDIR)"' % x) for x in lst] inst_part = '\n\t'.join(['install-headers:'] + inst_part) return list_part + '\n\n' + inst_part elif name == 'PRG_OBJ_RULES': programs = get_list(makefile, 'bin_PROGRAMS') lst = [] for p in programs: up = underscorize(p) for x in fix_suffixes(get_list(makefile, '%s_SOURCES' % up), '.c'): deps = format_list(get_file_deps(x)) lst.append(object_rule % (x, deps, 'PRG', x)) return '\n'.join(lst) elif name == 'MODULES': mods = get_list(makefile, r'\w+_LTLIBRARIES') mods = expand_make_vars(mods, supplementary) mods = fix_suffixes(fix_suffixes(mods, '.la', '.dll'), ')', ').dll') return name + ' =' + format_list(mods) elif name == 'MOD_OBJ_RULES': mods = get_list(makefile, r'\w+_LTLIBRARIES') mods = expand_make_vars(mods, supplementary) lst = [] for m in mods: um = underscorize(m) for x in get_list(makefile, '%s_SOURCES' % um): # Ignore header files in SOURCES if not x.endswith('.c'): continue x = x[:-2] deps = format_list(get_file_deps(x, um)) lst.append(object_rule % (x, deps, 'MOD', x)) return '\n'.join(lst) elif name == 'MOD_DLL_RULES': mods = get_list(makefile, r'\w+_LTLIBRARIES') mods = expand_make_vars(mods, supplementary) mods = fix_suffixes(mods, '.la') lst = [] for m in mods: lst.append(mod_dll_rule % (m, m, m, m, m)) return '\n'.join(lst) elif name == 'MO_INSTALL_RULES': pos = [l.strip() for l in file('LINGUAS')] pos = [l for l in pos if l and not l.strip().startswith('#')] assert len(pos) == 1 pos = re.split(r'\s+', pos[0]) if not pos: return lst = ['installdirs:', '\t-@mkdir "$(DEST_DIR)\\locale"'] for p in pos: lst.append('\t-@mkdir "$(DEST_DIR)\\locale\\%s"' % p) lst.append('\t-@mkdir "$(DEST_DIR)\\locale\\%s\\LC_MESSAGES"' % p) lst.append('') lst.append('install-mo:') for p in pos: lst.append(mo_inst_rule % (p, p)) return '\n'.join(lst) print 'WARNING: Unknown template %s' % name return ''
6,033
def tokenize(lines): "`Parse' a C file returning a sequence of Tokens" re_com = re.compile(r'/\*.*?\*/|//.*') re_mac = re.compile(r'#.*') re_str = re.compile(r'"([^\\"]+|\\"|\\[^"])*"') re_chr = re.compile(r'\'(?:.|\\.|\\[0-7]{3}|\\x[0-9a-f]{2})\'') re_id = re.compile(r'\b[A-Za-z_]\w*\b') # this eats some integers too re_dbl = re.compile(r'\b(\d*\.\d+|\d+\.?)(?:[Ee][-+]?\d+)?[FfLl]?\b') re_int = re.compile(r'\b(?:0[xX][a-fA-F0-9]+|0[0-7]+|[-+]?\d+)[LlUu]*\b') re_eq = re.compile(r'(?:[-+*%/&|!<>=^]|&&|>>|<<|\|\|)?=') re_grp = re.compile(r'&&|<<|>>|->|::|\.\*|->\*|\|\|') re_sin = re.compile(r'[][(){};:?,.+~!%^&*|/^<>]|-') re_tokens = re_com, re_str, re_chr, re_id, re_dbl, re_int, \ re_eq, re_grp, re_sin token_ids = { re_com: 0, re_str: Token.string, re_chr: Token.char, re_id: Token.ident, re_dbl: Token.double, re_int: Token.integer, re_eq: Token.punct, re_grp: Token.punct, re_sin: Token.punct } tokens = [] in_comment = False in_macro = False for i, l in enumerate(lines): l, col = blstrip(l, 0) # special processing when we are inside a multiline comment or macro if in_comment: base = l.find('*/') if base == -1: continue l = l[base+2:] col += base+2 l, col = blstrip(l, col) in_comment = False elif in_macro: in_macro = l.endswith('\\') continue elif l.startswith('#'): if l.endswith('\\'): in_macro = True continue while l: if l.startswith('/*') and l.find('*/') == -1: in_comment = True break for r in re_tokens: m = r.match(l) if m: if token_ids[r]: tokens.append(Token(i, col, token_ids[r], m.group())) col += m.end() l, col = blstrip(l[m.end():], col) break if not m: sys.stderr.write('*** ERROR: Completely ugly code ' + '(trying to sync): %s\n' % l) l = '' # Make tokens a doubly linked list for i, t in enumerate(tokens): if i: t.prec = tokens[i-1] else: t.prec = None try: t.succ = tokens[i+1] except IndexError: t.succ = None return tokens
def tokenize(lines): "`Parse' a C file returning a sequence of Tokens" re_com = re.compile(r'/\*.*?\*/|//.*') re_mac = re.compile(r'#.*') re_str = re.compile(r'"([^\\"]+|\\"|\\[^"])*"') re_chr = re.compile(r'\'(?:.|\\.|\\[0-7]{3}|\\x[0-9a-f]{2})\'') re_id = re.compile(r'\b[A-Za-z_]\w*\b') # this eats some integers too re_dbl = re.compile(r'\b(\d*\.\d+|\d+\.?)(?:[Ee][-+]?\d+)?[FfLl]?\b') re_int = re.compile(r'\b(?:0[xX][a-fA-F0-9]+|0[0-7]+|[-+]?\d+)[LlUu]*\b') re_eq = re.compile(r'(?:[-+*%/&|!<>=^]|&&|>>|<<|\|\|)?=') re_grp = re.compile(r'&&|<<|>>|->|::|\.\*|->\*|\|\||\+\+|--|\*\*+|\.\.\.') re_sin = re.compile(r'[][(){};:?,.+~!%^&*|/^<>]|-') re_tokens = re_com, re_str, re_chr, re_id, re_dbl, re_int, \ re_eq, re_grp, re_sin token_ids = { re_com: 0, re_str: Token.string, re_chr: Token.char, re_id: Token.ident, re_dbl: Token.double, re_int: Token.integer, re_eq: Token.punct, re_grp: Token.punct, re_sin: Token.punct } tokens = [] in_comment = False in_macro = False for i, l in enumerate(lines): l, col = blstrip(l, 0) # special processing when we are inside a multiline comment or macro if in_comment: base = l.find('*/') if base == -1: continue l = l[base+2:] col += base+2 l, col = blstrip(l, col) in_comment = False elif in_macro: in_macro = l.endswith('\\') continue elif l.startswith('#'): if l.endswith('\\'): in_macro = True continue while l: if l.startswith('/*') and l.find('*/') == -1: in_comment = True break for r in re_tokens: m = r.match(l) if m: if token_ids[r]: tokens.append(Token(i, col, token_ids[r], m.group())) col += m.end() l, col = blstrip(l[m.end():], col) break if not m: sys.stderr.write('*** ERROR: Completely ugly code ' + '(trying to sync): %s\n' % l) l = '' # Make tokens a doubly linked list for i, t in enumerate(tokens): if i: t.prec = tokens[i-1] else: t.prec = None try: t.succ = tokens[i+1] except IndexError: t.succ = None return tokens
6,034
def expand_template(makefile, name): if name == 'DATA': lst = get_list(makefile, '\w+_DATA') list_part = name + ' =' + ' \\\n\t'.join([''] + lst) inst_part = [('$(INSTALL) %s "$(DEST_DIR)\$(DATA_TYPE)"' % x) for x in lst] inst_part = '\n\t'.join(['install-data: data'] + inst_part) return list_part + '\n\n' + inst_part elif name == 'LIB_HEADERS': libraries = fix_suffixes(get_list(makefile, 'lib_LTLIBRARIES'), '.la') lst = [] for l in libraries: l = re.sub(r'[^a-z0-9]', '_', l) lst += get_list(makefile, '%sinclude_HEADERS' % l) return name + ' =' + ' \\\n\t'.join([''] + lst) elif name == 'LIB_OBJECTS': libraries = get_list(makefile, 'lib_LTLIBRARIES') lst = [] for l in libraries: l = re.sub(r'[^a-z0-9]', '_', l) lst += fix_suffixes(get_list(makefile, '%s_SOURCES' % l), '.c', '.obj') return name + ' =' + ' \\\n\t'.join([''] + lst) elif name == 'PRG_OBJECTS': programs = get_list(makefile, 'bin_PROGRAMS') lst = [] for p in programs: p = re.sub(r'[^a-z0-9]', '_', p) lst += fix_suffixes(get_list(makefile, '%s_SOURCES' % p), '.c', '.obj') return name + ' =' + ' \\\n\t'.join([''] + lst) elif name == 'PRG_OBJECT_RULES': programs = get_list(makefile, 'bin_PROGRAMS') lst = [] for p in programs: p = re.sub(r'[^a-z0-9]', '_', p) for x in fix_suffixes(get_list(makefile, '%s_SOURCES' % p), '.c'): lst.append(prg_object_rule % (x, x, x)) return '\n'.join(lst) elif name == 'MODULES': mods = fix_suffixes(get_list(makefile, r'\w+_LTLIBRARIES'), '.la', '.dll') return name + ' =' + ' \\\n\t'.join([''] + mods) elif name == 'MOD_DLL_RULES': mods = fix_suffixes(get_list(makefile, r'\w+_LTLIBRARIES'), '.la') lst = [] for m in mods: lst.append(mod_dll_rule % (m, m, m, m, m)) return '\n'.join(lst) elif name == 'MO_INSTALL_RULES': pos = [l.strip() for l in file('LINGUAS')] pos = [l for l in pos if l and not l.strip().startswith('#')] assert len(pos) == 1 pos = re.split('\s+', pos[0]) if not pos: return lst = ['installdirs:', '\t-@mkdir "$(DEST_DIR)\\locale"'] for p in pos: lst.append('\t-@mkdir "$(DEST_DIR)\\locale\\%s"' % p) lst.append('\t-@mkdir "$(DEST_DIR)\\locale\\%s\\LC_MESSAGES"' % p) lst.append('') lst.append('install-mo:') for p in pos: lst.append(mo_inst_rule % (p, p)) return '\n'.join(lst) print '*** Unknown template %s ***' % name return ''
def expand_template(makefile, name): if name == 'DATA': lst = get_list(makefile, '\w+_DATA') list_part = name + ' =' + ' \\\n\t'.join([''] + lst) inst_part = [('$(INSTALL) %s "$(DEST_DIR)\data\$(DATA_TYPE)"' % x) for x in lst] inst_part = '\n\t'.join(['install-data: data'] + inst_part) return list_part + '\n\n' + inst_part elif name == 'LIB_HEADERS': libraries = fix_suffixes(get_list(makefile, 'lib_LTLIBRARIES'), '.la') lst = [] for l in libraries: l = re.sub(r'[^a-z0-9]', '_', l) lst += get_list(makefile, '%sinclude_HEADERS' % l) return name + ' =' + ' \\\n\t'.join([''] + lst) elif name == 'LIB_OBJECTS': libraries = get_list(makefile, 'lib_LTLIBRARIES') lst = [] for l in libraries: l = re.sub(r'[^a-z0-9]', '_', l) lst += fix_suffixes(get_list(makefile, '%s_SOURCES' % l), '.c', '.obj') return name + ' =' + ' \\\n\t'.join([''] + lst) elif name == 'PRG_OBJECTS': programs = get_list(makefile, 'bin_PROGRAMS') lst = [] for p in programs: p = re.sub(r'[^a-z0-9]', '_', p) lst += fix_suffixes(get_list(makefile, '%s_SOURCES' % p), '.c', '.obj') return name + ' =' + ' \\\n\t'.join([''] + lst) elif name == 'PRG_OBJECT_RULES': programs = get_list(makefile, 'bin_PROGRAMS') lst = [] for p in programs: p = re.sub(r'[^a-z0-9]', '_', p) for x in fix_suffixes(get_list(makefile, '%s_SOURCES' % p), '.c'): lst.append(prg_object_rule % (x, x, x)) return '\n'.join(lst) elif name == 'MODULES': mods = fix_suffixes(get_list(makefile, r'\w+_LTLIBRARIES'), '.la', '.dll') return name + ' =' + ' \\\n\t'.join([''] + mods) elif name == 'MOD_DLL_RULES': mods = fix_suffixes(get_list(makefile, r'\w+_LTLIBRARIES'), '.la') lst = [] for m in mods: lst.append(mod_dll_rule % (m, m, m, m, m)) return '\n'.join(lst) elif name == 'MO_INSTALL_RULES': pos = [l.strip() for l in file('LINGUAS')] pos = [l for l in pos if l and not l.strip().startswith('#')] assert len(pos) == 1 pos = re.split('\s+', pos[0]) if not pos: return lst = ['installdirs:', '\t-@mkdir "$(DEST_DIR)\\locale"'] for p in pos: lst.append('\t-@mkdir "$(DEST_DIR)\\locale\\%s"' % p) lst.append('\t-@mkdir "$(DEST_DIR)\\locale\\%s\\LC_MESSAGES"' % p) lst.append('') lst.append('install-mo:') for p in pos: lst.append(mo_inst_rule % (p, p)) return '\n'.join(lst) print '*** Unknown template %s ***' % name return ''
6,035
def DBPRINT(*args): print ' '.join(args)
def DBPRINT(*args): print ' '.join(args)
6,036
def _get_opener(self): """Build a urllib2 OpenerDirector based on request options.""" if self.opts.opener: return self.opts.opener elif self._opener is None: handlers = [] # if you specify a ProxyHandler when creating the opener # it _must_ come before all other handlers in the list or urllib2 # chokes. if self.opts.proxies: handlers.append( CachedProxyHandler(self.opts.proxies) )
def _get_opener(self): """Build a urllib2 OpenerDirector based on request options.""" if self.opts.opener: return self.opts.opener elif self._opener is None: handlers = [] # if you specify a ProxyHandler when creating the opener # it _must_ come before all other handlers in the list or urllib2 # chokes. if self.opts.proxies: handlers.append( CachedProxyHandler(self.opts.proxies) )
6,037
def _get_opener(self): """Build a urllib2 OpenerDirector based on request options.""" if self.opts.opener: return self.opts.opener elif self._opener is None: handlers = [] # if you specify a ProxyHandler when creating the opener # it _must_ come before all other handlers in the list or urllib2 # chokes. if self.opts.proxies: handlers.append( CachedProxyHandler(self.opts.proxies) )
def _get_opener(self): """Build a urllib2 OpenerDirector based on request options.""" if self.opts.opener: return self.opts.opener elif self._opener is None: handlers = [] # if you specify a ProxyHandler when creating the opener # it _must_ come before all other handlers in the list or urllib2 # chokes. if self.opts.proxies: handlers.append( CachedProxyHandler(self.opts.proxies) )
6,038
def _get_opener(self): """Build a urllib2 OpenerDirector based on request options.""" if self.opts.opener: return self.opts.opener elif self._opener is None: handlers = [] # if you specify a ProxyHandler when creating the opener # it _must_ come before all other handlers in the list or urllib2 # chokes. if self.opts.proxies: handlers.append( CachedProxyHandler(self.opts.proxies) )
def _get_opener(self): """Build a urllib2 OpenerDirector based on request options.""" if self.opts.opener: return self.opts.opener elif self._opener is None: handlers = [] # if you specify a ProxyHandler when creating the opener # it _must_ come before all other handlers in the list or urllib2 # chokes. if self.opts.proxies: handlers.append( CachedProxyHandler(self.opts.proxies) )
6,039
def setUp(self): self.url = ref_proftp try: fo = urllib2.urlopen(self.url).close() except IOError: raise self.skip()
def setUp(self): self.url = ref_proftp try: fo = urllib2.urlopen(self.url).close() except IOError: self.skip()
6,040
def range_tuple_to_header(range_tup): """Convert a range tuple to a Range header value. Return a string of the form "bytes=<firstbyte>-<lastbyte>". """ if range_tup is None: return None range_tup = range_tuple_normalize(range_tup) if range_tup: if range_tup[1]: range_tup = (range_tup[0],range_tup[1] - 1) return 'bytes=%s-%s' % range_tup
def range_tuple_to_header(range_tup): """Convert a range tuple to a Range header value. Return a string of the form "bytes=<firstbyte>-<lastbyte>" or None if no range is needed. """ if range_tup is None: return None range_tup = range_tuple_normalize(range_tup) if range_tup: if range_tup[1]: range_tup = (range_tup[0],range_tup[1] - 1) return 'bytes=%s-%s' % range_tup
6,041
def range_tuple_to_header(range_tup): """Convert a range tuple to a Range header value. Return a string of the form "bytes=<firstbyte>-<lastbyte>". """ if range_tup is None: return None range_tup = range_tuple_normalize(range_tup) if range_tup: if range_tup[1]: range_tup = (range_tup[0],range_tup[1] - 1) return 'bytes=%s-%s' % range_tup
def range_tuple_to_header(range_tup): """Convert a range tuple to a Range header value. Return a string of the form "bytes=<firstbyte>-<lastbyte>". """ if range_tup is None: return None range_tup = range_tuple_normalize(range_tup) if range_tup: if range_tup[1]: range_tup = (range_tup[0],range_tup[1] - 1) return 'bytes=%s-%s' % range_tup
6,042
def urlgrab(self, url, filename=None, **kwargs): """grab the file at <url> and make a local copy at <filename> If filename is none, the basename of the url is used. urlgrab returns the filename of the local file, which may be different from the passed-in filename if copy_local == 0. """ opts = self.opts.derive(**kwargs) (url, parts) = self._parse_url(url) (scheme, host, path, parm, query, frag) = parts if filename is None: filename = os.path.basename( path ) if scheme == 'file' and not opts.copy_local: # just return the name of the local file - don't make a # copy currently if not os.path.exists(path): raise URLGrabError(2, _('Local file does not exist: %s') % (path, )) elif not os.path.isfile(path): raise URLGrabError(3, _('Not a normal file: %s') % (path, )) elif not opts.range: return path def retryfunc(opts, url, filename): fo = URLGrabberFileObject(url, filename, opts) try: fo._do_grab() if not opts.checkfunc is None: cb_func, cb_args, cb_kwargs = \ self._make_callback(opts.checkfunc) obj = CallbackObject() obj.filename = filename obj.url = url apply(cb_func, (obj, )+cb_args, cb_kwargs) finally: fo.close() return filename return self._retry(opts, retryfunc, url, filename)
def urlgrab(self, url, filename=None, **kwargs): """grab the file at <url> and make a local copy at <filename> If filename is none, the basename of the url is used. urlgrab returns the filename of the local file, which may be different from the passed-in filename if copy_local == 0. """ opts = self.opts.derive(**kwargs) (url, parts) = self._parse_url(url) (scheme, host, path, parm, query, frag) = parts if filename is None: if scheme in [ 'http', 'https' ]: filename = os.path.basename( urllib.unquote(path) ) else: filename = os.path.basename( path ) if scheme == 'file' and not opts.copy_local: # just return the name of the local file - don't make a # copy currently if not os.path.exists(path): raise URLGrabError(2, _('Local file does not exist: %s') % (path, )) elif not os.path.isfile(path): raise URLGrabError(3, _('Not a normal file: %s') % (path, )) elif not opts.range: return path def retryfunc(opts, url, filename): fo = URLGrabberFileObject(url, filename, opts) try: fo._do_grab() if not opts.checkfunc is None: cb_func, cb_args, cb_kwargs = \ self._make_callback(opts.checkfunc) obj = CallbackObject() obj.filename = filename obj.url = url apply(cb_func, (obj, )+cb_args, cb_kwargs) finally: fo.close() return filename return self._retry(opts, retryfunc, url, filename)
6,043
def _fill_buffer(self, amt=None): """fill the buffer to contain at least 'amt' bytes by reading from the underlying file object. If amt is None, then it will read until it gets nothing more. It updates the progress meter and throttles after every self._rbufsize bytes.""" # the _rbuf test is only in this first 'if' for speed. It's not # logically necessary if self._rbuf and not amt is None: L = len(self._rbuf) if amt > L: amt = amt - L else: return
def _fill_buffer(self, amt=None): """fill the buffer to contain at least 'amt' bytes by reading from the underlying file object. If amt is None, then it will read until it gets nothing more. It updates the progress meter and throttles after every self._rbufsize bytes.""" # the _rbuf test is only in this first 'if' for speed. It's not # logically necessary if self._rbuf and not amt is None: L = len(self._rbuf) if amt > L: amt = amt - L else: return
6,044
def _make_request(self, req, opener): try: if have_socket_timeout and self.opts.timeout: old_to = socket.getdefaulttimeout() socket.setdefaulttimeout(self.opts.timeout) try: fo = opener.open(req) finally: socket.setdefaulttimeout(old_to) else: fo = opener.open(req) hdr = fo.info() except ValueError, e: raise URLGrabError(1, _('Bad URL: %s') % (e, )) except RangeError, e: raise URLGrabError(9, _('%s') % (e, )) except IOError, e: if isinstance(e.reason, TimeoutError): raise URLGrabError(12, _('Timeout: %s') % (e, )) else: raise URLGrabError(4, _('IOError: %s') % (e, )) except OSError, e: raise URLGrabError(5, _('OSError: %s') % (e, )) except HTTPException, e: raise URLGrabError(7, _('HTTP Error (%s): %s') % \ (e.__class__.__name__, e)) else: return (fo, hdr)
def _make_request(self, req, opener): try: if have_socket_timeout and self.opts.timeout: old_to = socket.getdefaulttimeout() socket.setdefaulttimeout(self.opts.timeout) try: fo = opener.open(req) finally: socket.setdefaulttimeout(old_to) else: fo = opener.open(req) hdr = fo.info() except ValueError, e: raise URLGrabError(1, _('Bad URL: %s') % (e, )) except RangeError, e: raise URLGrabError(9, _('%s') % (e, )) except IOError, e: if hasattr(e, 'reason') and isinstance(e.reason, TimeoutError): raise URLGrabError(12, _('Timeout: %s') % (e, )) else: raise URLGrabError(4, _('IOError: %s') % (e, )) except OSError, e: raise URLGrabError(5, _('OSError: %s') % (e, )) except HTTPException, e: raise URLGrabError(7, _('HTTP Error (%s): %s') % \ (e.__class__.__name__, e)) else: return (fo, hdr)
6,045
def _parse_url(self,url): """break up the url into its component parts
def _parse_url(self,url): """break up the url into its component parts
6,046
def _set_defaults(self): """Set all options to their default values. When adding new options, make sure a default is provided here. """ self.progress_obj = None self.throttle = 1.0 self.bandwidth = 0 self.retry = None self.retrycodes = [-1,2,4,5,6,7] self.checkfunc = None self.copy_local = 0 self.close_connection = 0 self.range = None self.user_agent = 'urlgrabber/%s' % __version__ self.keepalive = 1 self.proxies = None self.reget = None self.failure_callback = None self.prefix = None self.opener = None
defself.cache_openers = True _set_defaults(self):self.cache_openers = True """Setself.cache_openers = True allself.cache_openers = True optionsself.cache_openers = True toself.cache_openers = True theirself.cache_openers = True defaultself.cache_openers = True values.self.cache_openers = True Whenself.cache_openers = True addingself.cache_openers = True newself.cache_openers = True options,self.cache_openers = True makeself.cache_openers = True sureself.cache_openers = True aself.cache_openers = True defaultself.cache_openers = True isself.cache_openers = True providedself.cache_openers = True here.self.cache_openers = True """self.cache_openers = True self.progress_objself.cache_openers = True =self.cache_openers = True Noneself.cache_openers = True self.throttleself.cache_openers = True =self.cache_openers = True 1.0self.cache_openers = True self.bandwidthself.cache_openers = True =self.cache_openers = True 0self.cache_openers = True self.retryself.cache_openers = True =self.cache_openers = True Noneself.cache_openers = True self.retrycodesself.cache_openers = True =self.cache_openers = True [-1,2,4,5,6,7]self.cache_openers = True self.checkfuncself.cache_openers = True =self.cache_openers = True Noneself.cache_openers = True self.copy_localself.cache_openers = True =self.cache_openers = True 0self.cache_openers = True self.close_connectionself.cache_openers = True =self.cache_openers = True 0self.cache_openers = True self.rangeself.cache_openers = True =self.cache_openers = True Noneself.cache_openers = True self.user_agentself.cache_openers = True =self.cache_openers = True 'urlgrabber/%s'self.cache_openers = True %self.cache_openers = True __version__self.cache_openers = True self.keepaliveself.cache_openers = True =self.cache_openers = True 1self.cache_openers = True self.proxiesself.cache_openers = True =self.cache_openers = True Noneself.cache_openers = True self.regetself.cache_openers = True =self.cache_openers = True Noneself.cache_openers = True self.failure_callbackself.cache_openers = True =self.cache_openers = True Noneself.cache_openers = True self.prefixself.cache_openers = True =self.cache_openers = True Noneself.cache_openers = True self.openerself.cache_openers = True =self.cache_openers = True Noneself.cache_openers = True
6,047
def _get_opener(self): """Build a urllib2 OpenerDirector based on request options.""" if self.opts.opener: return self.opts.opener elif self._opener is None: handlers = [] # if you specify a ProxyHandler when creating the opener # it _must_ come before all other handlers in the list or urllib2 # chokes. if self.opts.proxies: handlers.append( CachedProxyHandler(self.opts.proxies) ) if keepalive_handler and self.opts.keepalive: handlers.append( keepalive_handler ) if range_handlers and (self.opts.range or self.opts.reget): handlers.extend( range_handlers ) handlers.append( auth_handler ) # Temporarily disabling this because it doesn't yet work # correctly. Some reget tests fail. I really don't understand # why, but some of the error handlers aren't set correctly. #self._opener = CachedOpenerDirector(*handlers) self._opener = urllib2.build_opener(*handlers) # OK, I don't like to do this, but otherwise, we end up with # TWO user-agent headers. self._opener.addheaders = [] return self._opener
def _get_opener(self): """Build a urllib2 OpenerDirector based on request options.""" if self.opts.opener: return self.opts.opener elif self._opener is None: handlers = [] # if you specify a ProxyHandler when creating the opener # it _must_ come before all other handlers in the list or urllib2 # chokes. if self.opts.proxies: handlers.append( CachedProxyHandler(self.opts.proxies) ) if keepalive_handler and self.opts.keepalive: handlers.append( keepalive_handler ) if range_handlers and (self.opts.range or self.opts.reget): handlers.extend( range_handlers ) handlers.append( auth_handler ) # Temporarily disabling this because it doesn't yet work # correctly. Some reget tests fail. I really don't understand # why, but some of the error handlers aren't set correctly. #self._opener = CachedOpenerDirector(*handlers) self._opener = urllib2.build_opener(*handlers) # OK, I don't like to do this, but otherwise, we end up with # TWO user-agent headers. self._opener.addheaders = [] return self._opener
6,048
def retryfunc(opts, url, filename): fo = URLGrabberFileObject(url, filename, opts) try: fo._do_grab() if not opts.checkfunc is None: if callable(opts.checkfunc): func, args, kwargs = opts.checkfunc, (), {} else: func, args, kwargs = opts.checkfunc apply(func, (filename, )+args, kwargs) finally: fo.close() return filename
def retryfunc(opts, url, filename): fo = URLGrabberFileObject(url, filename, opts) try: fo._do_grab() if not opts.checkfunc is None: if callable(opts.checkfunc): func, args, kwargs = opts.checkfunc, (), {} else: func, args, kwargs = opts.checkfunc apply(func, (filename, )+args, kwargs) finally: fo.close() return filename
6,049
def retryfunc(opts, url, limit): fo = URLGrabberFileObject(url, filename=None, opts=opts) s = '' try: s = fo.read(limit) if not opts.checkfunc is None: if callable(opts.checkfunc): func, args, kwargs = opts.checkfunc, (), {} else: func, args, kwargs = opts.checkfunc apply(func, (s, )+args, kwargs) finally: fo.close() return s
def retryfunc(opts, url, limit): fo = URLGrabberFileObject(url, filename=None, opts=opts) s = '' try: if limit is None: s = fo.read() else: s = fo.read(limit) if not opts.checkfunc is None: if callable(opts.checkfunc): func, args, kwargs = opts.checkfunc, (), {} else: func, args, kwargs = opts.checkfunc apply(func, (s, )+args, kwargs) finally: fo.close() return s
6,050
def _parse_url(self,url): """break up the url into its component parts
def _parse_url(self,url): """break up the url into its component parts
6,051
def open_local_file(self, req): import mimetypes import mimetools host = req.get_host() file = req.get_selector() localfile = urllib.url2pathname(file) stats = os.stat(localfile) size = stats[stat.ST_SIZE] modified = rfc822.formatdate(stats[stat.ST_MTIME]) mtype = mimetypes.guess_type(file)[0] if host: host, port = urllib.splitport(host) if port or socket.gethostbyname(host) not in self.get_names(): raise URLError('file not on local host') fo = open(localfile,'rb') brange = req.headers.get('Range',None) brange = range_header_to_tuple(brange) assert brange != () if brange: (fb,lb) = brange if lb == '': lb = size if fb < 0 or fb > size or lb > size: raise RangeError('Requested Range Not Satisfiable') size = (lb - fb) fo = RangeableFileObject(fo, (fb,lb)) headers = mimetools.Message(StringIO( 'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' % (mtype or 'text/plain', size, modified))) return urllib.addinfourl(fo, headers, 'file:'+file)
def open_local_file(self, req): import mimetypes import mimetools host = req.get_host() file = req.get_selector() localfile = urllib.url2pathname(file) stats = os.stat(localfile) size = stats[stat.ST_SIZE] modified = rfc822.formatdate(stats[stat.ST_MTIME]) mtype = mimetypes.guess_type(file)[0] if host: host, port = urllib.splitport(host) if port or socket.gethostbyname(host) not in self.get_names(): raise urllib2.URLError('file not on local host') fo = open(localfile,'rb') brange = req.headers.get('Range',None) brange = range_header_to_tuple(brange) assert brange != () if brange: (fb,lb) = brange if lb == '': lb = size if fb < 0 or fb > size or lb > size: raise RangeError('Requested Range Not Satisfiable') size = (lb - fb) fo = RangeableFileObject(fo, (fb,lb)) headers = mimetools.Message(StringIO( 'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' % (mtype or 'text/plain', size, modified))) return urllib.addinfourl(fo, headers, 'file:'+file)
6,052
def ftp_open(self, req): host = req.get_host() if not host: raise IOError, ('ftp error', 'no host given') host, port = splitport(host) if port is None: port = ftplib.FTP_PORT
def ftp_open(self, req): host = req.get_host() if not host: raise IOError, ('ftp error', 'no host given') host, port = splitport(host) if port is None: port = ftplib.FTP_PORT
6,053
def _parse_url(self,url): """break up the url into its component parts
def _parse_url(self,url): """break up the url into its component parts
6,054
def _get_opener(self): """Build a urllib2 OpenerDirector based on request options.""" if self._opener is None: handlers = [] # if you specify a ProxyHandler when creating the opener # it _must_ come before all other handlers in the list or urllib2 # chokes. if self.opts.proxies: handlers.append( CachedProxyHandler(self.opts.proxies) ) if keepalive_handler and self.opts.keepalive: handlers.append( keepalive_handler ) if range_handlers and (self.opts.range or self.opts.reget): handlers.extend( range_handlers ) handlers.append( auth_handler ) self._opener = CachedOpenerDirector(*handlers) return self._opener
def _get_opener(self): """Build a urllib2 OpenerDirector based on request options.""" if self._opener is None: handlers = [] # if you specify a ProxyHandler when creating the opener # it _must_ come before all other handlers in the list or urllib2 # chokes. if self.opts.proxies: handlers.append( CachedProxyHandler(self.opts.proxies) ) if keepalive_handler and self.opts.keepalive: handlers.append( keepalive_handler ) if range_handlers and (self.opts.range or self.opts.reget): handlers.extend( range_handlers ) handlers.append( auth_handler ) self._opener = urllib2.build_opener(*handlers) self._opener.addheaders = [] return self._opener
6,055
def do_open(self, http_class, req): host = req.get_host() if not host: raise urllib2.URLError('no host given')
def do_open(self, http_class, req): host = req.get_host() if not host: raise urllib2.URLError('no host given')
6,056
def info(self): return self.msg
def info(self): return self.msg
6,057
def _(st): return st
def _(st): return st
6,058
def _(st): return st
def _(st): return st
6,059
def _(st): return st
def _(st): return st
6,060
def _(st): return st
def _(st): return st
6,061
def testIdentity(self): # test to make sure that objects retain identity properly x = [] y = (x) x.append(y) x.append(y) self.assertIdentical(x[0], x[1]) self.assertIdentical(x[0][0], x) d = self.encode(x) d.addCallback(self.shouldDecode) d.addCallback(self._testIdentity_1) return d
def testIdentity(self): # test to make sure that objects retain identity properly x = [] y = (x,) x.append(y) x.append(y) self.assertIdentical(x[0], x[1]) self.assertIdentical(x[0][0], x) d = self.encode(x) d.addCallback(self.shouldDecode) d.addCallback(self._testIdentity_1) return d
6,062
# TODO : selection "Object-Method" and choosing alt + j will open the class def file for THAT method
#TODO:selection"Object-Method"andchoosingalt+jwillopentheclassdeffileforTHATmethod
6,063
# TODO : selection "Object-Method" and choosing alt + j will open the class def file for THAT method
# TODO : selection "Object-Method" and choosing alt + j will open the class def file for THAT method
6,064
def __init__ (self,parent): wx.TextCtrl.__init__(self,parent,style = wx.TE_MULTILINE | wx.TE_RICH2 | wx.TE_READONLY) self.Bind(wx.EVT_CHAR, self.OnChar)
def__init__(self,parent):wx.TextCtrl.__init__(self,parent,style=wx.TE_MULTILINE|wx.TE_RICH2|wx.TE_READONLY)self.Bind(wx.EVT_CHAR,self.OnChar)
6,065
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
6,066
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
6,067
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
6,068
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
6,069
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
6,070
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
6,071
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
6,072
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
6,073
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
6,074
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
6,075
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
6,076
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
6,077
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
6,078
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
def__init__(self,parent):wx.stc.StyledTextCtrl.__init__(self,parent)font=wx.Font(10,wx.MODERN,wx.NORMAL,wx.NORMAL,False,"CourierNew")self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT,font)self.Bind(wx.EVT_CHAR,self.OnChar)self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT|wx.stc.STC_MOD_DELETETEXT|wx.stc.STC_PERFORMED_USER)self.Bind(wx.stc.EVT_STC_CHANGE,self.OnStcChange)self.CmdKeyAssign(ord('B'),stc.STC_SCMOD_CTRL,stc.STC_CMD_ZOOMIN)self.CmdKeyAssign(ord('N'),stc.STC_SCMOD_CTRL,stc.STC_CMD_ZOOMOUT)
6,079
def OnKeyPressed(self, event): if self.CallTipActive(): self.CallTipCancel() key = event.KeyCode()
defOnKeyPressed(self,event):ifself.CallTipActive():self.CallTipCancel()key=event.KeyCode()
6,080
def OnUpdateUI(self, evt): # check for matching braces braceAtCaret = -1 braceOpposite = -1 charBefore = None caretPos = self.GetCurrentPos()
def OnUpdateUI(self, evt): # check for matching braces braceAtCaret = -1 braceOpposite = -1 charBefore = None caretPos = self.GetCurrentPos()
6,081
def OnUpdateUI(self, evt): # check for matching braces braceAtCaret = -1 braceOpposite = -1 charBefore = None caretPos = self.GetCurrentPos()
def OnUpdateUI(self, evt): # check for matching braces braceAtCaret = -1 braceOpposite = -1 charBefore = None caretPos = self.GetCurrentPos()
6,082
def OnOpenFile(self,evt): fileDlg = wx.FileDialog(self,style=wx.OPEN) if fileDlg.ShowModal( ) == wx.ID_OK: path = fileDlg.GetPath() self.OpenFile(path)
def def OnCloseCodeWin(self,evt): activeWin = self.GetActiveChild( ) if activeWin == None: wx.MessageBox("ERROR : No document is active") elif not activeWin == self.logWin: if self.IsAllowedToCloseWindow(activeWin): activeWin.Destroy(); OnOpenFile(self,evt): def OnCloseCodeWin(self,evt): activeWin = self.GetActiveChild( ) if activeWin == None: wx.MessageBox("ERROR : No document is active") elif not activeWin == self.logWin: if self.IsAllowedToCloseWindow(activeWin): activeWin.Destroy(); fileDlg def OnCloseCodeWin(self,evt): activeWin = self.GetActiveChild( ) if activeWin == None: wx.MessageBox("ERROR : No document is active") elif not activeWin == self.logWin: if self.IsAllowedToCloseWindow(activeWin): activeWin.Destroy(); = def OnCloseCodeWin(self,evt): activeWin = self.GetActiveChild( ) if activeWin == None: wx.MessageBox("ERROR : No document is active") elif not activeWin == self.logWin: if self.IsAllowedToCloseWindow(activeWin): activeWin.Destroy(); wx.FileDialog(self,style=wx.OPEN) def OnCloseCodeWin(self,evt): activeWin = self.GetActiveChild( ) if activeWin == None: wx.MessageBox("ERROR : No document is active") elif not activeWin == self.logWin: if self.IsAllowedToCloseWindow(activeWin): activeWin.Destroy(); if def OnCloseCodeWin(self,evt): activeWin = self.GetActiveChild( ) if activeWin == None: wx.MessageBox("ERROR : No document is active") elif not activeWin == self.logWin: if self.IsAllowedToCloseWindow(activeWin): activeWin.Destroy(); fileDlg.ShowModal( def OnCloseCodeWin(self,evt): activeWin = self.GetActiveChild( ) if activeWin == None: wx.MessageBox("ERROR : No document is active") elif not activeWin == self.logWin: if self.IsAllowedToCloseWindow(activeWin): activeWin.Destroy(); ) def OnCloseCodeWin(self,evt): activeWin = self.GetActiveChild( ) if activeWin == None: wx.MessageBox("ERROR : No document is active") elif not activeWin == self.logWin: if self.IsAllowedToCloseWindow(activeWin): activeWin.Destroy(); == def OnCloseCodeWin(self,evt): activeWin = self.GetActiveChild( ) if activeWin == None: wx.MessageBox("ERROR : No document is active") elif not activeWin == self.logWin: if self.IsAllowedToCloseWindow(activeWin): activeWin.Destroy(); wx.ID_OK: def OnCloseCodeWin(self,evt): activeWin = self.GetActiveChild( ) if activeWin == None: wx.MessageBox("ERROR : No document is active") elif not activeWin == self.logWin: if self.IsAllowedToCloseWindow(activeWin): activeWin.Destroy(); path def OnCloseCodeWin(self,evt): activeWin = self.GetActiveChild( ) if activeWin == None: wx.MessageBox("ERROR : No document is active") elif not activeWin == self.logWin: if self.IsAllowedToCloseWindow(activeWin): activeWin.Destroy(); = def OnCloseCodeWin(self,evt): activeWin = self.GetActiveChild( ) if activeWin == None: wx.MessageBox("ERROR : No document is active") elif not activeWin == self.logWin: if self.IsAllowedToCloseWindow(activeWin): activeWin.Destroy(); fileDlg.GetPath() def OnCloseCodeWin(self,evt): activeWin = self.GetActiveChild( ) if activeWin == None: wx.MessageBox("ERROR : No document is active") elif not activeWin == self.logWin: if self.IsAllowedToCloseWindow(activeWin): activeWin.Destroy(); self.OpenFile(path) def OnCloseCodeWin(self,evt): activeWin = self.GetActiveChild( ) if activeWin == None: wx.MessageBox("ERROR : No document is active") elif not activeWin == self.logWin: if self.IsAllowedToCloseWindow(activeWin): activeWin.Destroy();
6,083
def OnSaveFile(self,evt): activeWin = self.GetActiveChild( ); self.OnSaveFileInWin(self,evt,activeWin)
def OnSaveFile(self,evt): activeWin = self.GetActiveChild( ); self.OnSaveFileInWin(self,evt,activeWin)
6,084
def OnSaveFileInWin(self,evt,activeWin): if activeWin == None: # TODO : disable menu items dynamically instead wx.MessageBox("ERROR : No document is active") else: #fileDlg = wx.FileDialog(self,style=wx.SAVE) path = activeWin.originalFilePath if path == "": self.OnSaveFileAsInWin(evt,activeWin) else: file = open(path ,"w" ) content = activeWin.codeSubWin.GetText() file.write(content) file.close()
def OnSaveFileInWin(self,evt,activeWin): if activeWin == None: # TODO : disable menu items dynamically instead wx.MessageBox("ERROR : No document is active") else: #fileDlg = wx.FileDialog(self,style=wx.SAVE) path = activeWin.originalFilePath if path == "": self.OnSaveFileAsInWin(evt,activeWin) else: file = open(path ,"w" ) content = activeWin.codeSubWin.GetText() file.write(content) file.close()
6,085
def GoToHelpFile(self): # TODO : test this : most help files don't open. remove trailing and leading spaces from sel, too, since wxTextCtrl is behaving strangely activeChild = self.GetActiveChild() sel = string.strip(str(activeChild.GetSelectedText())) foundFilePath = "" filePath = "" if sel != "": for helpFolder in [gAppHelpFolder,gHelpFolder]: for folderPath, foldersInPath, fileNamesInFolder in os.walk(helpFolder): # don't visit CVS directories if 'CVS' in foldersInPath: foldersInPath.remove('CVS') for fileName in fileNamesInFolder: filePath = os.path.join(folderPath, fileName) if fileName == sel + ".help.rtf": foundFilePath = filePath break if fileName == sel + ".rtf": foundFilePath = filePath break # for fileName # if file is found, let's break if foundFilePath != "": break # for folderPath, .... # if file is found, let's break if foundFilePath != "": break if foundFilePath == "": foundFilePath = os.path.join(gAppHelpFolder,"Help.help.rtf") self.OpenFile(foundFilePath)
def GoToHelpFile(self): # TODO : test this : most help files don't open. remove trailing and leading spaces from sel, too, since wxTextCtrl is behaving strangely activeChild = self.GetActiveChild() if not activeChild == self.logWin: sel = string.strip(str(activeChild.GetSelectedText())) else : sel = "" foundFilePath = "" filePath = "" if sel != "": for helpFolder in [gAppHelpFolder,gHelpFolder]: for folderPath, foldersInPath, fileNamesInFolder in os.walk(helpFolder): # don't visit CVS directories if 'CVS' in foldersInPath: foldersInPath.remove('CVS') for fileName in fileNamesInFolder: filePath = os.path.join(folderPath, fileName) if fileName == sel + ".help.rtf": foundFilePath = filePath break if fileName == sel + ".rtf": foundFilePath = filePath break # for fileName # if file is found, let's break if foundFilePath != "": break # for folderPath, .... # if file is found, let's break if foundFilePath != "": break if foundFilePath == "": foundFilePath = os.path.join(gAppHelpFolder,"Help.help.rtf") self.OpenFile(foundFilePath)
6,086
def GoToHelpFile(self): # TODO : test this : most help files don't open. remove trailing and leading spaces from sel, too, since wxTextCtrl is behaving strangely activeChild = self.GetActiveChild() sel = string.strip(str(activeChild.GetSelectedText())) foundFilePath = "" filePath = "" if sel != "": for helpFolder in [gAppHelpFolder,gHelpFolder]: for folderPath, foldersInPath, fileNamesInFolder in os.walk(helpFolder): # don't visit CVS directories if 'CVS' in foldersInPath: foldersInPath.remove('CVS') for fileName in fileNamesInFolder: filePath = os.path.join(folderPath, fileName) if fileName == sel + ".help.rtf": foundFilePath = filePath break if fileName == sel + ".rtf": foundFilePath = filePath break # for fileName # if file is found, let's break if foundFilePath != "": break # for folderPath, .... # if file is found, let's break if foundFilePath != "": break if foundFilePath == "": foundFilePath = os.path.join(gAppHelpFolder,"Help.help.rtf") self.OpenFile(foundFilePath)
def GoToHelpFile(self): # TODO : test this : most help files don't open. remove trailing and leading spaces from sel, too, since wxTextCtrl is behaving strangely activeChild = self.GetActiveChild() sel = string.strip(str(activeChild.GetSelectedText())) foundFilePath = "" filePath = "" if sel != "": for helpFolder in [gHelpFolder]: for folderPath, foldersInPath, fileNamesInFolder in os.walk(helpFolder): # don't visit CVS directories if 'CVS' in foldersInPath: foldersInPath.remove('CVS') for fileName in fileNamesInFolder: filePath = os.path.join(folderPath, fileName) if fileName == sel + ".help.rtf": foundFilePath = filePath break if fileName == sel + ".rtf": foundFilePath = filePath break # for fileName # if file is found, let's break if foundFilePath != "": break # for folderPath, .... # if file is found, let's break if foundFilePath != "": break if foundFilePath == "": foundFilePath = os.path.join(gAppHelpFolder,"Help.help.rtf") self.OpenFile(foundFilePath)
6,087
def GoToHelpFile(self): # TODO : test this : most help files don't open. remove trailing and leading spaces from sel, too, since wxTextCtrl is behaving strangely activeChild = self.GetActiveChild() sel = string.strip(str(activeChild.GetSelectedText())) foundFilePath = "" filePath = "" if sel != "": for helpFolder in [gAppHelpFolder,gHelpFolder]: for folderPath, foldersInPath, fileNamesInFolder in os.walk(helpFolder): # don't visit CVS directories if 'CVS' in foldersInPath: foldersInPath.remove('CVS') for fileName in fileNamesInFolder: filePath = os.path.join(folderPath, fileName) if fileName == sel + ".help.rtf": foundFilePath = filePath break if fileName == sel + ".rtf": foundFilePath = filePath break # for fileName # if file is found, let's break if foundFilePath != "": break # for folderPath, .... # if file is found, let's break if foundFilePath != "": break if foundFilePath == "": foundFilePath = os.path.join(gAppHelpFolder,"Help.help.rtf") self.OpenFile(foundFilePath)
def GoToHelpFile(self): # TODO : test this : most help files don't open. remove trailing and leading spaces from sel, too, since wxTextCtrl is behaving strangely activeChild = self.GetActiveChild() sel = string.strip(str(activeChild.GetSelectedText())) foundFilePath = "" filePath = "" if sel != "": for helpFolder in [gAppHelpFolder,gHelpFolder]: for folderPath, foldersInPath, fileNamesInFolder in os.walk(helpFolder): # don't visit CVS directories if 'CVS' in foldersInPath: foldersInPath.remove('CVS') for fileName in fileNamesInFolder: filePath = os.path.join(folderPath, fileName) if fileName == sel + ".help.rtf": foundFilePath = filePath break if fileName == sel + ".rtf": foundFilePath = filePath break # for fileName # if file is found, let's break if foundFilePath != "": break # for folderPath, .... # if file is found, let's break if foundFilePath != "": break if foundFilePath == "": foundFilePath = os.path.join(gHelpFolder,"Help.help.rtf") self.OpenFile(foundFilePath)
6,088
# TODO : selection "Object-Method" and choosing alt + j will open the class def file for THAT method
# TODO : selection "Object-Method" and choosing alt + j will open the class def file for THAT method
6,089
# TODO : selection "Object-Method" and choosing alt + j will open the class def file for THAT method
# TODO : selection "Object-Method" and choosing alt + j will open the class def file for THAT method
6,090
# TODO : selection "Object-Method" and choosing alt + j will open the class def file for THAT method
# TODO : selection "Object-Method" and choosing alt + j will open the class def file for THAT method
6,091
# TODO : selection "Object-Method" and choosing alt + j will open the class def file for THAT method
# TODO : selection "Object-Method" and choosing alt + j will open the class def file for THAT method
6,092
# TODO : selection "Object-Method" and choosing alt + j will open the class def file for THAT method
# TODO : selection "Object-Method" and choosing alt + j will open the class def file for THAT method
6,093
# TODO : selection "Object-Method" and choosing alt + j will open the class def file for THAT method
#TODO:selection"Object-Method"andchoosingalt+jwillopentheclassdeffileforTHATmethod
6,094
# TODO : selection "Object-Method" and choosing alt + j will open the class def file for THAT method
# TODO : selection "Object-Method" and choosing alt + j will open the class def file for THAT method
6,095
# TODO : selection "Object-Method" and choosing alt + j will open the class def file for THAT method
# TODO : selection "Object-Method" and choosing alt + j will open the class def file for THAT method
6,096
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
def __init__ (self,parent): wx.stc.StyledTextCtrl.__init__(self,parent) font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, False, "Courier New") self.StyleSetFont(wx.stc.STC_STYLE_DEFAULT, font) self.Bind(wx.EVT_CHAR, self.OnChar) self.SetModEventMask(wx.stc.STC_MOD_INSERTTEXT | wx.stc.STC_MOD_DELETETEXT | wx.stc.STC_PERFORMED_USER) self.Bind(wx.stc.EVT_STC_CHANGE, self.OnStcChange) self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT)
6,097
def FoldAll(self): lineCount = self.GetLineCount() expanding = True
defFoldAll(self):lineCount=self.GetLineCount()expanding=True
6,098
def __init__ (self,parent,ID,title,pos=wx.DefaultPosition,size=wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE | wx.VSCROLL | wx.HSCROLL, name = "frame"): wx.MDIParentFrame.__init__(self,parent,ID,title,pos,size,style) self.winCount = 0
def __init__ (self,parent,ID,title,pos=wx.DefaultPosition,size=wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE | wx.VSCROLL | wx.HSCROLL, name = "frame"): wx.MDIParentFrame.__init__(self,parent,ID,title,pos,size,style) self.winCount = 0
6,099