CXCV/Python/Controllers/OrdersController.py

45 lines
1.5 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from typing import Self, Any, Optional
from Abstracts.ControllerAbstract import ControllerAbstract
from Models.FileModel import FileModel
from Models.HashModel import HashModel
from Interfaces.FilesInterface import FilesInterface
from Utils.Utils import Utils
class OrdersController(ControllerAbstract):
def execute(self:Self,
inputs:dict[str, Any|None]|tuple[Any|None, ...]|list[Any|None]
) -> None:
file_name:str
_from:FilesInterface = FileModel.get_driver(self.cxcv, FileModel.get_inputs({
"mode" : "rb"
}, Utils.get_value("from", inputs)))
_to:FilesInterface = FileModel.get_driver(self.cxcv, FileModel.get_inputs({
"mode" : "wb"
}, Utils.get_value("to", inputs)))
from_path:str = Utils.get_value("from_path", inputs)
to_path:str = Utils.get_value("to_path", inputs)
tries:tuple[int, ...] = tuple(range(Utils.get_value("tries", inputs, 3)))
action:str = Utils.get_value("action", inputs, "copy")
remove_from:bool = action in ("move", "cut", "remove")
save_to:bool = action in ("copy", "move", "cut")
for file_name in _from.list():
try_i:int
for try_i in tries:
_from.open(from_path + "/" + file_name)
_to.reset(to_path + "/" + file_name)
if _from.is_file:
pass
elif _from.is_directory:
pass
else:
break