7
7
import logging as log
8
8
import os
9
9
import os .path as osp
10
+ import shutil
10
11
11
12
from datumaro .components .project import Project
12
13
from datumaro .components .comparator import Comparator
@@ -27,10 +28,13 @@ def create_command(args):
27
28
project_dir = osp .abspath (args .dst_dir )
28
29
project_path = make_project_path (project_dir )
29
30
30
- if not args .overwrite and osp .isdir (project_dir ) and os .listdir (project_dir ):
31
- log .error ("Directory '%s' already exists "
32
- "(pass --overwrite to force creation)" % project_dir )
33
- return 1
31
+ if osp .isdir (project_dir ) and os .listdir (project_dir ):
32
+ if not args .overwrite :
33
+ log .error ("Directory '%s' already exists "
34
+ "(pass --overwrite to force creation)" % project_dir )
35
+ return 1
36
+ else :
37
+ shutil .rmtree (project_dir )
34
38
os .makedirs (project_dir , exist_ok = args .overwrite )
35
39
36
40
if not args .overwrite and osp .isfile (project_path ):
@@ -78,10 +82,13 @@ def import_command(args):
78
82
project_dir = osp .abspath (args .dst_dir )
79
83
project_path = make_project_path (project_dir )
80
84
81
- if not args .overwrite and osp .isdir (project_dir ) and os .listdir (project_dir ):
82
- log .error ("Directory '%s' already exists "
83
- "(pass --overwrite to force creation)" % project_dir )
84
- return 1
85
+ if osp .isdir (project_dir ) and os .listdir (project_dir ):
86
+ if not args .overwrite :
87
+ log .error ("Directory '%s' already exists "
88
+ "(pass --overwrite to force creation)" % project_dir )
89
+ return 1
90
+ else :
91
+ shutil .rmtree (project_dir )
85
92
os .makedirs (project_dir , exist_ok = args .overwrite )
86
93
87
94
if not args .overwrite and osp .isfile (project_path ):
@@ -147,7 +154,11 @@ def export_command(args):
147
154
return 1
148
155
os .makedirs (dst_dir , exist_ok = args .overwrite )
149
156
150
- project .make_dataset ().export (
157
+ log .info ("Loading the project..." )
158
+ dataset = project .make_dataset ()
159
+
160
+ log .info ("Exporting the project..." )
161
+ dataset .export (
151
162
save_dir = dst_dir ,
152
163
output_format = args .output_format ,
153
164
filter_expr = args .filter ,
0 commit comments