@@ -27,6 +27,8 @@ def __init__(self,
27
27
28
28
def init_files (self ):
29
29
self .file_id_list = self .all_file_ids ()
30
+
31
+
30
32
def get_directory_list (self ):
31
33
"""
32
34
Get a list of available directories for a project
@@ -54,11 +56,14 @@ def get_directory_list(self):
54
56
if default_directory_json :
55
57
self .client .directory_id = default_directory_json .get ('id' )
56
58
57
- directory_list = self .convert_json_to_sdk_object (directory_list_json )
59
+ directory_list = self .convert_json_list_to_sdk_object (directory_list_json )
58
60
59
61
return directory_list
60
62
61
- def convert_json_to_sdk_object (self , directory_list_json ):
63
+ def convert_json_list_to_sdk_object (self , directory_list_json : list ):
64
+
65
+ if type (directory_list_json ) != list :
66
+ raise Exception ("directory_list_json must be type: list" )
62
67
63
68
directory_list = []
64
69
@@ -218,7 +223,7 @@ def new(self, name: str):
218
223
if project :
219
224
directory_list_json = project .get ('directory_list' )
220
225
if directory_list_json :
221
- self .client .directory_list = self .convert_json_to_sdk_object (directory_list_json )
226
+ self .client .directory_list = self .convert_json_list_to_sdk_object (directory_list_json )
222
227
223
228
new_directory = None
224
229
# TODO the route about should return the newly created dataset directly
@@ -304,24 +309,34 @@ def get(self,
304
309
if name is None :
305
310
raise Exception ("No name provided." )
306
311
307
- names_attempted = []
308
- did_set = False
309
-
312
+ # Cache
310
313
if not self .client .directory_list :
311
- self .client .directory_list = self . get_directory_list ()
314
+ self .client .directory_list = []
312
315
313
316
for directory in self .client .directory_list :
314
-
315
317
if directory .nickname == name :
316
318
directory .init_files ()
317
319
return directory
318
320
319
- else :
320
- names_attempted .append (directory .nickname )
321
+ params = {'name' : name }
322
+
323
+ endpoint = "/api/project/" + \
324
+ self .client .project_string_id + "/user/legacy/working_dir/view"
325
+
326
+ response = self .client .session .get (
327
+ self .client .host + endpoint ,
328
+ params = params )
329
+
330
+ self .client .handle_errors (response )
331
+
332
+ data = response .json ()
333
+ directory_json = data .get ('working_dir' )
334
+ directory_list = self .convert_json_list_to_sdk_object ([directory_json ])
335
+ directory = directory_list [0 ]
336
+ self .client .directory_list .append (directory )
337
+
338
+ return directory
321
339
322
- if did_set is False :
323
- raise Exception (name , " does not exist. Valid names are: " +
324
- str (names_attempted ))
325
340
326
341
def add (self ,
327
342
file_list : list = None ,
0 commit comments