@@ -33,7 +33,7 @@ class ShowFilesHandler(SQLHandler):
3333 Arguments
3434 ---------
3535 * ``<file-location>``: The location of the file, it can
36- be either 'personal ' or 'shared '.
36+ be either 'PERSONAL ' or 'SHARED '.
3737 * ``<path>``: A path in the personal/shared space.
3838 * ``<pattern>``: A pattern similar to SQL LIKE clause.
3939 Uses ``%`` as the wildcard character.
@@ -138,7 +138,7 @@ class UploadFileHandler(SQLHandler):
138138 Arguments
139139 ---------
140140 * ``<file-location>``: The location of the file, it can
141- be either 'personal ' or 'shared '.
141+ be either 'PERSONAL ' or 'SHARED '.
142142 * ``<path>``: The path in the personal/shared space where the file is uploaded.
143143 * ``<local-path>``: The path to the file to upload in the local
144144 directory.
@@ -203,7 +203,7 @@ class DownloadFileHandler(SQLHandler):
203203 Arguments
204204 ---------
205205 * ``<file-location>``: The location of the file, it can
206- be either 'personal ' or 'shared '.
206+ be either 'PERSONAL ' or 'SHARED '.
207207 * ``<path>``: The path to the file to download in a personal/shared space.
208208 * ``<encoding>``: The encoding to apply to the downloaded file.
209209 * ``<local-path>``: Specifies the path in the local directory
@@ -267,99 +267,71 @@ def run(self, params: Dict[str, Any]) -> Optional[FusionSQLResult]:
267267DownloadFileHandler .register (overwrite = True )
268268
269269
270- class DropFileHandler (SQLHandler ):
270+ class DropHandler (SQLHandler ):
271271 """
272- DROP <file-location> FILE path;
272+ DROP <file-location> <file-type> path
273+ [ recursive ];
273274
274275 # Path to file
275276 path = '<path>'
276277
278+ # Should folders be deleted recursively?
279+ recursive = RECURSIVE
280+
277281 Description
278282 -----------
279- Deletes a file from a personal/shared space.
283+ Deletes a file/folder from a personal/shared space.
280284
281285 Arguments
282286 ---------
283287 * ``<file-location>``: The location of the file, it can
284- be either 'personal' or 'shared'.
288+ be either 'PERSONAL' or 'SHARED'.
289+ * ``<file-type>``: The type of the file, it can
290+ be either 'FILE' or 'FOLDER'.
285291 * ``<path>``: The path to the file to delete in a personal/shared space.
286292
287293 Remarks
288294 -------
295+ * The ``RECURSIVE`` clause indicates that the specified folder
296+ is deleted recursively.
289297
290298 Example
291299 --------
292- The following commands delete a file from a personal/shared space::
300+ The following commands delete a file/folder from a personal/shared space::
293301
294302 DROP PERSONAL FILE '/data/stats.csv';
295303 DROP SHARED FILE '/data/stats.csv';
304+ DROP PERSONAL FOLDER '/data/' RECURSIVE;
305+ DROP SHARED FOLDER '/data/' RECURSIVE;
296306
297307 See Also
298308 --------
299- * ``DROP PERSONAL FOLDER``
300- * ``DROP SHARED FOLDER``
301309
302310 """ # noqa: E501
303311
304312 def run (self , params : Dict [str , Any ]) -> Optional [FusionSQLResult ]:
305313 file_space = get_file_space (params )
306- file_space .remove (params ['path' ])
307- return None
308-
309-
310- DropFileHandler .register (overwrite = True )
311-
312314
313- class DropFolderHandler (SQLHandler ):
314- """
315- DROP <file-location> FOLDER path
316- [ recursive ];
317-
318- # Path to folder
319- path = '<path>'
315+ file_type = params ['file_type' ]
316+ if not file_type :
317+ raise KeyError ('file type was not specified' )
320318
321- # Should folers be deleted recursively?
322- recursive = RECURSIVE
319+ file_type = file_type .lower ()
320+ if file_type not in ['file' , 'folder' ]:
321+ raise ValueError ('file type must be either FILE or FOLDER' )
323322
324- Description
325- -----------
326- Deletes a folder from a personal/shared space.
327-
328- Arguments
329- ---------
330- * ``<file-location>``: The location of the file, it can
331- be either 'personal' or 'shared'.
332- * ``<path>``: The path to the folder to delete in a personal/shared space.
333-
334- Remarks
335- -------
336- * The ``RECURSIVE`` clause indicates that the specified folder
337- is deleted recursively.
338-
339- Example
340- -------
341- The following command recursively deletes a folder from a personal/shared space::
342-
343- DROP PERSONAL FOLDER '/data/' RECURSIVE;
344- DROP SHARED FOLDER '/data/' RECURSIVE;
345-
346- See Also
347- --------
348- * ``DROP PERSONAL FILE``
349- * ``DROP SHARED FILE``
350-
351- """ # noqa: E501
323+ if file_type == 'file' :
324+ file_space .remove (params ['path' ])
325+ elif file_type == 'folder' :
326+ if params ['recursive' ]:
327+ file_space .removedirs (params ['path' ])
328+ else :
329+ file_space .rmdir (params ['path' ])
352330
353- def run (self , params : Dict [str , Any ]) -> Optional [FusionSQLResult ]:
354- file_space = get_file_space (params )
355- if params ['recursive' ]:
356- file_space .removedirs (params ['path' ])
357- else :
358- file_space .rmdir (params ['path' ])
359331 return None
360332
361333
362- DropFolderHandler .register (overwrite = True )
334+ DropHandler .register (overwrite = True )
363335
364336
365337class CreateFolderHandler (SQLHandler ):
@@ -380,7 +352,7 @@ class CreateFolderHandler(SQLHandler):
380352 Arguments
381353 ---------
382354 * ``<file-location>``: The location of the file, it can
383- be either 'personal ' or 'shared '.
355+ be either 'PERSONAL ' or 'SHARED '.
384356 * ``<path>``: The path in a personal/shared space where the folder
385357 is created. The path must end with a trailing slash (/).
386358
0 commit comments