rem
stringlengths 1
322k
| add
stringlengths 0
2.05M
| context
stringlengths 4
228k
| meta
stringlengths 156
215
|
---|---|---|---|
class MissingSectionHeaderError(Error): | class InterpolationDepthError(Error): def __init__(self, option, section, rawval): Error.__init__(self, "Value interpolation too deeply recursive:\n" "\tsection: [%s]\n" "\toption : %s\n" "\trawval : %s\n" % (section, option, rawval)) self.option = option self.section = section class ParsingError(Error): def __init__(self, filename): Error.__init__(self, 'File contains parsing errors: %s' % filename) self.filename = filename self.errors = [] def append(self, lineno, line): self.errors.append((lineno, line)) self._msg = self._msg + '\n\t[line %2d]: %s' % (lineno, line) class MissingSectionHeaderError(ParsingError): | def __init__(self, reference, option, section, rawval): Error.__init__(self, "Bad value substitution:\n" "\tsection: [%s]\n" "\toption : %s\n" "\tkey : %s\n" "\trawval : %s\n" % (section, option, reference, rawval)) self.reference = reference self.option = option self.section = section | cecb7da2a446f1c0227844233d9d438a365a7cc7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cecb7da2a446f1c0227844233d9d438a365a7cc7/ConfigParser.py |
class ParsingError(Error): def __init__(self, filename): Error.__init__(self, 'File contains parsing errors: %s' % filename) self.filename = filename self.errors = [] def append(self, lineno, line): self.errors.append((lineno, line)) self._msg = self._msg + '\n\t[line %2d]: %s' % (lineno, line) | def __init__(self, filename, lineno, line): Error.__init__( self, 'File contains no section headers.\nfile: %s, line: %d\n%s' % (filename, lineno, line)) self.filename = filename self.lineno = lineno self.line = line | cecb7da2a446f1c0227844233d9d438a365a7cc7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cecb7da2a446f1c0227844233d9d438a365a7cc7/ConfigParser.py |
|
return self.__sections.has_key(section) | return section in self.sections() | def has_section(self, section): """Indicate whether the named section is present in the configuration. | cecb7da2a446f1c0227844233d9d438a365a7cc7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cecb7da2a446f1c0227844233d9d438a365a7cc7/ConfigParser.py |
try: opts = self.__sections[section] except KeyError: raise NoSectionError(section) return opts.has_key(option) | return option in self.options(section) | def has_option(self, section, option): """Return whether the given section has the given option.""" try: opts = self.__sections[section] except KeyError: raise NoSectionError(section) return opts.has_key(option) | cecb7da2a446f1c0227844233d9d438a365a7cc7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cecb7da2a446f1c0227844233d9d438a365a7cc7/ConfigParser.py |
def get(self, section, option, raw=0, vars=None): """Get an option value for a given section. | cecb7da2a446f1c0227844233d9d438a365a7cc7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cecb7da2a446f1c0227844233d9d438a365a7cc7/ConfigParser.py |
||
return value | break if value.find("%(") >= 0: raise InterpolationDepthError(option, section, rawval) return value | def get(self, section, option, raw=0, vars=None): """Get an option value for a given section. | cecb7da2a446f1c0227844233d9d438a365a7cc7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cecb7da2a446f1c0227844233d9d438a365a7cc7/ConfigParser.py |
r'(?P<header>[-\w_.*,(){}]+)' | r'(?P<header>[-\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 | cecb7da2a446f1c0227844233d9d438a365a7cc7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cecb7da2a446f1c0227844233d9d438a365a7cc7/ConfigParser.py |
print "font=%r" % font | def __init__(self, root=None, font=None, name=None, exists=False, **options): if not root: root = Tkinter._default_root if font: # get actual settings corresponding to the given font font = root.tk.splitlist(root.tk.call("font", "actual", font)) else: font = self._set(options) if not name: name = "font" + str(id(self)) self.name = name | 4107b8a0be9cb1cc3c942c67da8c60ddb8e40d74 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4107b8a0be9cb1cc3c942c67da8c60ddb8e40d74/tkFont.py |
|
_tryorder = ["galeon", "skipstone", "mozilla", "netscape", | _tryorder = ["galeon", "skipstone", "mozilla-firefox", "mozilla-firebird", "mozilla", "netscape", | def open_new(self, url): self.open(url) | a6a97c6b82892ce489bf22e49f88129d407183b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a6a97c6b82892ce489bf22e49f88129d407183b4/webbrowser.py |
if _iscommand("mozilla"): register("mozilla", None, Netscape("mozilla")) if _iscommand("netscape"): register("netscape", None, Netscape("netscape")) | for browser in ("mozilla-firefox", "mozilla-firebird", "mozilla", "netscape"): if _iscommand(browser): register(browser, None, Netscape(browser)) | def open_new(self, url): self.open(url) | a6a97c6b82892ce489bf22e49f88129d407183b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a6a97c6b82892ce489bf22e49f88129d407183b4/webbrowser.py |
_combine = { ' ': ' ', '. ': '-', ' .': '+', '..': '^' } | def dump(tag, x, lo, hi): for i in xrange(lo, hi): print tag, x[i], | e850a274f34167df5ea0e1806902b943c3682a26 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e850a274f34167df5ea0e1806902b943c3682a26/ndiff.py |
|
def fancy_replace(a, alo, ahi, b, blo, bhi): if TRACE: print '*** fancy_replace', alo, ahi, blo, bhi dump('>', a, alo, ahi) dump('<', b, blo, bhi) # don't synch up unless the lines have a similarity score of at # least cutoff; best_ratio tracks the best score seen so far best_ratio, cutoff = 0.74, 0.75 cruncher = SequenceMatcher(IS_CHARACTER_JUNK) eqi, eqj = None, None # 1st indices of equal lines (if any) # search for the pair that matches best without being identical # (identical lines must be junk lines, & we don't want to synch up # on junk -- unless we have to) for j in xrange(blo, bhi): bj = b[j] cruncher.set_seq2(bj) for i in xrange(alo, ahi): ai = a[i] if ai == bj: if eqi is None: eqi, eqj = i, j continue cruncher.set_seq1(ai) # computing similarity is expensive, so use the quick # upper bounds first -- have seen this speed up messy # compares by a factor of 3. # note that ratio() is only expensive to compute the first # time it's called on a sequence pair; the expensive part # of the computation is cached by cruncher if cruncher.real_quick_ratio() > best_ratio and \ cruncher.quick_ratio() > best_ratio and \ cruncher.ratio() > best_ratio: best_ratio, best_i, best_j = cruncher.ratio(), i, j if best_ratio < cutoff: # no non-identical "pretty close" pair if eqi is None: # no identical pair either -- treat it as a straight replace plain_replace(a, alo, ahi, b, blo, bhi) return # no close pair, but an identical pair -- synch up on that best_i, best_j, best_ratio = eqi, eqj, 1.0 else: # there's a close pair, so forget the identical pair (if any) eqi = None # a[best_i] very similar to b[best_j]; eqi is None iff they're not # identical if TRACE: print '*** best_ratio', best_ratio, best_i, best_j dump('>', a, best_i, best_i+1) dump('<', b, best_j, best_j+1) # pump out diffs from before the synch point fancy_helper(a, alo, best_i, b, blo, best_j) # do intraline marking on the synch pair aelt, belt = a[best_i], b[best_j] if eqi is None: # pump out a '-', '+', '?' triple for the synched lines; atags = btags = "" cruncher.set_seqs(aelt, belt) for tag, ai1, ai2, bj1, bj2 in cruncher.get_opcodes(): la, lb = ai2 - ai1, bj2 - bj1 if tag == 'replace': atags = atags + '.' * la btags = btags + '.' * lb elif tag == 'delete': atags = atags + '.' * la elif tag == 'insert': btags = btags + '.' * lb elif tag == 'equal': atags = atags + ' ' * la btags = btags + ' ' * lb else: raise ValueError, 'unknown tag ' + `tag` la, lb = len(atags), len(btags) if la < lb: atags = atags + ' ' * (lb - la) elif lb < la: btags = btags + ' ' * (la - lb) combined = map(lambda x,y: _combine[x+y], atags, btags) printq(aelt, belt, string.rstrip(string.join(combined, ''))) else: # the synch pair is identical print ' ', aelt, # pump out diffs from after the synch point fancy_helper(a, best_i+1, ahi, b, best_j+1, bhi) | e850a274f34167df5ea0e1806902b943c3682a26 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e850a274f34167df5ea0e1806902b943c3682a26/ndiff.py |
||
atags = atags + '.' * la btags = btags + '.' * lb | atags += '^' * la btags += '^' * lb | def fancy_replace(a, alo, ahi, b, blo, bhi): if TRACE: print '*** fancy_replace', alo, ahi, blo, bhi dump('>', a, alo, ahi) dump('<', b, blo, bhi) # don't synch up unless the lines have a similarity score of at # least cutoff; best_ratio tracks the best score seen so far best_ratio, cutoff = 0.74, 0.75 cruncher = SequenceMatcher(IS_CHARACTER_JUNK) eqi, eqj = None, None # 1st indices of equal lines (if any) # search for the pair that matches best without being identical # (identical lines must be junk lines, & we don't want to synch up # on junk -- unless we have to) for j in xrange(blo, bhi): bj = b[j] cruncher.set_seq2(bj) for i in xrange(alo, ahi): ai = a[i] if ai == bj: if eqi is None: eqi, eqj = i, j continue cruncher.set_seq1(ai) # computing similarity is expensive, so use the quick # upper bounds first -- have seen this speed up messy # compares by a factor of 3. # note that ratio() is only expensive to compute the first # time it's called on a sequence pair; the expensive part # of the computation is cached by cruncher if cruncher.real_quick_ratio() > best_ratio and \ cruncher.quick_ratio() > best_ratio and \ cruncher.ratio() > best_ratio: best_ratio, best_i, best_j = cruncher.ratio(), i, j if best_ratio < cutoff: # no non-identical "pretty close" pair if eqi is None: # no identical pair either -- treat it as a straight replace plain_replace(a, alo, ahi, b, blo, bhi) return # no close pair, but an identical pair -- synch up on that best_i, best_j, best_ratio = eqi, eqj, 1.0 else: # there's a close pair, so forget the identical pair (if any) eqi = None # a[best_i] very similar to b[best_j]; eqi is None iff they're not # identical if TRACE: print '*** best_ratio', best_ratio, best_i, best_j dump('>', a, best_i, best_i+1) dump('<', b, best_j, best_j+1) # pump out diffs from before the synch point fancy_helper(a, alo, best_i, b, blo, best_j) # do intraline marking on the synch pair aelt, belt = a[best_i], b[best_j] if eqi is None: # pump out a '-', '+', '?' triple for the synched lines; atags = btags = "" cruncher.set_seqs(aelt, belt) for tag, ai1, ai2, bj1, bj2 in cruncher.get_opcodes(): la, lb = ai2 - ai1, bj2 - bj1 if tag == 'replace': atags = atags + '.' * la btags = btags + '.' * lb elif tag == 'delete': atags = atags + '.' * la elif tag == 'insert': btags = btags + '.' * lb elif tag == 'equal': atags = atags + ' ' * la btags = btags + ' ' * lb else: raise ValueError, 'unknown tag ' + `tag` la, lb = len(atags), len(btags) if la < lb: atags = atags + ' ' * (lb - la) elif lb < la: btags = btags + ' ' * (la - lb) combined = map(lambda x,y: _combine[x+y], atags, btags) printq(aelt, belt, string.rstrip(string.join(combined, ''))) else: # the synch pair is identical print ' ', aelt, # pump out diffs from after the synch point fancy_helper(a, best_i+1, ahi, b, best_j+1, bhi) | e850a274f34167df5ea0e1806902b943c3682a26 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e850a274f34167df5ea0e1806902b943c3682a26/ndiff.py |
atags = atags + '.' * la | atags += '-' * la | def fancy_replace(a, alo, ahi, b, blo, bhi): if TRACE: print '*** fancy_replace', alo, ahi, blo, bhi dump('>', a, alo, ahi) dump('<', b, blo, bhi) # don't synch up unless the lines have a similarity score of at # least cutoff; best_ratio tracks the best score seen so far best_ratio, cutoff = 0.74, 0.75 cruncher = SequenceMatcher(IS_CHARACTER_JUNK) eqi, eqj = None, None # 1st indices of equal lines (if any) # search for the pair that matches best without being identical # (identical lines must be junk lines, & we don't want to synch up # on junk -- unless we have to) for j in xrange(blo, bhi): bj = b[j] cruncher.set_seq2(bj) for i in xrange(alo, ahi): ai = a[i] if ai == bj: if eqi is None: eqi, eqj = i, j continue cruncher.set_seq1(ai) # computing similarity is expensive, so use the quick # upper bounds first -- have seen this speed up messy # compares by a factor of 3. # note that ratio() is only expensive to compute the first # time it's called on a sequence pair; the expensive part # of the computation is cached by cruncher if cruncher.real_quick_ratio() > best_ratio and \ cruncher.quick_ratio() > best_ratio and \ cruncher.ratio() > best_ratio: best_ratio, best_i, best_j = cruncher.ratio(), i, j if best_ratio < cutoff: # no non-identical "pretty close" pair if eqi is None: # no identical pair either -- treat it as a straight replace plain_replace(a, alo, ahi, b, blo, bhi) return # no close pair, but an identical pair -- synch up on that best_i, best_j, best_ratio = eqi, eqj, 1.0 else: # there's a close pair, so forget the identical pair (if any) eqi = None # a[best_i] very similar to b[best_j]; eqi is None iff they're not # identical if TRACE: print '*** best_ratio', best_ratio, best_i, best_j dump('>', a, best_i, best_i+1) dump('<', b, best_j, best_j+1) # pump out diffs from before the synch point fancy_helper(a, alo, best_i, b, blo, best_j) # do intraline marking on the synch pair aelt, belt = a[best_i], b[best_j] if eqi is None: # pump out a '-', '+', '?' triple for the synched lines; atags = btags = "" cruncher.set_seqs(aelt, belt) for tag, ai1, ai2, bj1, bj2 in cruncher.get_opcodes(): la, lb = ai2 - ai1, bj2 - bj1 if tag == 'replace': atags = atags + '.' * la btags = btags + '.' * lb elif tag == 'delete': atags = atags + '.' * la elif tag == 'insert': btags = btags + '.' * lb elif tag == 'equal': atags = atags + ' ' * la btags = btags + ' ' * lb else: raise ValueError, 'unknown tag ' + `tag` la, lb = len(atags), len(btags) if la < lb: atags = atags + ' ' * (lb - la) elif lb < la: btags = btags + ' ' * (la - lb) combined = map(lambda x,y: _combine[x+y], atags, btags) printq(aelt, belt, string.rstrip(string.join(combined, ''))) else: # the synch pair is identical print ' ', aelt, # pump out diffs from after the synch point fancy_helper(a, best_i+1, ahi, b, best_j+1, bhi) | e850a274f34167df5ea0e1806902b943c3682a26 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e850a274f34167df5ea0e1806902b943c3682a26/ndiff.py |
btags = btags + '.' * lb | btags += '+' * lb | def fancy_replace(a, alo, ahi, b, blo, bhi): if TRACE: print '*** fancy_replace', alo, ahi, blo, bhi dump('>', a, alo, ahi) dump('<', b, blo, bhi) # don't synch up unless the lines have a similarity score of at # least cutoff; best_ratio tracks the best score seen so far best_ratio, cutoff = 0.74, 0.75 cruncher = SequenceMatcher(IS_CHARACTER_JUNK) eqi, eqj = None, None # 1st indices of equal lines (if any) # search for the pair that matches best without being identical # (identical lines must be junk lines, & we don't want to synch up # on junk -- unless we have to) for j in xrange(blo, bhi): bj = b[j] cruncher.set_seq2(bj) for i in xrange(alo, ahi): ai = a[i] if ai == bj: if eqi is None: eqi, eqj = i, j continue cruncher.set_seq1(ai) # computing similarity is expensive, so use the quick # upper bounds first -- have seen this speed up messy # compares by a factor of 3. # note that ratio() is only expensive to compute the first # time it's called on a sequence pair; the expensive part # of the computation is cached by cruncher if cruncher.real_quick_ratio() > best_ratio and \ cruncher.quick_ratio() > best_ratio and \ cruncher.ratio() > best_ratio: best_ratio, best_i, best_j = cruncher.ratio(), i, j if best_ratio < cutoff: # no non-identical "pretty close" pair if eqi is None: # no identical pair either -- treat it as a straight replace plain_replace(a, alo, ahi, b, blo, bhi) return # no close pair, but an identical pair -- synch up on that best_i, best_j, best_ratio = eqi, eqj, 1.0 else: # there's a close pair, so forget the identical pair (if any) eqi = None # a[best_i] very similar to b[best_j]; eqi is None iff they're not # identical if TRACE: print '*** best_ratio', best_ratio, best_i, best_j dump('>', a, best_i, best_i+1) dump('<', b, best_j, best_j+1) # pump out diffs from before the synch point fancy_helper(a, alo, best_i, b, blo, best_j) # do intraline marking on the synch pair aelt, belt = a[best_i], b[best_j] if eqi is None: # pump out a '-', '+', '?' triple for the synched lines; atags = btags = "" cruncher.set_seqs(aelt, belt) for tag, ai1, ai2, bj1, bj2 in cruncher.get_opcodes(): la, lb = ai2 - ai1, bj2 - bj1 if tag == 'replace': atags = atags + '.' * la btags = btags + '.' * lb elif tag == 'delete': atags = atags + '.' * la elif tag == 'insert': btags = btags + '.' * lb elif tag == 'equal': atags = atags + ' ' * la btags = btags + ' ' * lb else: raise ValueError, 'unknown tag ' + `tag` la, lb = len(atags), len(btags) if la < lb: atags = atags + ' ' * (lb - la) elif lb < la: btags = btags + ' ' * (la - lb) combined = map(lambda x,y: _combine[x+y], atags, btags) printq(aelt, belt, string.rstrip(string.join(combined, ''))) else: # the synch pair is identical print ' ', aelt, # pump out diffs from after the synch point fancy_helper(a, best_i+1, ahi, b, best_j+1, bhi) | e850a274f34167df5ea0e1806902b943c3682a26 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e850a274f34167df5ea0e1806902b943c3682a26/ndiff.py |
atags = atags + ' ' * la btags = btags + ' ' * lb | atags += ' ' * la btags += ' ' * lb | def fancy_replace(a, alo, ahi, b, blo, bhi): if TRACE: print '*** fancy_replace', alo, ahi, blo, bhi dump('>', a, alo, ahi) dump('<', b, blo, bhi) # don't synch up unless the lines have a similarity score of at # least cutoff; best_ratio tracks the best score seen so far best_ratio, cutoff = 0.74, 0.75 cruncher = SequenceMatcher(IS_CHARACTER_JUNK) eqi, eqj = None, None # 1st indices of equal lines (if any) # search for the pair that matches best without being identical # (identical lines must be junk lines, & we don't want to synch up # on junk -- unless we have to) for j in xrange(blo, bhi): bj = b[j] cruncher.set_seq2(bj) for i in xrange(alo, ahi): ai = a[i] if ai == bj: if eqi is None: eqi, eqj = i, j continue cruncher.set_seq1(ai) # computing similarity is expensive, so use the quick # upper bounds first -- have seen this speed up messy # compares by a factor of 3. # note that ratio() is only expensive to compute the first # time it's called on a sequence pair; the expensive part # of the computation is cached by cruncher if cruncher.real_quick_ratio() > best_ratio and \ cruncher.quick_ratio() > best_ratio and \ cruncher.ratio() > best_ratio: best_ratio, best_i, best_j = cruncher.ratio(), i, j if best_ratio < cutoff: # no non-identical "pretty close" pair if eqi is None: # no identical pair either -- treat it as a straight replace plain_replace(a, alo, ahi, b, blo, bhi) return # no close pair, but an identical pair -- synch up on that best_i, best_j, best_ratio = eqi, eqj, 1.0 else: # there's a close pair, so forget the identical pair (if any) eqi = None # a[best_i] very similar to b[best_j]; eqi is None iff they're not # identical if TRACE: print '*** best_ratio', best_ratio, best_i, best_j dump('>', a, best_i, best_i+1) dump('<', b, best_j, best_j+1) # pump out diffs from before the synch point fancy_helper(a, alo, best_i, b, blo, best_j) # do intraline marking on the synch pair aelt, belt = a[best_i], b[best_j] if eqi is None: # pump out a '-', '+', '?' triple for the synched lines; atags = btags = "" cruncher.set_seqs(aelt, belt) for tag, ai1, ai2, bj1, bj2 in cruncher.get_opcodes(): la, lb = ai2 - ai1, bj2 - bj1 if tag == 'replace': atags = atags + '.' * la btags = btags + '.' * lb elif tag == 'delete': atags = atags + '.' * la elif tag == 'insert': btags = btags + '.' * lb elif tag == 'equal': atags = atags + ' ' * la btags = btags + ' ' * lb else: raise ValueError, 'unknown tag ' + `tag` la, lb = len(atags), len(btags) if la < lb: atags = atags + ' ' * (lb - la) elif lb < la: btags = btags + ' ' * (la - lb) combined = map(lambda x,y: _combine[x+y], atags, btags) printq(aelt, belt, string.rstrip(string.join(combined, ''))) else: # the synch pair is identical print ' ', aelt, # pump out diffs from after the synch point fancy_helper(a, best_i+1, ahi, b, best_j+1, bhi) | e850a274f34167df5ea0e1806902b943c3682a26 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e850a274f34167df5ea0e1806902b943c3682a26/ndiff.py |
la, lb = len(atags), len(btags) if la < lb: atags = atags + ' ' * (lb - la) elif lb < la: btags = btags + ' ' * (la - lb) combined = map(lambda x,y: _combine[x+y], atags, btags) printq(aelt, belt, string.rstrip(string.join(combined, ''))) | printq(aelt, belt, atags, btags) | def fancy_replace(a, alo, ahi, b, blo, bhi): if TRACE: print '*** fancy_replace', alo, ahi, blo, bhi dump('>', a, alo, ahi) dump('<', b, blo, bhi) # don't synch up unless the lines have a similarity score of at # least cutoff; best_ratio tracks the best score seen so far best_ratio, cutoff = 0.74, 0.75 cruncher = SequenceMatcher(IS_CHARACTER_JUNK) eqi, eqj = None, None # 1st indices of equal lines (if any) # search for the pair that matches best without being identical # (identical lines must be junk lines, & we don't want to synch up # on junk -- unless we have to) for j in xrange(blo, bhi): bj = b[j] cruncher.set_seq2(bj) for i in xrange(alo, ahi): ai = a[i] if ai == bj: if eqi is None: eqi, eqj = i, j continue cruncher.set_seq1(ai) # computing similarity is expensive, so use the quick # upper bounds first -- have seen this speed up messy # compares by a factor of 3. # note that ratio() is only expensive to compute the first # time it's called on a sequence pair; the expensive part # of the computation is cached by cruncher if cruncher.real_quick_ratio() > best_ratio and \ cruncher.quick_ratio() > best_ratio and \ cruncher.ratio() > best_ratio: best_ratio, best_i, best_j = cruncher.ratio(), i, j if best_ratio < cutoff: # no non-identical "pretty close" pair if eqi is None: # no identical pair either -- treat it as a straight replace plain_replace(a, alo, ahi, b, blo, bhi) return # no close pair, but an identical pair -- synch up on that best_i, best_j, best_ratio = eqi, eqj, 1.0 else: # there's a close pair, so forget the identical pair (if any) eqi = None # a[best_i] very similar to b[best_j]; eqi is None iff they're not # identical if TRACE: print '*** best_ratio', best_ratio, best_i, best_j dump('>', a, best_i, best_i+1) dump('<', b, best_j, best_j+1) # pump out diffs from before the synch point fancy_helper(a, alo, best_i, b, blo, best_j) # do intraline marking on the synch pair aelt, belt = a[best_i], b[best_j] if eqi is None: # pump out a '-', '+', '?' triple for the synched lines; atags = btags = "" cruncher.set_seqs(aelt, belt) for tag, ai1, ai2, bj1, bj2 in cruncher.get_opcodes(): la, lb = ai2 - ai1, bj2 - bj1 if tag == 'replace': atags = atags + '.' * la btags = btags + '.' * lb elif tag == 'delete': atags = atags + '.' * la elif tag == 'insert': btags = btags + '.' * lb elif tag == 'equal': atags = atags + ' ' * la btags = btags + ' ' * lb else: raise ValueError, 'unknown tag ' + `tag` la, lb = len(atags), len(btags) if la < lb: atags = atags + ' ' * (lb - la) elif lb < la: btags = btags + ' ' * (la - lb) combined = map(lambda x,y: _combine[x+y], atags, btags) printq(aelt, belt, string.rstrip(string.join(combined, ''))) else: # the synch pair is identical print ' ', aelt, # pump out diffs from after the synch point fancy_helper(a, best_i+1, ahi, b, best_j+1, bhi) | e850a274f34167df5ea0e1806902b943c3682a26 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e850a274f34167df5ea0e1806902b943c3682a26/ndiff.py |
def printq(aline, bline, qline): | def printq(aline, bline, atags, btags): | def printq(aline, bline, qline): common = min(count_leading(aline, "\t"), count_leading(bline, "\t")) common = min(common, count_leading(qline[:common], " ")) qline = "\t" * common + qline[common:] print '-', aline, '+', bline, '?', qline | e850a274f34167df5ea0e1806902b943c3682a26 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e850a274f34167df5ea0e1806902b943c3682a26/ndiff.py |
common = min(common, count_leading(qline[:common], " ")) qline = "\t" * common + qline[common:] print '-', aline, '+', bline, '?', qline | common = min(common, count_leading(atags[:common], " ")) print "-", aline, if count_leading(atags, " ") < len(atags): print "?", "\t" * common + atags[common:] print "+", bline, if count_leading(btags, " ") < len(btags): print "?", "\t" * common + btags[common:] | def printq(aline, bline, qline): common = min(count_leading(aline, "\t"), count_leading(bline, "\t")) common = min(common, count_leading(qline[:common], " ")) qline = "\t" * common + qline[common:] print '-', aline, '+', bline, '?', qline | e850a274f34167df5ea0e1806902b943c3682a26 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e850a274f34167df5ea0e1806902b943c3682a26/ndiff.py |
new = Request(newurl, req.get_data()) | new = Request(newurl, req.get_data(), req.headers) | def http_error_302(self, req, fp, code, msg, headers): if headers.has_key('location'): newurl = headers['location'] elif headers.has_key('uri'): newurl = headers['uri'] else: return newurl = urlparse.urljoin(req.get_full_url(), newurl) | 9b6c26fdd23687fbddc2e2daba87c16c76b2f32f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9b6c26fdd23687fbddc2e2daba87c16c76b2f32f/urllib2.py |
rx = re.compile('[ \t]*([^ \t]+)[ \t]+realm="([^"]*)"') | rx = re.compile('[ \t]*([^ \t]+)[ \t]+realm="([^"]*)"', re.I) | def find_user_password(self, realm, authuri): user, password = HTTPPasswordMgr.find_user_password(self,realm,authuri) if user is not None: return user, password return HTTPPasswordMgr.find_user_password(self, None, authuri) | 9e6896504f6621b865fbea34a8f1a4729e837c4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9e6896504f6621b865fbea34a8f1a4729e837c4a/urllib2.py |
module = filename | module = filename or "<unknown>" | def warn_explicit(message, category, filename, lineno, module=None, registry=None): if module is None: module = filename if module[-3:].lower() == ".py": module = module[:-3] # XXX What about leading pathname? if registry is None: registry = {} if isinstance(message, Warning): text = str(message) category = message.__class__ else: text = message message = category(message) key = (text, category, lineno) # Quick test for common case if registry.get(key): return # Search the filters for item in filters: action, msg, cat, mod, ln = item if ((msg is None or msg.match(text)) and issubclass(category, cat) and (mod is None or mod.match(module)) and (ln == 0 or lineno == ln)): break else: action = defaultaction # Early exit actions if action == "ignore": registry[key] = 1 return if action == "error": raise message # Other actions if action == "once": registry[key] = 1 oncekey = (text, category) if onceregistry.get(oncekey): return onceregistry[oncekey] = 1 elif action == "always": pass elif action == "module": registry[key] = 1 altkey = (text, category, 0) if registry.get(altkey): return registry[altkey] = 1 elif action == "default": registry[key] = 1 else: # Unrecognized actions are errors raise RuntimeError( "Unrecognized action (%r) in warnings.filters:\n %s" % (action, item)) # Print message and context showwarning(message, category, filename, lineno) | 995e7094055fa466233e078f237bc8b4b49f0174 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/995e7094055fa466233e078f237bc8b4b49f0174/warnings.py |
p = subprocess.Popen(cmdline, close_fds=True) | if sys.platform[:3] == 'win': p = subprocess.Popen(cmdline) else: p = subprocess.Popen(cmdline, close_fds=True) | def open(self, url, new=0, autoraise=1): cmdline = [self.name] + [arg.replace("%s", url) for arg in self.args] try: p = subprocess.Popen(cmdline, close_fds=True) return not p.wait() except OSError: return False | 384b608aeb32db1017935599fa5e0c61e4d02b07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/384b608aeb32db1017935599fa5e0c61e4d02b07/webbrowser.py |
setsid = getattr(os, 'setsid', None) if not setsid: setsid = getattr(os, 'setpgrp', None) | def open(self, url, new=0, autoraise=1): cmdline = [self.name] + [arg.replace("%s", url) for arg in self.args] setsid = getattr(os, 'setsid', None) if not setsid: setsid = getattr(os, 'setpgrp', None) try: p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid) return (p.poll() is None) except OSError: return False | 384b608aeb32db1017935599fa5e0c61e4d02b07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/384b608aeb32db1017935599fa5e0c61e4d02b07/webbrowser.py |
|
p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid) | if sys.platform[:3] == 'win': p = subprocess.Popen(cmdline) else: setsid = getattr(os, 'setsid', None) if not setsid: setsid = getattr(os, 'setpgrp', None) p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid) | def open(self, url, new=0, autoraise=1): cmdline = [self.name] + [arg.replace("%s", url) for arg in self.args] setsid = getattr(os, 'setsid', None) if not setsid: setsid = getattr(os, 'setpgrp', None) try: p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid) return (p.poll() is None) except OSError: return False | 384b608aeb32db1017935599fa5e0c61e4d02b07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/384b608aeb32db1017935599fa5e0c61e4d02b07/webbrowser.py |
self.assertEqual( posixpath.expanduser("~") + "/", posixpath.expanduser("~/") ) | if posixpath.expanduser("~") != '/': self.assertEqual( posixpath.expanduser("~") + "/", posixpath.expanduser("~/") ) | def test_expanduser(self): self.assertEqual(posixpath.expanduser("foo"), "foo") try: import pwd except ImportError: pass else: self.assert_(isinstance(posixpath.expanduser("~/"), basestring)) self.assertEqual( posixpath.expanduser("~") + "/", posixpath.expanduser("~/") ) self.assert_(isinstance(posixpath.expanduser("~root/"), basestring)) self.assert_(isinstance(posixpath.expanduser("~foo/"), basestring)) | db30339994b3d71237703a18c8cb210f50a3ad15 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/db30339994b3d71237703a18c8cb210f50a3ad15/test_posixpath.py |
raise ValueError, "overflow in number field" | raise ValueError("overflow in number field") | def itn(n, digits=8, posix=False): """Convert a python number to a number field. """ # POSIX 1003.1-1988 requires numbers to be encoded as a string of # octal digits followed by a null-byte, this allows values up to # (8**(digits-1))-1. GNU tar allows storing numbers greater than # that if necessary. A leading 0200 byte indicates this particular # encoding, the following digits-1 bytes are a big-endian # representation. This allows values up to (256**(digits-1))-1. if 0 <= n < 8 ** (digits - 1): s = "%0*o" % (digits - 1, n) + NUL else: if posix: raise ValueError, "overflow in number field" if n < 0: # XXX We mimic GNU tar's behaviour with negative numbers, # this could raise OverflowError. n = struct.unpack("L", struct.pack("l", n))[0] s = "" for i in xrange(digits - 1): s = chr(n & 0377) + s n >>= 8 s = chr(0200) + s return s | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise IOError, "end of file reached" | raise IOError("end of file reached") | 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 | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise IOError, "end of file reached" | raise IOError("end of file reached") | 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 | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise CompressionError, "zlib module is not available" | raise CompressionError("zlib module is not available") | def __init__(self, name, mode, comptype, fileobj, bufsize): """Construct a _Stream object. """ self._extfileobj = True if fileobj is None: fileobj = _LowLevelFile(name, mode) self._extfileobj = False | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise CompressionError, "bz2 module is not available" | raise CompressionError("bz2 module is not available") | def __init__(self, name, mode, comptype, fileobj, bufsize): """Construct a _Stream object. """ self._extfileobj = True if fileobj is None: fileobj = _LowLevelFile(name, mode) self._extfileobj = False | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ReadError, "not a gzip file" | raise ReadError("not a gzip file") | def _init_read_gz(self): """Initialize for reading a gzip compressed fileobj. """ self.cmp = self.zlib.decompressobj(-self.zlib.MAX_WBITS) self.dbuf = "" | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise CompressionError, "unsupported compression method" | raise CompressionError("unsupported compression method") | def _init_read_gz(self): """Initialize for reading a gzip compressed fileobj. """ self.cmp = self.zlib.decompressobj(-self.zlib.MAX_WBITS) self.dbuf = "" | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise StreamError, "seeking backwards is not allowed" | raise StreamError("seeking backwards is not allowed") | def seek(self, pos=0): """Set the stream's file pointer to pos. Negative seeking is forbidden. """ if pos - self.pos >= 0: blocks, remainder = divmod(pos - self.pos, self.bufsize) for i in xrange(blocks): self.read(self.bufsize) self.read(remainder) else: raise StreamError, "seeking backwards is not allowed" return self.pos | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ValueError, "file is closed" | raise ValueError("file is closed") | def _readnormal(self, size=None): """Read operation for regular files. """ if self.closed: raise ValueError, "file is closed" self.fileobj.seek(self.offset + self.pos) bytesleft = self.size - self.pos if size is None: bytestoread = bytesleft else: bytestoread = min(size, bytesleft) self.pos += bytestoread return self.__read(bytestoread) | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ValueError, "file is closed" | raise ValueError("file is closed") | def _readsparse(self, size=None): """Read operation for sparse files. """ if self.closed: raise ValueError, "file is closed" | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ValueError, "I/O operation on closed file" | raise ValueError("I/O operation on closed file") | def __iter__(self): """Get an iterator over the file object. """ if self.closed: raise ValueError, "I/O operation on closed file" return self | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ValueError, "truncated header" | raise ValueError("truncated header") | def frombuf(cls, buf): """Construct a TarInfo object from a 512 byte string buffer. """ if len(buf) != BLOCKSIZE: raise ValueError, "truncated header" if buf.count(NUL) == BLOCKSIZE: raise ValueError, "empty header" | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ValueError, "empty header" | raise ValueError("empty header") | def frombuf(cls, buf): """Construct a TarInfo object from a 512 byte string buffer. """ if len(buf) != BLOCKSIZE: raise ValueError, "truncated header" if buf.count(NUL) == BLOCKSIZE: raise ValueError, "empty header" | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ValueError, "invalid header" | raise ValueError("invalid header") | def frombuf(cls, buf): """Construct a TarInfo object from a 512 byte string buffer. """ if len(buf) != BLOCKSIZE: raise ValueError, "truncated header" if buf.count(NUL) == BLOCKSIZE: raise ValueError, "empty header" | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ValueError, "mode must be 'r', 'a' or 'w'" | raise ValueError("mode must be 'r', 'a' or 'w'") | def __init__(self, name=None, mode="r", fileobj=None): """Open an (uncompressed) tar archive `name'. `mode' is either 'r' to read from an existing archive, 'a' to append data to an existing file or 'w' to create a new file overwriting an existing one. `mode' defaults to 'r'. If `fileobj' is given, it is used for reading or writing data. If it can be determined, `mode' is overridden by `fileobj's mode. `fileobj' is not closed, when TarFile is closed. """ self.name = name | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ValueError, "nothing to open" | raise ValueError("nothing to open") | def open(cls, name=None, mode="r", fileobj=None, bufsize=20*512): """Open a tar archive for reading, writing or appending. Return an appropriate TarFile class. | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ReadError, "file could not be opened successfully" | raise ReadError("file could not be opened successfully") | def open(cls, name=None, mode="r", fileobj=None, bufsize=20*512): """Open a tar archive for reading, writing or appending. Return an appropriate TarFile class. | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise CompressionError, "unknown compression type %r" % comptype | raise CompressionError("unknown compression type %r" % comptype) | def open(cls, name=None, mode="r", fileobj=None, bufsize=20*512): """Open a tar archive for reading, writing or appending. Return an appropriate TarFile class. | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ValueError, "mode must be 'r' or 'w'" | raise ValueError("mode must be 'r' or 'w'") | def open(cls, name=None, mode="r", fileobj=None, bufsize=20*512): """Open a tar archive for reading, writing or appending. Return an appropriate TarFile class. | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ValueError, "undiscernible mode" | raise ValueError("undiscernible mode") | def open(cls, name=None, mode="r", fileobj=None, bufsize=20*512): """Open a tar archive for reading, writing or appending. Return an appropriate TarFile class. | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ValueError, "mode must be 'r', 'a' or 'w'" | raise ValueError("mode must be 'r', 'a' or 'w'") | def taropen(cls, name, mode="r", fileobj=None): """Open uncompressed tar archive name for reading or writing. """ if len(mode) > 1 or mode not in "raw": raise ValueError, "mode must be 'r', 'a' or 'w'" return cls(name, mode, fileobj) | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ValueError, "mode must be 'r' or 'w'" | raise ValueError("mode must be 'r' or 'w'") | def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9): """Open gzip compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError, "mode must be 'r' or 'w'" | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise CompressionError, "gzip module is not available" | raise CompressionError("gzip module is not available") | def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9): """Open gzip compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError, "mode must be 'r' or 'w'" | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ReadError, "not a gzip file" | raise ReadError("not a gzip file") | def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9): """Open gzip compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError, "mode must be 'r' or 'w'" | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ValueError, "mode must be 'r' or 'w'." | raise ValueError("mode must be 'r' or 'w'.") | def bz2open(cls, name, mode="r", fileobj=None, compresslevel=9): """Open bzip2 compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError, "mode must be 'r' or 'w'." | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise CompressionError, "bz2 module is not available" | raise CompressionError("bz2 module is not available") | def bz2open(cls, name, mode="r", fileobj=None, compresslevel=9): """Open bzip2 compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError, "mode must be 'r' or 'w'." | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ReadError, "not a bzip2 file" | raise ReadError("not a bzip2 file") | def bz2open(cls, name, mode="r", fileobj=None, compresslevel=9): """Open bzip2 compressed tar archive name for reading or writing. Appending is not allowed. """ if len(mode) > 1 or mode not in "rw": raise ValueError, "mode must be 'r' or 'w'." | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise KeyError, "filename %r not found" % name | raise KeyError("filename %r not found" % name) | def getmember(self, name): """Return a TarInfo object for member `name'. If `name' can not be found in the archive, KeyError is raised. If a member occurs more than once in the archive, its last occurence is assumed to be the most up-to-date version. """ tarinfo = self._getmember(name) if tarinfo is None: raise KeyError, "filename %r not found" % name return tarinfo | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ValueError, "file is too large (>= 8 GB)" | raise ValueError("file is too large (>= 8 GB)") | def addfile(self, tarinfo, fileobj=None): """Add the TarInfo object `tarinfo' to the archive. If `fileobj' is given, tarinfo.size bytes are read from it and added to the archive. You can create TarInfo objects using gettarinfo(). On Windows platforms, `fileobj' should always be opened with mode 'rb' to avoid irritation about the file size. """ self._check("aw") | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ValueError, "linkname is too long (>%d)" \ % (LENGTH_LINK) | raise ValueError("linkname is too long (>%d)" % (LENGTH_LINK)) | def addfile(self, tarinfo, fileobj=None): """Add the TarInfo object `tarinfo' to the archive. If `fileobj' is given, tarinfo.size bytes are read from it and added to the archive. You can create TarInfo objects using gettarinfo(). On Windows platforms, `fileobj' should always be opened with mode 'rb' to avoid irritation about the file size. """ self._check("aw") | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ValueError, "name is too long (>%d)" \ % (LENGTH_NAME) | raise ValueError("name is too long (>%d)" % (LENGTH_NAME)) | def addfile(self, tarinfo, fileobj=None): """Add the TarInfo object `tarinfo' to the archive. If `fileobj' is given, tarinfo.size bytes are read from it and added to the archive. You can create TarInfo objects using gettarinfo(). On Windows platforms, `fileobj' should always be opened with mode 'rb' to avoid irritation about the file size. """ self._check("aw") | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise StreamError, "cannot extract (sym)link as file object" | raise StreamError("cannot extract (sym)link as file object") | def extractfile(self, member): """Extract a member from the archive as a file object. `member' may be a filename or a TarInfo object. If `member' is a regular file, a file-like object is returned. If `member' is a link, a file-like object is constructed from the link's target. If `member' is none of the above, None is returned. The file-like object is read-only and provides the following methods: read(), readline(), readlines(), seek() and tell() """ self._check("r") | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ExtractError, "fifo not supported by system" | raise ExtractError("fifo not supported by system") | def makefifo(self, tarinfo, targetpath): """Make a fifo called targetpath. """ if hasattr(os, "mkfifo"): os.mkfifo(targetpath) else: raise ExtractError, "fifo not supported by system" | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ExtractError, "special devices not supported by system" | raise ExtractError("special devices not supported by system") | def makedev(self, tarinfo, targetpath): """Make a character or block device called targetpath. """ if not hasattr(os, "mknod") or not hasattr(os, "makedev"): raise ExtractError, "special devices not supported by system" | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise IOError, "link could not be created" | raise IOError("link could not be created") | def makelink(self, tarinfo, targetpath): """Make a (symbolic) link called targetpath. If it cannot be created (platform limitation), we try to make a copy of the referenced file instead of a link. """ linkpath = tarinfo.linkname try: if tarinfo.issym(): os.symlink(linkpath, targetpath) else: # See extract(). os.link(tarinfo._link_target, targetpath) except AttributeError: if tarinfo.issym(): linkpath = os.path.join(os.path.dirname(tarinfo.name), linkpath) linkpath = normpath(linkpath) | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ExtractError, "could not change owner" | raise ExtractError("could not change owner") | def chown(self, tarinfo, targetpath): """Set owner of targetpath according to tarinfo. """ if pwd and hasattr(os, "geteuid") and os.geteuid() == 0: # We have to be root to do so. try: g = grp.getgrnam(tarinfo.gname)[2] except KeyError: try: g = grp.getgrgid(tarinfo.gid)[2] except KeyError: g = os.getgid() try: u = pwd.getpwnam(tarinfo.uname)[2] except KeyError: try: u = pwd.getpwuid(tarinfo.uid)[2] except KeyError: u = os.getuid() try: if tarinfo.issym() and hasattr(os, "lchown"): os.lchown(targetpath, u, g) else: if sys.platform != "os2emx": os.chown(targetpath, u, g) except EnvironmentError, e: raise ExtractError, "could not change owner" | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ExtractError, "could not change mode" | raise ExtractError("could not change mode") | def chmod(self, tarinfo, targetpath): """Set file permissions of targetpath according to tarinfo. """ if hasattr(os, 'chmod'): try: os.chmod(targetpath, tarinfo.mode) except EnvironmentError, e: raise ExtractError, "could not change mode" | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ExtractError, "could not change modification time" | raise ExtractError("could not change modification time") | def utime(self, tarinfo, targetpath): """Set modification time of targetpath according to tarinfo. """ if not hasattr(os, 'utime'): return if sys.platform == "win32" and tarinfo.isdir(): # According to msdn.microsoft.com, it is an error (EACCES) # to use utime() on directories. return try: os.utime(targetpath, (tarinfo.mtime, tarinfo.mtime)) except EnvironmentError, e: raise ExtractError, "could not change modification time" | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
self._dbg(2, "0x%X: %s" % (self.offset, e)) | self._dbg(2, "0x%X: empty or invalid block: %s" % (self.offset, e)) | def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ReadError, str(e) | raise ReadError("empty, unreadable or compressed " "file: %s" % e) | def next(self): """Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available. """ self._check("ra") if self.firstmember is not None: m = self.firstmember self.firstmember = None return m | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise IOError, "%s is closed" % self.__class__.__name__ | raise IOError("%s is closed" % self.__class__.__name__) | def _check(self, mode=None): """Check if TarFile is still open, and if the operation's mode corresponds to TarFile's mode. """ if self.closed: raise IOError, "%s is closed" % self.__class__.__name__ if mode is not None and self._mode not in mode: raise IOError, "bad operation for mode %r" % self._mode | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise IOError, "bad operation for mode %r" % self._mode | raise IOError("bad operation for mode %r" % self._mode) | def _check(self, mode=None): """Check if TarFile is still open, and if the operation's mode corresponds to TarFile's mode. """ if self.closed: raise IOError, "%s is closed" % self.__class__.__name__ if mode is not None and self._mode not in mode: raise IOError, "bad operation for mode %r" % self._mode | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
raise ValueError, "unknown compression constant" | raise ValueError("unknown compression constant") | def __init__(self, file, mode="r", compression=TAR_PLAIN): if compression == TAR_PLAIN: self.tarfile = TarFile.taropen(file, mode) elif compression == TAR_GZIPPED: self.tarfile = TarFile.gzopen(file, mode) else: raise ValueError, "unknown compression constant" if mode[0:1] == "r": members = self.tarfile.getmembers() for m in members: m.filename = m.name m.file_size = m.size m.date_time = time.gmtime(m.mtime)[:6] | b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b4f9e5b91e72c3fe0ed21adc8fcc43e75b037e05/tarfile.py |
ifp = open(args) | ifp = open(args[0]) | def main(): global DEBUG # opts, args = getopt.getopt(sys.argv[1:], "D", ["debug"]) for opt, arg in opts: if opt in ("-D", "--debug"): DEBUG = DEBUG + 1 if len(args) == 0: ifp = sys.stdin ofp = sys.stdout elif len(args) == 1: ifp = open(args) ofp = sys.stdout elif len(args) == 2: ifp = open(args[0]) ofp = open(args[1], "w") else: usage() sys.exit(2) table = load_table(open(os.path.join(sys.path[0], 'conversion.xml'))) convert(ifp, ofp, table) | 082fec83c8af353bd090af107d5cb3647fed99c1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/082fec83c8af353bd090af107d5cb3647fed99c1/latex2esis.py |
def test_05_no_pop_tops(self): self.run_test(no_pop_tops) | ## def test_05_no_pop_tops(self): | ef70c4dadcacd8f988aaa366337187a233d67ae9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ef70c4dadcacd8f988aaa366337187a233d67ae9/test_trace.py |
|
container.set_payload(msg) | container.attach(msg) | def _parsebody(self, container, fp): # Parse the body, but first split the payload on the content-type # boundary if present. boundary = container.get_boundary() isdigest = (container.get_type() == 'multipart/digest') # If there's a boundary, split the payload text into its constituent # parts and parse each separately. Otherwise, just parse the rest of # the body as a single message. Note: any exceptions raised in the # recursive parse need to have their line numbers coerced. if boundary: preamble = epilogue = None # Split into subparts. The first boundary we're looking for won't # have the leading newline since we're at the start of the body # text. separator = '--' + boundary payload = fp.read() start = payload.find(separator) if start < 0: raise Errors.BoundaryError( "Couldn't find starting boundary: %s" % boundary) if start > 0: # there's some pre-MIME boundary preamble preamble = payload[0:start] # Find out what kind of line endings we're using start += len(separator) cre = re.compile('\r\n|\r|\n') mo = cre.search(payload, start) if mo: start += len(mo.group(0)) * (1 + isdigest) # We create a compiled regexp first because we need to be able to # specify the start position, and the module function doesn't # support this signature. :( cre = re.compile('(?P<sep>\r\n|\r|\n)' + re.escape(separator) + '--') mo = cre.search(payload, start) if not mo: raise Errors.BoundaryError( "Couldn't find terminating boundary: %s" % boundary) terminator = mo.start() linesep = mo.group('sep') if mo.end() < len(payload): # there's some post-MIME boundary epilogue epilogue = payload[mo.end():] # We split the textual payload on the boundary separator, which # includes the trailing newline. If the container is a # multipart/digest then the subparts are by default message/rfc822 # instead of text/plain. In that case, they'll have an extra # newline before the headers to distinguish the message's headers # from the subpart headers. separator += linesep * (1 + isdigest) parts = payload[start:terminator].split(linesep + separator) for part in parts: msgobj = self.parsestr(part) container.preamble = preamble container.epilogue = epilogue container.attach(msgobj) elif container.get_main_type() == 'multipart': # Very bad. A message is a multipart with no boundary! raise Errors.BoundaryError( 'multipart message with no defined boundary') elif container.get_type() == 'message/delivery-status': # This special kind of type contains blocks of headers separated # by a blank line. We'll represent each header block as a # separate Message object blocks = [] while 1: blockmsg = self._class() self._parseheaders(blockmsg, fp) if not len(blockmsg): # No more header blocks left break blocks.append(blockmsg) container.set_payload(blocks) elif container.get_main_type() == 'message': # Create a container for the payload, but watch out for there not # being any headers left try: msg = self.parse(fp) except Errors.HeaderParseError: msg = self._class() self._parsebody(msg, fp) container.set_payload(msg) else: container.set_payload(fp.read()) | d023012402c28000a8a1533ab4aa2455b6a4be4b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d023012402c28000a8a1533ab4aa2455b6a4be4b/Parser.py |
t = _translations.setdefault(key, class_(open(mofile, 'rb'))) | t = _translations.get(key) if t is None: t = _translations.setdefault(key, class_(open(mofile, 'rb'))) | def translation(domain, localedir=None, languages=None, class_=None): if class_ is None: class_ = GNUTranslations mofile = find(domain, localedir, languages) if mofile is None: raise IOError(ENOENT, 'No translation file found for domain', domain) key = os.path.abspath(mofile) # TBD: do we need to worry about the file pointer getting collected? t = _translations.setdefault(key, class_(open(mofile, 'rb'))) return t | e07d26144bc287651413cc5f1e67510b55983344 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e07d26144bc287651413cc5f1e67510b55983344/gettext.py |
def input(files=(), inplace=0, backup=""): | def input(files=None, inplace=0, backup=""): | def input(files=(), inplace=0, backup=""): global _state if _state and _state._file: raise RuntimeError, "input() already active" _state = FileInput(files, inplace, backup) return _state | 413b6a4a69e7d1143fbf5d8036bf65adb7bced6c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/413b6a4a69e7d1143fbf5d8036bf65adb7bced6c/fileinput.py |
def __init__(self, files=(), inplace=0, backup=""): | def __init__(self, files=None, inplace=0, backup=""): | def __init__(self, files=(), inplace=0, backup=""): if type(files) == type(''): files = (files,) else: files = tuple(files) if not files: files = tuple(sys.argv[1:]) if not files: files = ('-',) self._files = files self._inplace = inplace self._backup = backup self._savestdout = None self._output = None self._filename = None self._lineno = 0 self._filelineno = 0 self._file = None self._isstdin = 0 self._backupfilename = None | 413b6a4a69e7d1143fbf5d8036bf65adb7bced6c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/413b6a4a69e7d1143fbf5d8036bf65adb7bced6c/fileinput.py |
files = tuple(files) | if files is None: files = sys.argv[1:] | def __init__(self, files=(), inplace=0, backup=""): if type(files) == type(''): files = (files,) else: files = tuple(files) if not files: files = tuple(sys.argv[1:]) if not files: files = ('-',) self._files = files self._inplace = inplace self._backup = backup self._savestdout = None self._output = None self._filename = None self._lineno = 0 self._filelineno = 0 self._file = None self._isstdin = 0 self._backupfilename = None | 413b6a4a69e7d1143fbf5d8036bf65adb7bced6c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/413b6a4a69e7d1143fbf5d8036bf65adb7bced6c/fileinput.py |
files = tuple(sys.argv[1:]) if not files: files = ('-',) | files = ('-',) else: files = tuple(files) | def __init__(self, files=(), inplace=0, backup=""): if type(files) == type(''): files = (files,) else: files = tuple(files) if not files: files = tuple(sys.argv[1:]) if not files: files = ('-',) self._files = files self._inplace = inplace self._backup = backup self._savestdout = None self._output = None self._filename = None self._lineno = 0 self._filelineno = 0 self._file = None self._isstdin = 0 self._backupfilename = None | 413b6a4a69e7d1143fbf5d8036bf65adb7bced6c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/413b6a4a69e7d1143fbf5d8036bf65adb7bced6c/fileinput.py |
except: | except AttributeError: | def close(self): self.sync() try: self.dict.close() except: pass self.dict = 0 | 5184326ad9da95589399812261faa8359532f7cf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5184326ad9da95589399812261faa8359532f7cf/shelve.py |
import imp | def load_dynamic(self, name, filename, file): if name not in self.ok_dynamic_modules: raise ImportError, "untrusted dynamic module: %s" % name if sys.modules.has_key(name): src = sys.modules[name] else: import imp src = imp.load_dynamic(name, filename, file) dst = self.copy_except(src, []) return dst | d6a6439e7c2781a1ffe46e50bdf9c9432bd08a42 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d6a6439e7c2781a1ffe46e50bdf9c9432bd08a42/rexec.py |
|
db.readfp(f) return db.types_map | db.readfp(f, True) return db.types_map[True] | def read_mime_types(file): try: f = open(file) except IOError: return None db = MimeTypes() db.readfp(f) return db.types_map | 0b3b86b3273c4857e012732f9d1f861df055164f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0b3b86b3273c4857e012732f9d1f861df055164f/mimetypes.py |
codecs.StreamReader.__init__(self,strict,errors) | codecs.StreamReader.__init__(self,stream,errors) | def __init__(self,stream,errors='strict',mapping=None): | 3707af1c6fd31c337c2a36a51eb60e6612bae7e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3707af1c6fd31c337c2a36a51eb60e6612bae7e0/charmap.py |
if optional and len(params) == 1: line = line[m.end():] else: | def subconvert(self, endchar=None, depth=0): stack = [] line = self.line if DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `line[:20]`)) while line: if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line return line m = _comment_rx.match(line) if m: text = m.group(1) if text: self.write("(COMMENT\n- %s \n)COMMENT\n-\\n\n" % encode(text)) line = line[m.end():] continue m = _begin_env_rx.match(line) if m: # re-write to use the macro handler line = r"\%s %s" % (m.group(1), line[m.end():]) continue m = _end_env_rx.match(line) if m: # end of environment envname = m.group(1) if envname == "document": # special magic for n in stack[1:]: if n not in self.autoclosing: raise LaTeXFormatError( "open element on stack: " + `n`) # should be more careful, but this is easier to code: stack = [] self.write(")document\n") elif stack and envname == stack[-1]: self.write(")%s\n" % envname) del stack[-1] popping(envname, "a", len(stack) + depth) else: self.err_write("stack: %s\n" % `stack`) raise LaTeXFormatError( "environment close for %s doesn't match" % envname) line = line[m.end():] continue m = _begin_macro_rx.match(line) if m: # start of macro macroname = m.group(1) if macroname == "verbatim": # really magic case! pos = string.find(line, "\\end{verbatim}") text = line[m.end(1):pos] self.write("(verbatim\n") self.write("-%s\n" % encode(text)) self.write(")verbatim\n") line = line[pos + len("\\end{verbatim}"):] continue numbered = 1 opened = 0 if macroname[-1] == "*": macroname = macroname[:-1] numbered = 0 if macroname in self.autoclosing and macroname in stack: while stack[-1] != macroname: top = stack.pop() if top and top not in self.discards: self.write(")%s\n-\\n\n" % top) popping(top, "b", len(stack) + depth) if macroname not in self.discards: self.write("-\\n\n)%s\n-\\n\n" % macroname) popping(macroname, "c", len(stack) + depth - 1) del stack[-1] # if macroname in self.discards: self.push_output(StringIO.StringIO()) else: self.push_output(self.ofp) # params, optional, empty, environ = self.start_macro(macroname) if not numbered: self.write("Anumbered TOKEN no\n") # rip off the macroname if params: if optional and len(params) == 1: line = line[m.end():] else: line = line[m.end(1):] elif empty: line = line[m.end(1):] else: line = line[m.end():] # # Very ugly special case to deal with \item[]. The catch # is that this needs to occur outside the for loop that # handles attribute parsing so we can 'continue' the outer # loop. # if optional and type(params[0]) is type(()): # the attribute name isn't used in this special case pushing(macroname, "a", depth + len(stack)) stack.append(macroname) self.write("(%s\n" % macroname) m = _start_optional_rx.match(line) if m: self.line = line[m.end():] line = self.subconvert("]", depth + len(stack)) line = "}" + line continue # handle attribute mappings here: for attrname in params: if optional: optional = 0 if type(attrname) is type(""): m = _optional_rx.match(line) if m: line = line[m.end():] self.write("A%s TOKEN %s\n" % (attrname, encode(m.group(1)))) elif type(attrname) is type(()): # This is a sub-element; but don't place the # element we found on the stack (\section-like) pushing(macroname, "b", len(stack) + depth) stack.append(macroname) self.write("(%s\n" % macroname) macroname = attrname[0] m = _start_group_rx.match(line) if m: line = line[m.end():] elif type(attrname) is type([]): # A normal subelement: <macroname><attrname>...</>... attrname = attrname[0] if not opened: opened = 1 self.write("(%s\n" % macroname) pushing(macroname, "c", len(stack) + depth) self.write("(%s\n" % attrname) pushing(attrname, "sub-elem", len(stack) + depth + 1) self.line = skip_white(line)[1:] line = self.subconvert("}", len(stack) + depth + 1)[1:] dbgmsg("subconvert() ==> " + `line[:20]`) popping(attrname, "sub-elem", len(stack) + depth + 1) self.write(")%s\n" % attrname) else: m = _parameter_rx.match(line) if not m: raise LaTeXFormatError( "could not extract parameter %s for %s: %s" % (attrname, macroname, `line[:100]`)) value = m.group(1) if _token_rx.match(value): dtype = "TOKEN" else: dtype = "CDATA" self.write("A%s %s %s\n" % (attrname, dtype, encode(value))) line = line[m.end():] if params and type(params[-1]) is type('') \ and (not empty) and not environ: # attempt to strip off next '{' m = _start_group_rx.match(line) if not m: raise LaTeXFormatError( "non-empty element '%s' has no content: %s" % (macroname, line[:12])) line = line[m.end():] if not opened: self.write("(%s\n" % macroname) pushing(macroname, "d", len(stack) + depth) if empty: line = "}" + line stack.append(macroname) self.pop_output() continue if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line[1:] return self.line if line[0] == "}": # end of macro or group macroname = stack[-1] conversion = self.table.get(macroname) if macroname \ and macroname not in self.discards \ and type(conversion) is not type(""): # otherwise, it was just a bare group self.write(")%s\n" % stack[-1]) popping(macroname, "d", len(stack) + depth - 1) del stack[-1] line = line[1:] continue if line[0] == "{": pushing("", "e", len(stack) + depth) stack.append("") line = line[1:] continue if line[0] == "\\" and line[1] in ESCAPED_CHARS: self.write("-%s\n" % encode(line[1])) line = line[2:] continue if line[:2] == r"\\": self.write("(BREAK\n)BREAK\n") line = line[2:] continue m = _text_rx.match(line) if m: text = encode(m.group()) self.write("-%s\n" % text) line = line[m.end():] continue # special case because of \item[] if line[0] == "]": self.write("-]\n") line = line[1:] continue # avoid infinite loops extra = "" if len(line) > 100: extra = "..." raise LaTeXFormatError("could not identify markup: %s%s" % (`line[:100]`, extra)) while stack and stack[-1] in self.autoclosing: self.write("-\\n\n") self.write(")%s\n" % stack[-1]) popping(stack.pop(), "e", len(stack) + depth - 1) if stack: raise LaTeXFormatError("elements remain on stack: " + string.join(stack, ", ")) # otherwise we just ran out of input here... | bf2763cf07522d5ef19fe1c77b99de178484ab7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bf2763cf07522d5ef19fe1c77b99de178484ab7b/latex2esis.py |
|
if optional and type(params[0]) is type(()): | if optional and type(params[0]) is TupleType: | def subconvert(self, endchar=None, depth=0): stack = [] line = self.line if DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `line[:20]`)) while line: if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line return line m = _comment_rx.match(line) if m: text = m.group(1) if text: self.write("(COMMENT\n- %s \n)COMMENT\n-\\n\n" % encode(text)) line = line[m.end():] continue m = _begin_env_rx.match(line) if m: # re-write to use the macro handler line = r"\%s %s" % (m.group(1), line[m.end():]) continue m = _end_env_rx.match(line) if m: # end of environment envname = m.group(1) if envname == "document": # special magic for n in stack[1:]: if n not in self.autoclosing: raise LaTeXFormatError( "open element on stack: " + `n`) # should be more careful, but this is easier to code: stack = [] self.write(")document\n") elif stack and envname == stack[-1]: self.write(")%s\n" % envname) del stack[-1] popping(envname, "a", len(stack) + depth) else: self.err_write("stack: %s\n" % `stack`) raise LaTeXFormatError( "environment close for %s doesn't match" % envname) line = line[m.end():] continue m = _begin_macro_rx.match(line) if m: # start of macro macroname = m.group(1) if macroname == "verbatim": # really magic case! pos = string.find(line, "\\end{verbatim}") text = line[m.end(1):pos] self.write("(verbatim\n") self.write("-%s\n" % encode(text)) self.write(")verbatim\n") line = line[pos + len("\\end{verbatim}"):] continue numbered = 1 opened = 0 if macroname[-1] == "*": macroname = macroname[:-1] numbered = 0 if macroname in self.autoclosing and macroname in stack: while stack[-1] != macroname: top = stack.pop() if top and top not in self.discards: self.write(")%s\n-\\n\n" % top) popping(top, "b", len(stack) + depth) if macroname not in self.discards: self.write("-\\n\n)%s\n-\\n\n" % macroname) popping(macroname, "c", len(stack) + depth - 1) del stack[-1] # if macroname in self.discards: self.push_output(StringIO.StringIO()) else: self.push_output(self.ofp) # params, optional, empty, environ = self.start_macro(macroname) if not numbered: self.write("Anumbered TOKEN no\n") # rip off the macroname if params: if optional and len(params) == 1: line = line[m.end():] else: line = line[m.end(1):] elif empty: line = line[m.end(1):] else: line = line[m.end():] # # Very ugly special case to deal with \item[]. The catch # is that this needs to occur outside the for loop that # handles attribute parsing so we can 'continue' the outer # loop. # if optional and type(params[0]) is type(()): # the attribute name isn't used in this special case pushing(macroname, "a", depth + len(stack)) stack.append(macroname) self.write("(%s\n" % macroname) m = _start_optional_rx.match(line) if m: self.line = line[m.end():] line = self.subconvert("]", depth + len(stack)) line = "}" + line continue # handle attribute mappings here: for attrname in params: if optional: optional = 0 if type(attrname) is type(""): m = _optional_rx.match(line) if m: line = line[m.end():] self.write("A%s TOKEN %s\n" % (attrname, encode(m.group(1)))) elif type(attrname) is type(()): # This is a sub-element; but don't place the # element we found on the stack (\section-like) pushing(macroname, "b", len(stack) + depth) stack.append(macroname) self.write("(%s\n" % macroname) macroname = attrname[0] m = _start_group_rx.match(line) if m: line = line[m.end():] elif type(attrname) is type([]): # A normal subelement: <macroname><attrname>...</>... attrname = attrname[0] if not opened: opened = 1 self.write("(%s\n" % macroname) pushing(macroname, "c", len(stack) + depth) self.write("(%s\n" % attrname) pushing(attrname, "sub-elem", len(stack) + depth + 1) self.line = skip_white(line)[1:] line = self.subconvert("}", len(stack) + depth + 1)[1:] dbgmsg("subconvert() ==> " + `line[:20]`) popping(attrname, "sub-elem", len(stack) + depth + 1) self.write(")%s\n" % attrname) else: m = _parameter_rx.match(line) if not m: raise LaTeXFormatError( "could not extract parameter %s for %s: %s" % (attrname, macroname, `line[:100]`)) value = m.group(1) if _token_rx.match(value): dtype = "TOKEN" else: dtype = "CDATA" self.write("A%s %s %s\n" % (attrname, dtype, encode(value))) line = line[m.end():] if params and type(params[-1]) is type('') \ and (not empty) and not environ: # attempt to strip off next '{' m = _start_group_rx.match(line) if not m: raise LaTeXFormatError( "non-empty element '%s' has no content: %s" % (macroname, line[:12])) line = line[m.end():] if not opened: self.write("(%s\n" % macroname) pushing(macroname, "d", len(stack) + depth) if empty: line = "}" + line stack.append(macroname) self.pop_output() continue if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line[1:] return self.line if line[0] == "}": # end of macro or group macroname = stack[-1] conversion = self.table.get(macroname) if macroname \ and macroname not in self.discards \ and type(conversion) is not type(""): # otherwise, it was just a bare group self.write(")%s\n" % stack[-1]) popping(macroname, "d", len(stack) + depth - 1) del stack[-1] line = line[1:] continue if line[0] == "{": pushing("", "e", len(stack) + depth) stack.append("") line = line[1:] continue if line[0] == "\\" and line[1] in ESCAPED_CHARS: self.write("-%s\n" % encode(line[1])) line = line[2:] continue if line[:2] == r"\\": self.write("(BREAK\n)BREAK\n") line = line[2:] continue m = _text_rx.match(line) if m: text = encode(m.group()) self.write("-%s\n" % text) line = line[m.end():] continue # special case because of \item[] if line[0] == "]": self.write("-]\n") line = line[1:] continue # avoid infinite loops extra = "" if len(line) > 100: extra = "..." raise LaTeXFormatError("could not identify markup: %s%s" % (`line[:100]`, extra)) while stack and stack[-1] in self.autoclosing: self.write("-\\n\n") self.write(")%s\n" % stack[-1]) popping(stack.pop(), "e", len(stack) + depth - 1) if stack: raise LaTeXFormatError("elements remain on stack: " + string.join(stack, ", ")) # otherwise we just ran out of input here... | bf2763cf07522d5ef19fe1c77b99de178484ab7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bf2763cf07522d5ef19fe1c77b99de178484ab7b/latex2esis.py |
if type(attrname) is type(""): | if type(attrname) is StringType: | def subconvert(self, endchar=None, depth=0): stack = [] line = self.line if DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `line[:20]`)) while line: if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line return line m = _comment_rx.match(line) if m: text = m.group(1) if text: self.write("(COMMENT\n- %s \n)COMMENT\n-\\n\n" % encode(text)) line = line[m.end():] continue m = _begin_env_rx.match(line) if m: # re-write to use the macro handler line = r"\%s %s" % (m.group(1), line[m.end():]) continue m = _end_env_rx.match(line) if m: # end of environment envname = m.group(1) if envname == "document": # special magic for n in stack[1:]: if n not in self.autoclosing: raise LaTeXFormatError( "open element on stack: " + `n`) # should be more careful, but this is easier to code: stack = [] self.write(")document\n") elif stack and envname == stack[-1]: self.write(")%s\n" % envname) del stack[-1] popping(envname, "a", len(stack) + depth) else: self.err_write("stack: %s\n" % `stack`) raise LaTeXFormatError( "environment close for %s doesn't match" % envname) line = line[m.end():] continue m = _begin_macro_rx.match(line) if m: # start of macro macroname = m.group(1) if macroname == "verbatim": # really magic case! pos = string.find(line, "\\end{verbatim}") text = line[m.end(1):pos] self.write("(verbatim\n") self.write("-%s\n" % encode(text)) self.write(")verbatim\n") line = line[pos + len("\\end{verbatim}"):] continue numbered = 1 opened = 0 if macroname[-1] == "*": macroname = macroname[:-1] numbered = 0 if macroname in self.autoclosing and macroname in stack: while stack[-1] != macroname: top = stack.pop() if top and top not in self.discards: self.write(")%s\n-\\n\n" % top) popping(top, "b", len(stack) + depth) if macroname not in self.discards: self.write("-\\n\n)%s\n-\\n\n" % macroname) popping(macroname, "c", len(stack) + depth - 1) del stack[-1] # if macroname in self.discards: self.push_output(StringIO.StringIO()) else: self.push_output(self.ofp) # params, optional, empty, environ = self.start_macro(macroname) if not numbered: self.write("Anumbered TOKEN no\n") # rip off the macroname if params: if optional and len(params) == 1: line = line[m.end():] else: line = line[m.end(1):] elif empty: line = line[m.end(1):] else: line = line[m.end():] # # Very ugly special case to deal with \item[]. The catch # is that this needs to occur outside the for loop that # handles attribute parsing so we can 'continue' the outer # loop. # if optional and type(params[0]) is type(()): # the attribute name isn't used in this special case pushing(macroname, "a", depth + len(stack)) stack.append(macroname) self.write("(%s\n" % macroname) m = _start_optional_rx.match(line) if m: self.line = line[m.end():] line = self.subconvert("]", depth + len(stack)) line = "}" + line continue # handle attribute mappings here: for attrname in params: if optional: optional = 0 if type(attrname) is type(""): m = _optional_rx.match(line) if m: line = line[m.end():] self.write("A%s TOKEN %s\n" % (attrname, encode(m.group(1)))) elif type(attrname) is type(()): # This is a sub-element; but don't place the # element we found on the stack (\section-like) pushing(macroname, "b", len(stack) + depth) stack.append(macroname) self.write("(%s\n" % macroname) macroname = attrname[0] m = _start_group_rx.match(line) if m: line = line[m.end():] elif type(attrname) is type([]): # A normal subelement: <macroname><attrname>...</>... attrname = attrname[0] if not opened: opened = 1 self.write("(%s\n" % macroname) pushing(macroname, "c", len(stack) + depth) self.write("(%s\n" % attrname) pushing(attrname, "sub-elem", len(stack) + depth + 1) self.line = skip_white(line)[1:] line = self.subconvert("}", len(stack) + depth + 1)[1:] dbgmsg("subconvert() ==> " + `line[:20]`) popping(attrname, "sub-elem", len(stack) + depth + 1) self.write(")%s\n" % attrname) else: m = _parameter_rx.match(line) if not m: raise LaTeXFormatError( "could not extract parameter %s for %s: %s" % (attrname, macroname, `line[:100]`)) value = m.group(1) if _token_rx.match(value): dtype = "TOKEN" else: dtype = "CDATA" self.write("A%s %s %s\n" % (attrname, dtype, encode(value))) line = line[m.end():] if params and type(params[-1]) is type('') \ and (not empty) and not environ: # attempt to strip off next '{' m = _start_group_rx.match(line) if not m: raise LaTeXFormatError( "non-empty element '%s' has no content: %s" % (macroname, line[:12])) line = line[m.end():] if not opened: self.write("(%s\n" % macroname) pushing(macroname, "d", len(stack) + depth) if empty: line = "}" + line stack.append(macroname) self.pop_output() continue if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line[1:] return self.line if line[0] == "}": # end of macro or group macroname = stack[-1] conversion = self.table.get(macroname) if macroname \ and macroname not in self.discards \ and type(conversion) is not type(""): # otherwise, it was just a bare group self.write(")%s\n" % stack[-1]) popping(macroname, "d", len(stack) + depth - 1) del stack[-1] line = line[1:] continue if line[0] == "{": pushing("", "e", len(stack) + depth) stack.append("") line = line[1:] continue if line[0] == "\\" and line[1] in ESCAPED_CHARS: self.write("-%s\n" % encode(line[1])) line = line[2:] continue if line[:2] == r"\\": self.write("(BREAK\n)BREAK\n") line = line[2:] continue m = _text_rx.match(line) if m: text = encode(m.group()) self.write("-%s\n" % text) line = line[m.end():] continue # special case because of \item[] if line[0] == "]": self.write("-]\n") line = line[1:] continue # avoid infinite loops extra = "" if len(line) > 100: extra = "..." raise LaTeXFormatError("could not identify markup: %s%s" % (`line[:100]`, extra)) while stack and stack[-1] in self.autoclosing: self.write("-\\n\n") self.write(")%s\n" % stack[-1]) popping(stack.pop(), "e", len(stack) + depth - 1) if stack: raise LaTeXFormatError("elements remain on stack: " + string.join(stack, ", ")) # otherwise we just ran out of input here... | bf2763cf07522d5ef19fe1c77b99de178484ab7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bf2763cf07522d5ef19fe1c77b99de178484ab7b/latex2esis.py |
elif type(attrname) is type(()): | elif type(attrname) is TupleType: | def subconvert(self, endchar=None, depth=0): stack = [] line = self.line if DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `line[:20]`)) while line: if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line return line m = _comment_rx.match(line) if m: text = m.group(1) if text: self.write("(COMMENT\n- %s \n)COMMENT\n-\\n\n" % encode(text)) line = line[m.end():] continue m = _begin_env_rx.match(line) if m: # re-write to use the macro handler line = r"\%s %s" % (m.group(1), line[m.end():]) continue m = _end_env_rx.match(line) if m: # end of environment envname = m.group(1) if envname == "document": # special magic for n in stack[1:]: if n not in self.autoclosing: raise LaTeXFormatError( "open element on stack: " + `n`) # should be more careful, but this is easier to code: stack = [] self.write(")document\n") elif stack and envname == stack[-1]: self.write(")%s\n" % envname) del stack[-1] popping(envname, "a", len(stack) + depth) else: self.err_write("stack: %s\n" % `stack`) raise LaTeXFormatError( "environment close for %s doesn't match" % envname) line = line[m.end():] continue m = _begin_macro_rx.match(line) if m: # start of macro macroname = m.group(1) if macroname == "verbatim": # really magic case! pos = string.find(line, "\\end{verbatim}") text = line[m.end(1):pos] self.write("(verbatim\n") self.write("-%s\n" % encode(text)) self.write(")verbatim\n") line = line[pos + len("\\end{verbatim}"):] continue numbered = 1 opened = 0 if macroname[-1] == "*": macroname = macroname[:-1] numbered = 0 if macroname in self.autoclosing and macroname in stack: while stack[-1] != macroname: top = stack.pop() if top and top not in self.discards: self.write(")%s\n-\\n\n" % top) popping(top, "b", len(stack) + depth) if macroname not in self.discards: self.write("-\\n\n)%s\n-\\n\n" % macroname) popping(macroname, "c", len(stack) + depth - 1) del stack[-1] # if macroname in self.discards: self.push_output(StringIO.StringIO()) else: self.push_output(self.ofp) # params, optional, empty, environ = self.start_macro(macroname) if not numbered: self.write("Anumbered TOKEN no\n") # rip off the macroname if params: if optional and len(params) == 1: line = line[m.end():] else: line = line[m.end(1):] elif empty: line = line[m.end(1):] else: line = line[m.end():] # # Very ugly special case to deal with \item[]. The catch # is that this needs to occur outside the for loop that # handles attribute parsing so we can 'continue' the outer # loop. # if optional and type(params[0]) is type(()): # the attribute name isn't used in this special case pushing(macroname, "a", depth + len(stack)) stack.append(macroname) self.write("(%s\n" % macroname) m = _start_optional_rx.match(line) if m: self.line = line[m.end():] line = self.subconvert("]", depth + len(stack)) line = "}" + line continue # handle attribute mappings here: for attrname in params: if optional: optional = 0 if type(attrname) is type(""): m = _optional_rx.match(line) if m: line = line[m.end():] self.write("A%s TOKEN %s\n" % (attrname, encode(m.group(1)))) elif type(attrname) is type(()): # This is a sub-element; but don't place the # element we found on the stack (\section-like) pushing(macroname, "b", len(stack) + depth) stack.append(macroname) self.write("(%s\n" % macroname) macroname = attrname[0] m = _start_group_rx.match(line) if m: line = line[m.end():] elif type(attrname) is type([]): # A normal subelement: <macroname><attrname>...</>... attrname = attrname[0] if not opened: opened = 1 self.write("(%s\n" % macroname) pushing(macroname, "c", len(stack) + depth) self.write("(%s\n" % attrname) pushing(attrname, "sub-elem", len(stack) + depth + 1) self.line = skip_white(line)[1:] line = self.subconvert("}", len(stack) + depth + 1)[1:] dbgmsg("subconvert() ==> " + `line[:20]`) popping(attrname, "sub-elem", len(stack) + depth + 1) self.write(")%s\n" % attrname) else: m = _parameter_rx.match(line) if not m: raise LaTeXFormatError( "could not extract parameter %s for %s: %s" % (attrname, macroname, `line[:100]`)) value = m.group(1) if _token_rx.match(value): dtype = "TOKEN" else: dtype = "CDATA" self.write("A%s %s %s\n" % (attrname, dtype, encode(value))) line = line[m.end():] if params and type(params[-1]) is type('') \ and (not empty) and not environ: # attempt to strip off next '{' m = _start_group_rx.match(line) if not m: raise LaTeXFormatError( "non-empty element '%s' has no content: %s" % (macroname, line[:12])) line = line[m.end():] if not opened: self.write("(%s\n" % macroname) pushing(macroname, "d", len(stack) + depth) if empty: line = "}" + line stack.append(macroname) self.pop_output() continue if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line[1:] return self.line if line[0] == "}": # end of macro or group macroname = stack[-1] conversion = self.table.get(macroname) if macroname \ and macroname not in self.discards \ and type(conversion) is not type(""): # otherwise, it was just a bare group self.write(")%s\n" % stack[-1]) popping(macroname, "d", len(stack) + depth - 1) del stack[-1] line = line[1:] continue if line[0] == "{": pushing("", "e", len(stack) + depth) stack.append("") line = line[1:] continue if line[0] == "\\" and line[1] in ESCAPED_CHARS: self.write("-%s\n" % encode(line[1])) line = line[2:] continue if line[:2] == r"\\": self.write("(BREAK\n)BREAK\n") line = line[2:] continue m = _text_rx.match(line) if m: text = encode(m.group()) self.write("-%s\n" % text) line = line[m.end():] continue # special case because of \item[] if line[0] == "]": self.write("-]\n") line = line[1:] continue # avoid infinite loops extra = "" if len(line) > 100: extra = "..." raise LaTeXFormatError("could not identify markup: %s%s" % (`line[:100]`, extra)) while stack and stack[-1] in self.autoclosing: self.write("-\\n\n") self.write(")%s\n" % stack[-1]) popping(stack.pop(), "e", len(stack) + depth - 1) if stack: raise LaTeXFormatError("elements remain on stack: " + string.join(stack, ", ")) # otherwise we just ran out of input here... | bf2763cf07522d5ef19fe1c77b99de178484ab7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bf2763cf07522d5ef19fe1c77b99de178484ab7b/latex2esis.py |
elif type(attrname) is type([]): | elif type(attrname) is ListType: | def subconvert(self, endchar=None, depth=0): stack = [] line = self.line if DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `line[:20]`)) while line: if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line return line m = _comment_rx.match(line) if m: text = m.group(1) if text: self.write("(COMMENT\n- %s \n)COMMENT\n-\\n\n" % encode(text)) line = line[m.end():] continue m = _begin_env_rx.match(line) if m: # re-write to use the macro handler line = r"\%s %s" % (m.group(1), line[m.end():]) continue m = _end_env_rx.match(line) if m: # end of environment envname = m.group(1) if envname == "document": # special magic for n in stack[1:]: if n not in self.autoclosing: raise LaTeXFormatError( "open element on stack: " + `n`) # should be more careful, but this is easier to code: stack = [] self.write(")document\n") elif stack and envname == stack[-1]: self.write(")%s\n" % envname) del stack[-1] popping(envname, "a", len(stack) + depth) else: self.err_write("stack: %s\n" % `stack`) raise LaTeXFormatError( "environment close for %s doesn't match" % envname) line = line[m.end():] continue m = _begin_macro_rx.match(line) if m: # start of macro macroname = m.group(1) if macroname == "verbatim": # really magic case! pos = string.find(line, "\\end{verbatim}") text = line[m.end(1):pos] self.write("(verbatim\n") self.write("-%s\n" % encode(text)) self.write(")verbatim\n") line = line[pos + len("\\end{verbatim}"):] continue numbered = 1 opened = 0 if macroname[-1] == "*": macroname = macroname[:-1] numbered = 0 if macroname in self.autoclosing and macroname in stack: while stack[-1] != macroname: top = stack.pop() if top and top not in self.discards: self.write(")%s\n-\\n\n" % top) popping(top, "b", len(stack) + depth) if macroname not in self.discards: self.write("-\\n\n)%s\n-\\n\n" % macroname) popping(macroname, "c", len(stack) + depth - 1) del stack[-1] # if macroname in self.discards: self.push_output(StringIO.StringIO()) else: self.push_output(self.ofp) # params, optional, empty, environ = self.start_macro(macroname) if not numbered: self.write("Anumbered TOKEN no\n") # rip off the macroname if params: if optional and len(params) == 1: line = line[m.end():] else: line = line[m.end(1):] elif empty: line = line[m.end(1):] else: line = line[m.end():] # # Very ugly special case to deal with \item[]. The catch # is that this needs to occur outside the for loop that # handles attribute parsing so we can 'continue' the outer # loop. # if optional and type(params[0]) is type(()): # the attribute name isn't used in this special case pushing(macroname, "a", depth + len(stack)) stack.append(macroname) self.write("(%s\n" % macroname) m = _start_optional_rx.match(line) if m: self.line = line[m.end():] line = self.subconvert("]", depth + len(stack)) line = "}" + line continue # handle attribute mappings here: for attrname in params: if optional: optional = 0 if type(attrname) is type(""): m = _optional_rx.match(line) if m: line = line[m.end():] self.write("A%s TOKEN %s\n" % (attrname, encode(m.group(1)))) elif type(attrname) is type(()): # This is a sub-element; but don't place the # element we found on the stack (\section-like) pushing(macroname, "b", len(stack) + depth) stack.append(macroname) self.write("(%s\n" % macroname) macroname = attrname[0] m = _start_group_rx.match(line) if m: line = line[m.end():] elif type(attrname) is type([]): # A normal subelement: <macroname><attrname>...</>... attrname = attrname[0] if not opened: opened = 1 self.write("(%s\n" % macroname) pushing(macroname, "c", len(stack) + depth) self.write("(%s\n" % attrname) pushing(attrname, "sub-elem", len(stack) + depth + 1) self.line = skip_white(line)[1:] line = self.subconvert("}", len(stack) + depth + 1)[1:] dbgmsg("subconvert() ==> " + `line[:20]`) popping(attrname, "sub-elem", len(stack) + depth + 1) self.write(")%s\n" % attrname) else: m = _parameter_rx.match(line) if not m: raise LaTeXFormatError( "could not extract parameter %s for %s: %s" % (attrname, macroname, `line[:100]`)) value = m.group(1) if _token_rx.match(value): dtype = "TOKEN" else: dtype = "CDATA" self.write("A%s %s %s\n" % (attrname, dtype, encode(value))) line = line[m.end():] if params and type(params[-1]) is type('') \ and (not empty) and not environ: # attempt to strip off next '{' m = _start_group_rx.match(line) if not m: raise LaTeXFormatError( "non-empty element '%s' has no content: %s" % (macroname, line[:12])) line = line[m.end():] if not opened: self.write("(%s\n" % macroname) pushing(macroname, "d", len(stack) + depth) if empty: line = "}" + line stack.append(macroname) self.pop_output() continue if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line[1:] return self.line if line[0] == "}": # end of macro or group macroname = stack[-1] conversion = self.table.get(macroname) if macroname \ and macroname not in self.discards \ and type(conversion) is not type(""): # otherwise, it was just a bare group self.write(")%s\n" % stack[-1]) popping(macroname, "d", len(stack) + depth - 1) del stack[-1] line = line[1:] continue if line[0] == "{": pushing("", "e", len(stack) + depth) stack.append("") line = line[1:] continue if line[0] == "\\" and line[1] in ESCAPED_CHARS: self.write("-%s\n" % encode(line[1])) line = line[2:] continue if line[:2] == r"\\": self.write("(BREAK\n)BREAK\n") line = line[2:] continue m = _text_rx.match(line) if m: text = encode(m.group()) self.write("-%s\n" % text) line = line[m.end():] continue # special case because of \item[] if line[0] == "]": self.write("-]\n") line = line[1:] continue # avoid infinite loops extra = "" if len(line) > 100: extra = "..." raise LaTeXFormatError("could not identify markup: %s%s" % (`line[:100]`, extra)) while stack and stack[-1] in self.autoclosing: self.write("-\\n\n") self.write(")%s\n" % stack[-1]) popping(stack.pop(), "e", len(stack) + depth - 1) if stack: raise LaTeXFormatError("elements remain on stack: " + string.join(stack, ", ")) # otherwise we just ran out of input here... | bf2763cf07522d5ef19fe1c77b99de178484ab7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bf2763cf07522d5ef19fe1c77b99de178484ab7b/latex2esis.py |
dbgmsg("subconvert() ==> " + `line[:20]`) | def subconvert(self, endchar=None, depth=0): stack = [] line = self.line if DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `line[:20]`)) while line: if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line return line m = _comment_rx.match(line) if m: text = m.group(1) if text: self.write("(COMMENT\n- %s \n)COMMENT\n-\\n\n" % encode(text)) line = line[m.end():] continue m = _begin_env_rx.match(line) if m: # re-write to use the macro handler line = r"\%s %s" % (m.group(1), line[m.end():]) continue m = _end_env_rx.match(line) if m: # end of environment envname = m.group(1) if envname == "document": # special magic for n in stack[1:]: if n not in self.autoclosing: raise LaTeXFormatError( "open element on stack: " + `n`) # should be more careful, but this is easier to code: stack = [] self.write(")document\n") elif stack and envname == stack[-1]: self.write(")%s\n" % envname) del stack[-1] popping(envname, "a", len(stack) + depth) else: self.err_write("stack: %s\n" % `stack`) raise LaTeXFormatError( "environment close for %s doesn't match" % envname) line = line[m.end():] continue m = _begin_macro_rx.match(line) if m: # start of macro macroname = m.group(1) if macroname == "verbatim": # really magic case! pos = string.find(line, "\\end{verbatim}") text = line[m.end(1):pos] self.write("(verbatim\n") self.write("-%s\n" % encode(text)) self.write(")verbatim\n") line = line[pos + len("\\end{verbatim}"):] continue numbered = 1 opened = 0 if macroname[-1] == "*": macroname = macroname[:-1] numbered = 0 if macroname in self.autoclosing and macroname in stack: while stack[-1] != macroname: top = stack.pop() if top and top not in self.discards: self.write(")%s\n-\\n\n" % top) popping(top, "b", len(stack) + depth) if macroname not in self.discards: self.write("-\\n\n)%s\n-\\n\n" % macroname) popping(macroname, "c", len(stack) + depth - 1) del stack[-1] # if macroname in self.discards: self.push_output(StringIO.StringIO()) else: self.push_output(self.ofp) # params, optional, empty, environ = self.start_macro(macroname) if not numbered: self.write("Anumbered TOKEN no\n") # rip off the macroname if params: if optional and len(params) == 1: line = line[m.end():] else: line = line[m.end(1):] elif empty: line = line[m.end(1):] else: line = line[m.end():] # # Very ugly special case to deal with \item[]. The catch # is that this needs to occur outside the for loop that # handles attribute parsing so we can 'continue' the outer # loop. # if optional and type(params[0]) is type(()): # the attribute name isn't used in this special case pushing(macroname, "a", depth + len(stack)) stack.append(macroname) self.write("(%s\n" % macroname) m = _start_optional_rx.match(line) if m: self.line = line[m.end():] line = self.subconvert("]", depth + len(stack)) line = "}" + line continue # handle attribute mappings here: for attrname in params: if optional: optional = 0 if type(attrname) is type(""): m = _optional_rx.match(line) if m: line = line[m.end():] self.write("A%s TOKEN %s\n" % (attrname, encode(m.group(1)))) elif type(attrname) is type(()): # This is a sub-element; but don't place the # element we found on the stack (\section-like) pushing(macroname, "b", len(stack) + depth) stack.append(macroname) self.write("(%s\n" % macroname) macroname = attrname[0] m = _start_group_rx.match(line) if m: line = line[m.end():] elif type(attrname) is type([]): # A normal subelement: <macroname><attrname>...</>... attrname = attrname[0] if not opened: opened = 1 self.write("(%s\n" % macroname) pushing(macroname, "c", len(stack) + depth) self.write("(%s\n" % attrname) pushing(attrname, "sub-elem", len(stack) + depth + 1) self.line = skip_white(line)[1:] line = self.subconvert("}", len(stack) + depth + 1)[1:] dbgmsg("subconvert() ==> " + `line[:20]`) popping(attrname, "sub-elem", len(stack) + depth + 1) self.write(")%s\n" % attrname) else: m = _parameter_rx.match(line) if not m: raise LaTeXFormatError( "could not extract parameter %s for %s: %s" % (attrname, macroname, `line[:100]`)) value = m.group(1) if _token_rx.match(value): dtype = "TOKEN" else: dtype = "CDATA" self.write("A%s %s %s\n" % (attrname, dtype, encode(value))) line = line[m.end():] if params and type(params[-1]) is type('') \ and (not empty) and not environ: # attempt to strip off next '{' m = _start_group_rx.match(line) if not m: raise LaTeXFormatError( "non-empty element '%s' has no content: %s" % (macroname, line[:12])) line = line[m.end():] if not opened: self.write("(%s\n" % macroname) pushing(macroname, "d", len(stack) + depth) if empty: line = "}" + line stack.append(macroname) self.pop_output() continue if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line[1:] return self.line if line[0] == "}": # end of macro or group macroname = stack[-1] conversion = self.table.get(macroname) if macroname \ and macroname not in self.discards \ and type(conversion) is not type(""): # otherwise, it was just a bare group self.write(")%s\n" % stack[-1]) popping(macroname, "d", len(stack) + depth - 1) del stack[-1] line = line[1:] continue if line[0] == "{": pushing("", "e", len(stack) + depth) stack.append("") line = line[1:] continue if line[0] == "\\" and line[1] in ESCAPED_CHARS: self.write("-%s\n" % encode(line[1])) line = line[2:] continue if line[:2] == r"\\": self.write("(BREAK\n)BREAK\n") line = line[2:] continue m = _text_rx.match(line) if m: text = encode(m.group()) self.write("-%s\n" % text) line = line[m.end():] continue # special case because of \item[] if line[0] == "]": self.write("-]\n") line = line[1:] continue # avoid infinite loops extra = "" if len(line) > 100: extra = "..." raise LaTeXFormatError("could not identify markup: %s%s" % (`line[:100]`, extra)) while stack and stack[-1] in self.autoclosing: self.write("-\\n\n") self.write(")%s\n" % stack[-1]) popping(stack.pop(), "e", len(stack) + depth - 1) if stack: raise LaTeXFormatError("elements remain on stack: " + string.join(stack, ", ")) # otherwise we just ran out of input here... | bf2763cf07522d5ef19fe1c77b99de178484ab7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bf2763cf07522d5ef19fe1c77b99de178484ab7b/latex2esis.py |
|
if params and type(params[-1]) is type('') \ | if params and type(params[-1]) is StringType \ | def subconvert(self, endchar=None, depth=0): stack = [] line = self.line if DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `line[:20]`)) while line: if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line return line m = _comment_rx.match(line) if m: text = m.group(1) if text: self.write("(COMMENT\n- %s \n)COMMENT\n-\\n\n" % encode(text)) line = line[m.end():] continue m = _begin_env_rx.match(line) if m: # re-write to use the macro handler line = r"\%s %s" % (m.group(1), line[m.end():]) continue m = _end_env_rx.match(line) if m: # end of environment envname = m.group(1) if envname == "document": # special magic for n in stack[1:]: if n not in self.autoclosing: raise LaTeXFormatError( "open element on stack: " + `n`) # should be more careful, but this is easier to code: stack = [] self.write(")document\n") elif stack and envname == stack[-1]: self.write(")%s\n" % envname) del stack[-1] popping(envname, "a", len(stack) + depth) else: self.err_write("stack: %s\n" % `stack`) raise LaTeXFormatError( "environment close for %s doesn't match" % envname) line = line[m.end():] continue m = _begin_macro_rx.match(line) if m: # start of macro macroname = m.group(1) if macroname == "verbatim": # really magic case! pos = string.find(line, "\\end{verbatim}") text = line[m.end(1):pos] self.write("(verbatim\n") self.write("-%s\n" % encode(text)) self.write(")verbatim\n") line = line[pos + len("\\end{verbatim}"):] continue numbered = 1 opened = 0 if macroname[-1] == "*": macroname = macroname[:-1] numbered = 0 if macroname in self.autoclosing and macroname in stack: while stack[-1] != macroname: top = stack.pop() if top and top not in self.discards: self.write(")%s\n-\\n\n" % top) popping(top, "b", len(stack) + depth) if macroname not in self.discards: self.write("-\\n\n)%s\n-\\n\n" % macroname) popping(macroname, "c", len(stack) + depth - 1) del stack[-1] # if macroname in self.discards: self.push_output(StringIO.StringIO()) else: self.push_output(self.ofp) # params, optional, empty, environ = self.start_macro(macroname) if not numbered: self.write("Anumbered TOKEN no\n") # rip off the macroname if params: if optional and len(params) == 1: line = line[m.end():] else: line = line[m.end(1):] elif empty: line = line[m.end(1):] else: line = line[m.end():] # # Very ugly special case to deal with \item[]. The catch # is that this needs to occur outside the for loop that # handles attribute parsing so we can 'continue' the outer # loop. # if optional and type(params[0]) is type(()): # the attribute name isn't used in this special case pushing(macroname, "a", depth + len(stack)) stack.append(macroname) self.write("(%s\n" % macroname) m = _start_optional_rx.match(line) if m: self.line = line[m.end():] line = self.subconvert("]", depth + len(stack)) line = "}" + line continue # handle attribute mappings here: for attrname in params: if optional: optional = 0 if type(attrname) is type(""): m = _optional_rx.match(line) if m: line = line[m.end():] self.write("A%s TOKEN %s\n" % (attrname, encode(m.group(1)))) elif type(attrname) is type(()): # This is a sub-element; but don't place the # element we found on the stack (\section-like) pushing(macroname, "b", len(stack) + depth) stack.append(macroname) self.write("(%s\n" % macroname) macroname = attrname[0] m = _start_group_rx.match(line) if m: line = line[m.end():] elif type(attrname) is type([]): # A normal subelement: <macroname><attrname>...</>... attrname = attrname[0] if not opened: opened = 1 self.write("(%s\n" % macroname) pushing(macroname, "c", len(stack) + depth) self.write("(%s\n" % attrname) pushing(attrname, "sub-elem", len(stack) + depth + 1) self.line = skip_white(line)[1:] line = self.subconvert("}", len(stack) + depth + 1)[1:] dbgmsg("subconvert() ==> " + `line[:20]`) popping(attrname, "sub-elem", len(stack) + depth + 1) self.write(")%s\n" % attrname) else: m = _parameter_rx.match(line) if not m: raise LaTeXFormatError( "could not extract parameter %s for %s: %s" % (attrname, macroname, `line[:100]`)) value = m.group(1) if _token_rx.match(value): dtype = "TOKEN" else: dtype = "CDATA" self.write("A%s %s %s\n" % (attrname, dtype, encode(value))) line = line[m.end():] if params and type(params[-1]) is type('') \ and (not empty) and not environ: # attempt to strip off next '{' m = _start_group_rx.match(line) if not m: raise LaTeXFormatError( "non-empty element '%s' has no content: %s" % (macroname, line[:12])) line = line[m.end():] if not opened: self.write("(%s\n" % macroname) pushing(macroname, "d", len(stack) + depth) if empty: line = "}" + line stack.append(macroname) self.pop_output() continue if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line[1:] return self.line if line[0] == "}": # end of macro or group macroname = stack[-1] conversion = self.table.get(macroname) if macroname \ and macroname not in self.discards \ and type(conversion) is not type(""): # otherwise, it was just a bare group self.write(")%s\n" % stack[-1]) popping(macroname, "d", len(stack) + depth - 1) del stack[-1] line = line[1:] continue if line[0] == "{": pushing("", "e", len(stack) + depth) stack.append("") line = line[1:] continue if line[0] == "\\" and line[1] in ESCAPED_CHARS: self.write("-%s\n" % encode(line[1])) line = line[2:] continue if line[:2] == r"\\": self.write("(BREAK\n)BREAK\n") line = line[2:] continue m = _text_rx.match(line) if m: text = encode(m.group()) self.write("-%s\n" % text) line = line[m.end():] continue # special case because of \item[] if line[0] == "]": self.write("-]\n") line = line[1:] continue # avoid infinite loops extra = "" if len(line) > 100: extra = "..." raise LaTeXFormatError("could not identify markup: %s%s" % (`line[:100]`, extra)) while stack and stack[-1] in self.autoclosing: self.write("-\\n\n") self.write(")%s\n" % stack[-1]) popping(stack.pop(), "e", len(stack) + depth - 1) if stack: raise LaTeXFormatError("elements remain on stack: " + string.join(stack, ", ")) # otherwise we just ran out of input here... | bf2763cf07522d5ef19fe1c77b99de178484ab7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bf2763cf07522d5ef19fe1c77b99de178484ab7b/latex2esis.py |
and type(conversion) is not type(""): | and type(conversion) is not StringType: | def subconvert(self, endchar=None, depth=0): stack = [] line = self.line if DEBUG and endchar: self.err_write( "subconvert(%s)\n line = %s\n" % (`endchar`, `line[:20]`)) while line: if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line return line m = _comment_rx.match(line) if m: text = m.group(1) if text: self.write("(COMMENT\n- %s \n)COMMENT\n-\\n\n" % encode(text)) line = line[m.end():] continue m = _begin_env_rx.match(line) if m: # re-write to use the macro handler line = r"\%s %s" % (m.group(1), line[m.end():]) continue m = _end_env_rx.match(line) if m: # end of environment envname = m.group(1) if envname == "document": # special magic for n in stack[1:]: if n not in self.autoclosing: raise LaTeXFormatError( "open element on stack: " + `n`) # should be more careful, but this is easier to code: stack = [] self.write(")document\n") elif stack and envname == stack[-1]: self.write(")%s\n" % envname) del stack[-1] popping(envname, "a", len(stack) + depth) else: self.err_write("stack: %s\n" % `stack`) raise LaTeXFormatError( "environment close for %s doesn't match" % envname) line = line[m.end():] continue m = _begin_macro_rx.match(line) if m: # start of macro macroname = m.group(1) if macroname == "verbatim": # really magic case! pos = string.find(line, "\\end{verbatim}") text = line[m.end(1):pos] self.write("(verbatim\n") self.write("-%s\n" % encode(text)) self.write(")verbatim\n") line = line[pos + len("\\end{verbatim}"):] continue numbered = 1 opened = 0 if macroname[-1] == "*": macroname = macroname[:-1] numbered = 0 if macroname in self.autoclosing and macroname in stack: while stack[-1] != macroname: top = stack.pop() if top and top not in self.discards: self.write(")%s\n-\\n\n" % top) popping(top, "b", len(stack) + depth) if macroname not in self.discards: self.write("-\\n\n)%s\n-\\n\n" % macroname) popping(macroname, "c", len(stack) + depth - 1) del stack[-1] # if macroname in self.discards: self.push_output(StringIO.StringIO()) else: self.push_output(self.ofp) # params, optional, empty, environ = self.start_macro(macroname) if not numbered: self.write("Anumbered TOKEN no\n") # rip off the macroname if params: if optional and len(params) == 1: line = line[m.end():] else: line = line[m.end(1):] elif empty: line = line[m.end(1):] else: line = line[m.end():] # # Very ugly special case to deal with \item[]. The catch # is that this needs to occur outside the for loop that # handles attribute parsing so we can 'continue' the outer # loop. # if optional and type(params[0]) is type(()): # the attribute name isn't used in this special case pushing(macroname, "a", depth + len(stack)) stack.append(macroname) self.write("(%s\n" % macroname) m = _start_optional_rx.match(line) if m: self.line = line[m.end():] line = self.subconvert("]", depth + len(stack)) line = "}" + line continue # handle attribute mappings here: for attrname in params: if optional: optional = 0 if type(attrname) is type(""): m = _optional_rx.match(line) if m: line = line[m.end():] self.write("A%s TOKEN %s\n" % (attrname, encode(m.group(1)))) elif type(attrname) is type(()): # This is a sub-element; but don't place the # element we found on the stack (\section-like) pushing(macroname, "b", len(stack) + depth) stack.append(macroname) self.write("(%s\n" % macroname) macroname = attrname[0] m = _start_group_rx.match(line) if m: line = line[m.end():] elif type(attrname) is type([]): # A normal subelement: <macroname><attrname>...</>... attrname = attrname[0] if not opened: opened = 1 self.write("(%s\n" % macroname) pushing(macroname, "c", len(stack) + depth) self.write("(%s\n" % attrname) pushing(attrname, "sub-elem", len(stack) + depth + 1) self.line = skip_white(line)[1:] line = self.subconvert("}", len(stack) + depth + 1)[1:] dbgmsg("subconvert() ==> " + `line[:20]`) popping(attrname, "sub-elem", len(stack) + depth + 1) self.write(")%s\n" % attrname) else: m = _parameter_rx.match(line) if not m: raise LaTeXFormatError( "could not extract parameter %s for %s: %s" % (attrname, macroname, `line[:100]`)) value = m.group(1) if _token_rx.match(value): dtype = "TOKEN" else: dtype = "CDATA" self.write("A%s %s %s\n" % (attrname, dtype, encode(value))) line = line[m.end():] if params and type(params[-1]) is type('') \ and (not empty) and not environ: # attempt to strip off next '{' m = _start_group_rx.match(line) if not m: raise LaTeXFormatError( "non-empty element '%s' has no content: %s" % (macroname, line[:12])) line = line[m.end():] if not opened: self.write("(%s\n" % macroname) pushing(macroname, "d", len(stack) + depth) if empty: line = "}" + line stack.append(macroname) self.pop_output() continue if line[0] == endchar and not stack: if DEBUG: self.err_write("subconvert() --> %s\n" % `line[1:21]`) self.line = line[1:] return self.line if line[0] == "}": # end of macro or group macroname = stack[-1] conversion = self.table.get(macroname) if macroname \ and macroname not in self.discards \ and type(conversion) is not type(""): # otherwise, it was just a bare group self.write(")%s\n" % stack[-1]) popping(macroname, "d", len(stack) + depth - 1) del stack[-1] line = line[1:] continue if line[0] == "{": pushing("", "e", len(stack) + depth) stack.append("") line = line[1:] continue if line[0] == "\\" and line[1] in ESCAPED_CHARS: self.write("-%s\n" % encode(line[1])) line = line[2:] continue if line[:2] == r"\\": self.write("(BREAK\n)BREAK\n") line = line[2:] continue m = _text_rx.match(line) if m: text = encode(m.group()) self.write("-%s\n" % text) line = line[m.end():] continue # special case because of \item[] if line[0] == "]": self.write("-]\n") line = line[1:] continue # avoid infinite loops extra = "" if len(line) > 100: extra = "..." raise LaTeXFormatError("could not identify markup: %s%s" % (`line[:100]`, extra)) while stack and stack[-1] in self.autoclosing: self.write("-\\n\n") self.write(")%s\n" % stack[-1]) popping(stack.pop(), "e", len(stack) + depth - 1) if stack: raise LaTeXFormatError("elements remain on stack: " + string.join(stack, ", ")) # otherwise we just ran out of input here... | bf2763cf07522d5ef19fe1c77b99de178484ab7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bf2763cf07522d5ef19fe1c77b99de178484ab7b/latex2esis.py |
dummy, fp = os.popen4(cmd, "r") dummy.close() | child = popen2.Popen4(cmd) child.tochild.close() | def _cmd(self, output, dir, *cmditems): """Internal routine to run a shell command in a given directory.""" cmd = ("cd \"%s\"; " % dir) + " ".join(cmditems) if output: output.write("+ %s\n" % cmd) if NO_EXECUTE: return 0 dummy, fp = os.popen4(cmd, "r") dummy.close() while 1: line = fp.readline() if not line: break if output: output.write(line) rv = fp.close() return rv | c5fa057f06fde346ae334f98efa0a96c31c4c62e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c5fa057f06fde346ae334f98efa0a96c31c4c62e/pimp.py |
line = fp.readline() | line = child.fromchild.readline() | def _cmd(self, output, dir, *cmditems): """Internal routine to run a shell command in a given directory.""" cmd = ("cd \"%s\"; " % dir) + " ".join(cmditems) if output: output.write("+ %s\n" % cmd) if NO_EXECUTE: return 0 dummy, fp = os.popen4(cmd, "r") dummy.close() while 1: line = fp.readline() if not line: break if output: output.write(line) rv = fp.close() return rv | c5fa057f06fde346ae334f98efa0a96c31c4c62e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c5fa057f06fde346ae334f98efa0a96c31c4c62e/pimp.py |
rv = fp.close() return rv | return child.wait() | def _cmd(self, output, dir, *cmditems): """Internal routine to run a shell command in a given directory.""" cmd = ("cd \"%s\"; " % dir) + " ".join(cmditems) if output: output.write("+ %s\n" % cmd) if NO_EXECUTE: return 0 dummy, fp = os.popen4(cmd, "r") dummy.close() while 1: line = fp.readline() if not line: break if output: output.write(line) rv = fp.close() return rv | c5fa057f06fde346ae334f98efa0a96c31c4c62e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c5fa057f06fde346ae334f98efa0a96c31c4c62e/pimp.py |
return "install %s: running \"%s\" failed" % self.fullname() | return "install %s: running \"%s\" failed" % \ (self.fullname(), installcmd) | def installPackageOnly(self, output=None): """Install a single source package. If output is given it should be a file-like object and it will receive a log of what happened.""" if self._dict.has_key('Pre-install-command'): if self._cmd(output, self._buildDirname, self._dict['Pre-install-command']): return "pre-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Pre-install-command']) self.beforeInstall() installcmd = self._dict.get('Install-command') if not installcmd: installcmd = '"%s" setup.py install' % sys.executable if self._cmd(output, self._buildDirname, installcmd): return "install %s: running \"%s\" failed" % self.fullname() self.afterInstall() if self._dict.has_key('Post-install-command'): if self._cmd(output, self._buildDirname, self._dict['Post-install-command']): return "post-install %s: running \"%s\" failed" % \ (self.fullname(), self._dict['Post-install-command']) return None | c5fa057f06fde346ae334f98efa0a96c31c4c62e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c5fa057f06fde346ae334f98efa0a96c31c4c62e/pimp.py |
except error_proto(val): | except error_proto, val: | def quit(self): """Signoff: commit changes on server, unlock mailbox, close connection.""" try: resp = self._shortcmd('QUIT') except error_proto(val): resp = val self.file.close() self.sock.close() del self.file, self.sock return resp | 687ad76ca16d6b8bf53b2ced6111f69d14d88a28 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/687ad76ca16d6b8bf53b2ced6111f69d14d88a28/poplib.py |
strip_dir=python_build, | strip_dir=0, | def _setup_compile(self, outdir, macros, incdirs, sources, depends, extra): """Process arguments and decide which source files to compile. | 2132d8fd7252ef1da5aada223cc614a6ebef25a2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2132d8fd7252ef1da5aada223cc614a6ebef25a2/ccompiler.py |
objects = self.object_filenames(sources, strip_dir=python_build, output_dir=output_dir) | objects = self.object_filenames(sources, output_dir=output_dir) | def _prep_compile(self, sources, output_dir, depends=None): """Decide which souce files must be recompiled. | 2132d8fd7252ef1da5aada223cc614a6ebef25a2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2132d8fd7252ef1da5aada223cc614a6ebef25a2/ccompiler.py |
_platform_cache = None _platform_aliased_cache = None | _platform_cache = {True:None, False:None} _platform_aliased_cache = {True:None, False:None} | def python_compiler(): """ Returns a string identifying the compiler used for compiling Python. """ return _sys_version()[3] | 51b92569a7dcb6d35980977565c3b69cb6767752 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/51b92569a7dcb6d35980977565c3b69cb6767752/platform.py |
if not aliased and (_platform_cache is not None): return _platform_cache elif _platform_aliased_cache is not None: return _platform_aliased_cache | if not aliased and (_platform_cache[bool(terse)] is not None): return _platform_cache[bool(terse)] elif _platform_aliased_cache[bool(terse)] is not None: return _platform_aliased_cache[bool(terse)] | def platform(aliased=0, terse=0): """ Returns a single string identifying the underlying platform with as much useful information as possible (but no more :). The output is intended to be human readable rather than machine parseable. It may look different on different platforms and this is intended. If "aliased" is true, the function will use aliases for various platforms that report system names which differ from their common names, e.g. SunOS will be reported as Solaris. The system_alias() function is used to implement this. Setting terse to true causes the function to return only the absolute minimum information needed to identify the platform. """ global _platform_cache,_platform_aliased_cache if not aliased and (_platform_cache is not None): return _platform_cache elif _platform_aliased_cache is not None: return _platform_aliased_cache # Get uname information and then apply platform specific cosmetics # to it... system,node,release,version,machine,processor = uname() if machine == processor: processor = '' if aliased: system,release,version = system_alias(system,release,version) if system == 'Windows': # MS platforms rel,vers,csd,ptype = win32_ver(version) if terse: platform = _platform(system,release) else: platform = _platform(system,release,version,csd) elif system in ('Linux',): # Linux based systems distname,distversion,distid = dist('') if distname and not terse: platform = _platform(system,release,machine,processor, 'with', distname,distversion,distid) else: # If the distribution name is unknown check for libc vs. glibc libcname,libcversion = libc_ver(sys.executable) platform = _platform(system,release,machine,processor, 'with', libcname+libcversion) elif system == 'Java': # Java platforms r,v,vminfo,(os_name,os_version,os_arch) = java_ver() if terse: platform = _platform(system,release,version) else: platform = _platform(system,release,version, 'on', os_name,os_version,os_arch) elif system == 'MacOS': # MacOS platforms if terse: platform = _platform(system,release) else: platform = _platform(system,release,machine) else: # Generic handler if terse: platform = _platform(system,release) else: bits,linkage = architecture(sys.executable) platform = _platform(system,release,machine,processor,bits,linkage) if aliased: _platform_aliased_cache = platform elif terse: pass else: _platform_cache = platform return platform | 51b92569a7dcb6d35980977565c3b69cb6767752 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/51b92569a7dcb6d35980977565c3b69cb6767752/platform.py |
_platform_aliased_cache = platform | _platform_aliased_cache[bool(terse)] = platform | def platform(aliased=0, terse=0): """ Returns a single string identifying the underlying platform with as much useful information as possible (but no more :). The output is intended to be human readable rather than machine parseable. It may look different on different platforms and this is intended. If "aliased" is true, the function will use aliases for various platforms that report system names which differ from their common names, e.g. SunOS will be reported as Solaris. The system_alias() function is used to implement this. Setting terse to true causes the function to return only the absolute minimum information needed to identify the platform. """ global _platform_cache,_platform_aliased_cache if not aliased and (_platform_cache is not None): return _platform_cache elif _platform_aliased_cache is not None: return _platform_aliased_cache # Get uname information and then apply platform specific cosmetics # to it... system,node,release,version,machine,processor = uname() if machine == processor: processor = '' if aliased: system,release,version = system_alias(system,release,version) if system == 'Windows': # MS platforms rel,vers,csd,ptype = win32_ver(version) if terse: platform = _platform(system,release) else: platform = _platform(system,release,version,csd) elif system in ('Linux',): # Linux based systems distname,distversion,distid = dist('') if distname and not terse: platform = _platform(system,release,machine,processor, 'with', distname,distversion,distid) else: # If the distribution name is unknown check for libc vs. glibc libcname,libcversion = libc_ver(sys.executable) platform = _platform(system,release,machine,processor, 'with', libcname+libcversion) elif system == 'Java': # Java platforms r,v,vminfo,(os_name,os_version,os_arch) = java_ver() if terse: platform = _platform(system,release,version) else: platform = _platform(system,release,version, 'on', os_name,os_version,os_arch) elif system == 'MacOS': # MacOS platforms if terse: platform = _platform(system,release) else: platform = _platform(system,release,machine) else: # Generic handler if terse: platform = _platform(system,release) else: bits,linkage = architecture(sys.executable) platform = _platform(system,release,machine,processor,bits,linkage) if aliased: _platform_aliased_cache = platform elif terse: pass else: _platform_cache = platform return platform | 51b92569a7dcb6d35980977565c3b69cb6767752 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/51b92569a7dcb6d35980977565c3b69cb6767752/platform.py |
_platform_cache = platform | _platform_cache[bool(terse)] = platform | def platform(aliased=0, terse=0): """ Returns a single string identifying the underlying platform with as much useful information as possible (but no more :). The output is intended to be human readable rather than machine parseable. It may look different on different platforms and this is intended. If "aliased" is true, the function will use aliases for various platforms that report system names which differ from their common names, e.g. SunOS will be reported as Solaris. The system_alias() function is used to implement this. Setting terse to true causes the function to return only the absolute minimum information needed to identify the platform. """ global _platform_cache,_platform_aliased_cache if not aliased and (_platform_cache is not None): return _platform_cache elif _platform_aliased_cache is not None: return _platform_aliased_cache # Get uname information and then apply platform specific cosmetics # to it... system,node,release,version,machine,processor = uname() if machine == processor: processor = '' if aliased: system,release,version = system_alias(system,release,version) if system == 'Windows': # MS platforms rel,vers,csd,ptype = win32_ver(version) if terse: platform = _platform(system,release) else: platform = _platform(system,release,version,csd) elif system in ('Linux',): # Linux based systems distname,distversion,distid = dist('') if distname and not terse: platform = _platform(system,release,machine,processor, 'with', distname,distversion,distid) else: # If the distribution name is unknown check for libc vs. glibc libcname,libcversion = libc_ver(sys.executable) platform = _platform(system,release,machine,processor, 'with', libcname+libcversion) elif system == 'Java': # Java platforms r,v,vminfo,(os_name,os_version,os_arch) = java_ver() if terse: platform = _platform(system,release,version) else: platform = _platform(system,release,version, 'on', os_name,os_version,os_arch) elif system == 'MacOS': # MacOS platforms if terse: platform = _platform(system,release) else: platform = _platform(system,release,machine) else: # Generic handler if terse: platform = _platform(system,release) else: bits,linkage = architecture(sys.executable) platform = _platform(system,release,machine,processor,bits,linkage) if aliased: _platform_aliased_cache = platform elif terse: pass else: _platform_cache = platform return platform | 51b92569a7dcb6d35980977565c3b69cb6767752 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/51b92569a7dcb6d35980977565c3b69cb6767752/platform.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.