def add(self, origin):
        """Add new element to fsdb.

         Args:
            origin -- could be the path of a file or a readable/seekable object ( fileobject, stream, stringIO...)
         Returns:
            String rapresenting the digest of the file
        """

        digest = self._calc_digest(origin)

        if self.exists(digest):
            self.logger.debug('Added File: [{0}] ( Already exists. Skipping transfer)'.format(digest))
            return digest

        absPath = self.get_file_path(digest)
        absFolderPath = os.path.dirname(absPath)

        # make all parent directories if they do not exist
        self._makedirs(absFolderPath)
        self._copy_content(origin, absPath)

        self.logger.debug('Added file: "{0}" [{1}]'.format(digest, absPath))

        return digest
def add ( self , origin ) : digest = self . _calc_digest ( origin ) if self . exists ( digest ) : self . logger . debug ( 'Added File: [{0}] ( Already exists. Skipping transfer)' . format ( digest ) ) return digest absPath = self . get_file_path ( digest ) absFolderPath = os . path . dirname ( absPath ) self . _makedirs ( absFolderPath ) self . _copy_content ( origin , absPath ) self . logger . debug ( 'Added file: "{0}" [{1}]' . format ( digest , absPath ) ) return digest
Add new element to fsdb.

         Args:
            origin -- could be the path of a file or a readable/seekable object ( fileobject, stream, stringIO...)
         Returns:
            String rapresenting the digest of the file