Exemplo n.º 1
0
 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
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
    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 '???'
Exemplo n.º 4
0
    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 '???'
Exemplo n.º 5
0
    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
Exemplo n.º 6
0
    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
Exemplo n.º 7
0
 def watched_file_name_updated(self, file_name):
     self.watched_file_name_data(read_file(file_name))
Exemplo n.º 8
0
 def watched_file_name_updated ( self, file_name ):
     self.watched_file_name_data( read_file( file_name ) )