Beispiel #1
0
    def save_one(self, id, obj, directory, extension):
        """Saves a single object supporting the bob save() protocol.

        .. deprecated:: 1.1.0

            This function is *deprecated*, use :py:meth:`.File.save()` instead.

        This method will call save() on the the given object using the correct
        database filename stem for the given id.

        Keyword Parameters:

        id
            The id of the object in the database table "file".

        obj
            The object that needs to be saved, respecting the bob save() protocol.

        directory
            This is the base directory to which you want to save the data. The
            directory is tested for existence and created if it is not there with
            os.makedirs()

        extension
            The extension determines the way each of the arrays will be saved.
        """

        import warnings
        warnings.warn(
            "The method Database.save_one() is deprecated, use the File object directly as returned by Database.objects() for more powerful object manipulation.",
            DeprecationWarning)

        self.assert_validity()

        fobj = self.session.query(File).filter_by(id=id).one()

        fullpath = os.path.join(directory, str(fobj.path) + extension)
        fulldir = os.path.dirname(fullpath)
        utils.makedirs_safe(fulldir)

        from bob.io.base import save

        save(obj, fullpath)
Beispiel #2
0
    def save_one(self, id, obj, directory, extension):
        """Saves a single object supporting the bob save() protocol.

        .. deprecated:: 1.1.0

            This function is *deprecated*, use :py:meth:`.File.save()` instead.

        This method will call save() on the the given object using the correct
        database filename stem for the given id.

        Keyword Parameters:

        id
            The id of the object in the database table "file".

        obj
            The object that needs to be saved, respecting the bob save() protocol.

        directory
            This is the base directory to which you want to save the data. The
            directory is tested for existence and created if it is not there with
            os.makedirs()

        extension
            The extension determines the way each of the arrays will be saved.
        """

        import warnings
        warnings.warn(
            "The method Database.save_one() is deprecated, use the File object directly as returned by Database.objects() for more powerful object manipulation.",
            DeprecationWarning)

        self.assert_validity()

        fobj = self.session.query(File).filter_by(id=id).one()

        fullpath = os.path.join(directory, str(fobj.path) + extension)
        fulldir = os.path.dirname(fullpath)
        utils.makedirs_safe(fulldir)

        from bob.io.base import save

        save(obj, fullpath)
Beispiel #3
0
    def save_by_filename(self, filename, obj, directory, extension):
        """Saves a single object supporting the bob save() protocol.

    .. deprecated:: 1.1.0

      This function is *deprecated*, use :py:meth:`.File.save()` instead.

    This method will call save() on the the given object using the correct
    database filename stem for the given filename

    Keyword Parameters:

    filename
      The unique filename under which the object will be saved. Before calling this method, the method files() should be called (with no directory and extension arguments passed) in order to obtain the unique filenames for each of the files to be saved.

    obj
      The object that needs to be saved, respecting the bob save() protocol.

    directory
      This is the base directory to which you want to save the data. The
      directory is tested for existence and created if it is not there with
      os.makedirs()

    extension
      The extension determines the way each of the arrays will be saved.
    """

        import warnings
        warnings.warn(
            "The method Database.save() is deprecated, use the File object directly as returned by Database.objects() for more powerful object manipulation.",
            DeprecationWarning)

        from bob.io.base import save

        fullpath = os.path.join(directory, filename + extension)
        fulldir = os.path.dirname(fullpath)
        utils.makedirs_safe(fulldir)
        save(obj, fullpath)
Beispiel #4
0
  def save_by_filename(self, filename, obj, directory, extension):
    """Saves a single object supporting the bob save() protocol.

    .. deprecated:: 1.1.0

      This function is *deprecated*, use :py:meth:`.File.save()` instead.

    This method will call save() on the the given object using the correct
    database filename stem for the given filename

    Keyword Parameters:

    filename
      The unique filename under which the object will be saved. Before calling this method, the method files() should be called (with no directory and extension arguments passed) in order to obtain the unique filenames for each of the files to be saved.

    obj
      The object that needs to be saved, respecting the bob save() protocol.

    directory
      This is the base directory to which you want to save the data. The
      directory is tested for existence and created if it is not there with
      os.makedirs()

    extension
      The extension determines the way each of the arrays will be saved.
    """

    import warnings
    warnings.warn("The method Database.save() is deprecated, use the File object directly as returned by Database.objects() for more powerful object manipulation.", DeprecationWarning)

    from bob.io.base import save

    fullpath = os.path.join(directory, filename + extension)
    fulldir = os.path.dirname(fullpath)
    utils.makedirs_safe(fulldir)
    save(obj, fullpath)