(self, root_src_dir: str, root_dst_dir: str)
Copy directory tree. Overwrites also read only files.
Copy directory tree. Overwrites also read only files.
Copy directory tree . Overwrites also read only files .
def copy_tree(self, root_src_dir: str, root_dst_dir: str) -> None:
        """
        Copy directory tree. Overwrites also read only files.
        """
        for src_dir, _, files in os.walk(root_src_dir):
            dst_dir = src_dir.replace(root_src_dir, root_dst_dir, 1)
            if not os.path.exists(dst_dir):
                os.makedirs(dst_dir)
            for file_ in files:
                src_file = os.path.join(src_dir, file_)
                dst_file = os.path.join(dst_dir, file_)
                if os.path.exists(dst_file):
                    try:
                        os.remove(dst_file)
                    except PermissionError:
                        os.chmod(dst_file, stat.S_IWUSR)
                        os.remove(dst_file)
                shutil.copy2(src_file, dst_dir)
def copy_tree ( self , root_src_dir : str , root_dst_dir : str ) -> None : for src_dir , _ , files in os . walk ( root_src_dir ) : dst_dir = src_dir . replace ( root_src_dir , root_dst_dir , 1 ) if not os . path . exists ( dst_dir ) : os . makedirs ( dst_dir ) for file_ in files : src_file = os . path . join ( src_dir , file_ ) dst_file = os . path . join ( dst_dir , file_ ) if os . path . exists ( dst_file ) : try : os . remove ( dst_file ) except PermissionError : os . chmod ( dst_file , stat . S_IWUSR ) os . remove ( dst_file ) shutil . copy2 ( src_file , dst_dir )