|
|
|
@ -2,10 +2,11 @@ from magic import from_file |
|
|
|
from gapi.api import API |
|
|
|
import re |
|
|
|
APPLICATION_NAME = "Google Calendar API Python" |
|
|
|
|
|
|
|
def is_folder(element): |
|
|
|
return element['mimeType'] == 'application/vnd.google-apps.folder' |
|
|
|
def split_path(path,rev=False): |
|
|
|
|
|
|
|
def split_path(path,rev=False): |
|
|
|
s = re.findall(r'(?:^/|[^/\x00]+)',path) |
|
|
|
if rev: |
|
|
|
return s[::-1] |
|
|
|
@ -21,6 +22,7 @@ def without(node,*keys): |
|
|
|
return ret |
|
|
|
|
|
|
|
class drive_api(API): |
|
|
|
|
|
|
|
def __init__( |
|
|
|
self, |
|
|
|
app_name, |
|
|
|
@ -64,6 +66,7 @@ class drive_api(API): |
|
|
|
return ret |
|
|
|
except KeyError: |
|
|
|
raise FileNotFoundError() |
|
|
|
|
|
|
|
def upload(self,local_path,remote_path): |
|
|
|
try: |
|
|
|
fid = get_file_by_path(remote_path) |
|
|
|
@ -97,6 +100,7 @@ class drive_api(API): |
|
|
|
'parents' : [parent[0]['id']] |
|
|
|
} |
|
|
|
return self.files().create(body = meta).execute() |
|
|
|
|
|
|
|
# finds all files and folders from a parent |
|
|
|
def __fill_in__(self,parent): |
|
|
|
parent_id = parent[0]['id'] |
|
|
|
|