Example #1
0
    def move(self, dest, copy=False):
        """Moves or copies the item's file, updating the path value if
        the move succeeds. If a file exists at ``dest``, then it is
        slightly modified to be unique.
        """
        if not util.samefile(self.path, dest):
            dest = util.unique_path(dest)
        if copy:
            util.copy(self.path, dest)
        else:
            util.move(self.path, dest)

        # Either copying or moving succeeded, so update the stored path.
        self.path = dest
Example #2
0
 def move(self, dest, copy=False):
     """Moves or copies the item's file, updating the path value if
     the move succeeds. If a file exists at ``dest``, then it is
     slightly modified to be unique.
     """
     if not util.samefile(self.path, dest):
         dest = util.unique_path(dest)
     if copy:
         util.copy(self.path, dest)
     else:
         util.move(self.path, dest)
         
     # Either copying or moving succeeded, so update the stored path.
     self.path = dest
Example #3
0
    def set_art(self, path):
        """Sets the album's cover art to the image at the given path.
        The image is copied into place, replacing any existing art.
        """
        path = bytestring_path(path)
        oldart = self.artpath
        artdest = self.art_destination(path)

        if oldart and samefile(path, oldart):
            # Art already set.
            return
        elif samefile(path, artdest):
            # Art already in place.
            self.artpath = path
            return

        # Normal operation.
        if oldart == artdest:
            util.soft_remove(oldart)
        artdest = util.unique_path(artdest)
        util.copy(path, artdest)
        self.artpath = artdest
Example #4
0
    def set_art(self, path):
        """Sets the album's cover art to the image at the given path.
        The image is copied into place, replacing any existing art.
        """
        path = bytestring_path(path)
        oldart = self.artpath
        artdest = self.art_destination(path)

        if oldart and samefile(path, oldart):
            # Art already set.
            return
        elif samefile(path, artdest):
            # Art already in place.
            self.artpath = path
            return

        # Normal operation.
        if oldart == artdest:
            util.soft_remove(oldart)
        artdest = util.unique_path(artdest)
        util.copy(path, artdest)
        self.artpath = artdest