rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
('build_platlib', 'build_dir'), ('install_platlib', 'install_dir'))
('build_lib', 'build_dir'), ('install_lib', 'install_dir'))
def finalize_options (self): self.set_undefined_options ('install', ('build_platlib', 'build_dir'), ('install_platlib', 'install_dir'))
531349f28e6c87ca6ccfa3abd161ea259f10e32a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/531349f28e6c87ca6ccfa3abd161ea259f10e32a/install_ext.py
req.add_header(self.auth_header, auth_val)
req.add_unredirected_header(self.auth_header, auth_val)
def retry_http_digest_auth(self, req, auth): token, challenge = auth.split(' ', 1) chal = parse_keqv_list(parse_http_list(challenge)) auth = self.get_authorization(req, chal) if auth: auth_val = 'Digest %s' % auth if req.headers.get(self.auth_header, None) == auth_val: return None req.add_header(self.auth_header, auth_val) resp = self.parent.open(req) return resp
852bb008182c012bae6d53c8c8c8f83d1ec9445a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/852bb008182c012bae6d53c8c8c8f83d1ec9445a/urllib2.py
def group(i):
def group(self, i):
def group(i):
63e18195b8b7a064488d106537703861f08aa415 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/63e18195b8b7a064488d106537703861f08aa415/re.py
def assemble_set(self, position, labels):
def assemble(self, position, labels):
def assemble_set(self, position, labels):
63e18195b8b7a064488d106537703861f08aa415 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/63e18195b8b7a064488d106537703861f08aa415/re.py
if c in self.set[2]:
if c in self.set:
def assemble_set(self, position, labels):
63e18195b8b7a064488d106537703861f08aa415 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/63e18195b8b7a064488d106537703861f08aa415/re.py
result = result + `char`
result = result + char
def __repr__(self):
63e18195b8b7a064488d106537703861f08aa415 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/63e18195b8b7a064488d106537703861f08aa415/re.py
if stack[-1][0][1] > 0:
if stack[-1][0].register > 0:
def compile(pattern, flags=0): stack = [] index = 0 label = 0 register = 1 groupindex = {} callouts = [] while (index < len(pattern)): char = pattern[index] index = index + 1 if char == '\\': if index < len(pattern): next = pattern[index] index = index + 1 if next == 't': stack.append([Exact(chr(9))]) elif next == 'n': stack.append([Exact(chr(10))]) elif next == 'r': stack.append([Exact(chr(13))]) elif next == 'f': stack.append([Exact(chr(12))]) elif next == 'a': stack.append([Exact(chr(7))]) elif next == 'e': stack.append([Exact(chr(27))]) elif next in '0123456789': value = next while (index < len(pattern)) and \ (pattern[index] in string.digits): value = value + pattern[index] index = index + 1 if (len(value) == 3) or \ ((len(value) == 2) and (value[0] == '0')): value = string.atoi(value, 8) if value > 255: raise error, 'octal char out of range' stack.append([Exact(chr(value))]) elif value == '0': stack.append([Exact(chr(0))]) elif len(value) > 3: raise error, 'too many digits' else: value = string.atoi(value) if value >= register: raise error, ('cannot reference a register ' 'not yet used') elif value == 0: raise error, ('register 0 cannot be used ' 'during match') stack.append([MatchMemory(value)]) elif next == 'x': value = '' while (index < len(pattern)) and \ (pattern[index] in string.hexdigits): value = value + pattern[index] index = index + 1 value = string.atoi(value, 16) if value > 255: raise error, 'hex char out of range' stack.append([Exact(chr(value))]) elif next == 'c': if index >= len(pattern): raise error, '\\c at end of re' elif pattern[index] in 'abcdefghijklmnopqrstuvwxyz': stack.append(Exact(chr(ord(pattern[index]) - ord('a') + 1))) else: stack.append(Exact(chr(ord(pattern[index]) ^ 64))) index = index + 1 elif next == 'A': stack.append([BegBuf()]) elif next == 'Z': stack.append([EndBuf()]) elif next == 'b': stack.append([WordBound()]) elif next == 'B': stack.append([NotWordBound()]) elif next == 'w': stack.append([SyntaxSpec('word')]) elif next == 'W': stack.append([NotSyntaxSpec('word')]) elif next == 's': stack.append([SyntaxSpec('whitespace')]) elif next == 'S': stack.append([NotSyntaxSpec('whitespace')]) elif next == 'd': stack.append([SyntaxSpec('digit')]) elif next == 'D': stack.append([NotSyntaxSpec('digit')]) elif next in 'GluLUQE': # some perl-isms that we don't support raise error, '\\' + next + ' not supported' else: stack.append([Exact(pattern[index])]) else: raise error, 'backslash at the end of a string' elif char == '|': if len(stack) == 0: raise error, 'nothing to alternate' expr = [] while (len(stack) != 0) and \ (stack[-1][0].name != '(') and \ (stack[-1][0].name != '|'): expr = stack[-1] + expr del stack[-1] stack.append([FailureJump(label)] + \ expr + \ [Jump(-1), Label(label)]) stack.append([('|',)]) label = label + 1 elif char == '(': if index >= len(pattern): raise error, 'no matching close paren' elif pattern[index] == '?': # Perl style (?...) extensions index = index + 1 if index >= len(pattern): raise error, 'extension ends prematurely' elif pattern[index] == 'P': # Python extensions index = index + 1 if index >= len(pattern): raise error, 'extension ends prematurely' elif pattern[index] == '<': # Handle Python symbolic group names (?<...>...) index = index + 1 end = string.find(pattern, '>', index) if end == -1: raise error, 'no end to symbolic group name' name = pattern[index:end] # XXX check syntax of name index = end + 1 groupindex[name] = register stack.append([OpenParen(register)]) register = register + 1 elif pattern[index] == '=': # backreference to symbolic group name if index >= len(pattern): raise error, '(?P= at the end of the pattern' start = index + 1 end = string.find(pattern, ')', start) if end == -1: raise error, 'no ) to end symbolic group name' name = pattern[start:end] if name not in groupindex: raise error, ('symbolic group name ' + name + \ ' has not been used yet') stack.append([MatchMemory(groupindex[name])]) index = end + 1 elif pattern[index] == '!': # function callout if index >= len(pattern): raise error, 'no function callout name' start = index + 1 end = string.find(pattern, ')', start) if end == -1: raise error, 'no ) to end function callout name' name = pattern[start:end] if name not in callouts: raise error, ('function callout name not listed ' 'in callouts dict') stack.append([FunctionCallout(name)]) else: raise error, 'unknown Python extension' elif pattern[index] == ':': # grouping, but no registers index = index + 1 stack.append([('(', -1)]) elif pattern[index] == '#': # comment index = index + 1 end = string.find(pattern, ')', index) if end == -1: raise error, 'no end to comment' index = end + 1 elif pattern[index] == '=': raise error, ('zero-width positive lookahead ' 'assertion is unsupported') elif pattern[index] == '!': raise error, ('zero-width negative lookahead ' 'assertion is unsupported') elif pattern[index] in 'iImMsSxX': while (index < len(pattern)) and (pattern[index] != ')'): if pattern[index] == 'iI': flags = flags | IGNORECASE elif pattern[index] == 'mM': flags = flags | MULTILINE elif pattern[index] == 'sS': flags = flags | DOTALL elif pattern[index] in 'xX': flags = flags | VERBOSE else: raise error, 'unknown flag' index = index + 1 index = index + 1 else: raise error, 'unknown extension' else: stack.append([OpenParen(register)]) register = register + 1 elif char == ')': # make one expression out of everything on the stack up to # the marker left by the last parenthesis expr = [] while (len(stack) > 0) and (stack[-1][0].name != '('): expr = stack[-1] + expr del stack[-1] if len(stack) == 0: raise error, 'too many close parens' if len(expr) == 0: raise error, 'nothing inside parens' # check to see if alternation used correctly if (expr[-1].name == '|'): raise error, 'alternation with nothing on the right' # remove markers left by alternation expr = filter(lambda x: x.name != '|', expr) # clean up jumps inserted by alternation need_label = 0 for i in range(len(expr)): if (expr[i].name == 'jump') and (expr[i].label == -1): expr[i] = JumpOpcode(label) need_label = 1 if need_label: expr.append(Label(label)) label = label + 1 if stack[-1][0][1] > 0: expr = [StartMemory(stack[-1][0].register)] + \ expr + \ [EndMemory(stack[-1][0].register)] del stack[-1] stack.append(expr) elif char == '{': if len(stack) == 0: raise error, 'no expression to repeat' end = string.find(pattern, '}', index) if end == -1: raise error, ('no close curly bracket to match' ' open curly bracket') fields = map(string.strip, string.split(pattern[index:end], ',')) index = end + 1 minimal = 0 if (index < len(pattern)) and (pattern[index] == '?'): minimal = 1 index = index + 1 if len(fields) == 1: # {n} or {n}? (there's really no difference) try: count = string.atoi(fields[0]) except ValueError: raise error, ('count must be an integer ' 'inside curly braces') if count > 65535: raise error, 'repeat count out of range' expr = [] while count > 0: expr = expr + stack[-1] count = count - 1 del stack[-1] stack.append(expr) elif len(fields) == 2: # {n,} or {n,m} if fields[1] == '': # {n,} try: min = string.atoi(fields[0]) except ValueError: raise error, ('minimum must be an integer ' 'inside curly braces') if min > 65535: raise error, 'minimum repeat count out of range' expr = [] while min > 0: expr = expr + stack[-1] min = min - 1 registers = registers_used(stack[-1]) if minimal: expr = expr + \ ([Jump(label + 1), Label(label)] + \ stack[-1] + \ [Label(label + 1), FailureJump(label, registers)]) else: expr = expr + \ ([Label(label), FailureJump(label + 1, registers)] + stack[-1] + [StarJump(label), Label(label + 1)]) del stack[-1] stack.append(expr) label = label + 2 else: # {n,m} try: min = string.atoi(fields[0]) except ValueError: raise error, ('minimum must be an integer ' 'inside curly braces') try: max = string.atoi(fields[1]) except ValueError: raise error, ('maximum must be an integer ' 'inside curly braces') if min > 65535: raise error, ('minumim repeat count out ' 'of range') if max > 65535: raise error, ('maximum repeat count out ' 'of range') if min > max: raise error, ('minimum repeat count must be ' 'less than the maximum ' 'repeat count') expr = [] while min > 0: expr = expr + stack[-1] min = min - 1 max = max - 1 if minimal: while max > 0: expr = expr + \ [FailureJump(label), Jump(label + 1), Label(label)] + \ stack[-1] + \ [Label(label + 1)] label = label + 2 del stack[-1] stack.append(expr) else: while max > 0: expr = expr + \ [FailureJump(label)] + \ stack[-1] max = max - 1 del stack[-1] stack.append(expr + [Label(label)]) label = label + 1 else: raise error, ('there need to be one or two fields ' 'in a {} expression') index = end + 1 elif char == '}': raise error, 'unbalanced close curly brace' elif char == '*': # Kleene closure if len(stack) == 0: raise error, 'the Kleene closure needs something to repeat' registers = registers_used(stack[-1]) if (index < len(pattern)) and (pattern[index] == '?'): # non-greedy matching expr = [JumpInstructions(label + 1), Label(label)] + \ stack[-1] + \ [Label(label + 1), FailureJump(label)] index = index + 1 else: # greedy matching expr = [Label(label), FailureJump(label + 1)] + \ stack[-1] + \ [StarJump(label), Label(label + 1)] del stack[-1] stack.append(expr) label = label + 2 elif char == '+': # positive closure if len(stack) == 0: raise error, 'the positive closure needs something to repeat' registers = registers_used(stack[-1]) if (index < len(pattern)) and (pattern[index] == '?'): # non-greedy expr = [Label(label)] + \ stack[-1] + \ [FailureJump(label)] label = label + 1 index = index + 1 else: # greedy expr = [DummyFailureJump(label + 1), Label(label), FailureJump(label + 2), Label(label + 1)] + \ stack[-1] + \ [StarJump(label), Label(label + 2)] label = label + 3 del stack[-1] stack.append(expr) elif char == '?': if len(stack) == 0: raise error, 'need something to be optional' registers = registers_used(stack[-1]) if (index < len(pattern)) and (pattern[index] == '?'): # non-greedy matching expr = [FailureJump(label), Jump(label + 1), Label(label)] + \ stack[-1] + \ [Label(label + 1)] label = label + 2 index = index + 1 else: # greedy matching expr = [FailureJump(label)] + \ stack[-1] + \ [Label(label)] label = label + 1 del stack[-1] stack.append(expr) elif char == '.': if flags & DOTALL: stack.append(Set(map(chr, range(256)))) else: stack.append([AnyChar()]) elif char == '^': if flags & MULTILINE: stack.append([Bol()]) else: stack.append([BegBuf()]) elif char == '$': if flags & MULTILINE: stack.append([Eol()]) else: stack.append([EndBuf()]) elif char == '#': if flags & VERBOSE: # comment index = index + 1 end = string.find(pattern, '\n', index) if end == -1: index = len(pattern) else: index = end + 1 else: stack.append([Exact(char)]) elif char in string.whitespace: if flags & VERBOSE: stack.append([Exact(char)]) elif char == '[': if index >= len(pattern): raise error, 'incomplete set' negate = 0 last = '' set = [] if pattern[index] == '^': negate = 1 index = index + 1 if index >= len(pattern): raise error, 'incomplete set' if pattern[index] in ']-': set.append(pattern[index]) last = pattern[index] index = index + 1 while (index < len(pattern)) and (pattern[index] != ']'): next = pattern[index] index = index + 1 if next == '-': if (index >= len(pattern)) or (pattern[index] == ']'): raise error, 'incomplete range in set' if last > pattern[index]: raise error, 'range arguments out of order in set' for next in map(chr, \ range(ord(last), \ ord(pattern[index]) + 1)): if next not in set: set.append(next) last = '' index = index + 1 elif next == '\\': # expand syntax meta-characters and add to set if index >= len(pattern): raise error, 'incomplete set' elif (pattern[index] == ']'): raise error, 'backslash at the end of a set' elif pattern[index] == 'w': for next in syntax_table.keys(): if 'word' in syntax_table[next]: set.append(next) elif pattern[index] == 'W': for next in syntax_table.keys(): if 'word' not in syntax_table[next]: set.append(next) elif pattern[index] == 'd': for next in syntax_table.keys(): if 'digit' in syntax_table[next]: set.append(next) elif pattern[index] == 'D': for next in syntax_table.keys(): if 'digit' not in syntax_table[next]: set.append(next) elif pattern[index] == 's': for next in syntax_table.keys(): if 'whitespace' in syntax_table[next]: set.append(next) elif pattern[index] == 'S': for next in syntax_table.keys(): if 'whitespace' not in syntax_table[next]: set.append(next) else: raise error, 'unknown meta in set' last = '' index = index + 1 else: if next not in set: set.append(next) last = next if pattern[index] != ']': raise error, 'incomplete set' index = index + 1 if negate: notset = [] for char in map(chr, range(256)): if char not in set: notset.append(char) stack.append([Set(notset)]) else: stack.append([Set(set)]) else: stack.append([Exact(char)]) code = [] while len(stack) > 0: if stack[-1][0].name == '(': raise error, 'too many open parens' code = stack[-1] + code del stack[-1] if len(code) == 0: raise error, 'no code generated' if (code[-1].name == '|'): raise error, 'alternation with nothing on the right' code = filter(lambda x: x.name != '|', code) need_label = 0 for i in range(len(code)): if (code[i].name == 'jump') and (code[i].label == -1): code[i] = Jump(label) need_label = 1 if need_label: code.append(Label(label)) label = label + 1 code.append(End()) return RegexObject(pattern, flags, code, register, groupindex, callouts)
63e18195b8b7a064488d106537703861f08aa415 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/63e18195b8b7a064488d106537703861f08aa415/re.py
def compile(pattern, flags=0): stack = [] index = 0 label = 0 register = 1 groupindex = {} callouts = [] while (index < len(pattern)): char = pattern[index] index = index + 1 if char == '\\': if index < len(pattern): next = pattern[index] index = index + 1 if next == 't': stack.append([Exact(chr(9))]) elif next == 'n': stack.append([Exact(chr(10))]) elif next == 'r': stack.append([Exact(chr(13))]) elif next == 'f': stack.append([Exact(chr(12))]) elif next == 'a': stack.append([Exact(chr(7))]) elif next == 'e': stack.append([Exact(chr(27))]) elif next in '0123456789': value = next while (index < len(pattern)) and \ (pattern[index] in string.digits): value = value + pattern[index] index = index + 1 if (len(value) == 3) or \ ((len(value) == 2) and (value[0] == '0')): value = string.atoi(value, 8) if value > 255: raise error, 'octal char out of range' stack.append([Exact(chr(value))]) elif value == '0': stack.append([Exact(chr(0))]) elif len(value) > 3: raise error, 'too many digits' else: value = string.atoi(value) if value >= register: raise error, ('cannot reference a register ' 'not yet used') elif value == 0: raise error, ('register 0 cannot be used ' 'during match') stack.append([MatchMemory(value)]) elif next == 'x': value = '' while (index < len(pattern)) and \ (pattern[index] in string.hexdigits): value = value + pattern[index] index = index + 1 value = string.atoi(value, 16) if value > 255: raise error, 'hex char out of range' stack.append([Exact(chr(value))]) elif next == 'c': if index >= len(pattern): raise error, '\\c at end of re' elif pattern[index] in 'abcdefghijklmnopqrstuvwxyz': stack.append(Exact(chr(ord(pattern[index]) - ord('a') + 1))) else: stack.append(Exact(chr(ord(pattern[index]) ^ 64))) index = index + 1 elif next == 'A': stack.append([BegBuf()]) elif next == 'Z': stack.append([EndBuf()]) elif next == 'b': stack.append([WordBound()]) elif next == 'B': stack.append([NotWordBound()]) elif next == 'w': stack.append([SyntaxSpec('word')]) elif next == 'W': stack.append([NotSyntaxSpec('word')]) elif next == 's': stack.append([SyntaxSpec('whitespace')]) elif next == 'S': stack.append([NotSyntaxSpec('whitespace')]) elif next == 'd': stack.append([SyntaxSpec('digit')]) elif next == 'D': stack.append([NotSyntaxSpec('digit')]) elif next in 'GluLUQE': # some perl-isms that we don't support raise error, '\\' + next + ' not supported' else: stack.append([Exact(pattern[index])]) else: raise error, 'backslash at the end of a string' elif char == '|': if len(stack) == 0: raise error, 'nothing to alternate' expr = [] while (len(stack) != 0) and \ (stack[-1][0].name != '(') and \ (stack[-1][0].name != '|'): expr = stack[-1] + expr del stack[-1] stack.append([FailureJump(label)] + \ expr + \ [Jump(-1), Label(label)]) stack.append([('|',)]) label = label + 1 elif char == '(': if index >= len(pattern): raise error, 'no matching close paren' elif pattern[index] == '?': # Perl style (?...) extensions index = index + 1 if index >= len(pattern): raise error, 'extension ends prematurely' elif pattern[index] == 'P': # Python extensions index = index + 1 if index >= len(pattern): raise error, 'extension ends prematurely' elif pattern[index] == '<': # Handle Python symbolic group names (?<...>...) index = index + 1 end = string.find(pattern, '>', index) if end == -1: raise error, 'no end to symbolic group name' name = pattern[index:end] # XXX check syntax of name index = end + 1 groupindex[name] = register stack.append([OpenParen(register)]) register = register + 1 elif pattern[index] == '=': # backreference to symbolic group name if index >= len(pattern): raise error, '(?P= at the end of the pattern' start = index + 1 end = string.find(pattern, ')', start) if end == -1: raise error, 'no ) to end symbolic group name' name = pattern[start:end] if name not in groupindex: raise error, ('symbolic group name ' + name + \ ' has not been used yet') stack.append([MatchMemory(groupindex[name])]) index = end + 1 elif pattern[index] == '!': # function callout if index >= len(pattern): raise error, 'no function callout name' start = index + 1 end = string.find(pattern, ')', start) if end == -1: raise error, 'no ) to end function callout name' name = pattern[start:end] if name not in callouts: raise error, ('function callout name not listed ' 'in callouts dict') stack.append([FunctionCallout(name)]) else: raise error, 'unknown Python extension' elif pattern[index] == ':': # grouping, but no registers index = index + 1 stack.append([('(', -1)]) elif pattern[index] == '#': # comment index = index + 1 end = string.find(pattern, ')', index) if end == -1: raise error, 'no end to comment' index = end + 1 elif pattern[index] == '=': raise error, ('zero-width positive lookahead ' 'assertion is unsupported') elif pattern[index] == '!': raise error, ('zero-width negative lookahead ' 'assertion is unsupported') elif pattern[index] in 'iImMsSxX': while (index < len(pattern)) and (pattern[index] != ')'): if pattern[index] == 'iI': flags = flags | IGNORECASE elif pattern[index] == 'mM': flags = flags | MULTILINE elif pattern[index] == 'sS': flags = flags | DOTALL elif pattern[index] in 'xX': flags = flags | VERBOSE else: raise error, 'unknown flag' index = index + 1 index = index + 1 else: raise error, 'unknown extension' else: stack.append([OpenParen(register)]) register = register + 1 elif char == ')': # make one expression out of everything on the stack up to # the marker left by the last parenthesis expr = [] while (len(stack) > 0) and (stack[-1][0].name != '('): expr = stack[-1] + expr del stack[-1] if len(stack) == 0: raise error, 'too many close parens' if len(expr) == 0: raise error, 'nothing inside parens' # check to see if alternation used correctly if (expr[-1].name == '|'): raise error, 'alternation with nothing on the right' # remove markers left by alternation expr = filter(lambda x: x.name != '|', expr) # clean up jumps inserted by alternation need_label = 0 for i in range(len(expr)): if (expr[i].name == 'jump') and (expr[i].label == -1): expr[i] = JumpOpcode(label) need_label = 1 if need_label: expr.append(Label(label)) label = label + 1 if stack[-1][0][1] > 0: expr = [StartMemory(stack[-1][0].register)] + \ expr + \ [EndMemory(stack[-1][0].register)] del stack[-1] stack.append(expr) elif char == '{': if len(stack) == 0: raise error, 'no expression to repeat' end = string.find(pattern, '}', index) if end == -1: raise error, ('no close curly bracket to match' ' open curly bracket') fields = map(string.strip, string.split(pattern[index:end], ',')) index = end + 1 minimal = 0 if (index < len(pattern)) and (pattern[index] == '?'): minimal = 1 index = index + 1 if len(fields) == 1: # {n} or {n}? (there's really no difference) try: count = string.atoi(fields[0]) except ValueError: raise error, ('count must be an integer ' 'inside curly braces') if count > 65535: raise error, 'repeat count out of range' expr = [] while count > 0: expr = expr + stack[-1] count = count - 1 del stack[-1] stack.append(expr) elif len(fields) == 2: # {n,} or {n,m} if fields[1] == '': # {n,} try: min = string.atoi(fields[0]) except ValueError: raise error, ('minimum must be an integer ' 'inside curly braces') if min > 65535: raise error, 'minimum repeat count out of range' expr = [] while min > 0: expr = expr + stack[-1] min = min - 1 registers = registers_used(stack[-1]) if minimal: expr = expr + \ ([Jump(label + 1), Label(label)] + \ stack[-1] + \ [Label(label + 1), FailureJump(label, registers)]) else: expr = expr + \ ([Label(label), FailureJump(label + 1, registers)] + stack[-1] + [StarJump(label), Label(label + 1)]) del stack[-1] stack.append(expr) label = label + 2 else: # {n,m} try: min = string.atoi(fields[0]) except ValueError: raise error, ('minimum must be an integer ' 'inside curly braces') try: max = string.atoi(fields[1]) except ValueError: raise error, ('maximum must be an integer ' 'inside curly braces') if min > 65535: raise error, ('minumim repeat count out ' 'of range') if max > 65535: raise error, ('maximum repeat count out ' 'of range') if min > max: raise error, ('minimum repeat count must be ' 'less than the maximum ' 'repeat count') expr = [] while min > 0: expr = expr + stack[-1] min = min - 1 max = max - 1 if minimal: while max > 0: expr = expr + \ [FailureJump(label), Jump(label + 1), Label(label)] + \ stack[-1] + \ [Label(label + 1)] label = label + 2 del stack[-1] stack.append(expr) else: while max > 0: expr = expr + \ [FailureJump(label)] + \ stack[-1] max = max - 1 del stack[-1] stack.append(expr + [Label(label)]) label = label + 1 else: raise error, ('there need to be one or two fields ' 'in a {} expression') index = end + 1 elif char == '}': raise error, 'unbalanced close curly brace' elif char == '*': # Kleene closure if len(stack) == 0: raise error, 'the Kleene closure needs something to repeat' registers = registers_used(stack[-1]) if (index < len(pattern)) and (pattern[index] == '?'): # non-greedy matching expr = [JumpInstructions(label + 1), Label(label)] + \ stack[-1] + \ [Label(label + 1), FailureJump(label)] index = index + 1 else: # greedy matching expr = [Label(label), FailureJump(label + 1)] + \ stack[-1] + \ [StarJump(label), Label(label + 1)] del stack[-1] stack.append(expr) label = label + 2 elif char == '+': # positive closure if len(stack) == 0: raise error, 'the positive closure needs something to repeat' registers = registers_used(stack[-1]) if (index < len(pattern)) and (pattern[index] == '?'): # non-greedy expr = [Label(label)] + \ stack[-1] + \ [FailureJump(label)] label = label + 1 index = index + 1 else: # greedy expr = [DummyFailureJump(label + 1), Label(label), FailureJump(label + 2), Label(label + 1)] + \ stack[-1] + \ [StarJump(label), Label(label + 2)] label = label + 3 del stack[-1] stack.append(expr) elif char == '?': if len(stack) == 0: raise error, 'need something to be optional' registers = registers_used(stack[-1]) if (index < len(pattern)) and (pattern[index] == '?'): # non-greedy matching expr = [FailureJump(label), Jump(label + 1), Label(label)] + \ stack[-1] + \ [Label(label + 1)] label = label + 2 index = index + 1 else: # greedy matching expr = [FailureJump(label)] + \ stack[-1] + \ [Label(label)] label = label + 1 del stack[-1] stack.append(expr) elif char == '.': if flags & DOTALL: stack.append(Set(map(chr, range(256)))) else: stack.append([AnyChar()]) elif char == '^': if flags & MULTILINE: stack.append([Bol()]) else: stack.append([BegBuf()]) elif char == '$': if flags & MULTILINE: stack.append([Eol()]) else: stack.append([EndBuf()]) elif char == '#': if flags & VERBOSE: # comment index = index + 1 end = string.find(pattern, '\n', index) if end == -1: index = len(pattern) else: index = end + 1 else: stack.append([Exact(char)]) elif char in string.whitespace: if flags & VERBOSE: stack.append([Exact(char)]) elif char == '[': if index >= len(pattern): raise error, 'incomplete set' negate = 0 last = '' set = [] if pattern[index] == '^': negate = 1 index = index + 1 if index >= len(pattern): raise error, 'incomplete set' if pattern[index] in ']-': set.append(pattern[index]) last = pattern[index] index = index + 1 while (index < len(pattern)) and (pattern[index] != ']'): next = pattern[index] index = index + 1 if next == '-': if (index >= len(pattern)) or (pattern[index] == ']'): raise error, 'incomplete range in set' if last > pattern[index]: raise error, 'range arguments out of order in set' for next in map(chr, \ range(ord(last), \ ord(pattern[index]) + 1)): if next not in set: set.append(next) last = '' index = index + 1 elif next == '\\': # expand syntax meta-characters and add to set if index >= len(pattern): raise error, 'incomplete set' elif (pattern[index] == ']'): raise error, 'backslash at the end of a set' elif pattern[index] == 'w': for next in syntax_table.keys(): if 'word' in syntax_table[next]: set.append(next) elif pattern[index] == 'W': for next in syntax_table.keys(): if 'word' not in syntax_table[next]: set.append(next) elif pattern[index] == 'd': for next in syntax_table.keys(): if 'digit' in syntax_table[next]: set.append(next) elif pattern[index] == 'D': for next in syntax_table.keys(): if 'digit' not in syntax_table[next]: set.append(next) elif pattern[index] == 's': for next in syntax_table.keys(): if 'whitespace' in syntax_table[next]: set.append(next) elif pattern[index] == 'S': for next in syntax_table.keys(): if 'whitespace' not in syntax_table[next]: set.append(next) else: raise error, 'unknown meta in set' last = '' index = index + 1 else: if next not in set: set.append(next) last = next if pattern[index] != ']': raise error, 'incomplete set' index = index + 1 if negate: notset = [] for char in map(chr, range(256)): if char not in set: notset.append(char) stack.append([Set(notset)]) else: stack.append([Set(set)]) else: stack.append([Exact(char)]) code = [] while len(stack) > 0: if stack[-1][0].name == '(': raise error, 'too many open parens' code = stack[-1] + code del stack[-1] if len(code) == 0: raise error, 'no code generated' if (code[-1].name == '|'): raise error, 'alternation with nothing on the right' code = filter(lambda x: x.name != '|', code) need_label = 0 for i in range(len(code)): if (code[i].name == 'jump') and (code[i].label == -1): code[i] = Jump(label) need_label = 1 if need_label: code.append(Label(label)) label = label + 1 code.append(End()) return RegexObject(pattern, flags, code, register, groupindex, callouts)
63e18195b8b7a064488d106537703861f08aa415 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/63e18195b8b7a064488d106537703861f08aa415/re.py
raise DistutilsFileErorr, \
raise DistutilsFileError, \
def check_package (self, package, package_dir):
56359f591b361f41f661a14e5ed129bf8f22fa87 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/56359f591b361f41f661a14e5ed129bf8f22fa87/build_py.py
dict = {}
def readmodule(module, path=[], inpackage=0): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module.''' i = string.rfind(module, '.') if i >= 0: # Dotted module name package = string.strip(module[:i]) submodule = string.strip(module[i+1:]) parent = readmodule(package, path, inpackage) child = readmodule(submodule, parent['__path__'], 1) return child if _modules.has_key(module): # we've seen this module before... return _modules[module] if module in sys.builtin_module_names: # this is a built-in module dict = {} _modules[module] = dict return dict # search the path for the module f = None if inpackage: try: f, file, (suff, mode, type) = \ imp.find_module(module, path) except ImportError: f = None if f is None: fullpath = list(path) + sys.path f, file, (suff, mode, type) = imp.find_module(module, fullpath) if type == imp.PKG_DIRECTORY: dict = {'__path__': [file]} _modules[module] = dict # XXX Should we recursively look for submodules? return dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() dict = {} _modules[module] = dict return dict dict = {} _modules[module] = dict imports = [] classstack = [] # stack of (class, indent) pairs src = f.read() f.close() # To avoid having to stop the regexp at each newline, instead # when we need a line number we simply string.count the number of # newlines in the string since the last time we did this; i.e., # lineno = lineno + \ # string.count(src, '\n', last_lineno_pos, here) # last_lineno_pos = here countnl = string.count lineno, last_lineno_pos = 1, 0 i = 0 while 1: m = _getnext(src, i) if not m: break start, i = m.span() if m.start("Method") >= 0: # found a method definition or function thisindent = _indent(m.group("MethodIndent")) # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # and we know the class it belongs to meth_name = m.group("MethodName") lineno = lineno + \ countnl(src, '\n', last_lineno_pos, start) last_lineno_pos = start cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) elif m.start("String") >= 0: pass elif m.start("Class") >= 0: # we found a class definition thisindent = _indent(m.group("ClassIndent")) # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] lineno = lineno + \ countnl(src, '\n', last_lineno_pos, start) last_lineno_pos = start class_name = m.group("ClassName") inherit = m.group("ClassSupers") if inherit: # the class inherits from other classes inherit = string.strip(inherit[1:-1]) names = [] for n in string.splitfields(inherit, ','): n = string.strip(n) if dict.has_key(n): # we know this super class n = dict[n] else: c = string.splitfields(n, '.') if len(c) > 1: # super class # is of the # form module.class: # look in # module for class m = c[-2] c = c[-1] if _modules.has_key(m): d = _modules[m] if d.has_key(c): n = d[c] names.append(n) inherit = names # remember this class cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif m.start("Import") >= 0: # import module for n in string.split(m.group("ImportList"), ','): n = string.strip(n) try: # recursively read the imported module d = readmodule(n, path, inpackage) except: print 'module', n, 'not found' elif m.start("ImportFrom") >= 0: # from module import stuff mod = m.group("ImportFromPath") names = string.split(m.group("ImportFromList"), ',') try: # recursively read the imported module d = readmodule(mod, path, inpackage) except: print 'module', mod, 'not found' continue # add any classes that were defined in the # imported module to our name space if they # were mentioned in the list for n in names: n = string.strip(n) if d.has_key(n): dict[n] = d[n] elif n == '*': # only add a name if not # already there (to mimic what # Python does internally) # also don't add names that # start with _ for n in d.keys(): if n[0] != '_' and \ not dict.has_key(n): dict[n] = d[n] else: assert 0, "regexp _getnext found something unexpected" return dict
3d548717f502b068a582f3f1de82084dbd100c7a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3d548717f502b068a582f3f1de82084dbd100c7a/pyclbr.py
dict = {'__path__': [file]}
dict['__path__'] = [file]
def readmodule(module, path=[], inpackage=0): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module.''' i = string.rfind(module, '.') if i >= 0: # Dotted module name package = string.strip(module[:i]) submodule = string.strip(module[i+1:]) parent = readmodule(package, path, inpackage) child = readmodule(submodule, parent['__path__'], 1) return child if _modules.has_key(module): # we've seen this module before... return _modules[module] if module in sys.builtin_module_names: # this is a built-in module dict = {} _modules[module] = dict return dict # search the path for the module f = None if inpackage: try: f, file, (suff, mode, type) = \ imp.find_module(module, path) except ImportError: f = None if f is None: fullpath = list(path) + sys.path f, file, (suff, mode, type) = imp.find_module(module, fullpath) if type == imp.PKG_DIRECTORY: dict = {'__path__': [file]} _modules[module] = dict # XXX Should we recursively look for submodules? return dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() dict = {} _modules[module] = dict return dict dict = {} _modules[module] = dict imports = [] classstack = [] # stack of (class, indent) pairs src = f.read() f.close() # To avoid having to stop the regexp at each newline, instead # when we need a line number we simply string.count the number of # newlines in the string since the last time we did this; i.e., # lineno = lineno + \ # string.count(src, '\n', last_lineno_pos, here) # last_lineno_pos = here countnl = string.count lineno, last_lineno_pos = 1, 0 i = 0 while 1: m = _getnext(src, i) if not m: break start, i = m.span() if m.start("Method") >= 0: # found a method definition or function thisindent = _indent(m.group("MethodIndent")) # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # and we know the class it belongs to meth_name = m.group("MethodName") lineno = lineno + \ countnl(src, '\n', last_lineno_pos, start) last_lineno_pos = start cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) elif m.start("String") >= 0: pass elif m.start("Class") >= 0: # we found a class definition thisindent = _indent(m.group("ClassIndent")) # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] lineno = lineno + \ countnl(src, '\n', last_lineno_pos, start) last_lineno_pos = start class_name = m.group("ClassName") inherit = m.group("ClassSupers") if inherit: # the class inherits from other classes inherit = string.strip(inherit[1:-1]) names = [] for n in string.splitfields(inherit, ','): n = string.strip(n) if dict.has_key(n): # we know this super class n = dict[n] else: c = string.splitfields(n, '.') if len(c) > 1: # super class # is of the # form module.class: # look in # module for class m = c[-2] c = c[-1] if _modules.has_key(m): d = _modules[m] if d.has_key(c): n = d[c] names.append(n) inherit = names # remember this class cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif m.start("Import") >= 0: # import module for n in string.split(m.group("ImportList"), ','): n = string.strip(n) try: # recursively read the imported module d = readmodule(n, path, inpackage) except: print 'module', n, 'not found' elif m.start("ImportFrom") >= 0: # from module import stuff mod = m.group("ImportFromPath") names = string.split(m.group("ImportFromList"), ',') try: # recursively read the imported module d = readmodule(mod, path, inpackage) except: print 'module', mod, 'not found' continue # add any classes that were defined in the # imported module to our name space if they # were mentioned in the list for n in names: n = string.strip(n) if d.has_key(n): dict[n] = d[n] elif n == '*': # only add a name if not # already there (to mimic what # Python does internally) # also don't add names that # start with _ for n in d.keys(): if n[0] != '_' and \ not dict.has_key(n): dict[n] = d[n] else: assert 0, "regexp _getnext found something unexpected" return dict
3d548717f502b068a582f3f1de82084dbd100c7a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3d548717f502b068a582f3f1de82084dbd100c7a/pyclbr.py
return dict
path = [file] + path f, file, (suff, mode, type) = \ imp.find_module('__init__', [file])
def readmodule(module, path=[], inpackage=0): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module.''' i = string.rfind(module, '.') if i >= 0: # Dotted module name package = string.strip(module[:i]) submodule = string.strip(module[i+1:]) parent = readmodule(package, path, inpackage) child = readmodule(submodule, parent['__path__'], 1) return child if _modules.has_key(module): # we've seen this module before... return _modules[module] if module in sys.builtin_module_names: # this is a built-in module dict = {} _modules[module] = dict return dict # search the path for the module f = None if inpackage: try: f, file, (suff, mode, type) = \ imp.find_module(module, path) except ImportError: f = None if f is None: fullpath = list(path) + sys.path f, file, (suff, mode, type) = imp.find_module(module, fullpath) if type == imp.PKG_DIRECTORY: dict = {'__path__': [file]} _modules[module] = dict # XXX Should we recursively look for submodules? return dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() dict = {} _modules[module] = dict return dict dict = {} _modules[module] = dict imports = [] classstack = [] # stack of (class, indent) pairs src = f.read() f.close() # To avoid having to stop the regexp at each newline, instead # when we need a line number we simply string.count the number of # newlines in the string since the last time we did this; i.e., # lineno = lineno + \ # string.count(src, '\n', last_lineno_pos, here) # last_lineno_pos = here countnl = string.count lineno, last_lineno_pos = 1, 0 i = 0 while 1: m = _getnext(src, i) if not m: break start, i = m.span() if m.start("Method") >= 0: # found a method definition or function thisindent = _indent(m.group("MethodIndent")) # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # and we know the class it belongs to meth_name = m.group("MethodName") lineno = lineno + \ countnl(src, '\n', last_lineno_pos, start) last_lineno_pos = start cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) elif m.start("String") >= 0: pass elif m.start("Class") >= 0: # we found a class definition thisindent = _indent(m.group("ClassIndent")) # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] lineno = lineno + \ countnl(src, '\n', last_lineno_pos, start) last_lineno_pos = start class_name = m.group("ClassName") inherit = m.group("ClassSupers") if inherit: # the class inherits from other classes inherit = string.strip(inherit[1:-1]) names = [] for n in string.splitfields(inherit, ','): n = string.strip(n) if dict.has_key(n): # we know this super class n = dict[n] else: c = string.splitfields(n, '.') if len(c) > 1: # super class # is of the # form module.class: # look in # module for class m = c[-2] c = c[-1] if _modules.has_key(m): d = _modules[m] if d.has_key(c): n = d[c] names.append(n) inherit = names # remember this class cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif m.start("Import") >= 0: # import module for n in string.split(m.group("ImportList"), ','): n = string.strip(n) try: # recursively read the imported module d = readmodule(n, path, inpackage) except: print 'module', n, 'not found' elif m.start("ImportFrom") >= 0: # from module import stuff mod = m.group("ImportFromPath") names = string.split(m.group("ImportFromList"), ',') try: # recursively read the imported module d = readmodule(mod, path, inpackage) except: print 'module', mod, 'not found' continue # add any classes that were defined in the # imported module to our name space if they # were mentioned in the list for n in names: n = string.strip(n) if d.has_key(n): dict[n] = d[n] elif n == '*': # only add a name if not # already there (to mimic what # Python does internally) # also don't add names that # start with _ for n in d.keys(): if n[0] != '_' and \ not dict.has_key(n): dict[n] = d[n] else: assert 0, "regexp _getnext found something unexpected" return dict
3d548717f502b068a582f3f1de82084dbd100c7a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3d548717f502b068a582f3f1de82084dbd100c7a/pyclbr.py
dict = {}
def readmodule(module, path=[], inpackage=0): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module.''' i = string.rfind(module, '.') if i >= 0: # Dotted module name package = string.strip(module[:i]) submodule = string.strip(module[i+1:]) parent = readmodule(package, path, inpackage) child = readmodule(submodule, parent['__path__'], 1) return child if _modules.has_key(module): # we've seen this module before... return _modules[module] if module in sys.builtin_module_names: # this is a built-in module dict = {} _modules[module] = dict return dict # search the path for the module f = None if inpackage: try: f, file, (suff, mode, type) = \ imp.find_module(module, path) except ImportError: f = None if f is None: fullpath = list(path) + sys.path f, file, (suff, mode, type) = imp.find_module(module, fullpath) if type == imp.PKG_DIRECTORY: dict = {'__path__': [file]} _modules[module] = dict # XXX Should we recursively look for submodules? return dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() dict = {} _modules[module] = dict return dict dict = {} _modules[module] = dict imports = [] classstack = [] # stack of (class, indent) pairs src = f.read() f.close() # To avoid having to stop the regexp at each newline, instead # when we need a line number we simply string.count the number of # newlines in the string since the last time we did this; i.e., # lineno = lineno + \ # string.count(src, '\n', last_lineno_pos, here) # last_lineno_pos = here countnl = string.count lineno, last_lineno_pos = 1, 0 i = 0 while 1: m = _getnext(src, i) if not m: break start, i = m.span() if m.start("Method") >= 0: # found a method definition or function thisindent = _indent(m.group("MethodIndent")) # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # and we know the class it belongs to meth_name = m.group("MethodName") lineno = lineno + \ countnl(src, '\n', last_lineno_pos, start) last_lineno_pos = start cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) elif m.start("String") >= 0: pass elif m.start("Class") >= 0: # we found a class definition thisindent = _indent(m.group("ClassIndent")) # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] lineno = lineno + \ countnl(src, '\n', last_lineno_pos, start) last_lineno_pos = start class_name = m.group("ClassName") inherit = m.group("ClassSupers") if inherit: # the class inherits from other classes inherit = string.strip(inherit[1:-1]) names = [] for n in string.splitfields(inherit, ','): n = string.strip(n) if dict.has_key(n): # we know this super class n = dict[n] else: c = string.splitfields(n, '.') if len(c) > 1: # super class # is of the # form module.class: # look in # module for class m = c[-2] c = c[-1] if _modules.has_key(m): d = _modules[m] if d.has_key(c): n = d[c] names.append(n) inherit = names # remember this class cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif m.start("Import") >= 0: # import module for n in string.split(m.group("ImportList"), ','): n = string.strip(n) try: # recursively read the imported module d = readmodule(n, path, inpackage) except: print 'module', n, 'not found' elif m.start("ImportFrom") >= 0: # from module import stuff mod = m.group("ImportFromPath") names = string.split(m.group("ImportFromList"), ',') try: # recursively read the imported module d = readmodule(mod, path, inpackage) except: print 'module', mod, 'not found' continue # add any classes that were defined in the # imported module to our name space if they # were mentioned in the list for n in names: n = string.strip(n) if d.has_key(n): dict[n] = d[n] elif n == '*': # only add a name if not # already there (to mimic what # Python does internally) # also don't add names that # start with _ for n in d.keys(): if n[0] != '_' and \ not dict.has_key(n): dict[n] = d[n] else: assert 0, "regexp _getnext found something unexpected" return dict
3d548717f502b068a582f3f1de82084dbd100c7a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3d548717f502b068a582f3f1de82084dbd100c7a/pyclbr.py
dict = {}
def readmodule(module, path=[], inpackage=0): '''Read a module file and return a dictionary of classes. Search for MODULE in PATH and sys.path, read and parse the module and return a dictionary with one entry for each class found in the module.''' i = string.rfind(module, '.') if i >= 0: # Dotted module name package = string.strip(module[:i]) submodule = string.strip(module[i+1:]) parent = readmodule(package, path, inpackage) child = readmodule(submodule, parent['__path__'], 1) return child if _modules.has_key(module): # we've seen this module before... return _modules[module] if module in sys.builtin_module_names: # this is a built-in module dict = {} _modules[module] = dict return dict # search the path for the module f = None if inpackage: try: f, file, (suff, mode, type) = \ imp.find_module(module, path) except ImportError: f = None if f is None: fullpath = list(path) + sys.path f, file, (suff, mode, type) = imp.find_module(module, fullpath) if type == imp.PKG_DIRECTORY: dict = {'__path__': [file]} _modules[module] = dict # XXX Should we recursively look for submodules? return dict if type != imp.PY_SOURCE: # not Python source, can't do anything with this module f.close() dict = {} _modules[module] = dict return dict dict = {} _modules[module] = dict imports = [] classstack = [] # stack of (class, indent) pairs src = f.read() f.close() # To avoid having to stop the regexp at each newline, instead # when we need a line number we simply string.count the number of # newlines in the string since the last time we did this; i.e., # lineno = lineno + \ # string.count(src, '\n', last_lineno_pos, here) # last_lineno_pos = here countnl = string.count lineno, last_lineno_pos = 1, 0 i = 0 while 1: m = _getnext(src, i) if not m: break start, i = m.span() if m.start("Method") >= 0: # found a method definition or function thisindent = _indent(m.group("MethodIndent")) # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] if classstack: # and we know the class it belongs to meth_name = m.group("MethodName") lineno = lineno + \ countnl(src, '\n', last_lineno_pos, start) last_lineno_pos = start cur_class = classstack[-1][0] cur_class._addmethod(meth_name, lineno) elif m.start("String") >= 0: pass elif m.start("Class") >= 0: # we found a class definition thisindent = _indent(m.group("ClassIndent")) # close all classes indented at least as much while classstack and \ classstack[-1][1] >= thisindent: del classstack[-1] lineno = lineno + \ countnl(src, '\n', last_lineno_pos, start) last_lineno_pos = start class_name = m.group("ClassName") inherit = m.group("ClassSupers") if inherit: # the class inherits from other classes inherit = string.strip(inherit[1:-1]) names = [] for n in string.splitfields(inherit, ','): n = string.strip(n) if dict.has_key(n): # we know this super class n = dict[n] else: c = string.splitfields(n, '.') if len(c) > 1: # super class # is of the # form module.class: # look in # module for class m = c[-2] c = c[-1] if _modules.has_key(m): d = _modules[m] if d.has_key(c): n = d[c] names.append(n) inherit = names # remember this class cur_class = Class(module, class_name, inherit, file, lineno) dict[class_name] = cur_class classstack.append((cur_class, thisindent)) elif m.start("Import") >= 0: # import module for n in string.split(m.group("ImportList"), ','): n = string.strip(n) try: # recursively read the imported module d = readmodule(n, path, inpackage) except: print 'module', n, 'not found' elif m.start("ImportFrom") >= 0: # from module import stuff mod = m.group("ImportFromPath") names = string.split(m.group("ImportFromList"), ',') try: # recursively read the imported module d = readmodule(mod, path, inpackage) except: print 'module', mod, 'not found' continue # add any classes that were defined in the # imported module to our name space if they # were mentioned in the list for n in names: n = string.strip(n) if d.has_key(n): dict[n] = d[n] elif n == '*': # only add a name if not # already there (to mimic what # Python does internally) # also don't add names that # start with _ for n in d.keys(): if n[0] != '_' and \ not dict.has_key(n): dict[n] = d[n] else: assert 0, "regexp _getnext found something unexpected" return dict
3d548717f502b068a582f3f1de82084dbd100c7a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3d548717f502b068a582f3f1de82084dbd100c7a/pyclbr.py
path = os.path.join(host, path) if path[-1] == "/": path = path + "index.html"
if not path or path[-1] == "/": path = path + "index.html"
def savefilename(self, url): type, rest = urllib.splittype(url) host, path = urllib.splithost(rest) while path[:1] == "/": path = path[1:] user, host = urllib.splituser(host) host, port = urllib.splitnport(host) host = string.lower(host) path = os.path.join(host, path) if path[-1] == "/": path = path + "index.html" if os.sep != "/": path = string.join(string.split(path, "/"), os.sep) return path
d328a9b5f41b38d6127d697b0f9fb5f85e52adfa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d328a9b5f41b38d6127d697b0f9fb5f85e52adfa/websucker.py
if c not in '123': raise error_proto, resp return resp
raise error_proto, resp
def getresp(self): resp = self.getmultiline() if self.debugging: print '*resp*', self.sanitize(resp) self.lastresp = resp[:3] c = resp[:1] if c == '4': raise error_temp, resp if c == '5': raise error_perm, resp if c not in '123': raise error_proto, resp return resp
c88a6c75df1e2dac818b63a36db6c8282f4541f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c88a6c75df1e2dac818b63a36db6c8282f4541f7/ftplib.py
if resp[:3] <> '229':
if resp[:3] != '229':
def parse229(resp, peer): '''Parse the '229' response for a EPSV request. Raises error_proto if it does not contain '(|||port|)' Return ('host.addr.as.numbers', port#) tuple.''' if resp[:3] <> '229': raise error_reply, resp left = resp.find('(') if left < 0: raise error_proto, resp right = resp.find(')', left + 1) if right < 0: raise error_proto, resp # should contain '(|||port|)' if resp[left + 1] <> resp[right - 1]: raise error_proto, resp parts = resp[left + 1:right].split(resp[left+1]) if len(parts) <> 5: raise error_proto, resp host = peer[0] port = int(parts[3]) return host, port
c88a6c75df1e2dac818b63a36db6c8282f4541f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c88a6c75df1e2dac818b63a36db6c8282f4541f7/ftplib.py
if resp[left + 1] <> resp[right - 1]:
if resp[left + 1] != resp[right - 1]:
def parse229(resp, peer): '''Parse the '229' response for a EPSV request. Raises error_proto if it does not contain '(|||port|)' Return ('host.addr.as.numbers', port#) tuple.''' if resp[:3] <> '229': raise error_reply, resp left = resp.find('(') if left < 0: raise error_proto, resp right = resp.find(')', left + 1) if right < 0: raise error_proto, resp # should contain '(|||port|)' if resp[left + 1] <> resp[right - 1]: raise error_proto, resp parts = resp[left + 1:right].split(resp[left+1]) if len(parts) <> 5: raise error_proto, resp host = peer[0] port = int(parts[3]) return host, port
c88a6c75df1e2dac818b63a36db6c8282f4541f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c88a6c75df1e2dac818b63a36db6c8282f4541f7/ftplib.py
if len(parts) <> 5:
if len(parts) != 5:
def parse229(resp, peer): '''Parse the '229' response for a EPSV request. Raises error_proto if it does not contain '(|||port|)' Return ('host.addr.as.numbers', port#) tuple.''' if resp[:3] <> '229': raise error_reply, resp left = resp.find('(') if left < 0: raise error_proto, resp right = resp.find(')', left + 1) if right < 0: raise error_proto, resp # should contain '(|||port|)' if resp[left + 1] <> resp[right - 1]: raise error_proto, resp parts = resp[left + 1:right].split(resp[left+1]) if len(parts) <> 5: raise error_proto, resp host = peer[0] port = int(parts[3]) return host, port
c88a6c75df1e2dac818b63a36db6c8282f4541f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c88a6c75df1e2dac818b63a36db6c8282f4541f7/ftplib.py
Usage: ftp [-d] [-r[file]] host [-l[dir]] [-d[dir]] [-p] [file] ...'''
Usage: ftp [-d] [-r[file]] host [-l[dir]] [-d[dir]] [-p] [file] ... -d dir -l list -p password ''' if len(sys.argv) < 2: print test.__doc__ sys.exit(0)
def test(): '''Test program. Usage: ftp [-d] [-r[file]] host [-l[dir]] [-d[dir]] [-p] [file] ...''' debugging = 0 rcfile = None while sys.argv[1] == '-d': debugging = debugging+1 del sys.argv[1] if sys.argv[1][:2] == '-r': # get name of alternate ~/.netrc file: rcfile = sys.argv[1][2:] del sys.argv[1] host = sys.argv[1] ftp = FTP(host) ftp.set_debuglevel(debugging) userid = passwd = acct = '' try: netrc = Netrc(rcfile) except IOError: if rcfile is not None: sys.stderr.write("Could not open account file" " -- using anonymous login.") else: try: userid, passwd, acct = netrc.get_account(host) except KeyError: # no account for host sys.stderr.write( "No account -- using anonymous login.") ftp.login(userid, passwd, acct) for file in sys.argv[2:]: if file[:2] == '-l': ftp.dir(file[2:]) elif file[:2] == '-d': cmd = 'CWD' if file[2:]: cmd = cmd + ' ' + file[2:] resp = ftp.sendcmd(cmd) elif file == '-p': ftp.set_pasv(not ftp.passiveserver) else: ftp.retrbinary('RETR ' + file, \ sys.stdout.write, 1024) ftp.quit()
c88a6c75df1e2dac818b63a36db6c8282f4541f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c88a6c75df1e2dac818b63a36db6c8282f4541f7/ftplib.py
(S_IFLNK, "l", S_IFREG, "-", S_IFBLK, "b", S_IFDIR, "d", S_IFCHR, "c", S_IFIFO, "p"), (TUREAD, "r"), (TUWRITE, "w"), (TUEXEC, "x", TSUID, "S", TUEXEC|TSUID, "s"), (TGREAD, "r"), (TGWRITE, "w"), (TGEXEC, "x", TSGID, "S", TGEXEC|TSGID, "s"), (TOREAD, "r"), (TOWRITE, "w"), (TOEXEC, "x", TSVTX, "T", TOEXEC|TSVTX, "t"))
((S_IFLNK, "l"), (S_IFREG, "-"), (S_IFBLK, "b"), (S_IFDIR, "d"), (S_IFCHR, "c"), (S_IFIFO, "p")), ((TUREAD, "r"),), ((TUWRITE, "w"),), ((TUEXEC|TSUID, "s"), (TSUID, "S"), (TUEXEC, "x")), ((TGREAD, "r"),), ((TGWRITE, "w"),), ((TGEXEC|TSGID, "s"), (TSGID, "S"), (TGEXEC, "x")), ((TOREAD, "r"),), ((TOWRITE, "w"),), ((TOEXEC|TSVTX, "t"), (TSVTX, "T"), (TOEXEC, "x")) )
def copyfileobj(src, dst, length=None): """Copy length bytes from fileobj src to fileobj dst. If length is None, copy the entire content. """ if length == 0: return if length is None: shutil.copyfileobj(src, dst) return BUFSIZE = 16 * 1024 blocks, remainder = divmod(length, BUFSIZE) for b in xrange(blocks): buf = src.read(BUFSIZE) if len(buf) < BUFSIZE: raise IOError, "end of file reached" dst.write(buf) if remainder != 0: buf = src.read(remainder) if len(buf) < remainder: raise IOError, "end of file reached" dst.write(buf) return
8bc462fcafe9f11094f0185813f95c0f569b112e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8bc462fcafe9f11094f0185813f95c0f569b112e/tarfile.py
s = "" for t in filemode_table: while True: if mode & t[0] == t[0]: s += t[1] elif len(t) > 2: t = t[2:] continue else: s += "-" break return s
perm = [] for table in filemode_table: for bit, char in table: if mode & bit == bit: perm.append(char) break else: perm.append("-") return "".join(perm)
def filemode(mode): """Convert a file's mode to a string of the form -rwxrwxrwx. Used by TarFile.list() """ s = "" for t in filemode_table: while True: if mode & t[0] == t[0]: s += t[1] elif len(t) > 2: t = t[2:] continue else: s += "-" break return s
8bc462fcafe9f11094f0185813f95c0f569b112e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8bc462fcafe9f11094f0185813f95c0f569b112e/tarfile.py
l.grid(row=self.row, col=0, sticky="nw")
l.grid(row=self.row, column=0, sticky="nw")
def make_entry(self, label, var): l = Label(self.top, text=label) l.grid(row=self.row, col=0, sticky="nw") e = Entry(self.top, textvariable=var, exportselection=0) e.grid(row=self.row, col=1, sticky="nwe") self.row = self.row + 1 return e
4fc904708bc3175669d158d647b8a2fd14036373 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4fc904708bc3175669d158d647b8a2fd14036373/SearchDialogBase.py
e.grid(row=self.row, col=1, sticky="nwe")
e.grid(row=self.row, column=1, sticky="nwe")
def make_entry(self, label, var): l = Label(self.top, text=label) l.grid(row=self.row, col=0, sticky="nw") e = Entry(self.top, textvariable=var, exportselection=0) e.grid(row=self.row, col=1, sticky="nwe") self.row = self.row + 1 return e
4fc904708bc3175669d158d647b8a2fd14036373 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4fc904708bc3175669d158d647b8a2fd14036373/SearchDialogBase.py
l.grid(row=self.row, col=0, sticky="nw")
l.grid(row=self.row, column=0, sticky="nw")
def make_frame(self,labeltext=None): if labeltext: l = Label(self.top, text=labeltext) l.grid(row=self.row, col=0, sticky="nw") f = Frame(self.top) f.grid(row=self.row, col=1, columnspan=1, sticky="nwe") self.row = self.row + 1 return f
4fc904708bc3175669d158d647b8a2fd14036373 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4fc904708bc3175669d158d647b8a2fd14036373/SearchDialogBase.py
f.grid(row=self.row, col=1, columnspan=1, sticky="nwe")
f.grid(row=self.row, column=1, columnspan=1, sticky="nwe")
def make_frame(self,labeltext=None): if labeltext: l = Label(self.top, text=labeltext) l.grid(row=self.row, col=0, sticky="nw") f = Frame(self.top) f.grid(row=self.row, col=1, columnspan=1, sticky="nwe") self.row = self.row + 1 return f
4fc904708bc3175669d158d647b8a2fd14036373 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4fc904708bc3175669d158d647b8a2fd14036373/SearchDialogBase.py
f.grid(row=0,col=2,padx=2,pady=2,ipadx=2,ipady=2)
f.grid(row=0,column=2,padx=2,pady=2,ipadx=2,ipady=2)
def create_command_buttons(self): # # place button frame on the right f = self.buttonframe = Frame(self.top) f.grid(row=0,col=2,padx=2,pady=2,ipadx=2,ipady=2)
4fc904708bc3175669d158d647b8a2fd14036373 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4fc904708bc3175669d158d647b8a2fd14036373/SearchDialogBase.py
def startElement(self, name, tagName, attrs):
def startElement(self, name, attrs):
def startElement(self, name, tagName, attrs): if not hasattr(self, "curNode"): # FIXME: hack! self.startDocument()
e84bf751bb0d18851877518dbb6d382f909f16b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e84bf751bb0d18851877518dbb6d382f909f16b4/pulldom.py
node = self.document.createElement(tagName) for attr in attrs.keys():
node = self.document.createElement(name) for (attr, value) in attrs.items():
def startElement(self, name, tagName, attrs): if not hasattr(self, "curNode"): # FIXME: hack! self.startDocument()
e84bf751bb0d18851877518dbb6d382f909f16b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e84bf751bb0d18851877518dbb6d382f909f16b4/pulldom.py
def startElement(self, name, tagName, attrs): if not hasattr(self, "curNode"): # FIXME: hack! self.startDocument()
e84bf751bb0d18851877518dbb6d382f909f16b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e84bf751bb0d18851877518dbb6d382f909f16b4/pulldom.py
def endElement(self, name, tagName):
def endElement(self, name):
def endElement(self, name, tagName): node = self.curNode self.lastEvent[1] = [(END_ELEMENT, node), None] self.lastEvent = self.lastEvent[1] #self.events.append((END_ELEMENT, node)) self.curNode = node.parentNode
e84bf751bb0d18851877518dbb6d382f909f16b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e84bf751bb0d18851877518dbb6d382f909f16b4/pulldom.py
exts.append( Extension('pwd', ['pwdmodule.c']) ) exts.append( Extension('grp', ['grpmodule.c']) )
if platform not in ['mac']: exts.append( Extension('pwd', ['pwdmodule.c']) ) exts.append( Extension('grp', ['grpmodule.c']) )
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
73aa1fff85c7c6ff940ace1a5de8a895e24e0132 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/73aa1fff85c7c6ff940ace1a5de8a895e24e0132/setup.py
if platform not in ['atheos']:
if platform not in ['atheos', 'mac']:
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
73aa1fff85c7c6ff940ace1a5de8a895e24e0132 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/73aa1fff85c7c6ff940ace1a5de8a895e24e0132/setup.py
exts.append( Extension('syslog', ['syslogmodule.c']) )
if platform not in ['mac']: exts.append( Extension('syslog', ['syslogmodule.c']) )
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
73aa1fff85c7c6ff940ace1a5de8a895e24e0132 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/73aa1fff85c7c6ff940ace1a5de8a895e24e0132/setup.py
if self.compiler.find_library_file(lib_dirs, 'crypt'): libs = ['crypt'] else: libs = [] exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) )
if platform not in ['mac']: if self.compiler.find_library_file(lib_dirs, 'crypt'): libs = ['crypt'] else: libs = [] exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) )
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
73aa1fff85c7c6ff940ace1a5de8a895e24e0132 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/73aa1fff85c7c6ff940ace1a5de8a895e24e0132/setup.py
if platform not in ['cygwin']:
if platform not in ['cygwin', 'mac']:
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
73aa1fff85c7c6ff940ace1a5de8a895e24e0132 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/73aa1fff85c7c6ff940ace1a5de8a895e24e0132/setup.py
strftime_output = time.strftime("%c", self.time_tuple) self.failUnless(strftime_output == time.strftime(self.LT_ins.LC_date_time, self.time_tuple), "LC_date_time incorrect")
def test_date_time(self): # Check that LC_date_time, LC_date, and LC_time are correct strftime_output = time.strftime("%c", self.time_tuple) self.failUnless(strftime_output == time.strftime(self.LT_ins.LC_date_time, self.time_tuple), "LC_date_time incorrect") strftime_output = time.strftime("%x", self.time_tuple) self.failUnless(strftime_output == time.strftime(self.LT_ins.LC_date, self.time_tuple), "LC_date incorrect") strftime_output = time.strftime("%X", self.time_tuple) self.failUnless(strftime_output == time.strftime(self.LT_ins.LC_time, self.time_tuple), "LC_time incorrect")
472c5229c4876fad95fca103fd81d35b7dd9fc13 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/472c5229c4876fad95fca103fd81d35b7dd9fc13/test_strptime.py
on connect to the Net for testing.
on connecting to the Net for testing.
def hexescape(char): """Escape char as RFC 2396 specifies""" hex_repr = hex(ord(char))[2:].upper() if len(hex_repr) == 1: hex_repr = "0%s" % hex_repr return "%" + hex_repr
f1a2f9ec41e3477ae09da0ead52a573ec578de42 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f1a2f9ec41e3477ae09da0ead52a573ec578de42/test_urllib.py
return apply(Open, (), options).show()
return Open(**options).show()
def askopenfilename(**options): "Ask for a filename to open" return apply(Open, (), options).show()
25ee87cc50ab99a1342091b5067c074878c9b212 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/25ee87cc50ab99a1342091b5067c074878c9b212/tkFileDialog.py
return apply(SaveAs, (), options).show()
return SaveAs(**options).show()
def asksaveasfilename(**options): "Ask for a filename to save as" return apply(SaveAs, (), options).show()
25ee87cc50ab99a1342091b5067c074878c9b212 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/25ee87cc50ab99a1342091b5067c074878c9b212/tkFileDialog.py
filename = apply(Open, (), options).show()
filename = Open(**options).show()
def askopenfile(mode = "r", **options): "Ask for a filename to open, and returned the opened file" filename = apply(Open, (), options).show() if filename: return open(filename, mode) return None
25ee87cc50ab99a1342091b5067c074878c9b212 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/25ee87cc50ab99a1342091b5067c074878c9b212/tkFileDialog.py
filename = apply(SaveAs, (), options).show()
filename = SaveAs(**options).show()
def asksaveasfile(mode = "w", **options): "Ask for a filename to save as, and returned the opened file" filename = apply(SaveAs, (), options).show() if filename: return open(filename, mode) return None
25ee87cc50ab99a1342091b5067c074878c9b212 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/25ee87cc50ab99a1342091b5067c074878c9b212/tkFileDialog.py
self.top.wm_deiconify() self.top.tkraise()
def close(self): self.top.wm_deiconify() self.top.tkraise() reply = self.maybesave() if reply != "cancel": self._close() return reply
67716b5f53715e57d147cde9539b8d76a5a56e11 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/67716b5f53715e57d147cde9539b8d76a5a56e11/EditorWindow.py
r'(?P<option>[-\w_.*,(){}]+)'
r'(?P<option>[]\-[\w_.*,(){}]+)'
def remove_section(self, section): """Remove a file section.""" if self.__sections.has_key(section): del self.__sections[section] return 1 else: return 0
d83bbbfd222d7e399fd8b2b17492c1448dc4f2a2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d83bbbfd222d7e399fd8b2b17492c1448dc4f2a2/ConfigParser.py
else: if __debug__: self.fail("AssertionError not raised by assert 0")
def testAssert(self): # assert_stmt: 'assert' test [',' test] assert 1 assert 1, 1 assert lambda x:x assert 1, lambda x:x+1 try: assert 0, "msg" except AssertionError, e: self.assertEquals(e.args[0], "msg") # we can not expect an assertion error to be raised # if the tests are run in an optimized python #else: # self.fail("AssertionError not raised by assert 0")
facd273198689d9c083056e55fca95c1db348d0e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/facd273198689d9c083056e55fca95c1db348d0e/test_grammar.py
self.c_func_name = arg
self.c_func_name = repr(arg)
def trace_dispatch(self, frame, event, arg): timer = self.timer t = timer() t = t[0] + t[1] - self.t - self.bias
2e39d80925437b8f5aac6bd130188ead381792ec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2e39d80925437b8f5aac6bd130188ead381792ec/profile.py
self.c_func_name = arg
self.c_func_name = repr(arg)
def trace_dispatch_i(self, frame, event, arg): timer = self.timer t = timer() - self.t - self.bias
2e39d80925437b8f5aac6bd130188ead381792ec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2e39d80925437b8f5aac6bd130188ead381792ec/profile.py
self.c_func_name = arg
self.c_func_name = repr(arg)
def trace_dispatch_mac(self, frame, event, arg): timer = self.timer t = timer()/60.0 - self.t - self.bias
2e39d80925437b8f5aac6bd130188ead381792ec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2e39d80925437b8f5aac6bd130188ead381792ec/profile.py
self.c_func_name = arg
self.c_func_name = repr(arg)
def trace_dispatch_l(self, frame, event, arg): get_time = self.get_time t = get_time() - self.t - self.bias
2e39d80925437b8f5aac6bd130188ead381792ec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2e39d80925437b8f5aac6bd130188ead381792ec/profile.py
import warnings warnings.warn("cookielib bug!", stacklevel=2) import traceback traceback.print_exc()
import warnings, traceback, StringIO f = StringIO.StringIO() traceback.print_exc(None, f) msg = f.getvalue() warnings.warn("cookielib bug!\n%s" % msg, stacklevel=2)
def reraise_unmasked_exceptions(unmasked=()): # There are a few catch-all except: statements in this module, for # catching input that's bad in unexpected ways. # This function re-raises some exceptions we don't want to trap. unmasked = unmasked + (KeyboardInterrupt, SystemExit, MemoryError) etype = sys.exc_info()[0] if issubclass(etype, unmasked): raise # swallowed an exception import warnings warnings.warn("cookielib bug!", stacklevel=2) import traceback traceback.print_exc()
ae40c2f795c038abbc5e6df05f050f3d8154c4a7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ae40c2f795c038abbc5e6df05f050f3d8154c4a7/cookielib.py
print "<H3>Shell environment:</H3>"
print "<H3>Shell Environment:</H3>"
def print_environ(): """Dump the shell environment as HTML.""" keys = environ.keys() keys.sort() print print "<H3>Shell environment:</H3>" print "<DL>" for key in keys: print "<DT>", escape(key), "<DD>", escape(environ[key]) print "</DL>" print
503e50b0fa73e3e549dde6cf643bac27f5f6b124 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/503e50b0fa73e3e549dde6cf643bac27f5f6b124/cgi.py
print "<H3>Form contents:</H3>"
print "<H3>Form Contents:</H3>"
def print_form(form): """Dump the contents of a form as HTML.""" keys = form.keys() keys.sort() print print "<H3>Form contents:</H3>" print "<DL>" for key in keys: print "<DT>" + escape(key) + ":", value = form[key] print "<i>" + escape(`type(value)`) + "</i>" print "<DD>" + escape(`value`) print "</DL>" print
503e50b0fa73e3e549dde6cf643bac27f5f6b124 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/503e50b0fa73e3e549dde6cf643bac27f5f6b124/cgi.py
print "<H3>Command line Arguments:</H3>"
print "<H3>Command Line Arguments:</H3>"
def print_arguments(): print print "<H3>Command line Arguments:</H3>" print print sys.argv print
503e50b0fa73e3e549dde6cf643bac27f5f6b124 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/503e50b0fa73e3e549dde6cf643bac27f5f6b124/cgi.py
def _call_chain(self, chain, kind, meth_name, *args): # XXX raise an exception if no one else should try to handle # this url. return None if you can't but someone else could. handlers = chain.get(kind, ()) for handler in handlers: func = getattr(handler, meth_name)
c5ffd9191189b00c9801f126604bb0b575e19e16 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c5ffd9191189b00c9801f126604bb0b575e19e16/urllib2.py
class CustomProxy: def __init__(self, proto, func=None, proxy_addr=None): self.proto = proto self.func = func self.addr = proxy_addr def handle(self, req): if self.func and self.func(req): return 1 def get_proxy(self): return self.addr class CustomProxyHandler(BaseHandler): handler_order = 100 def __init__(self, *proxies): self.proxies = {} def proxy_open(self, req): proto = req.get_type() try: proxies = self.proxies[proto] except KeyError: return None for p in proxies: if p.handle(req): req.set_proxy(p.get_proxy()) return self.parent.open(req) return None def do_proxy(self, p, req): return self.parent.open(req) def add_proxy(self, cpo): if cpo.proto in self.proxies: self.proxies[cpo.proto].append(cpo) else: self.proxies[cpo.proto] = [cpo]
def proxy_open(self, req, proxy, type): orig_type = req.get_type() proxy_type, user, password, hostport = _parse_proxy(proxy) if proxy_type is None: proxy_type = orig_type if user and password: user_pass = '%s:%s' % (unquote(user), unquote(password)) creds = base64.encodestring(user_pass).strip() req.add_header('Proxy-authorization', 'Basic ' + creds) hostport = unquote(hostport) req.set_proxy(hostport, proxy_type) if orig_type == proxy_type: # let other handlers take care of it return None else: # need to start over, because the other handlers don't # grok the proxy's URL type # e.g. if we have a constructor arg proxies like so: # {'http': 'ftp://proxy.example.com'}, we may end up turning # a request for http://acme.example.com/a into one for # ftp://proxy.example.com/a return self.parent.open(req)
c5ffd9191189b00c9801f126604bb0b575e19e16 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c5ffd9191189b00c9801f126604bb0b575e19e16/urllib2.py
class OpenerFactory: default_handlers = [UnknownHandler, HTTPHandler, HTTPDefaultErrorHandler, HTTPRedirectHandler, FTPHandler, FileHandler] handlers = [] replacement_handlers = [] def add_handler(self, h): self.handlers = self.handlers + [h] def replace_handler(self, h): pass def build_opener(self): opener = OpenerDirector() for ph in self.default_handlers: if inspect.isclass(ph): ph = ph() opener.add_handler(ph)
def gopher_open(self, req): import gopherlib # this raises DeprecationWarning in 2.5 host = req.get_host() if not host: raise GopherError('no host given') host = unquote(host) selector = req.get_selector() type, selector = splitgophertype(selector) selector, query = splitquery(selector) selector = unquote(selector) if query: query = unquote(query) fp = gopherlib.send_query(selector, query, host) else: fp = gopherlib.send_selector(selector, host) return addinfourl(fp, noheaders(), req.get_full_url())
c5ffd9191189b00c9801f126604bb0b575e19e16 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c5ffd9191189b00c9801f126604bb0b575e19e16/urllib2.py
vout.setpf(1, -2))
vout.setpf((1, -2))
def record(v, info, filename, audiofilename, mono, grey, greybits, \ monotreshold, fields, preallocspace): import thread format, x, y, qsize, rate = info fps = 59.64 # Fields per second # XXX (Strange: need fps of Indigo monitor, not of PAL or NTSC!) tpf = 1000.0 / fps # Time per field in msec if filename: vout = VFile.VoutFile().init(filename) if mono: format = 'mono' elif grey and greybits == 8: format = 'grey' elif grey: format = 'grey'+`abs(greybits)` else: format = 'rgb8' vout.setformat(format) vout.setsize(x, y) if fields: vout.setpf(1, -2)) vout.writeheader() if preallocspace: print 'Preallocating space...' vout.prealloc(preallocspace) print 'done.' MAXSIZE = 20 # XXX should be a user option import Queue queue = Queue.Queue().init(MAXSIZE) done = thread.allocate_lock() done.acquire_lock() convertor = None if grey: if greybits == 2: convertor = imageop.grey2grey2 elif greybits == 4: convertor = imageop.grey2grey4 elif greybits == -2: convertor = imageop.dither2grey2 thread.start_new_thread(saveframes, \ (vout, queue, done, mono, monotreshold, convertor)) if audiofilename: audiodone = thread.allocate_lock() audiodone.acquire_lock() audiostop = [] initaudio(audiofilename, audiostop, audiodone) gl.wintitle('(rec) ' + filename) lastid = 0 t0 = time.millitimer() count = 0 ids = [] v.InitContinuousCapture(info) while not gl.qtest(): try: cd, id = v.GetCaptureData() except sv.error: #time.millisleep(10) # XXX is this necessary? sgi.nap(1) # XXX Try by Jack continue ids.append(id) id = id + 2*rate
f48b419a075dc237eb145e1b71cec12afdb7aff4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f48b419a075dc237eb145e1b71cec12afdb7aff4/Vrec.py
iv = (float(i)/float(maxi-1))-0.5
if maxi = 1: iv = 0 else: iv = (float(i)/float(maxi-1))-0.5
def initcmap(ybits,ibits,qbits,chrompack): if ybits+ibits+qbits > 11: raise 'Sorry, 11 bits max' maxy = pow(2,ybits) maxi = pow(2,ibits) maxq = pow(2,qbits) for i in range(2048,4096-256): mapcolor(i, 0, 255, 0) for y in range(maxy): yv = float(y)/float(maxy-1) for i in range(maxi): iv = (float(i)/float(maxi-1))-0.5 for q in range(maxq): qv = (float(q)/float(maxq-1))-0.5 index = 2048 + y + (i << ybits) + (q << (ybits+ibits)) rv,gv,bv = colorsys.yiq_to_rgb(yv,iv,qv) r,g,b = int(rv*255.0), int(gv*255.0), int(bv*255.0) if index < 4096 - 256: mapcolor(index, r,g,b)
696f91151c6fe3d885fc658056c3fd19aceb4943 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/696f91151c6fe3d885fc658056c3fd19aceb4943/video.py
qv = (float(q)/float(maxq-1))-0.5
if maxq = 1: qv = 0 else: qv = (float(q)/float(maxq-1))-0.5
def initcmap(ybits,ibits,qbits,chrompack): if ybits+ibits+qbits > 11: raise 'Sorry, 11 bits max' maxy = pow(2,ybits) maxi = pow(2,ibits) maxq = pow(2,qbits) for i in range(2048,4096-256): mapcolor(i, 0, 255, 0) for y in range(maxy): yv = float(y)/float(maxy-1) for i in range(maxi): iv = (float(i)/float(maxi-1))-0.5 for q in range(maxq): qv = (float(q)/float(maxq-1))-0.5 index = 2048 + y + (i << ybits) + (q << (ybits+ibits)) rv,gv,bv = colorsys.yiq_to_rgb(yv,iv,qv) r,g,b = int(rv*255.0), int(gv*255.0), int(bv*255.0) if index < 4096 - 256: mapcolor(index, r,g,b)
696f91151c6fe3d885fc658056c3fd19aceb4943 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/696f91151c6fe3d885fc658056c3fd19aceb4943/video.py
def initcmap(ybits,ibits,qbits,chrompack): if ybits+ibits+qbits > 11: raise 'Sorry, 11 bits max' maxy = pow(2,ybits) maxi = pow(2,ibits) maxq = pow(2,qbits) for i in range(2048,4096-256): mapcolor(i, 0, 255, 0) for y in range(maxy): yv = float(y)/float(maxy-1) for i in range(maxi): iv = (float(i)/float(maxi-1))-0.5 for q in range(maxq): qv = (float(q)/float(maxq-1))-0.5 index = 2048 + y + (i << ybits) + (q << (ybits+ibits)) rv,gv,bv = colorsys.yiq_to_rgb(yv,iv,qv) r,g,b = int(rv*255.0), int(gv*255.0), int(bv*255.0) if index < 4096 - 256: mapcolor(index, r,g,b)
696f91151c6fe3d885fc658056c3fd19aceb4943 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/696f91151c6fe3d885fc658056c3fd19aceb4943/video.py
(self.ac_out_buffer is '') and
(self.ac_out_buffer == '') and
def writable (self): "predicate for inclusion in the writable for select()" # return len(self.ac_out_buffer) or len(self.producer_fifo) or (not self.connected) # this is about twice as fast, though not as clear. return not ( (self.ac_out_buffer is '') and self.producer_fifo.is_empty() and self.connected )
6fd71206169c48daf9a45fe246b495bb8113fd10 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6fd71206169c48daf9a45fe246b495bb8113fd10/asynchat.py
if os.path.exists(filename) or hasattr(getmodule(object), '__loader__'):
if os.path.exists(filename): return filename if filename[:1]!='<' and hasattr(getmodule(object), '__loader__'):
def getsourcefile(object): """Return the Python source file an object was defined in, if it exists.""" filename = getfile(object) if string.lower(filename[-4:]) in ('.pyc', '.pyo'): filename = filename[:-4] + '.py' for suffix, mode, kind in imp.get_suffixes(): if 'b' in mode and string.lower(filename[-len(suffix):]) == suffix: # Looks like a binary file. We want to only return a text file. return None if os.path.exists(filename) or hasattr(getmodule(object), '__loader__'): return filename
72ae6c80d489ea9d26958616d57cc37a5bd27d46 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/72ae6c80d489ea9d26958616d57cc37a5bd27d46/inspect.py
elif type( item )==StringType:
elif type( item ) in [StringType, UnicodeType]:
def _getName( item, nameFromNum ): "Helper function -- don't use it directly" if type( item ) == IntType: try: keyname = nameFromNum( item ) except (WindowsError, EnvironmentError): raise IndexError, item elif type( item )==StringType: keyname=item else: raise exceptions.TypeError, \ "Requires integer index or string key name" return keyname
abfeff7f44fcc9451d7f4588bda53adebd2d4ea4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/abfeff7f44fcc9451d7f4588bda53adebd2d4ea4/winreg.py
if type( data )==StringType:
if type( data ) in [StringType, UnicodeType]:
def setValue( self, valname, data, regtype=None ): "Set a data value's data (and optionally type)" if regtype: typeint=regtype.intval else: if type( data )==StringType: typeint=_winreg.REG_SZ elif type( data )==IntType: typeint=_winreg.REG_DWORD elif type( data )==array.ArrayType: typeint=_winreg.REG_BINARY data=data.tostring() _winreg.SetValueEx( self.handle, valname, 0, typeint, data )
abfeff7f44fcc9451d7f4588bda53adebd2d4ea4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/abfeff7f44fcc9451d7f4588bda53adebd2d4ea4/winreg.py
data=data.tostring()
def setValue( self, valname, data, regtype=None ): "Set a data value's data (and optionally type)" if regtype: typeint=regtype.intval else: if type( data )==StringType: typeint=_winreg.REG_SZ elif type( data )==IntType: typeint=_winreg.REG_DWORD elif type( data )==array.ArrayType: typeint=_winreg.REG_BINARY data=data.tostring() _winreg.SetValueEx( self.handle, valname, 0, typeint, data )
abfeff7f44fcc9451d7f4588bda53adebd2d4ea4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/abfeff7f44fcc9451d7f4588bda53adebd2d4ea4/winreg.py
prefix = get_config_vars('prefix', 'exec_prefix')
(prefix, exec_prefix) = get_config_vars('prefix', 'exec_prefix')
def finalize_options (self):
e918b6fdb52bcb904b63da1d14256d76ae48ede6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e918b6fdb52bcb904b63da1d14256d76ae48ede6/install.py
zip file will be named 'base_dir' + ".zip". Uses either the InfoZIP "zip" utility (if installed and found on the default search path) or the "zipfile" Python module (if available). If neither tool is available, raises DistutilsExecError. Returns the name of the output zip file.
zip file will be named 'base_dir' + ".zip". Uses either the "zipfile" Python module (if available) or the InfoZIP "zip" utility (if installed and found on the default search path). If neither tool is available, raises DistutilsExecError. Returns the name of the output zip file.
def make_zipfile (base_name, base_dir, verbose=0, dry_run=0): """Create a zip file from all the files under 'base_dir'. The output zip file will be named 'base_dir' + ".zip". Uses either the InfoZIP "zip" utility (if installed and found on the default search path) or the "zipfile" Python module (if available). If neither tool is available, raises DistutilsExecError. Returns the name of the output zip file. """ # This initially assumed the Unix 'zip' utility -- but # apparently InfoZIP's zip.exe works the same under Windows, so # no changes needed! zip_filename = base_name + ".zip" mkpath(os.path.dirname(zip_filename), dry_run=dry_run) try: spawn(["zip", "-rq", zip_filename, base_dir], dry_run=dry_run) except DistutilsExecError: # XXX really should distinguish between "couldn't find # external 'zip' command" and "zip failed" -- shouldn't try # again in the latter case. (I think fixing this will # require some cooperation from the spawn module -- perhaps # a utility function to search the path, so we can fallback # on zipfile.py without the failed spawn.) try: import zipfile except ImportError: raise DistutilsExecError, \ ("unable to create zip file '%s': " + "could neither find a standalone zip utility nor " + "import the 'zipfile' module") % zip_filename log.info("creating '%s' and adding '%s' to it", zip_filename, base_dir) def visit (z, dirname, names): for name in names: path = os.path.normpath(os.path.join(dirname, name)) if os.path.isfile(path): z.write(path, path) if not dry_run: z = zipfile.ZipFile(zip_filename, "w", compression=zipfile.ZIP_DEFLATED) os.path.walk(base_dir, visit, z) z.close() return zip_filename
cdd215789c86f3cd729cf10c9d6fe6b3d5df5d7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cdd215789c86f3cd729cf10c9d6fe6b3d5df5d7b/archive_util.py
try: import zipfile except ImportError: zipfile = None
def make_zipfile (base_name, base_dir, verbose=0, dry_run=0): """Create a zip file from all the files under 'base_dir'. The output zip file will be named 'base_dir' + ".zip". Uses either the InfoZIP "zip" utility (if installed and found on the default search path) or the "zipfile" Python module (if available). If neither tool is available, raises DistutilsExecError. Returns the name of the output zip file. """ # This initially assumed the Unix 'zip' utility -- but # apparently InfoZIP's zip.exe works the same under Windows, so # no changes needed! zip_filename = base_name + ".zip" mkpath(os.path.dirname(zip_filename), dry_run=dry_run) try: spawn(["zip", "-rq", zip_filename, base_dir], dry_run=dry_run) except DistutilsExecError: # XXX really should distinguish between "couldn't find # external 'zip' command" and "zip failed" -- shouldn't try # again in the latter case. (I think fixing this will # require some cooperation from the spawn module -- perhaps # a utility function to search the path, so we can fallback # on zipfile.py without the failed spawn.) try: import zipfile except ImportError: raise DistutilsExecError, \ ("unable to create zip file '%s': " + "could neither find a standalone zip utility nor " + "import the 'zipfile' module") % zip_filename log.info("creating '%s' and adding '%s' to it", zip_filename, base_dir) def visit (z, dirname, names): for name in names: path = os.path.normpath(os.path.join(dirname, name)) if os.path.isfile(path): z.write(path, path) if not dry_run: z = zipfile.ZipFile(zip_filename, "w", compression=zipfile.ZIP_DEFLATED) os.path.walk(base_dir, visit, z) z.close() return zip_filename
cdd215789c86f3cd729cf10c9d6fe6b3d5df5d7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cdd215789c86f3cd729cf10c9d6fe6b3d5df5d7b/archive_util.py
try: spawn(["zip", "-rq", zip_filename, base_dir], dry_run=dry_run) except DistutilsExecError:
def make_zipfile (base_name, base_dir, verbose=0, dry_run=0): """Create a zip file from all the files under 'base_dir'. The output zip file will be named 'base_dir' + ".zip". Uses either the InfoZIP "zip" utility (if installed and found on the default search path) or the "zipfile" Python module (if available). If neither tool is available, raises DistutilsExecError. Returns the name of the output zip file. """ # This initially assumed the Unix 'zip' utility -- but # apparently InfoZIP's zip.exe works the same under Windows, so # no changes needed! zip_filename = base_name + ".zip" mkpath(os.path.dirname(zip_filename), dry_run=dry_run) try: spawn(["zip", "-rq", zip_filename, base_dir], dry_run=dry_run) except DistutilsExecError: # XXX really should distinguish between "couldn't find # external 'zip' command" and "zip failed" -- shouldn't try # again in the latter case. (I think fixing this will # require some cooperation from the spawn module -- perhaps # a utility function to search the path, so we can fallback # on zipfile.py without the failed spawn.) try: import zipfile except ImportError: raise DistutilsExecError, \ ("unable to create zip file '%s': " + "could neither find a standalone zip utility nor " + "import the 'zipfile' module") % zip_filename log.info("creating '%s' and adding '%s' to it", zip_filename, base_dir) def visit (z, dirname, names): for name in names: path = os.path.normpath(os.path.join(dirname, name)) if os.path.isfile(path): z.write(path, path) if not dry_run: z = zipfile.ZipFile(zip_filename, "w", compression=zipfile.ZIP_DEFLATED) os.path.walk(base_dir, visit, z) z.close() return zip_filename
cdd215789c86f3cd729cf10c9d6fe6b3d5df5d7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cdd215789c86f3cd729cf10c9d6fe6b3d5df5d7b/archive_util.py
if zipfile is None: if verbose: zipoptions = "-r" else: zipoptions = "-rq"
def make_zipfile (base_name, base_dir, verbose=0, dry_run=0): """Create a zip file from all the files under 'base_dir'. The output zip file will be named 'base_dir' + ".zip". Uses either the InfoZIP "zip" utility (if installed and found on the default search path) or the "zipfile" Python module (if available). If neither tool is available, raises DistutilsExecError. Returns the name of the output zip file. """ # This initially assumed the Unix 'zip' utility -- but # apparently InfoZIP's zip.exe works the same under Windows, so # no changes needed! zip_filename = base_name + ".zip" mkpath(os.path.dirname(zip_filename), dry_run=dry_run) try: spawn(["zip", "-rq", zip_filename, base_dir], dry_run=dry_run) except DistutilsExecError: # XXX really should distinguish between "couldn't find # external 'zip' command" and "zip failed" -- shouldn't try # again in the latter case. (I think fixing this will # require some cooperation from the spawn module -- perhaps # a utility function to search the path, so we can fallback # on zipfile.py without the failed spawn.) try: import zipfile except ImportError: raise DistutilsExecError, \ ("unable to create zip file '%s': " + "could neither find a standalone zip utility nor " + "import the 'zipfile' module") % zip_filename log.info("creating '%s' and adding '%s' to it", zip_filename, base_dir) def visit (z, dirname, names): for name in names: path = os.path.normpath(os.path.join(dirname, name)) if os.path.isfile(path): z.write(path, path) if not dry_run: z = zipfile.ZipFile(zip_filename, "w", compression=zipfile.ZIP_DEFLATED) os.path.walk(base_dir, visit, z) z.close() return zip_filename
cdd215789c86f3cd729cf10c9d6fe6b3d5df5d7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cdd215789c86f3cd729cf10c9d6fe6b3d5df5d7b/archive_util.py
import zipfile except ImportError:
spawn(["zip", zipoptions, zip_filename, base_dir], dry_run=dry_run) except DistutilsExecError:
def make_zipfile (base_name, base_dir, verbose=0, dry_run=0): """Create a zip file from all the files under 'base_dir'. The output zip file will be named 'base_dir' + ".zip". Uses either the InfoZIP "zip" utility (if installed and found on the default search path) or the "zipfile" Python module (if available). If neither tool is available, raises DistutilsExecError. Returns the name of the output zip file. """ # This initially assumed the Unix 'zip' utility -- but # apparently InfoZIP's zip.exe works the same under Windows, so # no changes needed! zip_filename = base_name + ".zip" mkpath(os.path.dirname(zip_filename), dry_run=dry_run) try: spawn(["zip", "-rq", zip_filename, base_dir], dry_run=dry_run) except DistutilsExecError: # XXX really should distinguish between "couldn't find # external 'zip' command" and "zip failed" -- shouldn't try # again in the latter case. (I think fixing this will # require some cooperation from the spawn module -- perhaps # a utility function to search the path, so we can fallback # on zipfile.py without the failed spawn.) try: import zipfile except ImportError: raise DistutilsExecError, \ ("unable to create zip file '%s': " + "could neither find a standalone zip utility nor " + "import the 'zipfile' module") % zip_filename log.info("creating '%s' and adding '%s' to it", zip_filename, base_dir) def visit (z, dirname, names): for name in names: path = os.path.normpath(os.path.join(dirname, name)) if os.path.isfile(path): z.write(path, path) if not dry_run: z = zipfile.ZipFile(zip_filename, "w", compression=zipfile.ZIP_DEFLATED) os.path.walk(base_dir, visit, z) z.close() return zip_filename
cdd215789c86f3cd729cf10c9d6fe6b3d5df5d7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cdd215789c86f3cd729cf10c9d6fe6b3d5df5d7b/archive_util.py
("unable to create zip file '%s': " + "could neither find a standalone zip utility nor " + "import the 'zipfile' module") % zip_filename
("unable to create zip file '%s': " "could neither import the 'zipfile' module nor " "find a standalone zip utility") % zip_filename
def make_zipfile (base_name, base_dir, verbose=0, dry_run=0): """Create a zip file from all the files under 'base_dir'. The output zip file will be named 'base_dir' + ".zip". Uses either the InfoZIP "zip" utility (if installed and found on the default search path) or the "zipfile" Python module (if available). If neither tool is available, raises DistutilsExecError. Returns the name of the output zip file. """ # This initially assumed the Unix 'zip' utility -- but # apparently InfoZIP's zip.exe works the same under Windows, so # no changes needed! zip_filename = base_name + ".zip" mkpath(os.path.dirname(zip_filename), dry_run=dry_run) try: spawn(["zip", "-rq", zip_filename, base_dir], dry_run=dry_run) except DistutilsExecError: # XXX really should distinguish between "couldn't find # external 'zip' command" and "zip failed" -- shouldn't try # again in the latter case. (I think fixing this will # require some cooperation from the spawn module -- perhaps # a utility function to search the path, so we can fallback # on zipfile.py without the failed spawn.) try: import zipfile except ImportError: raise DistutilsExecError, \ ("unable to create zip file '%s': " + "could neither find a standalone zip utility nor " + "import the 'zipfile' module") % zip_filename log.info("creating '%s' and adding '%s' to it", zip_filename, base_dir) def visit (z, dirname, names): for name in names: path = os.path.normpath(os.path.join(dirname, name)) if os.path.isfile(path): z.write(path, path) if not dry_run: z = zipfile.ZipFile(zip_filename, "w", compression=zipfile.ZIP_DEFLATED) os.path.walk(base_dir, visit, z) z.close() return zip_filename
cdd215789c86f3cd729cf10c9d6fe6b3d5df5d7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cdd215789c86f3cd729cf10c9d6fe6b3d5df5d7b/archive_util.py
log.info("creating '%s' and adding '%s' to it",
else: log.info("creating '%s' and adding '%s' to it",
def make_zipfile (base_name, base_dir, verbose=0, dry_run=0): """Create a zip file from all the files under 'base_dir'. The output zip file will be named 'base_dir' + ".zip". Uses either the InfoZIP "zip" utility (if installed and found on the default search path) or the "zipfile" Python module (if available). If neither tool is available, raises DistutilsExecError. Returns the name of the output zip file. """ # This initially assumed the Unix 'zip' utility -- but # apparently InfoZIP's zip.exe works the same under Windows, so # no changes needed! zip_filename = base_name + ".zip" mkpath(os.path.dirname(zip_filename), dry_run=dry_run) try: spawn(["zip", "-rq", zip_filename, base_dir], dry_run=dry_run) except DistutilsExecError: # XXX really should distinguish between "couldn't find # external 'zip' command" and "zip failed" -- shouldn't try # again in the latter case. (I think fixing this will # require some cooperation from the spawn module -- perhaps # a utility function to search the path, so we can fallback # on zipfile.py without the failed spawn.) try: import zipfile except ImportError: raise DistutilsExecError, \ ("unable to create zip file '%s': " + "could neither find a standalone zip utility nor " + "import the 'zipfile' module") % zip_filename log.info("creating '%s' and adding '%s' to it", zip_filename, base_dir) def visit (z, dirname, names): for name in names: path = os.path.normpath(os.path.join(dirname, name)) if os.path.isfile(path): z.write(path, path) if not dry_run: z = zipfile.ZipFile(zip_filename, "w", compression=zipfile.ZIP_DEFLATED) os.path.walk(base_dir, visit, z) z.close() return zip_filename
cdd215789c86f3cd729cf10c9d6fe6b3d5df5d7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cdd215789c86f3cd729cf10c9d6fe6b3d5df5d7b/archive_util.py
def make_zipfile (base_name, base_dir, verbose=0, dry_run=0): """Create a zip file from all the files under 'base_dir'. The output zip file will be named 'base_dir' + ".zip". Uses either the InfoZIP "zip" utility (if installed and found on the default search path) or the "zipfile" Python module (if available). If neither tool is available, raises DistutilsExecError. Returns the name of the output zip file. """ # This initially assumed the Unix 'zip' utility -- but # apparently InfoZIP's zip.exe works the same under Windows, so # no changes needed! zip_filename = base_name + ".zip" mkpath(os.path.dirname(zip_filename), dry_run=dry_run) try: spawn(["zip", "-rq", zip_filename, base_dir], dry_run=dry_run) except DistutilsExecError: # XXX really should distinguish between "couldn't find # external 'zip' command" and "zip failed" -- shouldn't try # again in the latter case. (I think fixing this will # require some cooperation from the spawn module -- perhaps # a utility function to search the path, so we can fallback # on zipfile.py without the failed spawn.) try: import zipfile except ImportError: raise DistutilsExecError, \ ("unable to create zip file '%s': " + "could neither find a standalone zip utility nor " + "import the 'zipfile' module") % zip_filename log.info("creating '%s' and adding '%s' to it", zip_filename, base_dir) def visit (z, dirname, names): for name in names: path = os.path.normpath(os.path.join(dirname, name)) if os.path.isfile(path): z.write(path, path) if not dry_run: z = zipfile.ZipFile(zip_filename, "w", compression=zipfile.ZIP_DEFLATED) os.path.walk(base_dir, visit, z) z.close() return zip_filename
cdd215789c86f3cd729cf10c9d6fe6b3d5df5d7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cdd215789c86f3cd729cf10c9d6fe6b3d5df5d7b/archive_util.py
return if address.lower().startswith('stimpy'): self.push('503 You suck %s' % address)
def smtp_RCPT(self, arg): print >> DEBUGSTREAM, '===> RCPT', arg if not self.__mailfrom: self.push('503 Error: need MAIL command') return address = self.__getaddr('TO:', arg) if not address: self.push('501 Syntax: RCPT TO: <address>') return if address.lower().startswith('stimpy'): self.push('503 You suck %s' % address) return self.__rcpttos.append(address) print >> DEBUGSTREAM, 'recips:', self.__rcpttos self.push('250 Ok')
bdc8289e06fb95578187e203048d7ae445e5bb6d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bdc8289e06fb95578187e203048d7ae445e5bb6d/smtpd.py
_mesg('untagged responses dump:%s%s' % (t, j(l, t)))
_mesg('untagged responses dump:%s%s' % (t, t.join(l)))
def _dump_ur(dict): # Dump untagged responses (in `dict'). l = dict.items() if not l: return t = '\n\t\t' l = map(lambda x:'%s: "%s"' % (x[0], x[1][0] and '" "'.join(x[1]) or ''), l) _mesg('untagged responses dump:%s%s' % (t, j(l, t)))
34d97059437f81d2accb664758a31d2c4b863cf5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/34d97059437f81d2accb664758a31d2c4b863cf5/imaplib.py
if short_first: self.format_option_strings = self.format_option_strings_short_first else: self.format_option_strings = self.format_option_strings_long_first
self.short_first = short_first
def __init__ (self, indent_increment, max_help_position, width, short_first): self.indent_increment = indent_increment self.help_position = self.max_help_position = max_help_position self.width = width self.current_indent = 0 self.level = 0 self.help_width = width - max_help_position if short_first: self.format_option_strings = self.format_option_strings_short_first else: self.format_option_strings = self.format_option_strings_long_first
2492fcf3b0d58eafc9a7551263857649fcc7f1a4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2492fcf3b0d58eafc9a7551263857649fcc7f1a4/optparse.py
raise NotImplementedError( "abstract method: use format_option_strings_short_first or " "format_option_strings_long_first instead.") def format_option_strings_short_first (self, option): opts = [] takes_value = option.takes_value() if takes_value:
if option.takes_value():
def format_option_strings (self, option): """Return a comma-separated list of option strings & metavariables.""" raise NotImplementedError( "abstract method: use format_option_strings_short_first or " "format_option_strings_long_first instead.")
2492fcf3b0d58eafc9a7551263857649fcc7f1a4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2492fcf3b0d58eafc9a7551263857649fcc7f1a4/optparse.py
for sopt in option._short_opts: opts.append(sopt + metavar) for lopt in option._long_opts: opts.append(lopt + "=" + metavar) else: for opt in option._short_opts + option._long_opts: opts.append(opt)
short_opts = [sopt + metavar for sopt in option._short_opts] long_opts = [lopt + "=" + metavar for lopt in option._long_opts] else: short_opts = option._short_opts long_opts = option._long_opts if self.short_first: opts = short_opts + long_opts else: opts = long_opts + short_opts
def format_option_strings_short_first (self, option): opts = [] # list of "-a" or "--foo=FILE" strings takes_value = option.takes_value() if takes_value: metavar = option.metavar or option.dest.upper() for sopt in option._short_opts: opts.append(sopt + metavar) for lopt in option._long_opts: opts.append(lopt + "=" + metavar) else: for opt in option._short_opts + option._long_opts: opts.append(opt) return ", ".join(opts)
2492fcf3b0d58eafc9a7551263857649fcc7f1a4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2492fcf3b0d58eafc9a7551263857649fcc7f1a4/optparse.py
def format_option_strings_long_first (self, option): opts = [] takes_value = option.takes_value() if takes_value: metavar = option.metavar or option.dest.upper() for lopt in option._long_opts: opts.append(lopt + "=" + metavar) for sopt in option._short_opts: opts.append(sopt + metavar) else: for opt in option._long_opts + option._short_opts: opts.append(opt) return ", ".join(opts)
def format_option_strings_short_first (self, option): opts = [] # list of "-a" or "--foo=FILE" strings takes_value = option.takes_value() if takes_value: metavar = option.metavar or option.dest.upper() for sopt in option._short_opts: opts.append(sopt + metavar) for lopt in option._long_opts: opts.append(lopt + "=" + metavar) else: for opt in option._short_opts + option._long_opts: opts.append(opt) return ", ".join(opts)
2492fcf3b0d58eafc9a7551263857649fcc7f1a4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2492fcf3b0d58eafc9a7551263857649fcc7f1a4/optparse.py
self._short_opts = [] self._long_opts = []
def __init__ (self, *opts, **attrs): # Set _short_opts, _long_opts attrs from 'opts' tuple opts = self._check_opt_strings(opts) self._set_opt_strings(opts)
2492fcf3b0d58eafc9a7551263857649fcc7f1a4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2492fcf3b0d58eafc9a7551263857649fcc7f1a4/optparse.py
raise OptionError("at least one option string must be supplied", self)
raise TypeError("at least one option string must be supplied")
def _check_opt_strings (self, opts): # Filter out None because early versions of Optik had exactly # one short option and one long option, either of which # could be None. opts = filter(None, opts) if not opts: raise OptionError("at least one option string must be supplied", self) return opts
2492fcf3b0d58eafc9a7551263857649fcc7f1a4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2492fcf3b0d58eafc9a7551263857649fcc7f1a4/optparse.py
self._short_opts = [] self._long_opts = []
def _set_opt_strings (self, opts): self._short_opts = [] self._long_opts = [] for opt in opts: if len(opt) < 2: raise OptionError( "invalid option string %r: " "must be at least two characters long" % opt, self) elif len(opt) == 2: if not (opt[0] == "-" and opt[1] != "-"): raise OptionError( "invalid short option string %r: " "must be of the form -x, (x any non-dash char)" % opt, self) self._short_opts.append(opt) else: if not (opt[0:2] == "--" and opt[2] != "-"): raise OptionError( "invalid long option string %r: " "must start with --, followed by non-dash" % opt, self) self._long_opts.append(opt)
2492fcf3b0d58eafc9a7551263857649fcc7f1a4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2492fcf3b0d58eafc9a7551263857649fcc7f1a4/optparse.py
if self._short_opts or self._long_opts: return "/".join(self._short_opts + self._long_opts) else: raise RuntimeError, "short_opts and long_opts both empty!"
return "/".join(self._short_opts + self._long_opts)
def __str__ (self): if self._short_opts or self._long_opts: return "/".join(self._short_opts + self._long_opts) else: raise RuntimeError, "short_opts and long_opts both empty!"
2492fcf3b0d58eafc9a7551263857649fcc7f1a4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2492fcf3b0d58eafc9a7551263857649fcc7f1a4/optparse.py
setattr(values, dest, 1)
setattr(values, dest, True)
def take_action (self, action, dest, opt, value, values, parser): if action == "store": setattr(values, dest, value) elif action == "store_const": setattr(values, dest, self.const) elif action == "store_true": setattr(values, dest, 1) elif action == "store_false": setattr(values, dest, 0) elif action == "append": values.ensure_value(dest, []).append(value) elif action == "count": setattr(values, dest, values.ensure_value(dest, 0) + 1) elif action == "callback": args = self.callback_args or () kwargs = self.callback_kwargs or {} self.callback(self, opt, value, parser, *args, **kwargs) elif action == "help": parser.print_help() sys.exit(0) elif action == "version": parser.print_version() sys.exit(0) else: raise RuntimeError, "unknown action %r" % self.action
2492fcf3b0d58eafc9a7551263857649fcc7f1a4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2492fcf3b0d58eafc9a7551263857649fcc7f1a4/optparse.py
setattr(values, dest, 0)
setattr(values, dest, False)
def take_action (self, action, dest, opt, value, values, parser): if action == "store": setattr(values, dest, value) elif action == "store_const": setattr(values, dest, self.const) elif action == "store_true": setattr(values, dest, 1) elif action == "store_false": setattr(values, dest, 0) elif action == "append": values.ensure_value(dest, []).append(value) elif action == "count": setattr(values, dest, values.ensure_value(dest, 0) + 1) elif action == "callback": args = self.callback_args or () kwargs = self.callback_kwargs or {} self.callback(self, opt, value, parser, *args, **kwargs) elif action == "help": parser.print_help() sys.exit(0) elif action == "version": parser.print_version() sys.exit(0) else: raise RuntimeError, "unknown action %r" % self.action
2492fcf3b0d58eafc9a7551263857649fcc7f1a4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2492fcf3b0d58eafc9a7551263857649fcc7f1a4/optparse.py
your program (os.path.basename(sys.argv[0])).
your program (self.prog or os.path.basename(sys.argv[0])). prog : string the name of the current program (to override os.path.basename(sys.argv[0])).
def format_help (self, formatter): result = formatter.format_heading(self.title) formatter.indent() result += OptionContainer.format_help(self, formatter) formatter.dedent() return result
2492fcf3b0d58eafc9a7551263857649fcc7f1a4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2492fcf3b0d58eafc9a7551263857649fcc7f1a4/optparse.py
add_help_option=1):
add_help_option=1, prog=None):
def __init__ (self, usage=None, option_list=None, option_class=Option, version=None, conflict_handler="error", description=None, formatter=None, add_help_option=1): OptionContainer.__init__( self, option_class, conflict_handler, description) self.set_usage(usage) self.version = version self.allow_interspersed_args = 1 if formatter is None: formatter = IndentedHelpFormatter() self.formatter = formatter
2492fcf3b0d58eafc9a7551263857649fcc7f1a4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2492fcf3b0d58eafc9a7551263857649fcc7f1a4/optparse.py
lines = linecache.getlines(file, getmodule(object).__dict__)
module = getmodule(object) if module: lines = linecache.getlines(file, module.__dict__) else: lines = linecache.getlines(file)
def findsource(object): """Return the entire source file and starting line number for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of all the lines in the file and the line number indexes a line in that list. An IOError is raised if the source code cannot be retrieved.""" file = getsourcefile(object) or getfile(object) lines = linecache.getlines(file, getmodule(object).__dict__) if not lines: raise IOError('could not get source code') if ismodule(object): return lines, 0 if isclass(object): name = object.__name__ pat = re.compile(r'^\s*class\s*' + name + r'\b') for i in range(len(lines)): if pat.match(lines[i]): return lines, i else: raise IOError('could not find class definition') if ismethod(object): object = object.im_func if isfunction(object): object = object.func_code if istraceback(object): object = object.tb_frame if isframe(object): object = object.f_code if iscode(object): if not hasattr(object, 'co_firstlineno'): raise IOError('could not find function definition') lnum = object.co_firstlineno - 1 pat = re.compile(r'^(\s*def\s)|(.*(?<!\w)lambda(:|\s))|^(\s*@)') while lnum > 0: if pat.match(lines[lnum]): break lnum = lnum - 1 return lines, lnum raise IOError('could not find code object')
208badda275a7aaf722a8db87297637e161fa7aa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/208badda275a7aaf722a8db87297637e161fa7aa/inspect.py
moddir = os.path.join(os.getcwd(), 'Modules', srcdir)
moddir = os.path.join(os.getcwd(), srcdir, 'Modules')
def build_extensions(self):
726b78ecb8660278399abaf36f98dec56ecf1271 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/726b78ecb8660278399abaf36f98dec56ecf1271/setup.py
log.warn(("warngin: no files found matching '%s' " +
log.warn(("warning: no files found matching '%s' " +
def process_template_line (self, line):
cbd0b365c1f27d390827e74a88a96f3a13034e0e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cbd0b365c1f27d390827e74a88a96f3a13034e0e/filelist.py
print msg % args
if not args: print msg else: print msg % args
def _log(self, level, msg, args): if level >= self.threshold: print msg % args sys.stdout.flush()
1c5a59f80a614df368cb7f545112862b2e7e1d5e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1c5a59f80a614df368cb7f545112862b2e7e1d5e/log.py
fp = MyURLopener().open(url).fp
fp = urllib2.urlopen(url).fp
def appendURL(self, url, included=0): """Append packages from the database with the given URL. Only the first database should specify included=0, so the global information (maintainer, description) get stored.""" if url in self._urllist: return self._urllist.append(url) fp = MyURLopener().open(url).fp dict = plistlib.Plist.fromFile(fp) # Test here for Pimp version, etc if not included: self._version = dict.get('Version', '0.1') if self._version != PIMP_VERSION: sys.stderr.write("Warning: database version %s does not match %s\n" % (self._version, PIMP_VERSION)) self._maintainer = dict.get('Maintainer', '') self._description = dict.get('Description', '') self._appendPackages(dict['Packages']) others = dict.get('Include', []) for url in others: self.appendURL(url, included=1)
47e5987256e6faf99bc8e474fd8351aa39808785 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/47e5987256e6faf99bc8e474fd8351aa39808785/pimp.py
def _help(): print "Usage: pimp [-v] -s [package ...] List installed status" print " pimp [-v] -l [package ...] Show package information" print " pimp [-vf] -i package ... Install packages" print " pimp -d Dump database to stdout" print "Options:" print " -v Verbose" print " -f Force installation" sys.exit(1)
47e5987256e6faf99bc8e474fd8351aa39808785 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/47e5987256e6faf99bc8e474fd8351aa39808785/pimp.py
def __init__(self, verbose=0): self.verbose = verbose self.reset()
08f8dd6d0caead7891d1a70f956409a88d0ed5a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/08f8dd6d0caead7891d1a70f956409a88d0ed5a6/sgmllib.py
def reset(self): self.rawdata = '' self.stack = [] self.lasttag = '???' self.nomoretags = 0 self.literal = 0
08f8dd6d0caead7891d1a70f956409a88d0ed5a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/08f8dd6d0caead7891d1a70f956409a88d0ed5a6/sgmllib.py
def setnomoretags(self): self.nomoretags = self.literal = 1
08f8dd6d0caead7891d1a70f956409a88d0ed5a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/08f8dd6d0caead7891d1a70f956409a88d0ed5a6/sgmllib.py
def setliteral(self, *args): self.literal = 1
08f8dd6d0caead7891d1a70f956409a88d0ed5a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/08f8dd6d0caead7891d1a70f956409a88d0ed5a6/sgmllib.py
def feed(self, data): self.rawdata = self.rawdata + data self.goahead(0)
08f8dd6d0caead7891d1a70f956409a88d0ed5a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/08f8dd6d0caead7891d1a70f956409a88d0ed5a6/sgmllib.py
def report_unbalanced(self, tag): if self.verbose: print '*** Unbalanced </' + tag + '>' print '*** Stack:', self.stack
08f8dd6d0caead7891d1a70f956409a88d0ed5a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/08f8dd6d0caead7891d1a70f956409a88d0ed5a6/sgmllib.py