hi I am stuck in a program logic is I am getting paths from 3rd party api like
paths = ['path1' , 'path2']
now I have to get child of both . api will return every time just 1 step further for example If I will pass a path to it
result = get_path_from_api(path='path1')
it will result into
paths = ['path1/subpath1' , 'path1/subpath2']
now thing is I will stop when I will get []
from this get_path_from_api
call. and I have to find for further even ['path1/subpath1' , 'path1/subpath2']
all sub paths as well and finally merge in single array.
for now my function is like
def get_subpaths(path_name):
sub_paths = []
print(path_name, "path_name")
paths = get_path_from_api(path=path_name)
for path in paths:
if path.is_directory:
sub_paths.append(path.name)
sub_path_final = []
while sub_path_final != None:
sub_path_final = get_subpaths(path.name)
return sub_paths if sub_paths else None
any help would be highly appreciated .
Final expected result
final = ['path1' , 'path1/subpath1' , 'path1/subpath2' , 'path2' , 'path2/subpath2' , 'path2/subpath2' , 'path3/subpath3']