@@ -62,14 +62,16 @@ def build_import_parser(parser):
62
62
dir_parser .add_argument ('url' ,
63
63
help = "Path to the source directory" )
64
64
dir_parser .add_argument ('--copy' , action = 'store_true' ,
65
- help = "Copy data to the project " )
65
+ help = "Copy the dataset instead of saving source links " )
66
66
67
+ parser .add_argument ('-n' , '--name' , default = None ,
68
+ help = "Name of the new source" )
67
69
parser .add_argument ('-f' , '--format' , default = None ,
68
70
help = "Name of the source dataset format (default: 'project')" )
69
- parser .add_argument ('-n' , '--name' , default = None ,
70
- help = "Name of the source to be imported" )
71
71
parser .add_argument ('-p' , '--project' , dest = 'project_dir' , default = '.' ,
72
72
help = "Directory of the project to operate on (default: current dir)" )
73
+ parser .add_argument ('--skip-check' , action = 'store_true' ,
74
+ help = "Skip source checking" )
73
75
return parser
74
76
75
77
def import_command (args ):
@@ -99,6 +101,10 @@ def import_command(args):
99
101
if args .format :
100
102
source ['format' ] = args .format
101
103
project .add_source (name , source )
104
+
105
+ if not args .skip_check :
106
+ log .info ("Checking the source..." )
107
+ project .make_source_project (name )
102
108
project .save ()
103
109
104
110
log .info ("Source '%s' has been added to the project, location: '%s'" \
@@ -131,6 +137,10 @@ def import_command(args):
131
137
if args .format :
132
138
source ['format' ] = args .format
133
139
project .add_source (name , source )
140
+
141
+ if not args .skip_check :
142
+ log .info ("Checking the source..." )
143
+ project .make_source_project (name )
134
144
project .save ()
135
145
136
146
log .info ("Source '%s' has been added to the project, location: '%s'" \
@@ -184,6 +194,8 @@ def build_export_parser(parser):
184
194
help = "Output format" )
185
195
parser .add_argument ('-p' , '--project' , dest = 'project_dir' , default = '.' ,
186
196
help = "Directory of the project to operate on (default: current dir)" )
197
+ parser .add_argument ('--overwrite' , action = 'store_true' ,
198
+ help = "Overwrite existing files in the save directory" )
187
199
parser .add_argument ('extra_args' , nargs = argparse .REMAINDER , default = None ,
188
200
help = "Additional arguments for converter (pass '-- -h' for help)" )
189
201
return parser
@@ -192,7 +204,11 @@ def export_command(args):
192
204
project = load_project (args .project_dir )
193
205
194
206
dst_dir = osp .abspath (args .dst_dir )
195
- os .makedirs (dst_dir , exist_ok = False )
207
+ if not args .overwrite and osp .isdir (dst_dir ) and os .listdir (dst_dir ):
208
+ log .error ("Directory '%s' already exists "
209
+ "(pass --overwrite to force creation)" % dst_dir )
210
+ return 1
211
+ os .makedirs (dst_dir , exist_ok = args .overwrite )
196
212
197
213
source_project = project .make_source_project (args .name )
198
214
source_project .make_dataset ().export (
0 commit comments