rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
return manuel.testing.TestSuite(m, *tests, globs={'path_to_test': os.path.join(here, 'bugs.txt')})
return manuel.testing.TestSuite(m, *tests, **dict( globs={'path_to_test': os.path.join(here, 'bugs.txt')}))
def test_suite(): optionflags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS checker = renormalizing.RENormalizing([ (re.compile(r'<zope\.testing\.doctest\.'), '<doctest.'), ]) tests = ['../index.txt', 'table-example.txt', 'README.txt', 'bugs.txt', 'capture.txt'] m = manuel.ignore.Manuel() m += manuel.doctest.Manuel(optionflags=optionflags, checker=checker) m += manuel.codeblock.Manuel() m += manuel.capture.Manuel() return manuel.testing.TestSuite(m, *tests, globs={'path_to_test': os.path.join(here, 'bugs.txt')})
42b07890390e5ad1e2fd10b9e603dc5974714365 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9784/42b07890390e5ad1e2fd10b9e603dc5974714365/tests.py
self.stc.encoding = detectEncoding(self.utf8)
text = self.utf8 self.stc.encoding, self.stc.refstc.bom = detectEncoding(text)
def testUTF8(self): self.stc.encoding = detectEncoding(self.utf8) print self.stc.encoding self.stc.decodeText(self.utf8) self.stc.prepareEncoding() assert self.utf8 == self.stc.refstc.encoded
8c2fdf4ae6ccd2cd0d7c40694df117e33c96e8bb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/8c2fdf4ae6ccd2cd0d7c40694df117e33c96e8bb/test_unicode.py
self.stc.decodeText(self.utf8)
self.stc.decodeText(text)
def testUTF8(self): self.stc.encoding = detectEncoding(self.utf8) print self.stc.encoding self.stc.decodeText(self.utf8) self.stc.prepareEncoding() assert self.utf8 == self.stc.refstc.encoded
8c2fdf4ae6ccd2cd0d7c40694df117e33c96e8bb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/8c2fdf4ae6ccd2cd0d7c40694df117e33c96e8bb/test_unicode.py
assert self.utf8 == self.stc.refstc.encoded
assert text == self.stc.refstc.encoded def testUTF8BOM(self): text = self.utf8_bom self.stc.encoding, self.stc.refstc.bom = detectEncoding(text) print self.stc.encoding self.stc.decodeText(text) self.stc.prepareEncoding() assert text == self.stc.refstc.encoded
def testUTF8(self): self.stc.encoding = detectEncoding(self.utf8) print self.stc.encoding self.stc.decodeText(self.utf8) self.stc.prepareEncoding() assert self.utf8 == self.stc.refstc.encoded
8c2fdf4ae6ccd2cd0d7c40694df117e33c96e8bb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/8c2fdf4ae6ccd2cd0d7c40694df117e33c96e8bb/test_unicode.py
self.stc.refstc.encoding = detectEncoding(self.utf8)
self.stc.refstc.encoding, self.stc.refstc.bom = detectEncoding(self.utf8)
def testChangeLatin(self): self.stc.refstc.encoding = detectEncoding(self.utf8) print self.stc.refstc.encoding self.stc.decodeText(self.utf8) unicode1 = self.stc.GetLine(1) print repr(unicode1) start = self.stc.FindText(0, self.stc.GetLength(), 'UTF-8') self.stc.SetTargetStart(start) self.stc.SetTargetEnd(start+5) self.stc.ReplaceTarget('latin-1') self.stc.prepareEncoding() print self.stc.refstc.encoded unicode2 = self.stc.GetLine(1) print repr(unicode2) assert unicode1 == unicode2
8c2fdf4ae6ccd2cd0d7c40694df117e33c96e8bb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/8c2fdf4ae6ccd2cd0d7c40694df117e33c96e8bb/test_unicode.py
self.stc.refstc.encoding = detectEncoding(self.latin1)
self.stc.refstc.encoding, self.stc.refstc.bom = detectEncoding(self.latin1)
def testLatin1(self): self.stc.refstc.encoding = detectEncoding(self.latin1) print repr(self.latin1) utf8 = unicode(self.latin1, "iso-8859-1").encode('utf-8') print repr(utf8) print repr(utf8.decode('utf-8')) print repr(self.latin1.decode('latin-1')) self.stc.decodeText(self.latin1) print repr(self.stc.GetText()) print self.stc.refstc.encoding self.stc.prepareEncoding() print "encoded: " + repr(self.stc.refstc.encoded) assert self.latin1 == self.stc.refstc.encoded
8c2fdf4ae6ccd2cd0d7c40694df117e33c96e8bb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/8c2fdf4ae6ccd2cd0d7c40694df117e33c96e8bb/test_unicode.py
self.mode.buffer.stc.setRemappedAccelerator(self.action, accelerator_text, self.append) wx.CallAfter(self.mode.resetList)
if accelerator_text: self.mode.buffer.stc.setRemappedAccelerator(self.action, accelerator_text, self.append) wx.CallAfter(self.mode.resetList) else: self.mode.setStatusText("No keystrokes recorded, so no key binding created.")
def finishRecordingHook(self, accelerator_text): self.mode.buffer.stc.setRemappedAccelerator(self.action, accelerator_text, self.append) wx.CallAfter(self.mode.resetList)
07c18d0928df36e3a196f21f31e46acb868fee85 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/07c18d0928df36e3a196f21f31e46acb868fee85/keyboard.py
def startupFailureCallback(self, p): dprint("Couldn't run %s" % p.cmd)
def startupFailureCallback(self, job, text): dprint("Couldn't run '%s':\n error: %s" % (job.cmd, text))
def startupFailureCallback(self, p): dprint("Couldn't run %s" % p.cmd)
a93e25bf540182b88282813a53eb40a70e1d8e9a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/a93e25bf540182b88282813a53eb40a70e1d8e9a/processmanager.py
def startupFailureCallback(self, p):
def startupFailureCallback(self, p, text):
def startupFailureCallback(self, p): self.callback(self)
a93e25bf540182b88282813a53eb40a70e1d8e9a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/a93e25bf540182b88282813a53eb40a70e1d8e9a/processmanager.py
wx.CallAfter(self._job.jobout.startupFailureCallback, msg)
wx.CallAfter(self._job.jobout.startupFailureCallback, self._job, err)
def run(self): """Run the process until finished or aborted. Don't call this directly instead call self.start() to start the thread else this will run in the context of the current thread. @note: overridden from Thread
a93e25bf540182b88282813a53eb40a70e1d8e9a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/a93e25bf540182b88282813a53eb40a70e1d8e9a/processmanager.py
try: key = str(url) if key in cls.layout[major_mode_keyword]: cls.layout[major_mode_keyword][ukey] = cls.layout[major_mode_keyword][key] del cls.layout[major_mode_keyword][key] except UnicodeEncodeError: pass
if major_mode_keyword in cls.layout: try: key = str(url) if key in cls.layout[major_mode_keyword]: cls.layout[major_mode_keyword][ukey] = cls.layout[major_mode_keyword][key] del cls.layout[major_mode_keyword][key] except UnicodeEncodeError: pass
def getLayoutSubsequent(cls, major_mode_keyword, url): #dprint("getLayoutSubsequent") ukey = unicode(url) try: key = str(url) # Convert old style string keyword to unicode keyword if key in cls.layout[major_mode_keyword]: cls.layout[major_mode_keyword][ukey] = cls.layout[major_mode_keyword][key] del cls.layout[major_mode_keyword][key] except UnicodeEncodeError: pass try: return cls.layout[major_mode_keyword][ukey] except KeyError: return {}
4e3454e9beed6a2bf2dacb218db783bfe75b09e0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/4e3454e9beed6a2bf2dacb218db783bfe75b09e0/major.py
self.mode.buffer.revert(text)
self.mode.buffer.revert(encoding=text)
def processMinibuffer(self, minibuffer, mode, text): #dprint("Revert to encoding %s" % text) # see if it's a known encoding try: 'test'.encode(text) # if we get here, it's valid self.mode.buffer.revert(text) if text != self.mode.buffer.stc.encoding: self.mode.setStatusText("Failed converting to %s; loaded as binary (probably not what you want)" % text) except LookupError: self.mode.setStatusText("Unknown encoding %s" % text)
cf56d234d99c79a038cfc2338a94d9a6f7416785 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/cf56d234d99c79a038cfc2338a94d9a6f7416785/fundamental_menu.py
print("sending %s to %s" % (result, callback))
def _do_callback(self, result, callback): # Ignore encoding errors and return an empty line instead try: result = result.decode(sys.getfilesystemencoding()) except UnicodeDecodeError: result = os.linesep
c60aa083174dfdb1f06aea69cb79d1ce7cca0a3c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/c60aa083174dfdb1f06aea69cb79d1ce7cca0a3c/processmanager.py
print("Windows command: %s" % command)
def run(self): """Run the process until finished or aborted. Don't call this directly instead call self.start() to start the thread else this will run in the context of the current thread. @note: overridden from Thread
c60aa083174dfdb1f06aea69cb79d1ce7cca0a3c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/c60aa083174dfdb1f06aea69cb79d1ce7cca0a3c/processmanager.py
print("Unix command: %s" % command)
def run(self): """Run the process until finished or aborted. Don't call this directly instead call self.start() to start the thread else this will run in the context of the current thread. @note: overridden from Thread
c60aa083174dfdb1f06aea69cb79d1ce7cca0a3c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/c60aa083174dfdb1f06aea69cb79d1ce7cca0a3c/processmanager.py
return cls.layout[major_mode_keyword][str(url)]
key = str(url) if key in cls.layout[major_mode_keyword]: cls.layout[major_mode_keyword][ukey] = cls.layout[major_mode_keyword][key] del cls.layout[major_mode_keyword][key] except UnicodeEncodeError: pass try: return cls.layout[major_mode_keyword][ukey]
def getLayoutSubsequent(cls, major_mode_keyword, url): #dprint("getLayoutSubsequent") try: #dprint(cls.layout[major_mode_keyword]) return cls.layout[major_mode_keyword][str(url)] except KeyError: return {}
367f9cf2f514f21a0bf61a0eae519b4412dfed9b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/367f9cf2f514f21a0bf61a0eae519b4412dfed9b/major.py
cls.layout[major_mode_keyword][str(url)] = perspective
cls.layout[major_mode_keyword][unicode(url)] = perspective
def updateLayoutSubsequent(cls, major_mode_keyword, url, perspective): #dprint("updateLayoutSubsequent") if major_mode_keyword not in cls.layout: cls.layout[major_mode_keyword] = {} cls.layout[major_mode_keyword][str(url)] = perspective
367f9cf2f514f21a0bf61a0eae519b4412dfed9b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/367f9cf2f514f21a0bf61a0eae519b4412dfed9b/major.py
def reportSuccess(self, text, data):
def reportSuccess(self, text, data=None):
def reportSuccess(self, text, data): import wx wx.CallAfter(self.reportSuccessGUI, text, data)
3534a980eb6b3a29e56a53f542a693e3dbe75262 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/3534a980eb6b3a29e56a53f542a693e3dbe75262/threadutils.py
if self._stdin is not None: stdin = subprocess.PIPE else: stdin = None
def run(self): """Run the process until finished or aborted. Don't call this directly instead call self.start() to start the thread else this will run in the context of the current thread. @note: overridden from Thread
b2a84c23c7e4f21c38f933384feb433f1442f031 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/b2a84c23c7e4f21c38f933384feb433f1442f031/processmanager.py
stdin=stdin,
stdin=subprocess.PIPE,
def run(self): """Run the process until finished or aborted. Don't call this directly instead call self.start() to start the thread else this will run in the context of the current thread. @note: overridden from Thread
b2a84c23c7e4f21c38f933384feb433f1442f031 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/b2a84c23c7e4f21c38f933384feb433f1442f031/processmanager.py
self._proc.stdin.close()
self._proc.stdin.close()
def run(self): """Run the process until finished or aborted. Don't call this directly instead call self.start() to start the thread else this will run in the context of the current thread. @note: overridden from Thread
b2a84c23c7e4f21c38f933384feb433f1442f031 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/b2a84c23c7e4f21c38f933384feb433f1442f031/processmanager.py
how_likely = mode.verifyLanguage(header) cls.dprint("%s: %d" % (mode, how_likely)) if how_likely > 0: likely.append((how_likely, mode))
try: how_likely = mode.verifyLanguage(header) cls.dprint("%s: %d" % (mode, how_likely)) if how_likely > 0: likely.append((how_likely, mode)) except UnicodeDecodeError: eprint("Encoding error: file likely not marked with the correct encoding. File type may be incorrectly idendified.")
def scanLanguage(cls, header, modes): """Scan for a pattern match in the first bytes of the file. Determine if there is a 'magic' pattern in the first n bytes of the file that can associate it with a major mode.
1fd5aa025ae2019565106b9f2416cc7b0e8f1529 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/1fd5aa025ae2019565106b9f2416cc7b0e8f1529/majormodematcher.py
self.heatmap = HSI.createCube('bsq', self.lines, self.samples, 1, self.dtype) data = self.heatmap.getBandRaw(0)
self.euclidean = HSI.createCube('bsq', self.lines, self.samples, 1, self.dtype) data = self.euclidean.getBandRaw(0)
def getEuclideanDistanceByBand(self,nbins=500): """Calculate the euclidean distance for every pixel in two cubes using bands Fast for BSQ cubes, slow for BIL, and extremely slow for BIP. """ self.heatmap = HSI.createCube('bsq', self.lines, self.samples, 1, self.dtype) data = self.heatmap.getBandRaw(0) working = numpy.zeros((self.lines, self.samples), dtype=numpy.float32) for i in range(self.bands): if self.bbl[i]: band1 = self.cube1.getBand(i) band2 = self.cube2.getBand(i) band = band1 - band2 working += numpy.square(band) data = numpy.sqrt(working) self.dprint(data) return self.euclidean
e6b4f8b8fef2188b2a8b908daaf998eee930bb85 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/e6b4f8b8fef2188b2a8b908daaf998eee930bb85/utils.py
ctrl = CommaSeparatedListCtrl(frame, -1, initialValue=", ".join([str(i) for i in range(300)]))
ctrl = CSVCtrl(frame, -1, initialValue=", ".join([str(i) for i in range(300)]))
def SetLabel(self, value): """ Set the label's current text """ rvalue = self.label.SetLabel(value) self.Refresh(True) return rvalue
20e3201ffa557da042c1f94b215cdedb83a88558 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/20e3201ffa557da042c1f94b215cdedb83a88558/csv_ctrl.py
wx.PopupWindow.__init__(self, frame, style)
PopupClass.__init__(self, frame, style)
def __init__(self, frame, delay=5000, style=wx.BORDER_SIMPLE): """Creates (but doesn't show) the PopupStatusBar @param frame: the parent frame @kwarg delay: (optional) delay in milliseconds before each message decays """ wx.PopupWindow.__init__(self, frame, style) self.SetBackgroundColour("#B6C1FF") self.stack = wx.BoxSizer(wx.VERTICAL) self.SetSizer(self.stack) self.timer = wx.Timer(self) self.delay = delay self.Bind(wx.EVT_TIMER, self.OnTimer) # Take over the frame's EVT_MENU_HIGHLIGHT frame.Bind(wx.EVT_MENU_HIGHLIGHT, self.OnMenuHighlight) # List of display times self.display_times = [] self.last_is_status = False self.Hide()
9d2a3edb8d79491148a780366f8fc90ef549bb6b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/9d2a3edb8d79491148a780366f8fc90ef549bb6b/popupstatusbar.py
def OnTimer(self, evt): if not self.display_times: # It is possible the timer could go off after the call to clear(), # so if the list is empty, return without restarting the timer return current = time.time() * 1000 #print("Timer at %f" % current) remove = True if (self.last_is_status and len(self.display_times) == 1): last_time, last_text = self.display_times[0] expires = last_time + self.delay #print("expires at: %d current=%d" % (expires, current)) if last_time + self.delay > current: remove = False if remove: expired_time, expired_text = self.display_times.pop(0) self.stack.Remove(expired_text) expired_text.Destroy() if self.display_times: remaining = self.delay - (current - self.display_times[0][0]) #print("Next timer: %d" % remaining) #print("\n".join("%f" % d[0] for d in self.display_times)) if remaining < 0: remaining = 1 self.timer.Start(remaining, True) self.positionAndShow() else: self.clear()
9d2a3edb8d79491148a780366f8fc90ef549bb6b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/9d2a3edb8d79491148a780366f8fc90ef549bb6b/popupstatusbar.py
if remaining < 0:
if remaining < 1:
def OnTimer(self, evt): if not self.display_times: # It is possible the timer could go off after the call to clear(), # so if the list is empty, return without restarting the timer return current = time.time() * 1000 #print("Timer at %f" % current) remove = True if (self.last_is_status and len(self.display_times) == 1): last_time, last_text = self.display_times[0] expires = last_time + self.delay #print("expires at: %d current=%d" % (expires, current)) if last_time + self.delay > current: remove = False if remove: expired_time, expired_text = self.display_times.pop(0) self.stack.Remove(expired_text) expired_text.Destroy() if self.display_times: remaining = self.delay - (current - self.display_times[0][0]) #print("Next timer: %d" % remaining) #print("\n".join("%f" % d[0] for d in self.display_times)) if remaining < 0: remaining = 1 self.timer.Start(remaining, True) self.positionAndShow() else: self.clear()
9d2a3edb8d79491148a780366f8fc90ef549bb6b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/9d2a3edb8d79491148a780366f8fc90ef549bb6b/popupstatusbar.py
while end < length and utext[end].isalpha():
while end < length and (utext[end].isalpha() or utext[end] == "'"):
def findNextWord(self, utext, index, length): """Find the next valid word to check. Designed to be overridden in subclasses, this method takes a starting position in an array of text and returns a tuple indicating the next valid word in the string. @param utext: array of unicode chars @param i: starting index within the array to search @param length: length of the text @return: tuple indicating the word start and end indexes, or (-1, -1) indicating that the end of the array was reached and no word was found """ while index < length: if utext[index].isalpha(): end = index + 1 while end < length and utext[end].isalpha(): end += 1 return (index, end) index += 1 return (-1, -1)
99d9d9195cb6b12285639df01acc58876d0a6b2d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/99d9d9195cb6b12285639df01acc58876d0a6b2d/stcspellcheck.py
end = self.stc.WordEndPosition(pos, True) start = self.stc.WordStartPosition(pos, True)
end = self.getLikelyWordEnd(pos) start = self.getLikelyWordStart(pos)
def checkWord(self, pos=None, atend=False): """Check the word at the current or specified position. @param pos: position of a character in the word (or at the start or end of the word), or None to use the current position @param atend: True if you know the cursor is at the end of the word """ if pos is None: pos = self.stc.GetCurrentPos() if atend: end = pos else: end = self.stc.WordEndPosition(pos, True) start = self.stc.WordStartPosition(pos, True) if self._spelling_debug: print("%d-%d: %s" % (start, end, self.stc.GetTextRange(start, end))) self.checkRange(start, end)
99d9d9195cb6b12285639df01acc58876d0a6b2d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/99d9d9195cb6b12285639df01acc58876d0a6b2d/stcspellcheck.py
word_start = self.stc.WordStartPosition(cursor, True) word_end = self.stc.WordEndPosition(cursor, True)
word_start = self.getLikelyWordStart(cursor) word_end = self.getLikelyWordEnd(cursor) if self._spelling_debug: print("cursor in middle of word, removing styling %d-%d" % (word_start, word_end))
def processDirtyRanges(self): cursor = self.stc.GetCurrentPos() # Check that the cursor has moved off the current word and if so check # its spelling if self.current_word_start > 0: if cursor < self.current_word_start or cursor > self.current_word_end: self.checkRange(self.current_word_start, self.current_word_end) self.current_word_start = -1 # Check spelling around the region currently being typed if self.current_dirty_start >= 0: range_start, range_end = self.processDirtyRange(self.current_dirty_start, self.current_dirty_end) # If the cursor is in the middle of a word, remove the spelling # markers if cursor >= range_start and cursor <= range_end: word_start = self.stc.WordStartPosition(cursor, True) word_end = self.stc.WordEndPosition(cursor, True) mask = self._spelling_indicator_mask self.stc.StartStyling(word_start, mask) self.stc.SetStyling(word_end - word_start, 0) if word_start != word_end: self.current_word_start = word_start self.current_word_end = word_end else: self.current_word_start = -1 self.current_dirty_start = self.current_dirty_end = -1 # Process a chunk of dirty ranges needed = min(len(self.dirty_ranges), self.dirty_range_count_per_idle) ranges = self.dirty_ranges[0:needed] self.dirty_ranges = self.dirty_ranges[needed:] for start, end in ranges: if self._spelling_debug: print("processing %d-%d" % (start, end)) self.processDirtyRange(start, end)
99d9d9195cb6b12285639df01acc58876d0a6b2d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/99d9d9195cb6b12285639df01acc58876d0a6b2d/stcspellcheck.py
range_start = self.stc.WordStartPosition(start, True) range_end = self.stc.WordEndPosition(end, True)
range_start = self.getLikelyWordStart(start) range_end = self.getLikelyWordEnd(end)
def processDirtyRange(self, start, end): range_start = self.stc.WordStartPosition(start, True) range_end = self.stc.WordEndPosition(end, True) if self._spelling_debug: print("processing dirty range %d-%d (modified from %d-%d): %s" % (range_start, range_end, start, end, repr(self.stc.GetTextRange(range_start, range_end)))) self.checkRange(range_start, range_end) return range_start, range_end
99d9d9195cb6b12285639df01acc58876d0a6b2d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/99d9d9195cb6b12285639df01acc58876d0a6b2d/stcspellcheck.py
fh = open(url, "rb") return matcher.iterMatches(url, fh)
try: fh = open(url, "rb") return matcher.iterMatches(url, fh) except: dprint("Failed opening %s" % url) return iter([])
def getMatchGenerator(self, url, matcher): if isinstance(url, vfs.Reference): if url.scheme != "file": dprint("vfs not threadsafe; skipping %s" % unicode(url).encode("utf-8")) return url = unicode(url.path).encode("utf-8") fh = open(url, "rb") return matcher.iterMatches(url, fh)
8a53ddc819dd15ee64c807b32a1cf51bc80f8754 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/8a53ddc819dd15ee64c807b32a1cf51bc80f8754/searchutils.py
default_menu = (("File/Print Options", 995.6), 100)
default_menu = (("File/Print Options", 995.5), 200)
def action(self, index=-1, multiplier=1): self.mode.classprefs.print_style = index
321ca99d283105a3d588f9c067273d5c3360f8d4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/321ca99d283105a3d588f9c067273d5c3360f8d4/text.py
if value == d[keyword]:
if keyword in d and value == d[keyword]:
def convertSection(cls, section):
912b3c0549a44850b5d18f984e16c0259760d52e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/912b3c0549a44850b5d18f984e16c0259760d52e/userparams.py
return stc.GetIndentString(7)
return stc.GetIndentString(6)
def getNewLineIndentString(self, stc, col, ind): """Return the number of characters to be indented on a new line @param stc: stc of interest @param col: column position of cursor on line @param ind: indentation in characters of cursor on line """ return stc.GetIndentString(7)
01e376734c4ebcf752b313d87d3255a417b01ac5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/01e376734c4ebcf752b313d87d3255a417b01ac5/fortran_77.py
connection_cache = TimeExpiringDict(10)
connection_cache = {}
def get_transport(transport_key): t = paramiko.Transport(transport_key) t.start_client() if not t.is_active(): raise OSError("Failure to connect to: '%s'" % str(transport_key)) pub_key = t.get_remote_server_key() return t
4d9958325e95abe3f6b98541473e740c9aefa612 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/4d9958325e95abe3f6b98541473e740c9aefa612/sftp.py
else:
transport = client.get_channel().get_transport() if not transport.is_active(): dprint("Cached channel closed. Opening new connection for %s" % ref) client = None if client is None:
def _get_client(cls, ref): newref = cls._copy_root_reference_without_username(ref) if newref in cls.connection_cache: client = cls.connection_cache[newref] if cls.debug: dprint("Found cached sftp connection: %s" % client) else: client = cls._get_sftp(ref) if cls.debug: dprint("Creating sftp connection: %s" % client) cls.connection_cache[newref] = client return client
4d9958325e95abe3f6b98541473e740c9aefa612 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/4d9958325e95abe3f6b98541473e740c9aefa612/sftp.py
cls.dprint("%s: layout=%s" % (url, layout))
cls.dprint("%s: layout=%s" % (unicode(url), unicode(layout)))
def getLayoutSubsequent(cls, major_mode_keyword, url): #dprint("getLayoutSubsequent") ukey = unicode(url).encode("utf-8") if major_mode_keyword in cls.layout: try: key = str(url) # Convert old style string keyword to unicode keyword if ukey != key and key in cls.layout[major_mode_keyword]: cls.layout[major_mode_keyword][ukey] = cls.layout[major_mode_keyword][key] del cls.layout[major_mode_keyword][key] except UnicodeEncodeError: pass try: layout = cls.layout[major_mode_keyword][ukey] except KeyError: layout = {} cls.dprint("%s: layout=%s" % (url, layout)) return layout
9bdec4c0b5dc03b247a33ca307b905d71f07cb38 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/9bdec4c0b5dc03b247a33ca307b905d71f07cb38/major.py
if action.keyboard is None: keyboard = "" else: keyboard = str(action.keyboard)
keyboard = action.keyboard if keyboard is None: keyboard = "" else: keyboard = str(keyboard)
def __cmp__(self, other): return cmp(self.name, other.name)
1b2d02320f7a2a1c281ed7c48ad12c342d7df7d3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/1b2d02320f7a2a1c281ed7c48ad12c342d7df7d3/keyboard.py
self.pid = wx.Execute(self.cmd, wx.EXEC_ASYNC, self.process)
if wx.Platform != '__WXMSW__': flag = wx.EXEC_ASYNC else: flag = wx.EXEC_NOHIDE self.pid = wx.Execute(self.cmd, flag, self.process)
def run(self, text=""): assert self.dprint("Running %s in %s" % (self.cmd, self.working_dir)) savecwd = os.getcwd() try: os.chdir(self.working_dir) self.process = wx.Process(self.handler) self.process.Redirect(); self.pid = wx.Execute(self.cmd, wx.EXEC_ASYNC, self.process) finally: os.chdir(savecwd) if self.pid==0: assert self.dprint("startup failed") self.process = None wx.CallAfter(self.jobout.startupFailureCallback, self) else: wx.CallAfter(self.jobout.startupCallback, self) size = len(text) fh = self.process.GetOutputStream() assert self.dprint("sending text size=%d to %s" % (size,fh)) # sending large chunks of text to a process's stdin would sometimes # freeze, but breaking up into < 1024 byte pieces seemed to work # on all platforms if size > 1000: for i in range(0,size,1000): last = i+1000 if last>size: last=size assert self.dprint("sending text[%d:%d] to %s" % (i,last,fh)) fh.write(text[i:last]) assert self.dprint("last write = %s" % str(fh.LastWrite())) elif len(text) > 0: fh.write(text) self.process.CloseOutput() self.stdout = self.process.GetInputStream() self.stderr = self.process.GetErrorStream()
69d51371f7dfef0688edc89a04e1c6055e0d3d33 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/69d51371f7dfef0688edc89a04e1c6055e0d3d33/processmanager.py
return attrs.st_mtime @classmethod def get_mtime(cls, ref): attrs = cls._stat(ref) return attrs.st_mtime
return datetime.fromtimestamp(attrs.st_mtime) get_ctime = get_mtime
def get_mtime(cls, ref): attrs = cls._stat(ref) return attrs.st_mtime
82daf178b495d3891617b5e173f5efa210a49c73 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/82daf178b495d3891617b5e173f5efa210a49c73/sftp.py
return attrs.st_atime
return datetime.fromtimestamp(attrs.st_atime)
def get_atime(cls, ref): attrs = cls._stat(ref) return attrs.st_atime
82daf178b495d3891617b5e173f5efa210a49c73 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/82daf178b495d3891617b5e173f5efa210a49c73/sftp.py
self._spelling_debug = True
self._spelling_debug = False
def __init__(self, stc, *args, **kwargs): """Mixin must be initialized using this constructor. Keyword arguments are also available instead of calling the convenience functions. For L{setIndicator}, use C{indicator}, C{indicator_color}, and {indicator_style}; for L{setLanguage}, use C{language}; and for L{setMinimumWordSize}, use C{min_word_size}. See the descriptions of those methods for more info. @kwarg language: default language string recognized by enchant (e.g. "en_US", "kr_KR", etc. If a default language isn't explicitly here, the default language is taken from the class method L{setDefaultLanguage} @kwarg check_region: optional function to specify if the region should be spell checked. Function should return True if the position should be spell-checked; False if it doesn't make sense to spell check that part of the document. Function should be a bound method to the STC. @kwarg idle_count: number of idle events that have to occur before an idle event is actually processed. This reduces processor usage by only processing one out of every idle_count events. """ self.stc = stc self.setIndicator(kwargs.get('indicator', 2), kwargs.get('indicator_color', "#FF0000"), kwargs.get('indicator_style', wx.stc.STC_INDIC_SQUIGGLE)) self.setMinimumWordSize(kwargs.get('min_word_size', 3)) if 'language' in kwargs: self.setDefaultLanguage(kwargs['language']) if 'check_region' in kwargs: self._spell_check_region = kwargs['check_region'] else: self._spell_check_region = lambda s: True if 'idle_count' in kwargs: self._num_idle_ticks = kwargs['idle_count'] else: self._num_idle_ticks = 10 self._idle_ticks = 0 self._spelling_debug = True self._spelling_last_idle_line = -1 self.dirty_range_count_per_idle = 5 self._no_update = False self._last_block = -1 self.clearDirtyRanges()
67dfdf80647b0e756f757c29fc2e4d8f127ec543 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/67dfdf80647b0e756f757c29fc2e4d8f127ec543/stcspellcheck.py
list.InsertSizedColumn(0, "URL", min=100, greedy=False)
list.InsertSizedColumn(0, "File", min=100, greedy=False)
def createColumns(self, list): list.InsertSizedColumn(0, "URL", min=100, greedy=False) list.InsertSizedColumn(1, "Line", min=10, greedy=False) list.InsertSizedColumn(2, "Match", min=300, greedy=True)
ac13a415d46371714bb2a8ae04bcd47af7cfe478 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/ac13a415d46371714bb2a8ae04bcd47af7cfe478/search_in_files.py
return (unicode(item.url), item.line, unicode(item.text))
return (unicode(item.short), item.line, unicode(item.text), item.url)
def getItemRawValues(self, index, item): return (unicode(item.url), item.line, unicode(item.text))
ac13a415d46371714bb2a8ae04bcd47af7cfe478 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/ac13a415d46371714bb2a8ae04bcd47af7cfe478/search_in_files.py
self.frame.open(values[0], options={'line':values[1] - 1})
self.frame.open(values[3], options={'line':values[1] - 1})
def OnItemActivated(self, evt): index = evt.GetIndex() orig_index = self.list.GetItemData(index) values = self.list.itemDataMap[orig_index] dprint(values) self.frame.open(values[0], options={'line':values[1] - 1})
ac13a415d46371714bb2a8ae04bcd47af7cfe478 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/ac13a415d46371714bb2a8ae04bcd47af7cfe478/search_in_files.py
dprint("no selection; cursor at %s" % start)
self.dprint("no selection; cursor at %s" % start)
def action(self, index=-1, multiplier=1): s = self.mode # FIXME: Because the autoindenter depends on the styling information, # need to make sure the document is up to date. But, is this call to # style the entire document fast enough in practice, or will it have # to be optimized? s.Colourise(0, s.GetTextLength())
ab601bed8fd584bac518307f6c201084880837c1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/ab601bed8fd584bac518307f6c201084880837c1/electric_actions.py
dprint("selection: %s - %s" % (start, end))
self.dprint("selection: %s - %s" % (start, end))
def action(self, index=-1, multiplier=1): s = self.mode # FIXME: Because the autoindenter depends on the styling information, # need to make sure the document is up to date. But, is this call to # style the entire document fast enough in practice, or will it have # to be optimized? s.Colourise(0, s.GetTextLength())
ab601bed8fd584bac518307f6c201084880837c1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/ab601bed8fd584bac518307f6c201084880837c1/electric_actions.py
except re.error:
self.error = "" except re.error, errmsg:
def __init__(self, string, match_case): try: if not match_case: flags = re.IGNORECASE else: flags = 0 self.cre = re.compile(string, flags) except re.error: self.cre = None self.last_match = None
f5abb7a4f84c8793efcf5ba079856510ba0a3fad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/f5abb7a4f84c8793efcf5ba079856510ba0a3fad/search_in_files.py
return bool(self.cre)
return bool(self.string) and bool(self.cre) def getErrorString(self): if len(self.string) == 0: return "Search error: search string is blank" return "Regular expression error: %s" % self.error
def isValid(self): return bool(self.cre)
f5abb7a4f84c8793efcf5ba079856510ba0a3fad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/f5abb7a4f84c8793efcf5ba079856510ba0a3fad/search_in_files.py
self.setStatusText("Invalid search string.")
if hasattr(matcher, "getErrorString"): error = matcher.getErrorString() else: error = "Invalid search string." self.setStatusText(error) self.showSearchButton(False)
def OnStartSearch(self, evt): if not self.isSearchRunning(): self.showSearchButton(True) method = self.buffer.stc.search_method.option if method.isValid(): status = SearchStatus(self) matcher = self.buffer.stc.search_type.option.getStringMatcher(self.search_text.GetValue()) ignorer = WildcardListIgnorer(self.ignore_filenames.GetValue()) if matcher.isValid(): self.buffer.stc.clearSearchResults() self.buffer.stc.setPrefix(method.getPrefix()) self.resetList() self.status_info.startProgress("Searching...") self.thread = SearchThread(self.buffer.stc, matcher, ignorer, status) self.thread.start() else: self.setStatusText("Invalid search string.") else: self.setStatusText(method.getErrorString())
f5abb7a4f84c8793efcf5ba079856510ba0a3fad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/f5abb7a4f84c8793efcf5ba079856510ba0a3fad/search_in_files.py
if not prefix.endswith("/"): prefix += "/"
if not prefix.endswith(os.sep): prefix += os.sep
def getPrefix(self): prefix = unicode(self.pathname) if not prefix.endswith("/"): prefix += "/" return prefix
2ba915f445ce6aec1f87d73643182fcbd8094d54 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/2ba915f445ce6aec1f87d73643182fcbd8094d54/search_in_files.py
self.wrapper.spring.clearRadio() self.frame.spring.clearRadio()
try: self.wrapper.spring.clearRadio() self.frame.spring.clearRadio() except wx.PyDeadObjectError: pass
def OnFocus(self, evt): """Callback used to pop down any springtabs. When the major mode loses keyboard focus, the springtabs should be cleared to allow the new focus receiver to display itself. This fails when the major mode never takes keyboard focus at all, in which case a focus-lost event is never generated and this method never gets called. """ self.wrapper.spring.clearRadio() self.frame.spring.clearRadio() evt.Skip()
df08ace7e45208aa8ac1fa9502266e36d825166f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/df08ace7e45208aa8ac1fa9502266e36d825166f/major.py
options = {'byte_order': self.endian}
options['byte_order'] = self.endian
def action(self, index=-1, multiplier=1): filename = self.frame.showSaveAs("Save Image as ENVI", wildcard="BIL (*.bil)|*.bil|BIP (*.bip)|*.bip|BSQ (*.bsq)|*.bsq") if filename: root, ext = os.path.splitext(filename) ext = ext.lower() if ext in ['.bil', '.bip', '.bsq']: handler = HyperspectralFileFormat.getHandlerByName("ENVI") if handler: try: self.mode.showBusy(True) self.mode.status_info.startProgress("Exporting to %s" % filename) wx.GetApp().cooperativeYield() if self.endian: options = {'byte_order': self.endian} handler.export(filename, self.mode.cube, options=options, progress=self.updateProgress) self.mode.status_info.stopProgress("Saved %s" % filename) wx.GetApp().cooperativeYield() finally: self.mode.showBusy(False) else: self.mode.setStatusText("Can't find ENVI handler") else: self.frame.showErrorDialog("Unrecognized file format %s\n\nThe filename extension determines the\ninterleave format. Use a filename extension of\n.bip, .bil, or .bsq" % filename)
243a1ac4bef98113e28a4c52f0495304da0962bd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/243a1ac4bef98113e28a4c52f0495304da0962bd/hsi_menu.py
list.InsertSizedColumn(0, "File", min=100, greedy=False)
list.InsertSizedColumn(0, "File", min=100, max=250, greedy=False)
def createColumns(self, list): list.InsertSizedColumn(0, "File", min=100, greedy=False) list.InsertSizedColumn(1, "Line", min=10, greedy=False) list.InsertSizedColumn(2, "Match", min=300, greedy=True)
522cdb56e377181d11d37e0775d5cff9a5347da2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/522cdb56e377181d11d37e0775d5cff9a5347da2/search_in_files.py
list.InsertSizedColumn(2, "Match", min=300, greedy=True)
list.InsertSizedColumn(2, "Match", min=300, greedy=True, ok_offscreen=True)
def createColumns(self, list): list.InsertSizedColumn(0, "File", min=100, greedy=False) list.InsertSizedColumn(1, "Line", min=10, greedy=False) list.InsertSizedColumn(2, "Match", min=300, greedy=True)
522cdb56e377181d11d37e0775d5cff9a5347da2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/522cdb56e377181d11d37e0775d5cff9a5347da2/search_in_files.py
self.raw.tofile(str(url.path))
filename = unicode(url.path) try: self.raw.tofile(filename) except ValueError: fd = open(filename, "wb") flat = self.raw.ravel() size = flat.size start = 0 while start < size: last = start + 10000 if last > size: last = size fd.write(flat[start:last].tostring()) start = last
def save(self, url): if self.mmap: self.mmap.flush() self.mmap.sync() else: self.raw.tofile(str(url.path))
9e795e7f858ef9646a014fc9761d64b26c050635 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/9e795e7f858ef9646a014fc9761d64b26c050635/cube.py
ukey = unicode(url)
ukey = unicode(url).encode("utf-8")
def getLayoutSubsequent(cls, major_mode_keyword, url): #dprint("getLayoutSubsequent") ukey = unicode(url) if major_mode_keyword in cls.layout: try: key = str(url) # Convert old style string keyword to unicode keyword if key in cls.layout[major_mode_keyword]: cls.layout[major_mode_keyword][ukey] = cls.layout[major_mode_keyword][key] del cls.layout[major_mode_keyword][key] except UnicodeEncodeError: pass try: return cls.layout[major_mode_keyword][ukey] except KeyError: return {}
82cadc0259af62e12f609221a12afb4db898cba4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/82cadc0259af62e12f609221a12afb4db898cba4/major.py
if key in cls.layout[major_mode_keyword]:
if ukey != key and key in cls.layout[major_mode_keyword]:
def getLayoutSubsequent(cls, major_mode_keyword, url): #dprint("getLayoutSubsequent") ukey = unicode(url) if major_mode_keyword in cls.layout: try: key = str(url) # Convert old style string keyword to unicode keyword if key in cls.layout[major_mode_keyword]: cls.layout[major_mode_keyword][ukey] = cls.layout[major_mode_keyword][key] del cls.layout[major_mode_keyword][key] except UnicodeEncodeError: pass try: return cls.layout[major_mode_keyword][ukey] except KeyError: return {}
82cadc0259af62e12f609221a12afb4db898cba4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/82cadc0259af62e12f609221a12afb4db898cba4/major.py
return cls.layout[major_mode_keyword][ukey]
layout = cls.layout[major_mode_keyword][ukey]
def getLayoutSubsequent(cls, major_mode_keyword, url): #dprint("getLayoutSubsequent") ukey = unicode(url) if major_mode_keyword in cls.layout: try: key = str(url) # Convert old style string keyword to unicode keyword if key in cls.layout[major_mode_keyword]: cls.layout[major_mode_keyword][ukey] = cls.layout[major_mode_keyword][key] del cls.layout[major_mode_keyword][key] except UnicodeEncodeError: pass try: return cls.layout[major_mode_keyword][ukey] except KeyError: return {}
82cadc0259af62e12f609221a12afb4db898cba4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/82cadc0259af62e12f609221a12afb4db898cba4/major.py
return {}
layout = {} cls.dprint("%s: layout=%s" % (url, layout)) return layout
def getLayoutSubsequent(cls, major_mode_keyword, url): #dprint("getLayoutSubsequent") ukey = unicode(url) if major_mode_keyword in cls.layout: try: key = str(url) # Convert old style string keyword to unicode keyword if key in cls.layout[major_mode_keyword]: cls.layout[major_mode_keyword][ukey] = cls.layout[major_mode_keyword][key] del cls.layout[major_mode_keyword][key] except UnicodeEncodeError: pass try: return cls.layout[major_mode_keyword][ukey] except KeyError: return {}
82cadc0259af62e12f609221a12afb4db898cba4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/82cadc0259af62e12f609221a12afb4db898cba4/major.py
if self.frame == frame:
if not self.frame: dprint("Frame has been deleted!!! Message was:") dprint(message) dlg = wx.MessageDialog(wx.GetApp().GetTopWindow(), message, "Error message for deleted frame!!!", wx.OK | wx.ICON_EXCLAMATION ) retval=dlg.ShowModal() dlg.Destroy() elif self.frame == frame:
def showError(self, message=None): data = message.data if isinstance(data, tuple) or isinstance(data, list): frame = data[0] text = data[1] else: frame = wx.GetApp().GetTopWindow() text = data if self.frame == frame: paneinfo = frame._mgr.GetPane(self) if self.classprefs.unhide_on_message: if not paneinfo.IsShown(): paneinfo.Show(True) frame._mgr.Update() if message.topic[-1] == 'wrap': columns = 72 import textwrap text = textwrap.fill(text, columns) self.addMessage(text)
057547cad5f4be297121616fac08b79566b49256 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/057547cad5f4be297121616fac08b79566b49256/error_log.py
StrParam('minor_modes', 'GraphvizView'), ) class GraphvizViewMinorMode(MinorMode, JobOutputMixin, wx.Panel, debugmixin): """Display the graphical view of the DOT file. This displays the graphic image that is represented by the .dot file. It calls the external graphviz program and displays a bitmap version of the graph. """ keyword="GraphvizView" default_classprefs = ( IntParam('best_width', 300), IntParam('best_height', 300), IntParam('min_width', 300), IntParam('min_height', 300),
StrParam('graphic_format', 'png'), StrParam('layout', 'dot'), SupersededParam('output_log')
def action(self, index=-1, multiplier=1): self.frame.open("about:sample.dot")
21834e12e052ab98f36c3cfa4905e6f6dd89dab8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/21834e12e052ab98f36c3cfa4905e6f6dd89dab8/graphviz.py
dotprogs = ['dot', 'neato', 'twopi', 'circo', 'fdp']
def getInterpreterArgs(self): self.dot_output = vfs.reference_with_new_extension(self.buffer.url, self.classprefs.graphic_format) args = "%s -v -T%s -K%s -o%s" % (self.classprefs.interpreter_args, self.classprefs.graphic_format, self.classprefs.layout, str(self.dot_output.path)) return args
def action(self, index=-1, multiplier=1): self.frame.open("about:sample.dot")
21834e12e052ab98f36c3cfa4905e6f6dd89dab8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/21834e12e052ab98f36c3cfa4905e6f6dd89dab8/graphviz.py
@classmethod def worksWithMajorMode(self, mode): if mode.__class__ == GraphvizMode: return True return False def __init__(self, parent, **kwargs): MinorMode.__init__(self, parent, **kwargs) wx.Panel.__init__(self, parent) self.sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(self.sizer) buttons = wx.BoxSizer(wx.HORIZONTAL) self.prog = wx.Choice(self, -1, (100, 50), choices = self.dotprogs) self.prog.SetSelection(0) buttons.Add(self.prog, 1, wx.EXPAND) self.regen = wx.Button(self, -1, "Regenerate") self.regen.Bind(wx.EVT_BUTTON, self.OnRegenerate) buttons.Add(self.regen, 1, wx.EXPAND) self.sizer.Add(buttons) self.preview = None self.drawing = BitmapScroller(self) self.sizer.Add(self.drawing, 1, wx.EXPAND) self.process = None self.Bind(wx.EVT_SIZE, self.OnSize) self.Layout() def deletePreHook(self): if self.process is not None: self.process.kill() def busy(self, busy): if busy: cursor = wx.StockCursor(wx.CURSOR_WATCH) else: cursor = wx.StockCursor(wx.CURSOR_DEFAULT) self.SetCursor(cursor) self.drawing.SetCursor(cursor) self.regen.SetCursor(cursor) self.regen.Enable(not busy) self.prog.SetCursor(cursor) self.prog.Enable(not busy) def OnRegenerate(self, event): prog = os.path.normpath(os.path.join(self.mode.classprefs.path,self.prog.GetStringSelection())) assert self.dprint("using %s to run graphviz" % repr(prog)) cmd = "%s -Tpng" % prog ProcessManager().run(cmd, self.mode.buffer.cwd(), self, self.mode.buffer.stc.GetText())
def getJobOutput(self): return self
def action(self, index=-1, multiplier=1): self.frame.open("about:sample.dot")
21834e12e052ab98f36c3cfa4905e6f6dd89dab8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/21834e12e052ab98f36c3cfa4905e6f6dd89dab8/graphviz.py
self.busy(True)
def startupCallback(self, job): self.process = job self.busy(True) self.preview = StringIO()
21834e12e052ab98f36c3cfa4905e6f6dd89dab8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/21834e12e052ab98f36c3cfa4905e6f6dd89dab8/graphviz.py
self.process = None self.busy(False) self.createImage() def createImage(self): assert self.dprint("using image, size=%s" % len(self.preview.getvalue())) if len(self.preview.getvalue())==0: self.mode.setStatusText("Error running graphviz!") return fh = StringIO(self.preview.getvalue()) img = wx.EmptyImage() if img.LoadStream(fh): self.bmp = wx.BitmapFromImage(img) self.mode.setStatusText("Graphviz completed.") else: self.bmp = None self.mode.setStatusText("Invalid image") self.drawing.setBitmap(self.bmp) def OnSize(self, evt): self.Refresh() evt.Skip()
del self.process self.frame.findTabOrOpen(self.dot_output)
def finishedCallback(self, job): assert self.dprint() self.process = None self.busy(False) self.createImage() # Don't call evt.Skip() here because it causes a crash
21834e12e052ab98f36c3cfa4905e6f6dd89dab8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/21834e12e052ab98f36c3cfa4905e6f6dd89dab8/graphviz.py
def getMinorModes(self): yield GraphvizViewMinorMode
def getMajorModes(self): yield GraphvizMode
21834e12e052ab98f36c3cfa4905e6f6dd89dab8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11522/21834e12e052ab98f36c3cfa4905e6f6dd89dab8/graphviz.py
def download(self, url, path):
def download(url, path):
def download(self, url, path): """ Download url and store it at path """ f = None g = None try: f = urllib.urlopen(url) g = open(path, 'wb') copyobj(f, g) finally: if f: f.close() if g: g.close()
86603d2facf8767a09b622a032e173fe518ddb13 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11095/86603d2facf8767a09b622a032e173fe518ddb13/agent.py
main()
main()
def main(): home = config.get_home() default_cache = os.path.join(home,"var","cache") default_cache = os.getenv("MULE_CACHE", default_cache) parser = OptionParser() parser.add_option("-f", "--foreground", action="store_true", dest="foreground", default=False, help="Do not fork [default: fork]") parser.add_option("-r", "--rls", action="store", dest="rls", default=DEFAULT_RLS, metavar="HOST", help="RLS host [def: %default]") parser.add_option("-c", "--cache", action="store", dest="cache", default=DEFAULT_CACHE, metavar="DIR", help="Cache directory [def: %default]") (options, args) = parser.parse_args() if len(args) > 0: parser.error("Invalid argument") if not options.rls: parser.error("Specify --rls or MULE_RLS environment") if os.path.isfile(options.cache): parser.error("--cache argument is file") if not os.path.isdir(options.cache): os.makedirs(options.cache) # Fork if not options.foreground: util.daemonize() os.chdir(config.get_home()) # Configure logging (after the fork) log.configure() l = log.get_log("agent") try: a = Agent(options.rls, options.cache) a.run() except Exception, e: l.exception(e) sys.exit(1)
86603d2facf8767a09b622a032e173fe518ddb13 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11095/86603d2facf8767a09b622a032e173fe518ddb13/agent.py
sys.stderr.write( "Usage: %s COMMAND\n" % os.path.basename(sys.argv[0])) sys.stderr.write( """
sys.stderr.write("Usage: %s COMMAND\n" % os.path.basename(sys.argv[0])) sys.stderr.write("""
def usage(): sys.stderr.write( "Usage: %s COMMAND\n" % os.path.basename(sys.argv[0])) sys.stderr.write( """
daeb8105f0fedc695bf3dfc5e9ad3c797f1949b3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11095/daeb8105f0fedc695bf3dfc5e9ad3c797f1949b3/client.py
"""
""")
def usage(): sys.stderr.write( "Usage: %s COMMAND\n" % os.path.basename(sys.argv[0])) sys.stderr.write( """
daeb8105f0fedc695bf3dfc5e9ad3c797f1949b3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11095/daeb8105f0fedc695bf3dfc5e9ad3c797f1949b3/client.py
main()
main()
def main(): if len(sys.argv) < 2: usage() cmd = sys.argv[1] args = sys.argv[2:] if cmd in ['get']: parser = OptionParser("Usage: %prog get LFN PATH") parser.add_option("-s", "--symlink", action="store_true", dest="symlink", default=SYMLINK, help="symlink PATH to cached file [default: %default]") (options, args) = parser.parse_args(args=args) if len(args) != 2: parser.error("Specify LFN and PATH") lfn = args[0] path = args[1] get(lfn, path, options.symlink) elif cmd in ['put']: parser = OptionParser("Usage: %prog put PATH LFN") parser.add_option("-r", "--rename", action="store_true", dest="rename", default=RENAME, help="rename PATH to cached file [default: %default]") (options, args) = parser.parse_args(args=args) if len(args) != 2: pasrser.error("Specify PATH and LFN") path = args[0] lfn = args[1] put(path, lfn, options.rename) elif cmd in ['remove','rm']: parser = OptionParser("Usage: %prog remove [options] LFN") parser.add_option("-f", "--force", action="store_true", dest="force", default=False, help="Force LFN to be removed from cache [default: %default]") (options, args) = parser.parse_args(args=args) if len(args) != 1: parser.error("Specify LFN") lfn = args[0] remove(lfn, options.force) elif cmd in ['list','ls']: parser = OptionParser("Usage: %prog list") (options, args) = parser.parse_args(args=args) if len(args) > 0: parser.error("Invalid argument") ls() elif cmd in ['rls_add','add']: parser = OptionParser("Usage: %prog rls_add LFN PFN") (options, args) = parser.parse_args(args=args) if len(args) != 2: parser.error("Specify LFN and PFN") lfn = args[0] pfn = args[1] rls_add(lfn, pfn) elif cmd in ['rls_lookup','rls_lu','lookup','lu']: parser = OptionParser("Usage: %prog rls_lookup LFN") (options, args) = parser.parse_args(args=args) if len(args) != 1: parser.error("Specify LFN") lfn = args[0] rls_lookup(lfn) elif cmd in ['rls_delete','rls_del','delete','del']: parser = OptionParser("Usage: %prog rls_del LFN [PFN]") (options, args) = parser.parse_args(args=args) if len(args) not in [1,2]: parser.error("Specify LFN and/or PFN") lfn = args[0] if len(args) > 1: pfn = args[1] else: pfn = None rls_delete(lfn, pfn) elif cmd in ['-h','help','-help','--help']: usage() else: sys.stderr.write("Unrecognized argument: %s\n" % cmd)
daeb8105f0fedc695bf3dfc5e9ad3c797f1949b3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11095/daeb8105f0fedc695bf3dfc5e9ad3c797f1949b3/client.py
except DBLockDeadlockError, e:
except bdb.DBLockDeadlockError, e:
def with_transaction(self, *args, **kwargs): deadlocks = 0 while True: txn = self.env.txn_begin() try: result = method(self, txn, *args, **kwargs) txn.commit() return result except DBLockDeadlockError, e: txn.abort() deadlocks += 1 if deadlocks < retries: self.log.info("Deadlock detected, retrying") continue else: self.log.error("Deadlock detected, aborting") raise except: txn.abort() raise
9e07faa89ded53ec47eff4d37dd1872c7441d8ff /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11095/9e07faa89ded53ec47eff4d37dd1872c7441d8ff/bdb.py
def list(self):
def list(self, txn):
def list(self): cur = self.db.cursor(txn) try: result = [] current = cur.first() while current is not None: rec = pickle.loads(current[1]) rec['lfn'] = current[0] result.append(rec) current = cur.next() return result finally: cur.close()
9e07faa89ded53ec47eff4d37dd1872c7441d8ff /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11095/9e07faa89ded53ec47eff4d37dd1872c7441d8ff/bdb.py
def with_transaction(method):
def with_transaction(method, retries=3):
def with_transaction(method): def with_transaction(self, *args, **kwargs): if len(args)>0 and isinstance(args[0],Database): return method(self, *args, **kwargs) else: txn = self.env.txn_begin() try: result = method(self, txn, *args, **kwargs) txn.commit() return result except: txn.abort() raise return with_transaction
29dcac664c3f2fbc9009978e949ae467280aa521 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11095/29dcac664c3f2fbc9009978e949ae467280aa521/bdb.py
if len(args)>0 and isinstance(args[0],Database): return method(self, *args, **kwargs) else:
deadlocks = 0 while True:
def with_transaction(self, *args, **kwargs): if len(args)>0 and isinstance(args[0],Database): return method(self, *args, **kwargs) else: txn = self.env.txn_begin() try: result = method(self, txn, *args, **kwargs) txn.commit() return result except: txn.abort() raise
29dcac664c3f2fbc9009978e949ae467280aa521 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11095/29dcac664c3f2fbc9009978e949ae467280aa521/bdb.py
class CheckpointThread(Thread):
class DatabaseManagerThread(Thread):
def with_transaction(self, *args, **kwargs): if len(args)>0 and isinstance(args[0],Database): return method(self, *args, **kwargs) else: txn = self.env.txn_begin() try: result = method(self, txn, *args, **kwargs) txn.commit() return result except: txn.abort() raise
29dcac664c3f2fbc9009978e949ae467280aa521 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11095/29dcac664c3f2fbc9009978e949ae467280aa521/bdb.py
self.log = log.get_log("ckpt_thread")
self.log = log.get_log("bdb manager")
def __init__(self, env, interval=300): Thread.__init__(self) self.setDaemon(True) self.log = log.get_log("ckpt_thread") self.env = env self.interval = interval
29dcac664c3f2fbc9009978e949ae467280aa521 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11095/29dcac664c3f2fbc9009978e949ae467280aa521/bdb.py
if bdb.version() > (4,7):
if hasattr(self.env, "log_set_config"):
def __init__(self, path, name, duplicates=False): self.path = path self.dbpath = os.path.join(self.path, name) if not os.path.isdir(self.path): os.makedirs(self.path) self.env = bdb.DBEnv() self.env.set_tx_max(self.max_txns) self.env.set_lk_max_lockers(self.max_txns*2) self.env.set_lk_max_locks(self.max_txns*2) self.env.set_lk_max_objects(self.max_txns*2) self.env.set_flags(bdb.DB_TXN_NOSYNC, True) if bdb.version() > (4,7): self.env.log_set_config(bdb.DB_LOG_AUTO_REMOVE, True) self.env.open(self.path, bdb.DB_CREATE | bdb.DB_INIT_LOCK | bdb.DB_INIT_LOG | bdb.DB_INIT_MPOOL | bdb.DB_INIT_TXN | bdb.DB_RECOVER | bdb.DB_THREAD) self.db = bdb.DB(self.env) if duplicates: self.db.set_flags(bdb.DB_DUPSORT) if bdb.version() > (4,1): txn = self.env.txn_begin() self.db.open(self.dbpath, name, flags=bdb.DB_CREATE|bdb.DB_THREAD, dbtype=bdb.DB_BTREE, txn=txn) txn.commit() else: self.db.open(self.dbpath, name, flags=bdb.DB_CREATE|bdb.DB_THREAD, dbtype=bdb.DB_BTREE)
29dcac664c3f2fbc9009978e949ae467280aa521 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11095/29dcac664c3f2fbc9009978e949ae467280aa521/bdb.py
def lookup(self, lfn): cur = self.db.cursor()
@with_transaction def lookup(self, txn, lfn): cur = self.db.cursor(txn)
def delete(self, txn, lfn, pfn=None): cur = self.db.cursor(txn) try: if pfn is None: current = cur.set(lfn) while current is not None: cur.delete() current = cur.next_dup() else: current = cur.set_both(lfn, pfn) if current is not None: cur.delete() finally: cur.close()
29dcac664c3f2fbc9009978e949ae467280aa521 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11095/29dcac664c3f2fbc9009978e949ae467280aa521/bdb.py
def get(self, lfn): current = self.db.get(lfn)
@with_transaction def get(self, txn, lfn): current = self.db.get(lfn, txn)
def get(self, lfn): current = self.db.get(lfn) if current is not None: return pickle.loads(current) else: return None
29dcac664c3f2fbc9009978e949ae467280aa521 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11095/29dcac664c3f2fbc9009978e949ae467280aa521/bdb.py
@with_transaction
def remove(self, txn, lfn): self.db.delete(lfn, txn)
29dcac664c3f2fbc9009978e949ae467280aa521 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11095/29dcac664c3f2fbc9009978e949ae467280aa521/bdb.py
cur = self.db.cursor()
cur = self.db.cursor(txn)
def list(self): cur = self.db.cursor() try: result = [] current = cur.first() while current is not None: rec = pickle.loads(current[1]) rec['lfn'] = current[0] result.append(rec) current = cur.next() return result finally: cur.close()
29dcac664c3f2fbc9009978e949ae467280aa521 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11095/29dcac664c3f2fbc9009978e949ae467280aa521/bdb.py
def lookup(lfn):
def lookup(self, conn, lfn):
def lookup(lfn): cur = conn.cursor() cur.execute("select pfn from map where lfn=?",(lfn,)) pfns = [] for row in cur.fetchall(): pfns.append(row['pfn']) cur.close() return pfns
6d1ce7533b0b5ddc33b669565f77b405949b61fe /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11095/6d1ce7533b0b5ddc33b669565f77b405949b61fe/db.py
current = self.db.get(lfn, txn)
current = self.db.get(lfn, None, txn)
def get(self, txn, lfn): current = self.db.get(lfn, txn) if current is not None: return pickle.loads(current) else: return None
05b4bdd65ddf75eb9be6dd90f51a8c2737df569b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11095/05b4bdd65ddf75eb9be6dd90f51a8c2737df569b/bdb.py
@mockdata.check_http_method def _http_request(self, path, data=None, method=None, **kwargs):
def _http_request(self, path, data=None, method=None):
def __repr__(self): return '<MailmanRESTClient: %s>' % self.host
a73b2f832d063623dfaf85e3b60c20180665247c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/2119/a73b2f832d063623dfaf85e3b60c20180665247c/mailman_rest_client.py
:param data: POST, PUT or PATCH data to send
:param data: POST oder PUT data to send
def _http_request(self, path, data=None, method=None, **kwargs): """Send an HTTP request. :param path: the path to send the request to :type path: string :param data: POST, PUT or PATCH data to send :type data: dict :param method: the HTTP method; defaults to GET or POST (if data is not None) :type method: string :return: the request content or a status code, depending on the method and if the request was successful :rtype: int, list or dict """ url = self.host + path # Include general header information headers = { 'User-Agent': 'MailmanRESTClient', 'Accept': 'text/plain', } if data is not None: data = urlencode(data) if method is None: if data is None: method = 'GET' else: method = 'POST' method = method.upper() if method == 'POST': headers['Content-type'] = "application/x-www-form-urlencoded" response, content = Http().request(url, method, data, headers) if method == 'GET': if response.status // 100 != 2: return response.status else: return json.loads(content) else: return response.status
a73b2f832d063623dfaf85e3b60c20180665247c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/2119/a73b2f832d063623dfaf85e3b60c20180665247c/mailman_rest_client.py
data = urlencode(data)
data = urlencode(data, doseq=True) headers['Content-type'] = "application/x-www-form-urlencoded"
def _http_request(self, path, data=None, method=None, **kwargs): """Send an HTTP request. :param path: the path to send the request to :type path: string :param data: POST, PUT or PATCH data to send :type data: dict :param method: the HTTP method; defaults to GET or POST (if data is not None) :type method: string :return: the request content or a status code, depending on the method and if the request was successful :rtype: int, list or dict """ url = self.host + path # Include general header information headers = { 'User-Agent': 'MailmanRESTClient', 'Accept': 'text/plain', } if data is not None: data = urlencode(data) if method is None: if data is None: method = 'GET' else: method = 'POST' method = method.upper() if method == 'POST': headers['Content-type'] = "application/x-www-form-urlencoded" response, content = Http().request(url, method, data, headers) if method == 'GET': if response.status // 100 != 2: return response.status else: return json.loads(content) else: return response.status
a73b2f832d063623dfaf85e3b60c20180665247c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/2119/a73b2f832d063623dfaf85e3b60c20180665247c/mailman_rest_client.py
if method == 'POST': headers['Content-type'] = "application/x-www-form-urlencoded"
def _http_request(self, path, data=None, method=None, **kwargs): """Send an HTTP request. :param path: the path to send the request to :type path: string :param data: POST, PUT or PATCH data to send :type data: dict :param method: the HTTP method; defaults to GET or POST (if data is not None) :type method: string :return: the request content or a status code, depending on the method and if the request was successful :rtype: int, list or dict """ url = self.host + path # Include general header information headers = { 'User-Agent': 'MailmanRESTClient', 'Accept': 'text/plain', } if data is not None: data = urlencode(data) if method is None: if data is None: method = 'GET' else: method = 'POST' method = method.upper() if method == 'POST': headers['Content-type'] = "application/x-www-form-urlencoded" response, content = Http().request(url, method, data, headers) if method == 'GET': if response.status // 100 != 2: return response.status else: return json.loads(content) else: return response.status
a73b2f832d063623dfaf85e3b60c20180665247c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/2119/a73b2f832d063623dfaf85e3b60c20180665247c/mailman_rest_client.py
def get_member(self, email_address, fqdn_listname): """Return a member object. :param email_adresses: the email address used :type email_address: string :param fqdn_listname: the mailing list :type fqdn_listname: string :return: a member object :rtype: _Member """ return _Member(self.host, email_address, fqdn_listname) def get_user(self, email_address): """Find and return a user object. :param email_address: one of the user's email addresses :type email: string: :returns: a user object :rtype: _User """ return _User(self.host, email_address)
def get_member(self, email_address, fqdn_listname): """Return a member object. :param email_adresses: the email address used :type email_address: string :param fqdn_listname: the mailing list :type fqdn_listname: string :return: a member object :rtype: _Member """ return _Member(self.host, email_address, fqdn_listname)
a73b2f832d063623dfaf85e3b60c20180665247c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/2119/a73b2f832d063623dfaf85e3b60c20180665247c/mailman_rest_client.py
@mockdata.add_list_mock_data
def delete_list(self, list_name): fqdn_listname = list_name + '@' + self.info['email_host'] return self._http_request('/3.0/lists/' + fqdn_listname, None, 'DELETE')
a73b2f832d063623dfaf85e3b60c20180665247c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/2119/a73b2f832d063623dfaf85e3b60c20180665247c/mailman_rest_client.py
def get_member(self, email_address): """Return a member object. :param email_adresses: the email address used :type email_address: string :param fqdn_listname: the mailing list :type fqdn_listname: string :return: a member object :rtype: _Member """ return _Member(self.host, email_address, self.info['fqdn_listname']) def update_list(self, data): """Update the settings for a list. """ return self._http_request('/3.0/lists/' + self.info['fqdn_listname'], data, method='PATCH') def __str__(self): """A string representation of a list. """ return "A list object for the list '%s'." % self.info['fqdn_listname'] @mockdata.add_user_mock_data class _User(MailmanRESTClient): """A user wrapper for the MailmanRESTClient.""" def __init__(self, host, email_address): """Connect to host and get user information. :param host: the host name of the REST API :type host: string :param email_address: email address :type email_address: string :return: a user object :rtype: _User """ super(_User, self).__init__(host) self.email_address = email_address self.info = {} def get_email_addresses(self): """Return a list of all email adresses used by this user. :return: a list of email addresses :rtype: list """ response = self._http_request('/3.0/users/' + self.email_address + '/email_adresses') if type(response) is int: return response elif 'entries' not in response: return [] else: return sorted(response['entries']) def get_lists(self): """Return a list of all mailing list connected to a user. :return: a list of dicts with all mailing lists :rtype: list """ path = '/3.0/users/%s/lists' % self.email_address response = self._http_request(path) if type(response) is int: return response elif 'entries' not in response: return [] else: return sorted(response['entries'], key=itemgetter('fqdn_listname')) def update(self, data=None): """Update user settings.""" if data is None: data = self.info path = '/3.0/users/%s' % (self.email_address) return self._http_request(path, data, method='PATCH') def __str__(self): """A string representation of a member.""" return "A user object for the user '%s'." % self.info['real_name'] @mockdata.add_member_mock_data class _Member(MailmanRESTClient): """A user wrapper for the MailmanRESTClient.""" def __init__(self, host, email_address, fqdn_listname): """Connect to host and get membership information. :param host: the host name of the REST API :type host: string :param email_address: email address :type email_address: string :param fqdn_listname: the mailing list :type fqdn_listname: string :return: a member object :rtype: _Member """ super(_Member, self).__init__(host) self.info = {} self.email_address = email_address self.fqdn_listname = fqdn_listname def update(self, data=None): """Update member settings.""" if data is None: data = self.info path = '/3.0/lists/%s/member/%s' % (self.fqdn_listname, self.email_address) return self._http_request(path, data, method='PATCH') def __str__(self): """A string representation of a member.""" return "A member object for '%s', subscribed to '%s'." \ % (self.email_address, self.fqdn_listname)
def update_config(self, data): """Update the list configuration. :param data: A dict with the config attributes to be updated. :type data: dict :return: the return code of the http request :rtype: integer """ url = '/3.0/lists/%s/config' % self.info['fqdn_listname'] status = self._http_request(url, data, 'PATCH') if status == 200: for key in data: self.config[key] = data[key] return status
def get_members(self): """Get a list of all list members.
a73b2f832d063623dfaf85e3b60c20180665247c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/2119/a73b2f832d063623dfaf85e3b60c20180665247c/mailman_rest_client.py
def avg (l): sum=0 for e in l: sum=sum+e; return sum/len(l)
1423e3f7721b69cf594f13a198480eefa2e824de /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7090/1423e3f7721b69cf594f13a198480eefa2e824de/regress.py
print("-> glob_corr=%f\n" % glob_corr)
print("-> glob_corr={}\n".format(glob_corr))
def correl_split_weighted( X , Y , segments ): # expects segments = [(0,i1-1),(i1-1,i2-1),(i2,len-1)] correl = list(); interv = list(); # regr. line coeffs and range glob_corr=0 sum_nb_val=0 for (start,stop) in segments: sum_nb_val = sum_nb_val + stop - start; #if start==stop : # return 0 S_XY= cov( X [start:stop+1], Y [start:stop+1] ) S_X2 = variance( X [start:stop+1] ) S_Y2 = variance( Y [start:stop+1] ) # to compute correlation if S_X2*S_Y2 == 0: return (0,[]) c = S_XY/(sqrt(S_X2)*sqrt(S_Y2)) a = S_XY/S_X2 # regr line coeffs b= avg ( Y[start:stop+1] ) - a * avg( X[start:stop+1] ) print(" range [%d,%d] corr=%f, coeff det=%f [a=%f, b=%f]" % (X[start],X[stop],c,c**2,a, b)) correl.append( (c, stop-start) ); # store correl. coef + number of values (segment length) interv.append( (a,b, X[start],X[stop]) ); for (c,l) in correl: glob_corr = glob_corr + (l/sum_nb_val)*c # weighted product of correlation print('-- %f * %f' % (c,l/sum_nb_val)) print("-> glob_corr=%f\n" % glob_corr) return (glob_corr,interv);
1423e3f7721b69cf594f13a198480eefa2e824de /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7090/1423e3f7721b69cf594f13a198480eefa2e824de/regress.py
readdata.append( (int(l[1]),float(l[3]) / 2 ) );
readdata.append( (int(l[1]),float(l[3])) );
def correl_split( X , Y , segments ): # expects segments = [(0,i1-1),(i1-1,i2-1),(i2,len-1)] correl = list(); interv = list(); # regr. line coeffs and range glob_corr=1 for (start,stop) in segments: #if start==stop : # return 0 S_XY= cov( X [start:stop+1], Y [start:stop+1] ) S_X2 = variance( X [start:stop+1] ) S_Y2 = variance( Y [start:stop+1] ) # to compute correlation if S_X2*S_Y2 == 0: return (0,[]) c = S_XY/(sqrt(S_X2)*sqrt(S_Y2)) a = S_XY/S_X2 # regr line coeffs b= avg ( Y[start:stop+1] ) - a * avg( X[start:stop+1] ) print(" range [%d,%d] corr=%f, coeff det=%f [a=%f, b=%f]" % (X[start],X[stop],c,c**2,a, b)) correl.append( (c, stop-start) ); # store correl. coef + number of values (segment length) interv.append( (a,b, X[start],X[stop]) ); for (c,l) in correl: glob_corr = glob_corr * c # product of correlation coeffs print("-> glob_corr=%f\n" % glob_corr) return (glob_corr,interv);
1423e3f7721b69cf594f13a198480eefa2e824de /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7090/1423e3f7721b69cf594f13a198480eefa2e824de/regress.py
print("** OPT: [%d .. %d]" % (i,j)) print("** Product of correl coefs = %f" % (max_glob_corr))
print("** OPT: [%d .. %d] correl coef prod=%f slope: %f x + %f" % (i,j,max_glob_corr,a,b))
def correl_split( X , Y , segments ): # expects segments = [(0,i1-1),(i1-1,i2-1),(i2,len-1)] correl = list(); interv = list(); # regr. line coeffs and range glob_corr=1 for (start,stop) in segments: #if start==stop : # return 0 S_XY= cov( X [start:stop+1], Y [start:stop+1] ) S_X2 = variance( X [start:stop+1] ) S_Y2 = variance( Y [start:stop+1] ) # to compute correlation if S_X2*S_Y2 == 0: return (0,[]) c = S_XY/(sqrt(S_X2)*sqrt(S_Y2)) a = S_XY/S_X2 # regr line coeffs b= avg ( Y[start:stop+1] ) - a * avg( X[start:stop+1] ) print(" range [%d,%d] corr=%f, coeff det=%f [a=%f, b=%f]" % (X[start],X[stop],c,c**2,a, b)) correl.append( (c, stop-start) ); # store correl. coef + number of values (segment length) interv.append( (a,b, X[start],X[stop]) ); for (c,l) in correl: glob_corr = glob_corr * c # product of correlation coeffs print("-> glob_corr=%f\n" % glob_corr) return (glob_corr,interv);
1423e3f7721b69cf594f13a198480eefa2e824de /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7090/1423e3f7721b69cf594f13a198480eefa2e824de/regress.py
for i in xrange(n):
for i in range(n):
def cov (X, Y): assert len(X) == len(Y) n = len(X) # n=len(X)=len(Y) avg_X = avg(X) avg_Y = avg(Y) S_XY = 0.0 for i in xrange(n): S_XY += (X[i] - avg_X) * (Y[i] - avg_Y) return (S_XY / n)
f08c51969b477f4df715e6ed41846f01e52450a7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7090/f08c51969b477f4df715e6ed41846f01e52450a7/calibrate_piecewise.py
for i in xrange(n):
for i in range(n):
def variance (X): n = len(X) avg_X = avg (X) S_X2 = 0.0 for i in xrange(n): S_X2 += (X[i] - avg_X) ** 2 return (S_X2 / n)
f08c51969b477f4df715e6ed41846f01e52450a7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7090/f08c51969b477f4df715e6ed41846f01e52450a7/calibrate_piecewise.py
l = line.split(); if line[0] != '
l = line.split(); if line[0] != '
def calibrate (links, latency, bandwidth, sizes, timings): assert len(sizes) == len(timings) if len(sizes) < 2: return None S_XY = cov(sizes, timings) S_X2 = variance(sizes) a = S_XY / S_X2 b = avg(timings) - a * avg(sizes) return (b * 1e-6) / (latency * links), 1e6 / (a * bandwidth)
f08c51969b477f4df715e6ed41846f01e52450a7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/7090/f08c51969b477f4df715e6ed41846f01e52450a7/calibrate_piecewise.py