solvedrive 0.0.1__tar.gz → 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: solvedrive
3
- Version: 0.0.1
3
+ Version: 0.1.0
4
4
  Summary: Google Drive client built on the Drive API
5
5
  Author-email: Nathan Cooper <nathanacooper@proton.me>
6
6
  License: Apache-2.0
@@ -22,7 +22,7 @@ Dynamic: license-file
22
22
 
23
23
  <!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
24
24
 
25
- solvedrive is an async Python client for Google Drive. It wraps the Drive REST API in a few small classes ([`Drive`](https://answerDotAI.github.io/solvedrive/core.html#drive), [`File`](https://answerDotAI.github.io/solvedrive/core.html#file), [`Folder`](https://answerDotAI.github.io/solvedrive/core.html#folder), and the [`Files`](https://answerDotAI.github.io/solvedrive/core.html#files) collection), so you can upload and download files, search with Drive’s query syntax, export Google Docs, organize with folders, and share, all with plain method calls.
25
+ solvedrive is an async Python client for Google Drive. It wraps the Drive REST API in a few small classes ([`GDrive`](https://answerDotAI.github.io/solvedrive/core.html#gdrive), [`Drive`](https://answerDotAI.github.io/solvedrive/core.html#drive), [`File`](https://answerDotAI.github.io/solvedrive/core.html#file), [`Folder`](https://answerDotAI.github.io/solvedrive/core.html#folder), and their collections), so you can upload and download files, search across My Drive and shared drives, export Google Docs, organize with folders, and share, all with plain method calls.
26
26
 
27
27
  It is built on [fastgws](https://github.com/AnswerDotAI/fastgws) for OAuth and API access, and runs every call asynchronously, so you `await` each one. Searches come back with the useful fields (`name`, `mimeType`, `size`, `parents`, `trashed`, `webViewLink`) already populated in one request, and reprs render file names as links that open the file in Drive.
28
28
 
@@ -38,11 +38,11 @@ $ pip install solvedrive
38
38
 
39
39
  solvedrive signs in with OAuth 2.0 through [fastgws](https://github.com/AnswerDotAI/fastgws), which expects an OAuth client secret at `~/.config/fastgws/credentials.json`. The fastgws docs cover how to create that file from a Google Cloud project. The first connection opens a browser to authorize the scopes you asked for, then caches the token so later runs don’t prompt again.
40
40
 
41
- Create a [`Drive`](https://answerDotAI.github.io/solvedrive/core.html#drive) client with the scopes you need: `readonly` to search and download, `file` to also manage the files your app created, or `full` for everything. `about()` returns the signed-in account, with the address on its `email` attribute.
41
+ Create a [`GDrive`](https://answerDotAI.github.io/solvedrive/core.html#gdrive) client with the scopes you need: `readonly` to search and download, `file` to also manage the files your app created, or `full` for everything. `about()` returns the signed-in account, with the address on its `email` attribute.
42
42
 
43
43
  ``` python
44
- drive = await Drive.init(scopes='full')
45
- about = await drive.about()
44
+ gd = await GDrive.init(scopes='full')
45
+ about = await gd.about()
46
46
  about.email
47
47
  ```
48
48
 
@@ -53,24 +53,24 @@ about.email
53
53
  `upload` sends bytes or a local path to Drive, returning the new [`File`](https://answerDotAI.github.io/solvedrive/core.html#file). Its repr shows the essentials, with the name linking to the file in Drive.
54
54
 
55
55
  ``` python
56
- f = await drive.upload(data=b'hello from solvedrive!', name='solvedrive_hello.txt')
56
+ f = await gd.upload(data=b'hello from solvedrive!', name='solvedrive_hello.txt')
57
57
  f
58
58
  ```
59
59
 
60
- File(1q7Ki1z40Q2Ec5Xl9eEHMDwMfx4lwGw3Q: <a href="https://drive.google.com/file/d/1q7Ki1z40Q2Ec5Xl9eEHMDwMfx4lwGw3Q/view?usp=drivesdk" target="_blank">solvedrive_hello.txt</a> (text/plain, 22B) 2026-07-28T13:48:55.654Z)
60
+ File(1X0jjggHSWBTQbxaLxtsSNqcDW9uIJpQh: <a href="https://drive.google.com/file/d/1X0jjggHSWBTQbxaLxtsSNqcDW9uIJpQh/view?usp=drivesdk" target="_blank">solvedrive_hello.txt</a> (text/plain, 22B) 2026-07-28T21:08:32.734Z)
61
61
 
62
62
  ### Searching
63
63
 
64
- `search_files` takes Drive’s own [query syntax](https://developers.google.com/workspace/drive/api/guides/search-files), the same operators the Drive search box uses, and returns a [`Files`](https://answerDotAI.github.io/solvedrive/core.html#files) collection with a table repr.
64
+ `search_files` takes Drive’s own [query syntax](https://developers.google.com/workspace/drive/api/guides/search-files), the same operators the Drive search box uses, and searches every drive you can see: My Drive, files shared with you, and all shared drives. Results are a [`Files`](https://answerDotAI.github.io/solvedrive/core.html#files) collection with a table repr.
65
65
 
66
66
  ``` python
67
- fs = await drive.search_files("name = 'solvedrive_hello.txt' and trashed=false")
67
+ fs = await gd.search_files("name = 'solvedrive_hello.txt' and trashed=false")
68
68
  fs
69
69
  ```
70
70
 
71
71
  | id | name | type | size | modified |
72
72
  |----|----|----|----|----|
73
- | 1q7Ki1z40Q2Ec5Xl9eEHMDwMfx4lwGw3Q | <a href="https://drive.google.com/file/d/1q7Ki1z40Q2Ec5Xl9eEHMDwMfx4lwGw3Q/view?usp=drivesdk" target="_blank">solvedrive_hello.txt</a> | text/plain | 22B | 2026-07-28 |
73
+ | 1X0jjggHSWBTQbxaLxtsSNqcDW9uIJpQh | <a href="https://drive.google.com/file/d/1X0jjggHSWBTQbxaLxtsSNqcDW9uIJpQh/view?usp=drivesdk" target="_blank">solvedrive_hello.txt</a> | text/plain | 22B | 2026-07-28 |
74
74
 
75
75
  ### Downloading
76
76
 
@@ -87,14 +87,25 @@ await f.download()
87
87
  A folder is a file with a special `mimeType`. `create_folder` makes one, `move` puts files in it, and `ls` lists what it holds.
88
88
 
89
89
  ``` python
90
- folder = await drive.create_folder('solvedrive demo')
90
+ folder = await gd.create_folder('solvedrive demo')
91
91
  await f.move(folder)
92
92
  await folder.ls()
93
93
  ```
94
94
 
95
95
  | id | name | type | size | modified |
96
96
  |----|----|----|----|----|
97
- | 1q7Ki1z40Q2Ec5Xl9eEHMDwMfx4lwGw3Q | <a href="https://drive.google.com/file/d/1q7Ki1z40Q2Ec5Xl9eEHMDwMfx4lwGw3Q/view?usp=drivesdk" target="_blank">solvedrive_hello.txt</a> | text/plain | 22B | 2026-07-28 |
97
+ | 1X0jjggHSWBTQbxaLxtsSNqcDW9uIJpQh | <a href="https://drive.google.com/file/d/1X0jjggHSWBTQbxaLxtsSNqcDW9uIJpQh/view?usp=drivesdk" target="_blank">solvedrive_hello.txt</a> | text/plain | 22B | 2026-07-28 |
98
+
99
+ ### Drives
100
+
101
+ Every file lives in a drive: your My Drive, or a shared drive owned by an organization. `list_drives` returns them as a [`Drives`](https://answerDotAI.github.io/solvedrive/core.html#drives) table, and each [`Drive`](https://answerDotAI.github.io/solvedrive/core.html#drive) knows your role on it and scopes `search_files` to its contents. `drive.root` is an ordinary [`Folder`](https://answerDotAI.github.io/solvedrive/core.html#folder), so uploading into and listing a shared drive works like any folder, and every file method sends `supportsAllDrives`, so a [`File`](https://answerDotAI.github.io/solvedrive/core.html#file) behaves the same wherever it lives.
102
+
103
+ ``` python
104
+ ds = await gd.list_drives()
105
+ ds[0]
106
+ ```
107
+
108
+ Drive(root: <a href="https://drive.google.com/drive/my-drive" target="_blank">My Drive</a>, owner)
98
109
 
99
110
  ### Sharing
100
111
 
@@ -107,7 +118,7 @@ await f.permissions
107
118
 
108
119
  [{'id': 'anyoneWithLink', 'type': 'anyone', 'role': 'reader'}, {'id': '12635610242443046038', 'type': 'user', 'emailAddress': 'nc@answer.ai', 'role': 'owner'}]
109
120
 
110
- There’s more in `solvedrive.core`: renaming and copying, trash versus permanent deletion, and operating on a whole [`Files`](https://answerDotAI.github.io/solvedrive/core.html#files) collection at once through Google’s batch protocol. See the [docs](https://answerDotAI.github.io/solvedrive/) for the full tour.
121
+ There’s more in `solvedrive.core`: working inside shared drives, renaming and copying, trash versus permanent deletion, and operating on a whole [`Files`](https://answerDotAI.github.io/solvedrive/core.html#files) collection at once through Google’s batch protocol. See the [docs](https://answerDotAI.github.io/solvedrive/) for the full tour.
111
122
 
112
123
  ### Use as an LLM skill
113
124
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  <!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
5
5
 
6
- solvedrive is an async Python client for Google Drive. It wraps the Drive REST API in a few small classes ([`Drive`](https://answerDotAI.github.io/solvedrive/core.html#drive), [`File`](https://answerDotAI.github.io/solvedrive/core.html#file), [`Folder`](https://answerDotAI.github.io/solvedrive/core.html#folder), and the [`Files`](https://answerDotAI.github.io/solvedrive/core.html#files) collection), so you can upload and download files, search with Drive’s query syntax, export Google Docs, organize with folders, and share, all with plain method calls.
6
+ solvedrive is an async Python client for Google Drive. It wraps the Drive REST API in a few small classes ([`GDrive`](https://answerDotAI.github.io/solvedrive/core.html#gdrive), [`Drive`](https://answerDotAI.github.io/solvedrive/core.html#drive), [`File`](https://answerDotAI.github.io/solvedrive/core.html#file), [`Folder`](https://answerDotAI.github.io/solvedrive/core.html#folder), and their collections), so you can upload and download files, search across My Drive and shared drives, export Google Docs, organize with folders, and share, all with plain method calls.
7
7
 
8
8
  It is built on [fastgws](https://github.com/AnswerDotAI/fastgws) for OAuth and API access, and runs every call asynchronously, so you `await` each one. Searches come back with the useful fields (`name`, `mimeType`, `size`, `parents`, `trashed`, `webViewLink`) already populated in one request, and reprs render file names as links that open the file in Drive.
9
9
 
@@ -19,11 +19,11 @@ $ pip install solvedrive
19
19
 
20
20
  solvedrive signs in with OAuth 2.0 through [fastgws](https://github.com/AnswerDotAI/fastgws), which expects an OAuth client secret at `~/.config/fastgws/credentials.json`. The fastgws docs cover how to create that file from a Google Cloud project. The first connection opens a browser to authorize the scopes you asked for, then caches the token so later runs don’t prompt again.
21
21
 
22
- Create a [`Drive`](https://answerDotAI.github.io/solvedrive/core.html#drive) client with the scopes you need: `readonly` to search and download, `file` to also manage the files your app created, or `full` for everything. `about()` returns the signed-in account, with the address on its `email` attribute.
22
+ Create a [`GDrive`](https://answerDotAI.github.io/solvedrive/core.html#gdrive) client with the scopes you need: `readonly` to search and download, `file` to also manage the files your app created, or `full` for everything. `about()` returns the signed-in account, with the address on its `email` attribute.
23
23
 
24
24
  ``` python
25
- drive = await Drive.init(scopes='full')
26
- about = await drive.about()
25
+ gd = await GDrive.init(scopes='full')
26
+ about = await gd.about()
27
27
  about.email
28
28
  ```
29
29
 
@@ -34,24 +34,24 @@ about.email
34
34
  `upload` sends bytes or a local path to Drive, returning the new [`File`](https://answerDotAI.github.io/solvedrive/core.html#file). Its repr shows the essentials, with the name linking to the file in Drive.
35
35
 
36
36
  ``` python
37
- f = await drive.upload(data=b'hello from solvedrive!', name='solvedrive_hello.txt')
37
+ f = await gd.upload(data=b'hello from solvedrive!', name='solvedrive_hello.txt')
38
38
  f
39
39
  ```
40
40
 
41
- File(1q7Ki1z40Q2Ec5Xl9eEHMDwMfx4lwGw3Q: <a href="https://drive.google.com/file/d/1q7Ki1z40Q2Ec5Xl9eEHMDwMfx4lwGw3Q/view?usp=drivesdk" target="_blank">solvedrive_hello.txt</a> (text/plain, 22B) 2026-07-28T13:48:55.654Z)
41
+ File(1X0jjggHSWBTQbxaLxtsSNqcDW9uIJpQh: <a href="https://drive.google.com/file/d/1X0jjggHSWBTQbxaLxtsSNqcDW9uIJpQh/view?usp=drivesdk" target="_blank">solvedrive_hello.txt</a> (text/plain, 22B) 2026-07-28T21:08:32.734Z)
42
42
 
43
43
  ### Searching
44
44
 
45
- `search_files` takes Drive’s own [query syntax](https://developers.google.com/workspace/drive/api/guides/search-files), the same operators the Drive search box uses, and returns a [`Files`](https://answerDotAI.github.io/solvedrive/core.html#files) collection with a table repr.
45
+ `search_files` takes Drive’s own [query syntax](https://developers.google.com/workspace/drive/api/guides/search-files), the same operators the Drive search box uses, and searches every drive you can see: My Drive, files shared with you, and all shared drives. Results are a [`Files`](https://answerDotAI.github.io/solvedrive/core.html#files) collection with a table repr.
46
46
 
47
47
  ``` python
48
- fs = await drive.search_files("name = 'solvedrive_hello.txt' and trashed=false")
48
+ fs = await gd.search_files("name = 'solvedrive_hello.txt' and trashed=false")
49
49
  fs
50
50
  ```
51
51
 
52
52
  | id | name | type | size | modified |
53
53
  |----|----|----|----|----|
54
- | 1q7Ki1z40Q2Ec5Xl9eEHMDwMfx4lwGw3Q | <a href="https://drive.google.com/file/d/1q7Ki1z40Q2Ec5Xl9eEHMDwMfx4lwGw3Q/view?usp=drivesdk" target="_blank">solvedrive_hello.txt</a> | text/plain | 22B | 2026-07-28 |
54
+ | 1X0jjggHSWBTQbxaLxtsSNqcDW9uIJpQh | <a href="https://drive.google.com/file/d/1X0jjggHSWBTQbxaLxtsSNqcDW9uIJpQh/view?usp=drivesdk" target="_blank">solvedrive_hello.txt</a> | text/plain | 22B | 2026-07-28 |
55
55
 
56
56
  ### Downloading
57
57
 
@@ -68,14 +68,25 @@ await f.download()
68
68
  A folder is a file with a special `mimeType`. `create_folder` makes one, `move` puts files in it, and `ls` lists what it holds.
69
69
 
70
70
  ``` python
71
- folder = await drive.create_folder('solvedrive demo')
71
+ folder = await gd.create_folder('solvedrive demo')
72
72
  await f.move(folder)
73
73
  await folder.ls()
74
74
  ```
75
75
 
76
76
  | id | name | type | size | modified |
77
77
  |----|----|----|----|----|
78
- | 1q7Ki1z40Q2Ec5Xl9eEHMDwMfx4lwGw3Q | <a href="https://drive.google.com/file/d/1q7Ki1z40Q2Ec5Xl9eEHMDwMfx4lwGw3Q/view?usp=drivesdk" target="_blank">solvedrive_hello.txt</a> | text/plain | 22B | 2026-07-28 |
78
+ | 1X0jjggHSWBTQbxaLxtsSNqcDW9uIJpQh | <a href="https://drive.google.com/file/d/1X0jjggHSWBTQbxaLxtsSNqcDW9uIJpQh/view?usp=drivesdk" target="_blank">solvedrive_hello.txt</a> | text/plain | 22B | 2026-07-28 |
79
+
80
+ ### Drives
81
+
82
+ Every file lives in a drive: your My Drive, or a shared drive owned by an organization. `list_drives` returns them as a [`Drives`](https://answerDotAI.github.io/solvedrive/core.html#drives) table, and each [`Drive`](https://answerDotAI.github.io/solvedrive/core.html#drive) knows your role on it and scopes `search_files` to its contents. `drive.root` is an ordinary [`Folder`](https://answerDotAI.github.io/solvedrive/core.html#folder), so uploading into and listing a shared drive works like any folder, and every file method sends `supportsAllDrives`, so a [`File`](https://answerDotAI.github.io/solvedrive/core.html#file) behaves the same wherever it lives.
83
+
84
+ ``` python
85
+ ds = await gd.list_drives()
86
+ ds[0]
87
+ ```
88
+
89
+ Drive(root: <a href="https://drive.google.com/drive/my-drive" target="_blank">My Drive</a>, owner)
79
90
 
80
91
  ### Sharing
81
92
 
@@ -88,7 +99,7 @@ await f.permissions
88
99
 
89
100
  [{'id': 'anyoneWithLink', 'type': 'anyone', 'role': 'reader'}, {'id': '12635610242443046038', 'type': 'user', 'emailAddress': 'nc@answer.ai', 'role': 'owner'}]
90
101
 
91
- There’s more in `solvedrive.core`: renaming and copying, trash versus permanent deletion, and operating on a whole [`Files`](https://answerDotAI.github.io/solvedrive/core.html#files) collection at once through Google’s batch protocol. See the [docs](https://answerDotAI.github.io/solvedrive/) for the full tour.
102
+ There’s more in `solvedrive.core`: working inside shared drives, renaming and copying, trash versus permanent deletion, and operating on a whole [`Files`](https://answerDotAI.github.io/solvedrive/core.html#files) collection at once through Google’s batch protocol. See the [docs](https://answerDotAI.github.io/solvedrive/) for the full tour.
92
103
 
93
104
  ### Use as an LLM skill
94
105
 
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
@@ -7,11 +7,15 @@ d = { 'settings': { 'branch': 'main',
7
7
  'lib_path': 'solvedrive'},
8
8
  'syms': { 'solvedrive.core': { 'solvedrive.core.Drive': ('core.html#drive', 'solvedrive/core.py'),
9
9
  'solvedrive.core.Drive.__init__': ('core.html#drive.__init__', 'solvedrive/core.py'),
10
- 'solvedrive.core.Drive.about': ('core.html#drive.about', 'solvedrive/core.py'),
11
- 'solvedrive.core.Drive.create_folder': ('core.html#drive.create_folder', 'solvedrive/core.py'),
12
- 'solvedrive.core.Drive.init': ('core.html#drive.init', 'solvedrive/core.py'),
10
+ 'solvedrive.core.Drive.__repr__': ('core.html#drive.__repr__', 'solvedrive/core.py'),
11
+ 'solvedrive.core.Drive._desc': ('core.html#drive._desc', 'solvedrive/core.py'),
12
+ 'solvedrive.core.Drive._repr_markdown_': ('core.html#drive._repr_markdown_', 'solvedrive/core.py'),
13
+ 'solvedrive.core.Drive.role': ('core.html#drive.role', 'solvedrive/core.py'),
14
+ 'solvedrive.core.Drive.root': ('core.html#drive.root', 'solvedrive/core.py'),
13
15
  'solvedrive.core.Drive.search_files': ('core.html#drive.search_files', 'solvedrive/core.py'),
14
- 'solvedrive.core.Drive.upload': ('core.html#drive.upload', 'solvedrive/core.py'),
16
+ 'solvedrive.core.Drives': ('core.html#drives', 'solvedrive/core.py'),
17
+ 'solvedrive.core.Drives.__init__': ('core.html#drives.__init__', 'solvedrive/core.py'),
18
+ 'solvedrive.core.Drives._repr_markdown_': ('core.html#drives._repr_markdown_', 'solvedrive/core.py'),
15
19
  'solvedrive.core.File': ('core.html#file', 'solvedrive/core.py'),
16
20
  'solvedrive.core.File.__init__': ('core.html#file.__init__', 'solvedrive/core.py'),
17
21
  'solvedrive.core.File.__repr__': ('core.html#file.__repr__', 'solvedrive/core.py'),
@@ -42,6 +46,17 @@ d = { 'settings': { 'branch': 'main',
42
46
  'solvedrive.core.Folder': ('core.html#folder', 'solvedrive/core.py'),
43
47
  'solvedrive.core.Folder.ls': ('core.html#folder.ls', 'solvedrive/core.py'),
44
48
  'solvedrive.core.Folder.upload': ('core.html#folder.upload', 'solvedrive/core.py'),
49
+ 'solvedrive.core.GDrive': ('core.html#gdrive', 'solvedrive/core.py'),
50
+ 'solvedrive.core.GDrive.__init__': ('core.html#gdrive.__init__', 'solvedrive/core.py'),
51
+ 'solvedrive.core.GDrive.about': ('core.html#gdrive.about', 'solvedrive/core.py'),
52
+ 'solvedrive.core.GDrive.create_folder': ('core.html#gdrive.create_folder', 'solvedrive/core.py'),
53
+ 'solvedrive.core.GDrive.init': ('core.html#gdrive.init', 'solvedrive/core.py'),
54
+ 'solvedrive.core.GDrive.list_drives': ('core.html#gdrive.list_drives', 'solvedrive/core.py'),
55
+ 'solvedrive.core.GDrive.search_files': ('core.html#gdrive.search_files', 'solvedrive/core.py'),
56
+ 'solvedrive.core.GDrive.upload': ('core.html#gdrive.upload', 'solvedrive/core.py'),
57
+ 'solvedrive.core._dlink': ('core.html#_dlink', 'solvedrive/core.py'),
58
+ 'solvedrive.core._drive_row': ('core.html#_drive_row', 'solvedrive/core.py'),
59
+ 'solvedrive.core._drole': ('core.html#_drole', 'solvedrive/core.py'),
45
60
  'solvedrive.core._fid': ('core.html#_fid', 'solvedrive/core.py'),
46
61
  'solvedrive.core._file_row': ('core.html#_file_row', 'solvedrive/core.py'),
47
62
  'solvedrive.core._link': ('core.html#_link', 'solvedrive/core.py'),
@@ -5,11 +5,11 @@ Docs: https://answerDotAI.github.io/solvedrive/core.html.md"""
5
5
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_core.ipynb.
6
6
 
7
7
  # %% auto #0
8
- __all__ = ['FIELDS', 'FOLDER_MIME', 'Drive', 'hsize', 'File', 'Folder', 'Files']
8
+ __all__ = ['FIELDS', 'FOLDER_MIME', 'DRIVE_FIELDS', 'GDrive', 'hsize', 'File', 'Folder', 'Files', 'Drive', 'Drives']
9
9
 
10
10
  # %% ../nbs/00_core.ipynb #4d53f263
11
11
  from fastcore.all import *
12
- from fastgws import Drive as GDrive
12
+ from fastgws import Drive as FGWSDrive
13
13
  from fastgws.auth import *
14
14
  from uuid import uuid4
15
15
 
@@ -18,8 +18,9 @@ import json, mimetypes, sys
18
18
  # %% ../nbs/00_core.ipynb #f4e588b0
19
19
  FIELDS = 'id,name,mimeType,size,modifiedTime,parents,trashed,webViewLink'
20
20
 
21
- class Drive:
22
- def __init__(self, client): self.client = client
21
+ class GDrive(GetAttr):
22
+ _default = 'api'
23
+ def __init__(self, api): self.api = api
23
24
 
24
25
  @classmethod
25
26
  async def init(cls, scopes='readonly', creds=None, redirect_uri='https://oauth.appapis.org/redirect',
@@ -27,11 +28,11 @@ class Drive:
27
28
  if scopes == 'full': scopes = ['https://www.googleapis.com/auth/drive']
28
29
  else: scopes = [f'https://www.googleapis.com/auth/drive.{x}' for x in listify(scopes)]
29
30
  if creds is None: creds = await oauth_creds(scopes=scopes, redirect_uri=redirect_uri, listen=listen, port=port, open_url=open_url)
30
- return cls(GDrive(creds=creds))
31
+ return cls(FGWSDrive(creds=creds))
31
32
 
32
33
  async def about(self):
33
34
  "User resource with `email` attribute"
34
- d = await self.client.about.get(fields='user')
35
+ d = await self.api.about.get(fields='user')
35
36
  return AttrDict(d.user, email=d.user.emailAddress)
36
37
 
37
38
  # %% ../nbs/00_core.ipynb #fe25d3be
@@ -52,9 +53,9 @@ def _link(f):
52
53
  return f'<a href="{url}" target="_blank">{nm}</a>' if (url:=f.get('webViewLink')) else nm
53
54
 
54
55
  class File(AttrDict):
55
- def __init__(self, drive, d):
56
+ def __init__(self, client, d):
56
57
  super().__init__(d)
57
- self.drive = drive
58
+ object.__setattr__(self, '_client', client)
58
59
 
59
60
  def _desc(self, nm):
60
61
  sz = f', {hsize(int(self.size))}' if self.get('size') else ''
@@ -65,19 +66,19 @@ class File(AttrDict):
65
66
  def _repr_markdown_(self): return self._desc(_link(self))
66
67
 
67
68
  async def refresh(self, fields=FIELDS):
68
- self.update(await self.drive.client.files.get(file_id=self.id, fields=fields))
69
+ self.update(await self._client.files.get(file_id=self.id, fields=fields, supports_all_drives=True))
69
70
  return self
70
71
 
71
72
  @classmethod
72
- async def fetch(cls, drive, id): return await cls(drive, dict(id=id)).refresh()
73
+ async def fetch(cls, client, id): return await cls(client, dict(id=id)).refresh()
73
74
 
74
75
  class Folder(File): pass
75
76
 
76
77
  def _fid(f): return f.id if isinstance(f, File) else f
77
78
 
78
- def _mk_file(drive, d):
79
+ def _mk_file(client, d):
79
80
  cls = Folder if d.get('mimeType')==FOLDER_MIME else File
80
- return cls(drive, d)
81
+ return cls(client, d)
81
82
 
82
83
  # %% ../nbs/00_core.ipynb #a5cc3392
83
84
  _upload_url = 'https://www.googleapis.com/upload/drive/v3/files'
@@ -89,7 +90,7 @@ def _multipart_related(meta, data, mime):
89
90
  return body, {'Content-Type': f'multipart/related; boundary={b}'}
90
91
 
91
92
  @patch
92
- async def upload(self:Drive,
93
+ async def upload(self:GDrive,
93
94
  path=None, # File to upload
94
95
  name=None, # Name in Drive (defaults to `path`'s name)
95
96
  data=None, # Content bytes, as an alternative to `path`
@@ -104,8 +105,8 @@ async def upload(self:Drive,
104
105
  meta = dict(name=name)
105
106
  if folder: meta['parents'] = [_fid(folder)]
106
107
  body, hdrs = _multipart_related(meta, data, mime)
107
- r = await self.client.transport.request('POST', _upload_url, content=body, headers=hdrs,
108
- params=dict(uploadType='multipart', fields=FIELDS))
108
+ r = await self.api.transport.request('POST', _upload_url, content=body, headers=hdrs,
109
+ params=dict(uploadType='multipart', fields=FIELDS, supportsAllDrives=True))
109
110
  return _mk_file(self, r)
110
111
 
111
112
  # %% ../nbs/00_core.ipynb #d7fe7a99
@@ -115,16 +116,18 @@ def _file_row(f):
115
116
 
116
117
  _file_hdr = '| id | name | type | size | modified |\n|-|-|-|-|-|\n'
117
118
  class Files(L):
118
- def __init__(self, d, *rest, drive=None, **kwargs):
119
+ def __init__(self, d, *rest, client=None, **kwargs):
119
120
  super().__init__(d, *rest, **kwargs)
120
- self.drive = drive
121
+ self._client = client
121
122
 
122
123
  def _repr_markdown_(self): return _file_hdr + '\n'.join(self.map(_file_row))
123
124
 
124
125
  @patch
125
- async def search_files(self:Drive, q=None, max_results=20, fields=FIELDS, **kwargs):
126
- r = await self.client.files.list(q=q, page_size=max_results, fields=f'files({fields})', **kwargs)
127
- return Files(L(r.get('files') or []).map(lambda o: _mk_file(self, o)), drive=self)
126
+ async def search_files(self:GDrive, q=None, max_results=20, fields=FIELDS, **kwargs):
127
+ "Search every drive you can see: My Drive, files shared with you, and all shared drives"
128
+ kwargs = dict(corpora='allDrives', include_items_from_all_drives=True, supports_all_drives=True) | kwargs
129
+ r = await self.api.files.list(q=q, page_size=max_results, fields=f'files({fields})', **kwargs)
130
+ return Files(L(r.get('files') or []).map(lambda o: _mk_file(self, o)), client=self)
128
131
 
129
132
  # %% ../nbs/00_core.ipynb #c5cc0e5e
130
133
  _exports = {'application/vnd.google-apps.document': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
@@ -141,8 +144,8 @@ async def download(self:File,
141
144
  native = self.mimeType.startswith('application/vnd.google-apps')
142
145
  if not native:
143
146
  if mime: raise ValueError(f'`mime` is for exporting Google-native files; {self.name} is {self.mimeType}')
144
- r = await self.drive.client.files.get(file_id=self.id, alt='media', raw=True)
145
- else: r = await self.drive.client.files.export(file_id=self.id, mime_type=mime or _exports[self.mimeType], raw=True)
147
+ r = await self._client.files.get(file_id=self.id, alt='media', raw=True, supports_all_drives=True)
148
+ else: r = await self._client.files.export(file_id=self.id, mime_type=mime or _exports[self.mimeType], raw=True)
146
149
  data = r.content
147
150
  if save:
148
151
  p = Path(save)
@@ -152,49 +155,104 @@ async def download(self:File,
152
155
 
153
156
  # %% ../nbs/00_core.ipynb #52081533
154
157
  @patch
155
- async def create_folder(self:Drive, name, parent=None):
158
+ async def create_folder(self:GDrive, name, parent=None):
156
159
  "Create a folder, returning the new `Folder`"
157
- meta = dict(name=name, mime_type=FOLDER_MIME, fields=FIELDS)
160
+ meta = dict(name=name, mime_type=FOLDER_MIME, fields=FIELDS, supports_all_drives=True)
158
161
  if parent: meta['parents'] = [_fid(parent)]
159
- return Folder(self, await self.client.files.create(**meta))
162
+ return Folder(self, await self.api.files.create(**meta))
160
163
 
161
164
  @patch
162
165
  async def ls(self:Folder, q=None, **kwargs):
163
166
  "Search within this folder"
164
167
  qs = f"'{self.id}' in parents and trashed=false"
165
168
  if q: qs = f'{qs} and ({q})'
166
- return await self.drive.search_files(qs, **kwargs)
169
+ return await self._client.search_files(qs, **kwargs)
167
170
 
168
171
  @patch
169
- @delegates(Drive.upload)
172
+ @delegates(GDrive.upload)
170
173
  async def upload(self:Folder, path=None, **kwargs):
171
174
  "Upload into this folder"
172
- return await self.drive.upload(path, folder=self, **kwargs)
175
+ return await self._client.upload(path, folder=self, **kwargs)
176
+
177
+ # %% ../nbs/00_core.ipynb #86d374ef
178
+ DRIVE_FIELDS = 'id,name,capabilities'
179
+
180
+ def _drole(d):
181
+ "Role implied by drive `capabilities`"
182
+ c = d.get('capabilities') or {}
183
+ for cap,role in [('canManageMembers','organizer'),('canTrashChildren','fileOrganizer'),
184
+ ('canAddChildren','writer'),('canComment','commenter')]:
185
+ if c.get(cap): return role
186
+ return 'reader'
187
+
188
+ def _dlink(d):
189
+ "Drive name as an anchor opening it in Drive in a new tab"
190
+ url = 'https://drive.google.com/drive/my-drive' if d.id=='root' else f'https://drive.google.com/drive/folders/{d.id}'
191
+ return f'<a href="{url}" target="_blank">{d.name}</a>'
192
+
193
+ class Drive(AttrDict):
194
+ def __init__(self, client, d):
195
+ super().__init__(d)
196
+ object.__setattr__(self, '_client', client)
197
+
198
+ @property
199
+ def role(self): return 'owner' if self.id=='root' else _drole(self)
200
+ def _desc(self, nm): return f'{type(self).__name__}({self.id}: {nm}, {self.role})'
201
+ def __repr__(self): return self._desc(self.name)
202
+ def _repr_markdown_(self): return self._desc(_dlink(self))
203
+
204
+ def _drive_row(d): return f'| {d.id} | {_dlink(d)} | {d.role} |'
205
+ _drive_hdr = '| id | name | role |\n|-|-|-|\n'
206
+ class Drives(L):
207
+ def __init__(self, d, *rest, client=None, **kwargs):
208
+ super().__init__(d, *rest, **kwargs)
209
+ self._client = client
210
+
211
+ def _repr_markdown_(self): return _drive_hdr + '\n'.join(self.map(_drive_row))
212
+
213
+ @patch
214
+ async def list_drives(self:GDrive, fields=DRIVE_FIELDS, **kwargs):
215
+ "Your drives: My Drive first, then every shared drive you're a member of"
216
+ r = await self.api.drives.list(fields=f'drives({fields})', **kwargs)
217
+ ds = [dict(id='root', name='My Drive')] + list(r.get('drives') or [])
218
+ return Drives(L(ds).map(lambda o: Drive(self, o)), client=self)
219
+
220
+ # %% ../nbs/00_core.ipynb #fb7d6f57
221
+ @patch
222
+ async def search_files(self:Drive, q=None, **kwargs):
223
+ "Search within this drive"
224
+ scope = dict(corpora='user') if self.id=='root' else dict(corpora='drive', drive_id=self.id)
225
+ return await self._client.search_files(q, **scope, **kwargs)
226
+
227
+ @patch(as_prop=True)
228
+ async def root(self:Drive):
229
+ "The drive's root `Folder`"
230
+ return await Folder.fetch(self._client, self.id)
173
231
 
174
232
  # %% ../nbs/00_core.ipynb #859523ef
175
233
  @patch
176
234
  async def rename(self:File, name):
177
235
  "Rename to `name`"
178
- return self.update(await self.drive.client.files.update(file_id=self.id, name=name, fields=FIELDS))
236
+ return self.update(await self._client.files.update(file_id=self.id, name=name, fields=FIELDS, supports_all_drives=True))
179
237
 
180
238
  @patch
181
239
  async def move(self:File, folder):
182
240
  "Move into `folder` (a `Folder` or folder id)"
183
- return self.update(await self.drive.client.files.update(file_id=self.id, add_parents=_fid(folder),
184
- remove_parents=','.join(self.get('parents') or []), fields=FIELDS))
241
+ return self.update(await self._client.files.update(file_id=self.id, add_parents=_fid(folder),
242
+ remove_parents=','.join(self.get('parents') or []), fields=FIELDS, supports_all_drives=True))
185
243
 
186
244
  @patch
187
245
  async def copy(self:File, name=None, folder=None):
188
246
  "Server-side copy, optionally renamed into `folder`; returns the new `File`"
189
- meta = dict(file_id=self.id, fields=FIELDS)
247
+ meta = dict(file_id=self.id, fields=FIELDS, supports_all_drives=True)
190
248
  if name: meta['name'] = name
191
249
  if folder: meta['parents'] = [_fid(folder)]
192
- return _mk_file(self.drive, await self.drive.client.files.copy(**meta))
250
+ return _mk_file(self._client, await self._client.files.copy(**meta))
193
251
 
194
252
  # %% ../nbs/00_core.ipynb #01e0b545
195
253
  @patch
196
254
  async def _set_trashed(self:File, trashed):
197
- return self.update(await self.drive.client.files.update(file_id=self.id, trashed=trashed, fields=FIELDS))
255
+ return self.update(await self._client.files.update(file_id=self.id, trashed=trashed, fields=FIELDS, supports_all_drives=True))
198
256
 
199
257
  @patch
200
258
  async def trash(self:File):
@@ -211,24 +269,24 @@ async def untrash(self:File):
211
269
  async def delete(self:File):
212
270
  "Delete permanently, skipping the trash"
213
271
  sys.audit('solvedrive.File.delete')
214
- return await self.drive.client.files.delete(file_id=self.id)
272
+ return await self._client.files.delete(file_id=self.id, supports_all_drives=True)
215
273
 
216
274
  # %% ../nbs/00_core.ipynb #72defcd0
217
275
  @patch
218
- def _gfiles(self:Files): return self.drive.client._gservice.files()
276
+ def _gfiles(self:Files): return self._client.api._gservice.files()
219
277
 
220
278
  @patch
221
279
  async def refresh(self:Files, fields=FIELDS):
222
280
  "Batch re-fetch metadata for all files"
223
281
  if not self: return self
224
- res = self.drive.client.batch_get([(f.id, self._gfiles().get(fileId=f.id, fields=fields)) for f in self])
282
+ res = self._client.batch_get([(f.id, self._gfiles().get(fileId=f.id, fields=fields, supportsAllDrives=True)) for f in self])
225
283
  for f in self: f.update(dict2obj(res[f.id]))
226
284
  return self
227
285
 
228
286
  @patch
229
287
  async def _set_trashed(self:Files, trashed):
230
288
  if not self: return self
231
- res = self.drive.client.batch_get([(f.id, self._gfiles().update(fileId=f.id, body=dict(trashed=trashed), fields=FIELDS)) for f in self])
289
+ res = self._client.batch_get([(f.id, self._gfiles().update(fileId=f.id, body=dict(trashed=trashed), fields=FIELDS, supportsAllDrives=True)) for f in self])
232
290
  for f in self: f.update(dict2obj(res[f.id]))
233
291
  return self
234
292
 
@@ -247,7 +305,7 @@ async def untrash(self:Files):
247
305
  async def delete(self:Files):
248
306
  "Batch delete all files permanently"
249
307
  sys.audit('solvedrive.Files.delete')
250
- if self: self.drive.client.batch_get([(f.id, self._gfiles().delete(fileId=f.id)) for f in self])
308
+ if self: self._client.batch_get([(f.id, self._gfiles().delete(fileId=f.id, supportsAllDrives=True)) for f in self])
251
309
 
252
310
  # %% ../nbs/00_core.ipynb #6d5ec299
253
311
  @patch
@@ -258,17 +316,17 @@ async def share(self:File,
258
316
  ):
259
317
  "Grant access, returning the new permission"
260
318
  sys.audit('solvedrive.File.share')
261
- meta = dict(file_id=self.id, role=role, send_notification_email=notify)
319
+ meta = dict(file_id=self.id, role=role, send_notification_email=notify, supports_all_drives=True)
262
320
  if email: meta.update(type='user', email_address=email)
263
321
  else: meta['type'] = 'anyone'
264
- return await self.drive.client.permissions.create(**meta)
322
+ return await self._client.permissions.create(**meta)
265
323
 
266
324
  @patch(as_prop=True)
267
325
  async def permissions(self:File):
268
- r = await self.drive.client.permissions.list(file_id=self.id, fields='permissions(id,type,role,emailAddress)')
326
+ r = await self._client.permissions.list(file_id=self.id, fields='permissions(id,type,role,emailAddress)', supports_all_drives=True)
269
327
  return r.permissions
270
328
 
271
329
  @patch
272
330
  async def unshare(self:File, permission_id):
273
331
  "Revoke a permission by id"
274
- return await self.drive.client.permissions.delete(file_id=self.id, permission_id=permission_id)
332
+ return await self._client.permissions.delete(file_id=self.id, permission_id=permission_id, supports_all_drives=True)
@@ -1,12 +1,14 @@
1
- """Load this skill when an agent needs to search, download, and upload Google Drive files using solvedrive. It covers connecting to Drive, searching with Drive's query syntax, downloading file content and exporting Google Docs, and uploading files and creating folders. Organizing, trash, deletion, and sharing are documented for reference but are not enabled by default.
1
+ """Load this skill when an agent needs to search, download, and upload Google Drive files using solvedrive. It covers connecting to Drive, searching across My Drive and shared drives with Drive's query syntax, downloading file content and exporting Google Docs, and uploading files and creating folders. Organizing, trash, deletion, and sharing are documented for reference but are not enabled by default.
2
2
 
3
- Connections use the `Drive` client: `drive = await Drive.init(scopes='readonly')`. Scopes control what the underlying OAuth token may do: `'readonly'` to search and download, `'file'` to also manage the files the app created, or `'full'` for everything. The first connection opens a browser to authorize, then caches the token so later runs don't re-prompt. `await drive.about()` returns the signed-in account, with the address on its `email` attribute.
3
+ Connections use the `GDrive` client: `gd = await GDrive.init(scopes='readonly')`. Scopes control what the underlying OAuth token may do: `'readonly'` to search and download, `'file'` to also manage the files the app created, or `'full'` for everything. The first connection opens a browser to authorize, then caches the token so later runs don't re-prompt. `await gd.about()` returns the signed-in account, with the address on its `email` attribute.
4
4
 
5
- Everything in Drive is a **file**: documents, images, even folders (a folder is a file with a special `mimeType`). solvedrive wraps them in three types:
5
+ Everything in Drive is a **file**: documents, images, even folders (a folder is a file with a special `mimeType`). Files live in drives: your personal My Drive, plus any shared drives you're a member of. solvedrive wraps the API in a handful of types:
6
6
 
7
+ - **GDrive**: the signed-in account, holding auth, `about`, `upload`, `create_folder`, cross-drive `search_files`, and `list_drives`.
8
+ - **Drive**: one drive, either My Drive (id `root`) or a shared drive. It reports your `role`, fetches its `root` folder, and scopes `search_files` to its contents.
7
9
  - **File**: id plus metadata, with content accessed via `download`. The API returns partial resources, so a `File` carries our default fields (`name`, `mimeType`, `size`, `modifiedTime`, `parents`, `trashed`, `webViewLink`); anything else needs `fields=` at search time or `await f.refresh(fields=...)`.
8
10
  - **Folder**: a `File` subclass adding `ls` and `upload` into itself.
9
- - **Files**: a collection of the above with a table repr and batch operations.
11
+ - **Files** and **Drives**: collections of the above with table reprs; `Files` adds batch operations.
10
12
 
11
13
  Reprs render file names as links opening the file in Drive, so include them when reporting results to the user.
12
14
 
@@ -16,11 +18,13 @@ All solvedrive methods are async, so `await` them.
16
18
 
17
19
  Search uses Drive's own query syntax. Common operators: `name = 'report.pdf'`, `name contains 'report'`, `fullText contains 'budget'`, `mimeType = 'application/pdf'`, `mimeType contains 'google-apps'` (Google-native files), `'<folder-id>' in parents`, `'user@example.com' in owners`, and date filters like `modifiedTime > '2026-01-01'`. Combine them with `and`/`or`/`not`.
18
20
 
19
- fs = await drive.search_files("name contains 'report' and trashed=false", max_results=20)
21
+ fs = await gd.search_files("name contains 'report' and trashed=false", max_results=20)
22
+
23
+ `gd.search_files` covers every drive you can see. To search one drive, take a `Drive` from `list_drives` and call its `search_files`. My Drive's scope is the `user` corpus, which also includes files shared directly with you, since the API offers no My-Drive-only scope.
20
24
 
21
25
  Trashed files match too unless you exclude them, so almost every query wants `and trashed=false`.
22
26
 
23
- `folder.ls(q=None)` searches within a folder (already excluding trashed), and `File.fetch(drive, id)` gets one file when its id is already known.
27
+ `folder.ls(q=None)` searches within a folder (already excluding trashed), and `File.fetch(gd, id)` gets one file when its id is already known.
24
28
 
25
29
  Search is keyword-driven and is not proof of absence. If a query comes back empty, try alternate terms (partial names, `fullText contains`, owners, likely parent folders) before concluding something isn't there.
26
30
 
@@ -38,10 +42,14 @@ Search is keyword-driven and is not proof of absence. If a query comes back empt
38
42
 
39
43
  `upload` sends a local path (or bytes plus a `name`) to Drive, returning the new `File`. The content type is guessed from the name unless `mime=` is given, and `folder=` targets a destination (default: My Drive root). Uploads are capped at 5MB.
40
44
 
41
- f = await drive.upload('report.pdf', folder=folder)
42
- f = await drive.upload(data=b'...', name='notes.txt')
45
+ f = await gd.upload('report.pdf', folder=folder)
46
+ f = await gd.upload(data=b'...', name='notes.txt')
47
+
48
+ `await gd.create_folder(name, parent=None)` makes a folder, and `await folder.upload(...)` drops files straight into one. Drive allows duplicate names, so uploading twice makes two files rather than overwriting.
43
49
 
44
- `await drive.create_folder(name, parent=None)` makes a folder, and `await folder.upload(...)` drops files straight into one. Drive allows duplicate names, so uploading twice makes two files rather than overwriting.
50
+ # Drives
51
+
52
+ `await gd.list_drives()` returns a `Drives` table: My Drive first (id `root`, role `owner`), then every shared drive you're a member of. A shared drive belongs to an organization rather than a person. Members hold one role each on the whole drive (`organizer`, `fileOrganizer`, `writer`, `commenter`, or `reader`), files have no owner, and `d.role` reports yours. `await d.root` is an ordinary `Folder`, so its `upload` and `ls` work inside a shared drive like anywhere else. Creating, deleting, and administering shared drives is not wrapped; the raw client (`gd.drives`) reaches those endpoints if the user asks for them.
45
53
 
46
54
  # Organizing (not enabled by default)
47
55
 
@@ -70,11 +78,13 @@ The API returns partial resources: only the default fields are present unless as
70
78
  Searches match trashed files unless the query excludes them with `trashed=false`.
71
79
 
72
80
  Scopes gate what you can do: `'readonly'` can't upload or modify. A permission error usually means the client was created with too narrow a scope.
81
+
82
+ Changes propagate with a small delay: a fresh upload or drive can be missing from a listing or search for a moment, so retry briefly before concluding it's absent.
73
83
  """
74
84
  from pyskills.core import allow
75
- from solvedrive.core import Drive, File, Folder, Files
85
+ from solvedrive.core import GDrive, Drive, File, Folder, Files, Drives
76
86
 
77
- __all__ = ['Drive', 'File', 'Folder', 'Files']
87
+ __all__ = ['GDrive', 'Drive', 'File', 'Folder', 'Files', 'Drives']
78
88
 
79
- allow({Drive: ['about', 'search_files', 'upload', 'create_folder'], File: ['refresh', 'fetch', 'download'],
80
- Folder: ['ls', 'upload'], Files: ['refresh']})
89
+ allow({GDrive: ['about', 'search_files', 'upload', 'create_folder', 'list_drives'], Drive: ['search_files'],
90
+ File: ['refresh', 'fetch', 'download'], Folder: ['ls', 'upload'], Files: ['refresh']})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: solvedrive
3
- Version: 0.0.1
3
+ Version: 0.1.0
4
4
  Summary: Google Drive client built on the Drive API
5
5
  Author-email: Nathan Cooper <nathanacooper@proton.me>
6
6
  License: Apache-2.0
@@ -22,7 +22,7 @@ Dynamic: license-file
22
22
 
23
23
  <!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
24
24
 
25
- solvedrive is an async Python client for Google Drive. It wraps the Drive REST API in a few small classes ([`Drive`](https://answerDotAI.github.io/solvedrive/core.html#drive), [`File`](https://answerDotAI.github.io/solvedrive/core.html#file), [`Folder`](https://answerDotAI.github.io/solvedrive/core.html#folder), and the [`Files`](https://answerDotAI.github.io/solvedrive/core.html#files) collection), so you can upload and download files, search with Drive’s query syntax, export Google Docs, organize with folders, and share, all with plain method calls.
25
+ solvedrive is an async Python client for Google Drive. It wraps the Drive REST API in a few small classes ([`GDrive`](https://answerDotAI.github.io/solvedrive/core.html#gdrive), [`Drive`](https://answerDotAI.github.io/solvedrive/core.html#drive), [`File`](https://answerDotAI.github.io/solvedrive/core.html#file), [`Folder`](https://answerDotAI.github.io/solvedrive/core.html#folder), and their collections), so you can upload and download files, search across My Drive and shared drives, export Google Docs, organize with folders, and share, all with plain method calls.
26
26
 
27
27
  It is built on [fastgws](https://github.com/AnswerDotAI/fastgws) for OAuth and API access, and runs every call asynchronously, so you `await` each one. Searches come back with the useful fields (`name`, `mimeType`, `size`, `parents`, `trashed`, `webViewLink`) already populated in one request, and reprs render file names as links that open the file in Drive.
28
28
 
@@ -38,11 +38,11 @@ $ pip install solvedrive
38
38
 
39
39
  solvedrive signs in with OAuth 2.0 through [fastgws](https://github.com/AnswerDotAI/fastgws), which expects an OAuth client secret at `~/.config/fastgws/credentials.json`. The fastgws docs cover how to create that file from a Google Cloud project. The first connection opens a browser to authorize the scopes you asked for, then caches the token so later runs don’t prompt again.
40
40
 
41
- Create a [`Drive`](https://answerDotAI.github.io/solvedrive/core.html#drive) client with the scopes you need: `readonly` to search and download, `file` to also manage the files your app created, or `full` for everything. `about()` returns the signed-in account, with the address on its `email` attribute.
41
+ Create a [`GDrive`](https://answerDotAI.github.io/solvedrive/core.html#gdrive) client with the scopes you need: `readonly` to search and download, `file` to also manage the files your app created, or `full` for everything. `about()` returns the signed-in account, with the address on its `email` attribute.
42
42
 
43
43
  ``` python
44
- drive = await Drive.init(scopes='full')
45
- about = await drive.about()
44
+ gd = await GDrive.init(scopes='full')
45
+ about = await gd.about()
46
46
  about.email
47
47
  ```
48
48
 
@@ -53,24 +53,24 @@ about.email
53
53
  `upload` sends bytes or a local path to Drive, returning the new [`File`](https://answerDotAI.github.io/solvedrive/core.html#file). Its repr shows the essentials, with the name linking to the file in Drive.
54
54
 
55
55
  ``` python
56
- f = await drive.upload(data=b'hello from solvedrive!', name='solvedrive_hello.txt')
56
+ f = await gd.upload(data=b'hello from solvedrive!', name='solvedrive_hello.txt')
57
57
  f
58
58
  ```
59
59
 
60
- File(1q7Ki1z40Q2Ec5Xl9eEHMDwMfx4lwGw3Q: <a href="https://drive.google.com/file/d/1q7Ki1z40Q2Ec5Xl9eEHMDwMfx4lwGw3Q/view?usp=drivesdk" target="_blank">solvedrive_hello.txt</a> (text/plain, 22B) 2026-07-28T13:48:55.654Z)
60
+ File(1X0jjggHSWBTQbxaLxtsSNqcDW9uIJpQh: <a href="https://drive.google.com/file/d/1X0jjggHSWBTQbxaLxtsSNqcDW9uIJpQh/view?usp=drivesdk" target="_blank">solvedrive_hello.txt</a> (text/plain, 22B) 2026-07-28T21:08:32.734Z)
61
61
 
62
62
  ### Searching
63
63
 
64
- `search_files` takes Drive’s own [query syntax](https://developers.google.com/workspace/drive/api/guides/search-files), the same operators the Drive search box uses, and returns a [`Files`](https://answerDotAI.github.io/solvedrive/core.html#files) collection with a table repr.
64
+ `search_files` takes Drive’s own [query syntax](https://developers.google.com/workspace/drive/api/guides/search-files), the same operators the Drive search box uses, and searches every drive you can see: My Drive, files shared with you, and all shared drives. Results are a [`Files`](https://answerDotAI.github.io/solvedrive/core.html#files) collection with a table repr.
65
65
 
66
66
  ``` python
67
- fs = await drive.search_files("name = 'solvedrive_hello.txt' and trashed=false")
67
+ fs = await gd.search_files("name = 'solvedrive_hello.txt' and trashed=false")
68
68
  fs
69
69
  ```
70
70
 
71
71
  | id | name | type | size | modified |
72
72
  |----|----|----|----|----|
73
- | 1q7Ki1z40Q2Ec5Xl9eEHMDwMfx4lwGw3Q | <a href="https://drive.google.com/file/d/1q7Ki1z40Q2Ec5Xl9eEHMDwMfx4lwGw3Q/view?usp=drivesdk" target="_blank">solvedrive_hello.txt</a> | text/plain | 22B | 2026-07-28 |
73
+ | 1X0jjggHSWBTQbxaLxtsSNqcDW9uIJpQh | <a href="https://drive.google.com/file/d/1X0jjggHSWBTQbxaLxtsSNqcDW9uIJpQh/view?usp=drivesdk" target="_blank">solvedrive_hello.txt</a> | text/plain | 22B | 2026-07-28 |
74
74
 
75
75
  ### Downloading
76
76
 
@@ -87,14 +87,25 @@ await f.download()
87
87
  A folder is a file with a special `mimeType`. `create_folder` makes one, `move` puts files in it, and `ls` lists what it holds.
88
88
 
89
89
  ``` python
90
- folder = await drive.create_folder('solvedrive demo')
90
+ folder = await gd.create_folder('solvedrive demo')
91
91
  await f.move(folder)
92
92
  await folder.ls()
93
93
  ```
94
94
 
95
95
  | id | name | type | size | modified |
96
96
  |----|----|----|----|----|
97
- | 1q7Ki1z40Q2Ec5Xl9eEHMDwMfx4lwGw3Q | <a href="https://drive.google.com/file/d/1q7Ki1z40Q2Ec5Xl9eEHMDwMfx4lwGw3Q/view?usp=drivesdk" target="_blank">solvedrive_hello.txt</a> | text/plain | 22B | 2026-07-28 |
97
+ | 1X0jjggHSWBTQbxaLxtsSNqcDW9uIJpQh | <a href="https://drive.google.com/file/d/1X0jjggHSWBTQbxaLxtsSNqcDW9uIJpQh/view?usp=drivesdk" target="_blank">solvedrive_hello.txt</a> | text/plain | 22B | 2026-07-28 |
98
+
99
+ ### Drives
100
+
101
+ Every file lives in a drive: your My Drive, or a shared drive owned by an organization. `list_drives` returns them as a [`Drives`](https://answerDotAI.github.io/solvedrive/core.html#drives) table, and each [`Drive`](https://answerDotAI.github.io/solvedrive/core.html#drive) knows your role on it and scopes `search_files` to its contents. `drive.root` is an ordinary [`Folder`](https://answerDotAI.github.io/solvedrive/core.html#folder), so uploading into and listing a shared drive works like any folder, and every file method sends `supportsAllDrives`, so a [`File`](https://answerDotAI.github.io/solvedrive/core.html#file) behaves the same wherever it lives.
102
+
103
+ ``` python
104
+ ds = await gd.list_drives()
105
+ ds[0]
106
+ ```
107
+
108
+ Drive(root: <a href="https://drive.google.com/drive/my-drive" target="_blank">My Drive</a>, owner)
98
109
 
99
110
  ### Sharing
100
111
 
@@ -107,7 +118,7 @@ await f.permissions
107
118
 
108
119
  [{'id': 'anyoneWithLink', 'type': 'anyone', 'role': 'reader'}, {'id': '12635610242443046038', 'type': 'user', 'emailAddress': 'nc@answer.ai', 'role': 'owner'}]
109
120
 
110
- There’s more in `solvedrive.core`: renaming and copying, trash versus permanent deletion, and operating on a whole [`Files`](https://answerDotAI.github.io/solvedrive/core.html#files) collection at once through Google’s batch protocol. See the [docs](https://answerDotAI.github.io/solvedrive/) for the full tour.
121
+ There’s more in `solvedrive.core`: working inside shared drives, renaming and copying, trash versus permanent deletion, and operating on a whole [`Files`](https://answerDotAI.github.io/solvedrive/core.html#files) collection at once through Google’s batch protocol. See the [docs](https://answerDotAI.github.io/solvedrive/) for the full tour.
111
122
 
112
123
  ### Use as an LLM skill
113
124
 
@@ -1 +0,0 @@
1
- __version__ = "0.0.1"
File without changes
File without changes
File without changes
File without changes