@@ -35,7 +35,7 @@ class Data(object):
3535 The Figshare token to use for data uploads.
3636 """
3737
38- def __init__ (self , project = None ):
38+ def __init__ (self , project = None , verbose = False ):
3939 self .project = project
4040
4141 if project is not None :
@@ -406,22 +406,22 @@ def _download_and_extract(self, path, r, kind, verbose):
406406 if verbose is True :
407407 print ("Extracted output to {}" .format (path ))
408408
409- def _zip_dir (self , dir_path , zip_home , zipf ):
409+ def _zip_dir (self , dir_path , zip_home , zipf , verbose = False ):
410410 """Zip a directory and return the zip file path."""
411411 for subfile in dir_path .rglob ("*" ):
412- if (subfile .name in DVCIGNORE ) and self . verbose :
412+ if (subfile .name in DVCIGNORE ) and verbose :
413413 print (f"Skipping { subfile } as it is in DVCIGNORE." )
414414 continue
415415 if subfile .is_file ():
416416 dest_path = subfile .relative_to (zip_home )
417- if self . verbose :
417+ if verbose :
418418 print (f" Zipping { subfile } to { dest_path } " )
419419 zipf .write (subfile , dest_path )
420420 if subfile .is_dir ():
421421 # Ensure directories are included in the zip
422422 self ._zip_dir (subfile , zip_home , zipf )
423423
424- def prepare_for_upload (self ):
424+ def prepare_for_upload (self , verbose = False ):
425425 """
426426 Prepare files for upload to Figshare.
427427
@@ -449,15 +449,15 @@ def prepare_for_upload(self):
449449 if path .is_file ():
450450 # If it's a file, just copy it to the output path
451451 dest_file = output_path / path .name
452- if self . verbose :
452+ if verbose :
453453 print (f"Copying file: { path } to { dest_file } " )
454454 dest_file .write_bytes (path .read_bytes ())
455455 if path .is_dir ():
456456 zipfile_name = output_path / f"{ path .name } .zip"
457457 with zipfile .ZipFile (zipfile_name , "w" ) as zipf :
458- if self . verbose :
458+ if verbose :
459459 print (f"Zipping directory: { path } to { zipfile_name } " )
460460 self ._zip_dir (path , path , zipf )
461- if self . verbose :
461+ if verbose :
462462 print (f"Prepared files for upload in { output_path } " )
463463 return output_path
0 commit comments