bugged stringlengths 4 228k | fixed stringlengths 0 96.3M | __index_level_0__ int64 0 481k |
|---|---|---|
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.Manu... | 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.Manu... | 480,600 |
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 | def testUTF8(self): text = self.utf8 self.stc.encoding, self.stc.refstc.bom = detectEncoding(text) print self.stc.encoding self.stc.decodeText(self.utf8) self.stc.prepareEncoding() assert self.utf8 == self.stc.refstc.encoded | 480,601 |
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 | def testUTF8(self): self.stc.encoding = detectEncoding(self.utf8) print self.stc.encoding self.stc.decodeText(text) self.stc.prepareEncoding() assert self.utf8 == self.stc.refstc.encoded | 480,602 |
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 | def testUTF8(self): self.stc.encoding = detectEncoding(self.utf8) print self.stc.encoding self.stc.decodeText(self.utf8) self.stc.prepareEncoding() 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 se... | 480,603 |
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... | def testChangeLatin(self): self.stc.refstc.encoding, self.stc.refstc.bom = 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.SetTa... | 480,604 |
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... | def testLatin1(self): self.stc.refstc.encoding, self.stc.refstc.bom = 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... | 480,605 |
def finishRecordingHook(self, accelerator_text): self.mode.buffer.stc.setRemappedAccelerator(self.action, accelerator_text, self.append) wx.CallAfter(self.mode.resetList) | def finishRecordingHook(self, accelerator_text): self.mode.buffer.stc.setRemappedAccelerator(self.action, accelerator_text, self.append) wx.CallAfter(self.mode.resetList) | 480,606 |
def startupFailureCallback(self, p): dprint("Couldn't run %s" % p.cmd) | def startupFailureCallback(self, p): dprint("Couldn't run %s" % p.cmd) | 480,607 |
def startupFailureCallback(self, p): self.callback(self) | def startupFailureCallback(self, p, text): self.callback(self) | 480,608 |
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 | 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 | 480,609 |
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_mo... | 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_mo... | 480,610 |
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 (pr... | 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(encoding=text) if text != self.mode.buffer.stc.encoding: self.mode.setStatusText("Failed converting to %s; loaded as b... | 480,611 |
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 | 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 | 480,612 |
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 | 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 | 480,613 |
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 | 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 | 480,614 |
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 {} | def getLayoutSubsequent(cls, major_mode_keyword, url): #dprint("getLayoutSubsequent") try: #dprint(cls.layout[major_mode_keyword])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 UnicodeEnc... | 480,615 |
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 | 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][unicode(url)] = perspective | 480,616 |
def reportSuccess(self, text, data): import wx wx.CallAfter(self.reportSuccessGUI, text, data) | def reportSuccess(self, text, data=None): import wx wx.CallAfter(self.reportSuccessGUI, text, data) | 480,617 |
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 | 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 | 480,618 |
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 | 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 | 480,619 |
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 | 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 | 480,620 |
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. | 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. | 480,621 |
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... | 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.euclidean = HSI.createCube('bsq', self.lines, self.samples, 1, self.dtype) data = self.euclidean.getBandRaw(0) working = n... | 480,622 |
def SetLabel(self, value): """ Set the label's current text """ rvalue = self.label.SetLabel(value) self.Refresh(True) return rvalue | def SetLabel(self, value): """ Set the label's current text """ rvalue = self.label.SetLabel(value) self.Refresh(True) return rvalue | 480,623 |
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.... | 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 """ PopupClass.__init__(self, frame, style) self.SetBackgroundColour("#B6C1FF") self.stack = wx.BoxS... | 480,624 |
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)... | 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)... | 480,625 |
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)... | 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)... | 480,626 |
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 ... | 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 ... | 480,627 |
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 = sel... | 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 = sel... | 480,628 |
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) se... | 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) se... | 480,629 |
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)... | def processDirtyRange(self, start, end): range_start = self.getLikelyWordStart(start) range_end = self.getLikelyWordEnd(end) 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.checkRang... | 480,630 |
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) | 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") try: fh = open(url, "rb") return matcher.iterMatches(url, fh) except: dprint("Failed opening %s" ... | 480,631 |
def action(self, index=-1, multiplier=1): self.mode.classprefs.print_style = index | def action(self, index=-1, multiplier=1): self.mode.classprefs.print_style = index | 480,632 |
def convertSection(cls, section): | def convertSection(cls, section): | 480,633 |
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) | 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) | 480,634 |
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 | 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 | 480,635 |
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) cl... | 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) transport = client.get_channel().get_transport() if not transport.is_active(): dprint("Cached chan... | 480,636 |
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... | 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... | 480,637 |
def __cmp__(self, other): return cmp(self.name, other.name) | def __cmp__(self, other): return cmp(self.name, other.name) | 480,638 |
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: ass... | 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(); if wx.Platform != '__WXMSW__': flag = wx.EXEC_ASYNC else: flag = wx.EXEC_NOHIDE self.pid = wx.Execute(self.... | 480,639 |
def get_mtime(cls, ref): attrs = cls._stat(ref) return attrs.st_mtime | def get_mtime(cls, ref): attrs = cls._stat(ref) return attrs.st_mtime | 480,640 |
def get_atime(cls, ref): attrs = cls._stat(ref) return attrs.st_atime | def get_atime(cls, ref): attrs = cls._stat(ref) return attrs.st_atime | 480,641 |
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{setMinimumW... | 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{setMinimumW... | 480,642 |
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) | 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) | 480,643 |
def getItemRawValues(self, index, item): return (unicode(item.url), item.line, unicode(item.text)) | def getItemRawValues(self, index, item): return (unicode(item.short), item.line, unicode(item.text), item.url) | 480,644 |
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}) | 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}) | 480,645 |
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()) | 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()) | 480,646 |
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()) | 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()) | 480,647 |
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 | def __init__(self, string, match_case): try: if not match_case: flags = re.IGNORECASE else: flags = 0 self.cre = re.compile(string, flags) self.error = "" except re.error, errmsg: self.cre = None self.last_match = None | 480,648 |
def isValid(self): return bool(self.cre) | def isValid(self): return bool(self.cre) | 480,649 |
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_fil... | 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_fil... | 480,650 |
def getPrefix(self): prefix = unicode(self.pathname) if not prefix.endswith("/"): prefix += "/" return prefix | def getPrefix(self): prefix = unicode(self.pathname) if not prefix.endswith(os.sep): prefix += os.sep return prefix | 480,651 |
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 t... | 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 t... | 480,652 |
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(... | 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(... | 480,653 |
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) | def createColumns(self, list): list.InsertSizedColumn(0, "File", min=100, max=250, greedy=False) list.InsertSizedColumn(1, "Line", min=10, greedy=False) list.InsertSizedColumn(2, "Match", min=300, greedy=True) | 480,654 |
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) | 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) | 480,655 |
def save(self, url): if self.mmap: self.mmap.flush() self.mmap.sync() else: self.raw.tofile(str(url.path)) | def save(self, url): if self.mmap: self.mmap.flush() self.mmap.sync() else: 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(f... | 480,656 |
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_... | 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 key in cls.layout[major_mode_keyword]: cls.layout[major_mode_keyword][ukey] = cls.la... | 480,657 |
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_... | 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 ukey != key and key in cls.layout[major_mode_keyword]: cls.layout[major_mode_keyword][ukey] = cls.la... | 480,658 |
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_... | 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_... | 480,659 |
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_... | 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_... | 480,660 |
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(): pa... | 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 not self.frame: dprint("Frame has been deleted!!! Message was:") dprint(message) dlg = wx.MessageDialog(wx.GetApp().GetTopW... | 480,661 |
def action(self, index=-1, multiplier=1): self.frame.open("about:sample.dot") | def action(self, index=-1, multiplier=1): self.frame.open("about:sample.dot") | 480,662 |
def action(self, index=-1, multiplier=1): self.frame.open("about:sample.dot") | def action(self, index=-1, multiplier=1): self.frame.open("about:sample.dot") | 480,663 |
def action(self, index=-1, multiplier=1): self.frame.open("about:sample.dot") | def action(self, index=-1, multiplier=1): self.frame.open("about:sample.dot") | 480,664 |
def startupCallback(self, job): self.process = job self.busy(True) self.preview = StringIO() | def startupCallback(self, job): self.process = job self.preview = StringIO() | 480,665 |
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 | 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 | 480,666 |
def getMajorModes(self): yield GraphvizMode | def getMajorModes(self): yield GraphvizMode | 480,667 |
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() | def download(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() | 480,668 |
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", ... | 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", ... | 480,669 |
def usage(): 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( """ | 480,670 |
def usage(): 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( """ | 480,671 |
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) = par... | 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) = par... | 480,672 |
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... | 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 bdb.DBLockDeadlockError, e: txn.abort() deadlocks += 1 if deadlocks < retries: self.log.info("Deadlock detected, retrying") continue else: ... | 480,673 |
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() | def list(self, txn): 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() | 480,674 |
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 | def with_transaction(method, retries=3): 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_t... | 480,675 |
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 | 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: txn.abort() raise | 480,676 |
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 | 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 | 480,677 |
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 | def __init__(self, env, interval=300): Thread.__init__(self) self.setDaemon(True) self.log = log.get_log("bdb manager") self.env = env self.interval = interval | 480,678 |
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.... | 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.... | 480,679 |
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() | 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() | 480,680 |
def get(self, lfn): current = self.db.get(lfn) if current is not None: return pickle.loads(current) else: return None | @with_transaction def get(self, txn, lfn): current = self.db.get(lfn, txn) if current is not None: return pickle.loads(current) else: return None | 480,681 |
def remove(self, txn, lfn): self.db.delete(lfn, txn) | def @with_transaction remove(self, @with_transaction txn, @with_transaction lfn): @with_transaction self.db.delete(lfn, @with_transaction txn) @with_transaction | 480,682 |
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() | 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() | 480,683 |
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 | def lookup(self, conn, 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 | 480,684 |
def get(self, txn, lfn): current = self.db.get(lfn, txn) if current is not None: return pickle.loads(current) else: return None | def get(self, txn, lfn): current = self.db.get(lfn, None, txn) if current is not None: return pickle.loads(current) else: return None | 480,685 |
def __repr__(self): return '<MailmanRESTClient: %s>' % self.host | def __repr__(self): return '<MailmanRESTClient: %s>' % self.host | 480,686 |
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 :ret... | 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 oder PUT 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: ... | 480,687 |
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 :ret... | 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 :ret... | 480,688 |
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 :ret... | 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 :ret... | 480,689 |
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_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... | 480,690 |
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') | 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') | 480,691 |
def get_members(self): """Get a list of all list members. | def get_members(self): """Get a list of all list members. | 480,692 |
def avg (l): sum=0 for e in l: sum=sum+e; return sum/len(l) | def avg (l): sum=0 for e in l: sum=sum+e; return sum/len(l) | 480,693 |
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], ... | 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], ... | 480,694 |
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 =... | 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 =... | 480,695 |
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 =... | 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 =... | 480,696 |
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) | 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 range(n): S_XY += (X[i] - avg_X) * (Y[i] - avg_Y) return (S_XY / n) | 480,697 |
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) | def variance (X): n = len(X) avg_X = avg (X) S_X2 = 0.0 for i in range(n): S_X2 += (X[i] - avg_X) ** 2 return (S_X2 / n) | 480,698 |
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) | 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) | 480,699 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.