Logo Search packages:      
Sourcecode: sabayon version File versions  Download package

def lib::storage::ProfileStorage::add (   self,
  path,
  src_dir,
  source,
  attributes = None,
  src_path = None 
)

Add a new - or update an existing - file or directory
to the profile. If @path is a directory, then the contents
of the directory will be recursively saved in the profile.

@path: the relative path of the file or directory.
@src_dir: the directory (which @path is relative to) from
which the file or directory contents should be copied to
the profile.
@source: the name of the #ProfileSource with which the file
or directory is associated.
@attributes: a varargs list of arbitrary key/value pairs
(specific to @source) which should be saved.

Definition at line 339 of file storage.py.

00339                                                                              :
        """Add a new - or update an existing - file or directory
        to the profile. If @path is a directory, then the contents
        of the directory will be recursively saved in the profile.

        @path: the relative path of the file or directory.
        @src_dir: the directory (which @path is relative to) from
        which the file or directory contents should be copied to
        the profile.
        @source: the name of the #ProfileSource with which the file
        or directory is associated.
        @attributes: a varargs list of arbitrary key/value pairs
        (specific to @source) which should be saved.
        """
        dprint ("Adding '%s' from %s:%s", path, source, src_dir)
        
        self.__unpack ()

        if src_path == None:
            src_path = path
        src_path = os.path.join (src_dir, src_path)
        dst_path = os.path.join (self.temp_path, path)

        if not os.path.exists (src_path):
            raise ProfileStorageException (_("Cannot add non-existent file '%s'") % src_path)

        # Remove old version
        node = self.__get_node (path)
        if node:
            node.unlinkNode ()
            node.freeNode ()
        recursive_del (dst_path)
        
        if os.path.isdir (src_path):
            self.__update_directory_node (path, source, attributes)
            copy_tree (self.temp_path, src_dir, path)
        else:
            self.__update_file_node (path, source, attributes)
            dirname = os.path.dirname (dst_path)
            if not os.path.exists (dirname):
                os.makedirs (dirname)
            shutil.copy2 (src_path, dst_path)

        self.needs_saving = True

    def __get_dir_node (self, path, metadata = None):


Generated by  Doxygen 1.6.0   Back to index