def file_size(session, ds_browser, ds_path, file_name):
 client_factory = session.vim.client.factory
 search_spec = search_datastore_spec(client_factory, file_name)
 search_task = session._call_method(session.vim, 'SearchDatastore_Task', ds_browser, datastorePath=str(ds_path), searchSpec=search_spec)
 task_info = session._wait_for_task(search_task)
 if hasattr(task_info.result, 'file'):
  return task_info.result.file[0].fileSize

def file_size ( session , ds_browser , ds_path , file_name ) : client_factory = session . vim . client . factory search_spec = search_datastore_spec ( client_factory , file_name ) search_task = session . _call_method ( session . vim , 'SearchDatastore_Task' , ds_browser , datastorePath = str ( ds_path ) , searchSpec = search_spec ) task_info = session . _wait_for_task ( search_task ) if hasattr ( task_info . result , 'file' ) : return task_info . result . file [ 0 ] . fileSize
obtains the size of a given file .