-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
33 lines (24 loc) · 712 Bytes
/
cli.py
File metadata and controls
33 lines (24 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from pathlib import Path
from shutil import copy, rmtree
from typing import List, Union
import typer
app = typer.Typer()
@app.command()
def copy_files(
path_in: Path,
path_out: Path,
create: bool = True,
excluded: List[str] = typer.Option([]),
):
if not path_out.exists() and create:
path_out.mkdir()
for file in path_in.iterdir():
if file.is_file() and file.name not in excluded:
copy(file, path_out / file.name)
@app.command()
def clean_folder(path: Path, excluded: List[str] = typer.Option([])):
for file in path.iterdir():
if file.is_file() and file.name not in excluded:
file.unlink()
if __name__ == "__main__":
app()