import os
from typing import Sequence

from clarabot_nano.server.fstx.filesystem.operation.base import AbstractIOQueueOperation


class ReplaceOperation(AbstractIOQueueOperation):
    OPERATION_KEY = "REP"

    def __init__(self, account_id: int, src: str, dst: str):
        AbstractIOQueueOperation.__init__(self, account_id)
        self.src = src
        self.dst = dst

    def paths(self) -> Sequence[str]:
        return (self.src, self.dst)

    def execute(self):
        os.replace(self.src, self.dst)
