python-irodsclient
python-irodsclient copied to clipboard
Put() and get() for collection
Hello, I'm working on an interface for irods to make it easier for our users to use irods. My first question is the following when I want to use the api to send or retrieve a file on irods I can use the function
session.data_objects.put(local_object,irods_path)
or
session.data_objects.get(iobject,local_path)
but when it comes to sending/retrieving collections it's more complicated, for sending I came up with a function such as :
def copy_folder_to_irods(racine, local_folder_path, irods_destination_path,session,list_of_icollection):
for root, dirs, files in os.walk(local_folder_path):
## Create the iRODS collection for the local folder if it does not exist
relative_path = racine.split("/")[-1]+"/"+ os.path.relpath(root, local_folder_path)
irods_collection_path = os.path.join(irods_destination_path, relative_path)
if irods_collection_path.endswith("/."):
irods_collection_path = irods_collection_path[:-2]
if irods_collection_path not in list_of_icollection:
session.collections.create(irods_collection_path)
## update the pickle file contining the list of collection
update_irods_collection2("add",irods_collection_path)
##Copy the files from the local folder to the iRODS collection
for file in files:
local_file_path = os.path.join(root, file)
irods_file_path = os.path.join(irods_collection_path, file)
session.data_objects.put(local_file_path,irods_file_path)
## Recursively copy the sub-folders
for dir in dirs:
local_subfolder_path = os.path.join(root, dir)
irods_subfolder_path = os.path.join(irods_destination_path, relative_path, dir)
copy_folder_to_irods(racine, local_subfolder_path, irods_subfolder_path, session, list_of_icollections)
But it would be much more practical to be able to use put() and get() on folders, as is the case with icommands.
is this currently possible? I think it could be relate to #276
Thank in advance Gautier