fsspec / dropboxdrivefs

dropbox implementation for intake module
BSD 3-Clause "New" or "Revised" License
4 stars 8 forks source link

rm not implemented #3

Closed rabernat closed 4 years ago

rabernat commented 4 years ago

Here is some code I tried

import dropboxdrivefs
token = 'secret' # not a real token
fs = dropboxdrivefs.DropboxDriveFileSystem(token=token)

test_path = '/my_test_path.txt'
with fs.open(test_path, mode='w') as f:
    f.write('some data')
fs.rm(test_path)

I got

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-22-f707f2b37254> in <module>
      2 with fs.open(test_path, mode='w') as f:
      3     f.write('some data')
----> 4 fs.rm(test_path)

~/opt/miniconda3/envs/pangeo-py38/lib/python3.8/site-packages/fsspec/spec.py in rm(self, path, recursive, maxdepth)
    702                     self.rmdir(pa_)
    703             else:
--> 704                 self._rm(p)
    705 
    706     @classmethod

~/opt/miniconda3/envs/pangeo-py38/lib/python3.8/site-packages/fsspec/spec.py in _rm(self, path)
    673     def _rm(self, path):
    674         """Delete a file"""
--> 675         raise NotImplementedError
    676 
    677     def rm(self, path, recursive=False, maxdepth=None):

NotImplementedError: 

Removing files is pretty important in order for this to be useful. Would you consider implementing it?

MarineChap commented 4 years ago

I did not have the use case until now but after checking in the dropbox api doc, yes it seems totally doable (3-4 code lines). Give me the weekend, I will do it. :)

MarineChap commented 4 years ago

Hello @rabernat. It should be okay. You can install the package from the master branch to have the feature.

However, I noticed a bug when writing in the file with your code, it seems the text is wrote 2 times in the file. It is your case too? This feature is coming from the fsspec package but I will definitely look at it closely.

MarineChap commented 4 years ago

Hello @rabernat, I fixed the write bug and released a new package version 1.3.0.

Note the mode "a" usually used to append a file, cannot be used in the same way with dropbox. It will create a new file by adding "(2)" in the name file and wrote in it.

MarineChap commented 4 years ago

Hello @rabernat, Can I close this issue ? Thanks :)

rabernat commented 4 years ago

Hi Marine. Sorry I was not responsive to your earlier comments. The past weeks have been very busy for me. Thank you so much for working on this feature. I will test it as soon as possible.