goodoc 1.0.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.
- goodoc-1.0.0/LICENSE +21 -0
- goodoc-1.0.0/PKG-INFO +139 -0
- goodoc-1.0.0/README.md +104 -0
- goodoc-1.0.0/pyproject.toml +56 -0
- goodoc-1.0.0/setup.cfg +4 -0
- goodoc-1.0.0/src/goodoc/__init__.py +0 -0
- goodoc-1.0.0/src/goodoc/main.py +129 -0
- goodoc-1.0.0/src/goodoc.egg-info/PKG-INFO +139 -0
- goodoc-1.0.0/src/goodoc.egg-info/SOURCES.txt +11 -0
- goodoc-1.0.0/src/goodoc.egg-info/dependency_links.txt +1 -0
- goodoc-1.0.0/src/goodoc.egg-info/entry_points.txt +2 -0
- goodoc-1.0.0/src/goodoc.egg-info/requires.txt +13 -0
- goodoc-1.0.0/src/goodoc.egg-info/top_level.txt +1 -0
goodoc-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Igor Djachenko
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
goodoc-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: goodoc
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Upload office files to Google Drive with auto-conversion to Docs/Sheets/Slides
|
|
5
|
+
Author: Igor Djachenko
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/djachenko/goodoc
|
|
8
|
+
Project-URL: Repository, https://github.com/djachenko/goodoc
|
|
9
|
+
Project-URL: Issues, https://github.com/djachenko/goodoc/issues
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
12
|
+
Classifier: Operating System :: MacOS
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Topic :: Utilities
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: google-auth>=2.0
|
|
24
|
+
Requires-Dist: google-auth-oauthlib>=1.0
|
|
25
|
+
Requires-Dist: google-api-python-client>=2.0
|
|
26
|
+
Requires-Dist: typer>=0.9
|
|
27
|
+
Provides-Extra: test
|
|
28
|
+
Requires-Dist: pytest; extra == "test"
|
|
29
|
+
Requires-Dist: ruff; extra == "test"
|
|
30
|
+
Requires-Dist: mypy; extra == "test"
|
|
31
|
+
Provides-Extra: release
|
|
32
|
+
Requires-Dist: build; extra == "release"
|
|
33
|
+
Requires-Dist: python-semantic-release; extra == "release"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
# goodoc
|
|
37
|
+
|
|
38
|
+
Upload `.docx`, `.xlsx`, and `.pptx` files to Google Drive with automatic conversion to native Google formats (Docs / Sheets / Slides). Integrates into macOS Finder as a right-click Quick Action.
|
|
39
|
+
|
|
40
|
+
**Typical workflow:** got a file to review → right-click → opens in Google Docs. No Word, no drag-and-drop.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Requirements
|
|
45
|
+
|
|
46
|
+
- macOS
|
|
47
|
+
- Python 3.10+
|
|
48
|
+
- [pipx](https://pipx.pypa.io/)
|
|
49
|
+
- A Google Cloud project with **Drive API** enabled and an OAuth 2.0 Desktop credentials file
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pipx install git+https://github.com/djachenko/goodoc.git
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Or clone and install locally:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
git clone https://github.com/djachenko/goodoc.git
|
|
63
|
+
cd goodoc
|
|
64
|
+
pipx install .
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Google Cloud setup
|
|
70
|
+
|
|
71
|
+
1. Go to [console.cloud.google.com](https://console.cloud.google.com) and create or select a project
|
|
72
|
+
2. **APIs & Services → Library** → search for `Google Drive API` → **Enable**
|
|
73
|
+
3. **APIs & Services → Credentials** → **Create Credentials → OAuth 2.0 Client ID**
|
|
74
|
+
- Application type: **Desktop app**
|
|
75
|
+
- Download the JSON file
|
|
76
|
+
4. Place the file at `~/.goodoc/credentials.json`:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
mkdir -p ~/.goodoc
|
|
80
|
+
mv ~/Downloads/client_secret_*.json ~/.goodoc/credentials.json
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
On first run, a browser window will open for Google authorization. The token is saved to `~/.goodoc/token.json` — subsequent runs are silent.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Usage
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
goodoc file.docx # upload and open in browser
|
|
91
|
+
goodoc file.xlsx --no-open # upload without opening
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Supported formats:
|
|
95
|
+
|
|
96
|
+
| Extension | Converts to |
|
|
97
|
+
|---|---|
|
|
98
|
+
| `.docx` | Google Docs |
|
|
99
|
+
| `.xlsx` | Google Sheets |
|
|
100
|
+
| `.pptx` | Google Slides |
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Finder integration (macOS Quick Action)
|
|
105
|
+
|
|
106
|
+
1. Open **Automator** → **New Document** → **Quick Action**
|
|
107
|
+
2. Set **Workflow receives current**: `files or folders` in `Finder`
|
|
108
|
+
3. Add a **Run Shell Script** action, set **Pass input**: `as arguments`
|
|
109
|
+
4. Paste the script:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
for f in "$@"; do
|
|
113
|
+
"$(which goodoc)" "$f"
|
|
114
|
+
done
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
5. **File → Save** → name it `Open in Google Docs`
|
|
118
|
+
|
|
119
|
+
Right-click any `.docx`, `.xlsx`, or `.pptx` in Finder → **Quick Actions → Open in Google Docs**.
|
|
120
|
+
|
|
121
|
+
> If `which goodoc` doesn't work in Automator, replace it with the full path from `which goodoc` in your terminal (e.g. `/Users/you/.local/bin/goodoc`).
|
|
122
|
+
|
|
123
|
+
> If the action doesn't appear in the menu: Finder → **Finder menu → Services → Services Preferences…** → find `Open in Google Docs` and enable it.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Revoking access
|
|
128
|
+
|
|
129
|
+
To re-authorize, delete the token:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
rm ~/.goodoc/token.json
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
MIT
|
goodoc-1.0.0/README.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# goodoc
|
|
2
|
+
|
|
3
|
+
Upload `.docx`, `.xlsx`, and `.pptx` files to Google Drive with automatic conversion to native Google formats (Docs / Sheets / Slides). Integrates into macOS Finder as a right-click Quick Action.
|
|
4
|
+
|
|
5
|
+
**Typical workflow:** got a file to review → right-click → opens in Google Docs. No Word, no drag-and-drop.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Requirements
|
|
10
|
+
|
|
11
|
+
- macOS
|
|
12
|
+
- Python 3.10+
|
|
13
|
+
- [pipx](https://pipx.pypa.io/)
|
|
14
|
+
- A Google Cloud project with **Drive API** enabled and an OAuth 2.0 Desktop credentials file
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pipx install git+https://github.com/djachenko/goodoc.git
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or clone and install locally:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
git clone https://github.com/djachenko/goodoc.git
|
|
28
|
+
cd goodoc
|
|
29
|
+
pipx install .
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Google Cloud setup
|
|
35
|
+
|
|
36
|
+
1. Go to [console.cloud.google.com](https://console.cloud.google.com) and create or select a project
|
|
37
|
+
2. **APIs & Services → Library** → search for `Google Drive API` → **Enable**
|
|
38
|
+
3. **APIs & Services → Credentials** → **Create Credentials → OAuth 2.0 Client ID**
|
|
39
|
+
- Application type: **Desktop app**
|
|
40
|
+
- Download the JSON file
|
|
41
|
+
4. Place the file at `~/.goodoc/credentials.json`:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
mkdir -p ~/.goodoc
|
|
45
|
+
mv ~/Downloads/client_secret_*.json ~/.goodoc/credentials.json
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
On first run, a browser window will open for Google authorization. The token is saved to `~/.goodoc/token.json` — subsequent runs are silent.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
goodoc file.docx # upload and open in browser
|
|
56
|
+
goodoc file.xlsx --no-open # upload without opening
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Supported formats:
|
|
60
|
+
|
|
61
|
+
| Extension | Converts to |
|
|
62
|
+
|---|---|
|
|
63
|
+
| `.docx` | Google Docs |
|
|
64
|
+
| `.xlsx` | Google Sheets |
|
|
65
|
+
| `.pptx` | Google Slides |
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Finder integration (macOS Quick Action)
|
|
70
|
+
|
|
71
|
+
1. Open **Automator** → **New Document** → **Quick Action**
|
|
72
|
+
2. Set **Workflow receives current**: `files or folders` in `Finder`
|
|
73
|
+
3. Add a **Run Shell Script** action, set **Pass input**: `as arguments`
|
|
74
|
+
4. Paste the script:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
for f in "$@"; do
|
|
78
|
+
"$(which goodoc)" "$f"
|
|
79
|
+
done
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
5. **File → Save** → name it `Open in Google Docs`
|
|
83
|
+
|
|
84
|
+
Right-click any `.docx`, `.xlsx`, or `.pptx` in Finder → **Quick Actions → Open in Google Docs**.
|
|
85
|
+
|
|
86
|
+
> If `which goodoc` doesn't work in Automator, replace it with the full path from `which goodoc` in your terminal (e.g. `/Users/you/.local/bin/goodoc`).
|
|
87
|
+
|
|
88
|
+
> If the action doesn't appear in the menu: Finder → **Finder menu → Services → Services Preferences…** → find `Open in Google Docs` and enable it.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Revoking access
|
|
93
|
+
|
|
94
|
+
To re-authorize, delete the token:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
rm ~/.goodoc/token.json
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
MIT
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77.0.3"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "goodoc"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Upload office files to Google Drive with auto-conversion to Docs/Sheets/Slides"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
authors = [{ name = "Igor Djachenko" }]
|
|
13
|
+
requires-python = ">=3.10"
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: End Users/Desktop",
|
|
17
|
+
"Operating System :: MacOS",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Programming Language :: Python :: 3.14",
|
|
24
|
+
"Topic :: Utilities",
|
|
25
|
+
]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"google-auth>=2.0",
|
|
28
|
+
"google-auth-oauthlib>=1.0",
|
|
29
|
+
"google-api-python-client>=2.0",
|
|
30
|
+
"typer>=0.9",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.optional-dependencies]
|
|
34
|
+
test = ["pytest", "ruff", "mypy"]
|
|
35
|
+
release = ["build", "python-semantic-release"]
|
|
36
|
+
|
|
37
|
+
[tool.setuptools.packages.find]
|
|
38
|
+
where = ["src"]
|
|
39
|
+
|
|
40
|
+
[project.urls]
|
|
41
|
+
Homepage = "https://github.com/djachenko/goodoc"
|
|
42
|
+
Repository = "https://github.com/djachenko/goodoc"
|
|
43
|
+
Issues = "https://github.com/djachenko/goodoc/issues"
|
|
44
|
+
|
|
45
|
+
[project.scripts]
|
|
46
|
+
goodoc = "goodoc.main:app"
|
|
47
|
+
|
|
48
|
+
[tool.mypy]
|
|
49
|
+
ignore_missing_imports = true
|
|
50
|
+
|
|
51
|
+
[tool.semantic_release]
|
|
52
|
+
version_toml = ["pyproject.toml:project.version"]
|
|
53
|
+
branch = "master"
|
|
54
|
+
build_command = "pip install build && python -m build"
|
|
55
|
+
changelog_file = "CHANGELOG.md"
|
|
56
|
+
commit_message = "chore(release): v{version} [skip ci]"
|
goodoc-1.0.0/setup.cfg
ADDED
|
File without changes
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
goodoc — uploads office files to Google Drive with conversion, opens in browser.
|
|
4
|
+
|
|
5
|
+
Supported formats:
|
|
6
|
+
.docx → Google Docs
|
|
7
|
+
.xlsx → Google Sheets
|
|
8
|
+
.pptx → Google Slides
|
|
9
|
+
|
|
10
|
+
Credentials: ~/.goodoc/credentials.json
|
|
11
|
+
Token: ~/.goodoc/token.json
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
goodoc file.docx
|
|
15
|
+
goodoc file.xlsx --no-open
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
|
|
20
|
+
import typer
|
|
21
|
+
import webbrowser
|
|
22
|
+
from google.auth.transport.requests import Request
|
|
23
|
+
from google.oauth2.credentials import Credentials
|
|
24
|
+
from google_auth_oauthlib.flow import InstalledAppFlow
|
|
25
|
+
from googleapiclient.discovery import build
|
|
26
|
+
from googleapiclient.http import MediaFileUpload
|
|
27
|
+
|
|
28
|
+
SCOPES = ["https://www.googleapis.com/auth/drive.file"]
|
|
29
|
+
|
|
30
|
+
GOODOC_DIR = Path.home() / ".goodoc"
|
|
31
|
+
CREDENTIALS_PATH = GOODOC_DIR / "credentials.json"
|
|
32
|
+
TOKEN_PATH = GOODOC_DIR / "token.json"
|
|
33
|
+
|
|
34
|
+
MIME_MAP = {
|
|
35
|
+
".docx": (
|
|
36
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
37
|
+
"application/vnd.google-apps.document",
|
|
38
|
+
),
|
|
39
|
+
".xlsx": (
|
|
40
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
41
|
+
"application/vnd.google-apps.spreadsheet",
|
|
42
|
+
),
|
|
43
|
+
".pptx": (
|
|
44
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
45
|
+
"application/vnd.google-apps.presentation",
|
|
46
|
+
),
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
app = typer.Typer(add_completion=False)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def get_credentials() -> Credentials:
|
|
53
|
+
if not CREDENTIALS_PATH.exists():
|
|
54
|
+
typer.echo(f"credentials.json not found: {CREDENTIALS_PATH}", err=True)
|
|
55
|
+
typer.echo("Place your OAuth credentials from Google Cloud Console at ~/.goodoc/credentials.json", err=True)
|
|
56
|
+
|
|
57
|
+
raise typer.Exit(1)
|
|
58
|
+
|
|
59
|
+
TOKEN_PATH.parent.mkdir(parents=True, exist_ok=True)
|
|
60
|
+
|
|
61
|
+
creds = None
|
|
62
|
+
|
|
63
|
+
if TOKEN_PATH.exists():
|
|
64
|
+
creds = Credentials.from_authorized_user_file(str(TOKEN_PATH), SCOPES)
|
|
65
|
+
|
|
66
|
+
if not creds or not creds.valid:
|
|
67
|
+
if creds and creds.expired and creds.refresh_token:
|
|
68
|
+
creds.refresh(Request())
|
|
69
|
+
else:
|
|
70
|
+
flow = InstalledAppFlow.from_client_secrets_file(str(CREDENTIALS_PATH), SCOPES)
|
|
71
|
+
creds = flow.run_local_server(port=0)
|
|
72
|
+
|
|
73
|
+
with TOKEN_PATH.open("w") as f:
|
|
74
|
+
f.write(creds.to_json())
|
|
75
|
+
|
|
76
|
+
return creds
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def upload(path: Path, creds: Credentials) -> str:
|
|
80
|
+
suffix = path.suffix.lower()
|
|
81
|
+
|
|
82
|
+
if suffix not in MIME_MAP:
|
|
83
|
+
supported = ", ".join(MIME_MAP)
|
|
84
|
+
typer.echo(f"Unsupported format: {suffix}. Supported: {supported}", err=True)
|
|
85
|
+
|
|
86
|
+
raise typer.Exit(1)
|
|
87
|
+
|
|
88
|
+
source_mime, target_mime = MIME_MAP[suffix]
|
|
89
|
+
|
|
90
|
+
service = build("drive", "v3", credentials=creds)
|
|
91
|
+
|
|
92
|
+
media = MediaFileUpload(str(path), mimetype=source_mime, resumable=False)
|
|
93
|
+
|
|
94
|
+
result = (
|
|
95
|
+
service.files()
|
|
96
|
+
.create(
|
|
97
|
+
body={"name": path.stem, "mimeType": target_mime},
|
|
98
|
+
media_body=media,
|
|
99
|
+
fields="id,webViewLink",
|
|
100
|
+
)
|
|
101
|
+
.execute()
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
return result["webViewLink"]
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
@app.command()
|
|
108
|
+
def main(
|
|
109
|
+
file: Path = typer.Argument(..., help="Path to file (.docx / .xlsx / .pptx)"),
|
|
110
|
+
no_open: bool = typer.Option(False, "--no-open", help="Do not open in browser"),
|
|
111
|
+
) -> None:
|
|
112
|
+
if not file.exists():
|
|
113
|
+
typer.echo(f"File not found: {file}", err=True)
|
|
114
|
+
|
|
115
|
+
raise typer.Exit(1)
|
|
116
|
+
|
|
117
|
+
typer.echo(f"Uploading {file.name}...")
|
|
118
|
+
|
|
119
|
+
creds = get_credentials()
|
|
120
|
+
url = upload(file, creds)
|
|
121
|
+
|
|
122
|
+
typer.echo(url)
|
|
123
|
+
|
|
124
|
+
if not no_open:
|
|
125
|
+
webbrowser.open(url)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
if __name__ == "__main__":
|
|
129
|
+
app()
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: goodoc
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Upload office files to Google Drive with auto-conversion to Docs/Sheets/Slides
|
|
5
|
+
Author: Igor Djachenko
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/djachenko/goodoc
|
|
8
|
+
Project-URL: Repository, https://github.com/djachenko/goodoc
|
|
9
|
+
Project-URL: Issues, https://github.com/djachenko/goodoc/issues
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
12
|
+
Classifier: Operating System :: MacOS
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Topic :: Utilities
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: google-auth>=2.0
|
|
24
|
+
Requires-Dist: google-auth-oauthlib>=1.0
|
|
25
|
+
Requires-Dist: google-api-python-client>=2.0
|
|
26
|
+
Requires-Dist: typer>=0.9
|
|
27
|
+
Provides-Extra: test
|
|
28
|
+
Requires-Dist: pytest; extra == "test"
|
|
29
|
+
Requires-Dist: ruff; extra == "test"
|
|
30
|
+
Requires-Dist: mypy; extra == "test"
|
|
31
|
+
Provides-Extra: release
|
|
32
|
+
Requires-Dist: build; extra == "release"
|
|
33
|
+
Requires-Dist: python-semantic-release; extra == "release"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
# goodoc
|
|
37
|
+
|
|
38
|
+
Upload `.docx`, `.xlsx`, and `.pptx` files to Google Drive with automatic conversion to native Google formats (Docs / Sheets / Slides). Integrates into macOS Finder as a right-click Quick Action.
|
|
39
|
+
|
|
40
|
+
**Typical workflow:** got a file to review → right-click → opens in Google Docs. No Word, no drag-and-drop.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Requirements
|
|
45
|
+
|
|
46
|
+
- macOS
|
|
47
|
+
- Python 3.10+
|
|
48
|
+
- [pipx](https://pipx.pypa.io/)
|
|
49
|
+
- A Google Cloud project with **Drive API** enabled and an OAuth 2.0 Desktop credentials file
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pipx install git+https://github.com/djachenko/goodoc.git
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Or clone and install locally:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
git clone https://github.com/djachenko/goodoc.git
|
|
63
|
+
cd goodoc
|
|
64
|
+
pipx install .
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Google Cloud setup
|
|
70
|
+
|
|
71
|
+
1. Go to [console.cloud.google.com](https://console.cloud.google.com) and create or select a project
|
|
72
|
+
2. **APIs & Services → Library** → search for `Google Drive API` → **Enable**
|
|
73
|
+
3. **APIs & Services → Credentials** → **Create Credentials → OAuth 2.0 Client ID**
|
|
74
|
+
- Application type: **Desktop app**
|
|
75
|
+
- Download the JSON file
|
|
76
|
+
4. Place the file at `~/.goodoc/credentials.json`:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
mkdir -p ~/.goodoc
|
|
80
|
+
mv ~/Downloads/client_secret_*.json ~/.goodoc/credentials.json
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
On first run, a browser window will open for Google authorization. The token is saved to `~/.goodoc/token.json` — subsequent runs are silent.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Usage
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
goodoc file.docx # upload and open in browser
|
|
91
|
+
goodoc file.xlsx --no-open # upload without opening
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Supported formats:
|
|
95
|
+
|
|
96
|
+
| Extension | Converts to |
|
|
97
|
+
|---|---|
|
|
98
|
+
| `.docx` | Google Docs |
|
|
99
|
+
| `.xlsx` | Google Sheets |
|
|
100
|
+
| `.pptx` | Google Slides |
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Finder integration (macOS Quick Action)
|
|
105
|
+
|
|
106
|
+
1. Open **Automator** → **New Document** → **Quick Action**
|
|
107
|
+
2. Set **Workflow receives current**: `files or folders` in `Finder`
|
|
108
|
+
3. Add a **Run Shell Script** action, set **Pass input**: `as arguments`
|
|
109
|
+
4. Paste the script:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
for f in "$@"; do
|
|
113
|
+
"$(which goodoc)" "$f"
|
|
114
|
+
done
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
5. **File → Save** → name it `Open in Google Docs`
|
|
118
|
+
|
|
119
|
+
Right-click any `.docx`, `.xlsx`, or `.pptx` in Finder → **Quick Actions → Open in Google Docs**.
|
|
120
|
+
|
|
121
|
+
> If `which goodoc` doesn't work in Automator, replace it with the full path from `which goodoc` in your terminal (e.g. `/Users/you/.local/bin/goodoc`).
|
|
122
|
+
|
|
123
|
+
> If the action doesn't appear in the menu: Finder → **Finder menu → Services → Services Preferences…** → find `Open in Google Docs` and enable it.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Revoking access
|
|
128
|
+
|
|
129
|
+
To re-authorize, delete the token:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
rm ~/.goodoc/token.json
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
MIT
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/goodoc/__init__.py
|
|
5
|
+
src/goodoc/main.py
|
|
6
|
+
src/goodoc.egg-info/PKG-INFO
|
|
7
|
+
src/goodoc.egg-info/SOURCES.txt
|
|
8
|
+
src/goodoc.egg-info/dependency_links.txt
|
|
9
|
+
src/goodoc.egg-info/entry_points.txt
|
|
10
|
+
src/goodoc.egg-info/requires.txt
|
|
11
|
+
src/goodoc.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
goodoc
|