Ejemplo n.º 1
0
 def _set_listener ( self, database = None, remove = False ):
     """ Adds/Removes a file watch for the database specified by *database*.
     """
     file_watch.watch(
         self.update_all_items, facet_db.db( database or self.database ),
         remove = remove
     )
Ejemplo n.º 2
0
    def _file_name_set ( self, old, new ):
        """ Handles the 'file_name' facet being changed.
        """
        if old != '':
            file_watch.watch( self._update, old, remove = True )

        if new != '':
            file_watch.watch( self._update, new )
            self._update( new )
Ejemplo n.º 3
0
 def update(self, file_name):
     """ Refreshes the text file from disk if it has not been modified and is
         still the same file.
     """
     if file_name == self.file_name:
         if self.ignore_reload:
             self.ignore_reload = False
         elif not self.modified:
             self.text = read_file(file_name)
             self.status = "File reloaded"
             self.modified = False
     else:
         file_watch.watch(self.update, file_name, remove=True)
Ejemplo n.º 4
0
 def _set_listener ( self, file_name, remove ):
     """ Sets up/Removes a file watch on a specified file.
     """
     if exists( file_name ):
         file_watch.watch( self._file_set, file_name, remove = remove )
Ejemplo n.º 5
0
    def _text_files_modified ( self, removed, added ):
        for tf in removed:
            file_watch.watch( tf.update, tf.file_name, remove = True )

        for tf in added:
            file_watch.watch( tf.update, tf.file_name )
Ejemplo n.º 6
0
 def stop_monitoring ( self ):
     """ Stops monitoring the associated path for file changes.
     """
     file_watch.watch( self._file_set, self.path, remove = True )
Ejemplo n.º 7
0
 def start_monitoring ( self ):
     """ Starts monitoring the associated path for file changes.
     """
     file_watch.watch( self._file_set, self.path )