File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -381,12 +381,8 @@ def finish_api_setup() -> None:
381381 * Rename `src` to `py`
382382 * Rename `tests` to `pytests`
383383 """
384- # We can't do a simple rename because the target directory might not be empty if
385- # overwriting an existing project.
386- _shutil .copytree ("src" , "py" , dirs_exist_ok = True )
387- _shutil .rmtree ("src" )
388- _shutil .copytree ("tests" , "pytests" , dirs_exist_ok = True )
389- _shutil .rmtree ("tests" )
384+ recursive_overwrite_move (_pathlib .Path ("src" ), _pathlib .Path ("py" ))
385+ recursive_overwrite_move (_pathlib .Path ("tests" ), _pathlib .Path ("pytests" ))
390386
391387
392388def finish_app_setup () -> None :
@@ -471,6 +467,19 @@ def try_run(
471467 return result
472468
473469
470+ def recursive_overwrite_move (src : _pathlib .Path , dst : _pathlib .Path ) -> None :
471+ """Recursively move a directory overwriting the target files if they exist.
472+
473+ Useful when overwriting an existing project to update it.
474+
475+ Args:
476+ src: The source directory.
477+ dst: The target directory.
478+ """
479+ _shutil .copytree (src , dst , dirs_exist_ok = True )
480+ _shutil .rmtree (src )
481+
482+
474483def success (message : str ) -> None :
475484 """Print a success message.
476485
You can’t perform that action at this time.
0 commit comments