from scripts.task import Task
from utils import FileUtils, TimeUtils
from utils.logger_utils import app_logger


class ProjectCopy(Task):

    def execute(self):
        self.init()
        result = FileUtils.copy(self.context.project_original_path, self.context.temp_project_path)
        app_logger().debug("Copied project '{}' to '{}'".format(self.context.project_original_path, result))
        pass

    def init(self):
        self.context.temp_project_path = self.context.project_original_path.replace("original",
                                                                                    self.context.package_name.replace(
                                                                                        ".", "_") +
                                                                                    "_" + self.context.local_repo_commit +
                                                                                    "_" + TimeUtils.get_current_time_str())

        pass
