|
|
|
@ -26,29 +26,25 @@ class drive_api(API): |
|
|
|
del root_meta['kind'] |
|
|
|
self.filesystem['/'][0] = root_meta |
|
|
|
|
|
|
|
def __inner_path_func__(self,path,parent): |
|
|
|
if len(path) > 1: |
|
|
|
n = path.pop() |
|
|
|
def get_file_by_path(self,path): |
|
|
|
path = split_path(path) |
|
|
|
parent = self.filesystem |
|
|
|
for sub in path[:-1]: |
|
|
|
try: |
|
|
|
new_parent = parent[n] |
|
|
|
parent = parent[sub] |
|
|
|
except KeyError: |
|
|
|
self.fill_in(parent) |
|
|
|
new_parent = parent[n] |
|
|
|
return self.__inner_path_func__(path,new_parent) |
|
|
|
else: |
|
|
|
parent = parent[sub] |
|
|
|
end = path[-1] |
|
|
|
try: |
|
|
|
return parent[path[0]] |
|
|
|
return parent[end] |
|
|
|
except KeyError: |
|
|
|
self.fill_in(parent) |
|
|
|
try: |
|
|
|
return parent[path[0]] |
|
|
|
return parent[end] |
|
|
|
except KeyError: |
|
|
|
raise FileNotFoundError() |
|
|
|
|
|
|
|
def get_file_by_path(self,path): |
|
|
|
path = split_path(path,True) |
|
|
|
return self.__inner_path_func__(path,self.filesystem) |
|
|
|
|
|
|
|
# finds all files and folders from a parent |
|
|
|
def fill_in(self,parent): |
|
|
|
parent_id = parent[0]['id'] |
|
|
|
|