File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed
Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -847,9 +847,12 @@ def is_dir(self, path: PathLike) -> bool:
847847 bool
848848
849849 """
850- raise ValueError (
851- 'Operation not supported: directories are currently not allowed in Files API' ,
852- )
850+ try :
851+ return self .info (path ).type == 'directory'
852+ except ManagementError as exc :
853+ if exc .errno == 404 :
854+ return False
855+ raise
853856
854857 # TODO: remove from FileLocation?
855858 def is_file (self , path : PathLike ) -> bool :
@@ -873,6 +876,19 @@ def is_file(self, path: PathLike) -> bool:
873876 return False
874877 raise
875878
879+ def _list_root_dir (self ) -> List [str ]:
880+ """
881+ Return the names of files in the root directory.
882+
883+ Parameters
884+ ----------
885+
886+ """
887+ res = self ._manager ._get (
888+ f'files/fs/{ self ._location } ' ,
889+ ).json ()
890+ return [x ['path' ] for x in res ['content' ] or []]
891+
876892 # TODO: remove from FileLocation?
877893 def listdir (
878894 self ,
@@ -893,6 +909,9 @@ def listdir(
893909 List[str]
894910
895911 """
912+ if path == '/' :
913+ return self ._list_root_dir ()
914+
896915 raise ValueError (
897916 'Operation not supported: directories are currently not allowed in Files API' ,
898917 )
You can’t perform that action at this time.
0 commit comments