Example #1
0
 def _fold(self, source, dest):
     """
     add the required actions for folding
     """
     self._collect_actions(source, dest)
     self.actions.add(actions.RemoveDirectory(self.subcmd, dest))
     self.actions.add(actions.SymbolicLink(self.subcmd, source, dest))
Example #2
0
 def _are_same_file(self, source, dest):
     """
     what to do if source and dest are the same files
     """
     if self.is_unfolding:
         self.actions.add(actions.SymbolicLink(self.subcmd, source, dest))
     else:
         self.actions.add(actions.AlreadyLinked(self.subcmd, source, dest))
Example #3
0
    def _collect_actions(self, source, dest):
        """
        Concrete method to collect required actions to perform a link
        sub-command
        """

        if dest.exists():
            if utils.is_same_file(dest, source):
                self.actions.add(
                    actions.AlreadyLinked(self.subcmd, source, dest))
            else:
                self.errors.add(
                    error.ConflictsWithExistingFile(self.subcmd, source, dest))
        elif dest.is_symlink():
            self.errors.add(
                error.ConflictsWithExistingLink(self.subcmd, source, dest))

        elif not dest.parent.exists():
            self.errors.add(
                error.NoSuchDirectoryToSubcmdInto(self.subcmd, dest.parent))

        else:
            self.actions.add(actions.SymbolicLink(self.subcmd, source, dest))
Example #4
0
 def _are_other(self, source, dest):
     self.actions.add(actions.SymbolicLink(self.subcmd, source, dest))