def _get_source(self): if self._source is None: try: self._source = read_file(self.file).split('\n')[self.line - 1].strip() except: self._source = '???' return self._source
def _get_source ( self ): if self._source is None: try: self._source = read_file( self.file ).split( '\n' )[ self.line - 1 ].strip() except: self._source = '???' return self._source
def source_for(self, line): if self._source_file is None: try: self._source_file = read_file(self.file).split('\n') except: self._source_file = [] try: return self._source_file[line - 1].strip() except: return '???'
def source_for ( self, line ): if self._source_file is None: try: self._source_file = read_file( self.file ).split( '\n' ) except: self._source_file = [] try: return self._source_file[ line - 1 ].strip() except: return '???'
def restore(self): """ Restores the correct line value based on current source file contents. """ self._file_changed() try: lines = read_file(self.file).split('\n') except: return False n = len(lines) line = self.line - 1 delta = self.end_line - self.line source = self.source # Search outward from the last known location of the source for a # match: for i in range(100): if ((line - i) < 0) and ((line + i) >= n): break j = line + i if (j < n) and (source == lines[j].strip()): self.line = j + 1 self.end_line = delta + j + 1 self.register() return True j = line - i if (j >= 0) and (source == lines[j].strip()): self.line = j + 1 self.end_line = delta + j + 1 self.register() return True # Indicate source line could not be found: self.line = 0 return False
def restore ( self ): """ Restores the correct line value based on current source file contents. """ self._file_changed() try: lines = read_file( self.file ).split( '\n' ) except: return False n = len( lines ) line = self.line - 1 delta = self.end_line - self.line source = self.source # Search outward from the last known location of the source for a # match: for i in range( 100 ): if ((line - i) < 0) and ((line + i) >= n): break j = line + i if (j < n) and (source == lines[j].strip()): self.line = j + 1 self.end_line = delta + j + 1 self.register() return True j = line - i if (j >= 0) and (source == lines[j].strip()): self.line = j + 1 self.end_line = delta + j + 1 self.register() return True # Indicate source line could not be found: self.line = 0 return False
def watched_file_name_updated(self, file_name): self.watched_file_name_data(read_file(file_name))
def watched_file_name_updated ( self, file_name ): self.watched_file_name_data( read_file( file_name ) )