officecli-sdk 0.1.0__tar.gz → 0.1.2__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.
- {officecli_sdk-0.1.0/officecli_sdk.egg-info → officecli_sdk-0.1.2}/PKG-INFO +18 -4
- officecli_sdk-0.1.0/PKG-INFO → officecli_sdk-0.1.2/README.md +15 -16
- {officecli_sdk-0.1.0 → officecli_sdk-0.1.2}/officecli.py +58 -3
- officecli_sdk-0.1.0/README.md → officecli_sdk-0.1.2/officecli_sdk.egg-info/PKG-INFO +30 -3
- {officecli_sdk-0.1.0 → officecli_sdk-0.1.2}/pyproject.toml +7 -7
- {officecli_sdk-0.1.0 → officecli_sdk-0.1.2}/officecli_sdk.egg-info/SOURCES.txt +0 -0
- {officecli_sdk-0.1.0 → officecli_sdk-0.1.2}/officecli_sdk.egg-info/dependency_links.txt +0 -0
- {officecli_sdk-0.1.0 → officecli_sdk-0.1.2}/officecli_sdk.egg-info/top_level.txt +0 -0
- {officecli_sdk-0.1.0 → officecli_sdk-0.1.2}/setup.cfg +0 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: officecli-sdk
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: Thin Python SDK for the officecli resident pipe — forwards officecli commands to a running resident, no per-command process spawn.
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://officecli.ai
|
|
7
|
+
Project-URL: Repository, https://github.com/iOfficeAI/OfficeCLI
|
|
6
8
|
Keywords: officecli,office,docx,xlsx,pptx,ooxml
|
|
7
9
|
Classifier: Programming Language :: Python :: 3
|
|
8
10
|
Classifier: Operating System :: MacOS
|
|
@@ -13,7 +15,7 @@ Description-Content-Type: text/markdown
|
|
|
13
15
|
|
|
14
16
|
# officecli — Python SDK
|
|
15
17
|
|
|
16
|
-
A **thin** Python SDK for the [officecli](
|
|
18
|
+
A **thin** Python SDK for the [officecli](https://officecli.ai) **resident pipe**. It does one
|
|
17
19
|
thing: forward an officecli command to a running resident over its named pipe and
|
|
18
20
|
hand back the response — no per-command process spawn, so a loop of edits is
|
|
19
21
|
~hundreds of times faster than shelling out to the CLI per command.
|
|
@@ -30,8 +32,20 @@ the day they ship without an SDK update.
|
|
|
30
32
|
|
|
31
33
|
`pip install officecli-sdk` installs **only this SDK** (the Python library). It
|
|
32
34
|
shells out to the `officecli` binary, which must be installed separately and on
|
|
33
|
-
your `PATH
|
|
34
|
-
|
|
35
|
+
your `PATH`. If `officecli --version` works in your shell you're set; otherwise
|
|
36
|
+
the SDK raises a clear error pointing here (never a cryptic `FileNotFoundError`).
|
|
37
|
+
|
|
38
|
+
Install the CLI once:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
python -m officecli install # runs officecli's official installer
|
|
42
|
+
# …or directly:
|
|
43
|
+
curl -fsSL https://raw.githubusercontent.com/iOfficeAI/OfficeCLI/main/install.sh | bash
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`officecli.install()` does the same from Python. Installation is always
|
|
47
|
+
**explicit** — the SDK never auto-downloads the binary behind your back. (Not on
|
|
48
|
+
Windows: grab it from [GitHub Releases](https://github.com/iOfficeAI/OfficeCLI/releases).)
|
|
35
49
|
|
|
36
50
|
## Install
|
|
37
51
|
|
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: officecli-sdk
|
|
3
|
-
Version: 0.1.0
|
|
4
|
-
Summary: Thin Python SDK for the officecli resident pipe — forwards officecli commands to a running resident, no per-command process spawn.
|
|
5
|
-
License-Expression: Apache-2.0
|
|
6
|
-
Keywords: officecli,office,docx,xlsx,pptx,ooxml
|
|
7
|
-
Classifier: Programming Language :: Python :: 3
|
|
8
|
-
Classifier: Operating System :: MacOS
|
|
9
|
-
Classifier: Operating System :: POSIX :: Linux
|
|
10
|
-
Classifier: Operating System :: Microsoft :: Windows
|
|
11
|
-
Requires-Python: >=3.8
|
|
12
|
-
Description-Content-Type: text/markdown
|
|
13
|
-
|
|
14
1
|
# officecli — Python SDK
|
|
15
2
|
|
|
16
|
-
A **thin** Python SDK for the [officecli](
|
|
3
|
+
A **thin** Python SDK for the [officecli](https://officecli.ai) **resident pipe**. It does one
|
|
17
4
|
thing: forward an officecli command to a running resident over its named pipe and
|
|
18
5
|
hand back the response — no per-command process spawn, so a loop of edits is
|
|
19
6
|
~hundreds of times faster than shelling out to the CLI per command.
|
|
@@ -30,8 +17,20 @@ the day they ship without an SDK update.
|
|
|
30
17
|
|
|
31
18
|
`pip install officecli-sdk` installs **only this SDK** (the Python library). It
|
|
32
19
|
shells out to the `officecli` binary, which must be installed separately and on
|
|
33
|
-
your `PATH
|
|
34
|
-
|
|
20
|
+
your `PATH`. If `officecli --version` works in your shell you're set; otherwise
|
|
21
|
+
the SDK raises a clear error pointing here (never a cryptic `FileNotFoundError`).
|
|
22
|
+
|
|
23
|
+
Install the CLI once:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
python -m officecli install # runs officecli's official installer
|
|
27
|
+
# …or directly:
|
|
28
|
+
curl -fsSL https://raw.githubusercontent.com/iOfficeAI/OfficeCLI/main/install.sh | bash
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`officecli.install()` does the same from Python. Installation is always
|
|
32
|
+
**explicit** — the SDK never auto-downloads the binary behind your back. (Not on
|
|
33
|
+
Windows: grab it from [GitHub Releases](https://github.com/iOfficeAI/OfficeCLI/releases).)
|
|
35
34
|
|
|
36
35
|
## Install
|
|
37
36
|
|
|
@@ -62,6 +62,17 @@ _IS_WIN = sys.platform.startswith("win")
|
|
|
62
62
|
_IS_MAC = sys.platform == "darwin"
|
|
63
63
|
_builtin_open = open # preserved; this module defines its own open() below
|
|
64
64
|
|
|
65
|
+
# officecli's official installer (README one-liner). install() shells out to it;
|
|
66
|
+
# the missing-CLI error points users at it / at install().
|
|
67
|
+
_INSTALL_URL = "https://raw.githubusercontent.com/iOfficeAI/OfficeCLI/main/install.sh"
|
|
68
|
+
_MISSING_CLI = (
|
|
69
|
+
"officecli CLI not found: {bin!r} is not on PATH. This SDK only forwards "
|
|
70
|
+
"commands to the officecli binary, which must be installed separately. Install it:\n"
|
|
71
|
+
" python -m officecli install # runs the official installer\n"
|
|
72
|
+
" # or: curl -fsSL " + _INSTALL_URL + " | bash\n"
|
|
73
|
+
"Already installed elsewhere? pass binary=\"/path/to/officecli\"."
|
|
74
|
+
)
|
|
75
|
+
|
|
65
76
|
|
|
66
77
|
class OfficeCliError(Exception):
|
|
67
78
|
"""Raised on transport/process failure (could not reach the resident).
|
|
@@ -218,6 +229,15 @@ def _serves(ping_path, full_path, timeout=1.0):
|
|
|
218
229
|
return a == full_path or ((_IS_MAC or _IS_WIN) and a.lower() == full_path.lower())
|
|
219
230
|
|
|
220
231
|
|
|
232
|
+
def _run_cli(binary, argv):
|
|
233
|
+
"""Run `binary <argv...>` (capturing output). A missing binary surfaces as a
|
|
234
|
+
clear OfficeCliError with install guidance, not a raw FileNotFoundError."""
|
|
235
|
+
try:
|
|
236
|
+
return subprocess.run([binary, *argv], capture_output=True, text=True)
|
|
237
|
+
except FileNotFoundError:
|
|
238
|
+
raise OfficeCliError(127, _MISSING_CLI.format(bin=binary)) from None
|
|
239
|
+
|
|
240
|
+
|
|
221
241
|
# ---------------------------------------------------------------- the shell
|
|
222
242
|
class Document:
|
|
223
243
|
def __init__(self, path, binary="officecli", timeout=30.0):
|
|
@@ -240,7 +260,7 @@ class Document:
|
|
|
240
260
|
return
|
|
241
261
|
# Otherwise spawn `officecli open` (one process). It's idempotent and uses
|
|
242
262
|
# the same TryConnect to start a fresh resident or replace a stale socket.
|
|
243
|
-
r =
|
|
263
|
+
r = _run_cli(self.bin, ["open", self.path])
|
|
244
264
|
if r.returncode != 0:
|
|
245
265
|
raise OfficeCliError(r.returncode, r.stderr or r.stdout)
|
|
246
266
|
|
|
@@ -370,7 +390,7 @@ def create(path, *args, binary="officecli", timeout=30.0):
|
|
|
370
390
|
another owner's active session.
|
|
371
391
|
• file exists without --force → file_exists (pass "--force" to overwrite)."""
|
|
372
392
|
full = os.path.abspath(path)
|
|
373
|
-
r =
|
|
393
|
+
r = _run_cli(binary, ["create", full, *args])
|
|
374
394
|
if r.returncode != 0:
|
|
375
395
|
raise OfficeCliError(r.returncode, r.stderr or r.stdout)
|
|
376
396
|
# create auto-started a resident for the new file; bind a handle to it
|
|
@@ -402,6 +422,41 @@ def open(path, binary="officecli", timeout=30.0):
|
|
|
402
422
|
return Document(path, binary=binary, timeout=timeout)
|
|
403
423
|
|
|
404
424
|
|
|
425
|
+
def install():
|
|
426
|
+
"""Install the officecli CLI binary via its OFFICIAL installer — explicit by
|
|
427
|
+
design (this SDK never auto-downloads a binary behind your back). Reuses
|
|
428
|
+
officecli's own install.sh (platform detection + checksum + ~/.local/bin),
|
|
429
|
+
rather than reimplementing download logic that would drift from upstream.
|
|
430
|
+
|
|
431
|
+
Equivalent to `python -m officecli install`, or the README one-liner
|
|
432
|
+
`curl -fsSL <install.sh> | bash`. Returns None on success; raises
|
|
433
|
+
OfficeCliError on failure. Not supported on Windows (install.sh needs bash) —
|
|
434
|
+
download from GitHub Releases and put officecli on PATH instead."""
|
|
435
|
+
if _IS_WIN:
|
|
436
|
+
raise OfficeCliError(1,
|
|
437
|
+
"Automatic install isn't supported on Windows (install.sh needs bash). "
|
|
438
|
+
"Download officecli from https://github.com/iOfficeAI/OfficeCLI/releases "
|
|
439
|
+
"and put it on PATH.")
|
|
440
|
+
print(f"Installing officecli via {_INSTALL_URL} ...", file=sys.stderr)
|
|
441
|
+
# Reuse the official installer verbatim; do NOT capture, so its progress and
|
|
442
|
+
# checksum output stream to the user (this is an explicit, interactive action).
|
|
443
|
+
r = subprocess.run(["bash", "-c", f"curl -fsSL {_INSTALL_URL} | bash"])
|
|
444
|
+
if r.returncode != 0:
|
|
445
|
+
raise OfficeCliError(r.returncode,
|
|
446
|
+
f"officecli install failed (exit {r.returncode}). Run manually:\n"
|
|
447
|
+
f" curl -fsSL {_INSTALL_URL} | bash")
|
|
448
|
+
return None
|
|
449
|
+
|
|
450
|
+
|
|
405
451
|
# Advertised surface = the command shell + its error. pipe_paths stays importable
|
|
406
452
|
# (officecli.pipe_paths) as a debug helper but isn't part of the command API.
|
|
407
|
-
__all__ = ["open", "create", "Document", "OfficeCliError"]
|
|
453
|
+
__all__ = ["open", "create", "install", "Document", "OfficeCliError"]
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
if __name__ == "__main__":
|
|
457
|
+
# `python -m officecli install` — bootstrap the CLI binary.
|
|
458
|
+
if len(sys.argv) >= 2 and sys.argv[1] == "install":
|
|
459
|
+
install()
|
|
460
|
+
else:
|
|
461
|
+
print("usage: python -m officecli install", file=sys.stderr)
|
|
462
|
+
sys.exit(2)
|
|
@@ -1,6 +1,21 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: officecli-sdk
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Thin Python SDK for the officecli resident pipe — forwards officecli commands to a running resident, no per-command process spawn.
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://officecli.ai
|
|
7
|
+
Project-URL: Repository, https://github.com/iOfficeAI/OfficeCLI
|
|
8
|
+
Keywords: officecli,office,docx,xlsx,pptx,ooxml
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: MacOS
|
|
11
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
12
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
13
|
+
Requires-Python: >=3.8
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
1
16
|
# officecli — Python SDK
|
|
2
17
|
|
|
3
|
-
A **thin** Python SDK for the [officecli](
|
|
18
|
+
A **thin** Python SDK for the [officecli](https://officecli.ai) **resident pipe**. It does one
|
|
4
19
|
thing: forward an officecli command to a running resident over its named pipe and
|
|
5
20
|
hand back the response — no per-command process spawn, so a loop of edits is
|
|
6
21
|
~hundreds of times faster than shelling out to the CLI per command.
|
|
@@ -17,8 +32,20 @@ the day they ship without an SDK update.
|
|
|
17
32
|
|
|
18
33
|
`pip install officecli-sdk` installs **only this SDK** (the Python library). It
|
|
19
34
|
shells out to the `officecli` binary, which must be installed separately and on
|
|
20
|
-
your `PATH
|
|
21
|
-
|
|
35
|
+
your `PATH`. If `officecli --version` works in your shell you're set; otherwise
|
|
36
|
+
the SDK raises a clear error pointing here (never a cryptic `FileNotFoundError`).
|
|
37
|
+
|
|
38
|
+
Install the CLI once:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
python -m officecli install # runs officecli's official installer
|
|
42
|
+
# …or directly:
|
|
43
|
+
curl -fsSL https://raw.githubusercontent.com/iOfficeAI/OfficeCLI/main/install.sh | bash
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`officecli.install()` does the same from Python. Installation is always
|
|
47
|
+
**explicit** — the SDK never auto-downloads the binary behind your back. (Not on
|
|
48
|
+
Windows: grab it from [GitHub Releases](https://github.com/iOfficeAI/OfficeCLI/releases).)
|
|
22
49
|
|
|
23
50
|
## Install
|
|
24
51
|
|
|
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
|
|
|
7
7
|
# (`import officecli`), like `pip install pillow` → `import PIL`. PyPI rejects
|
|
8
8
|
# the bare name "officecli" as too similar to the unrelated "office-cli" project.
|
|
9
9
|
name = "officecli-sdk"
|
|
10
|
-
version = "0.1.
|
|
10
|
+
version = "0.1.2"
|
|
11
11
|
description = "Thin Python SDK for the officecli resident pipe — forwards officecli commands to a running resident, no per-command process spawn."
|
|
12
12
|
readme = "README.md"
|
|
13
13
|
requires-python = ">=3.8"
|
|
@@ -20,13 +20,13 @@ classifiers = [
|
|
|
20
20
|
"Operating System :: POSIX :: Linux",
|
|
21
21
|
"Operating System :: Microsoft :: Windows",
|
|
22
22
|
]
|
|
23
|
-
# TODO(maintainer):
|
|
24
|
-
# authors = [{ name = "...", email = "..." }]
|
|
25
|
-
# [project.urls]
|
|
26
|
-
# Homepage = "..."
|
|
27
|
-
# Repository = "..."
|
|
23
|
+
# TODO(maintainer): optionally add authors = [{ name = "...", email = "..." }] above.
|
|
28
24
|
|
|
29
|
-
|
|
25
|
+
[project.urls]
|
|
26
|
+
Homepage = "https://officecli.ai"
|
|
27
|
+
Repository = "https://github.com/iOfficeAI/OfficeCLI"
|
|
28
|
+
|
|
29
|
+
# IMPORTANT: this package is only the SDK. It shells out to the `officecli`
|
|
30
30
|
# CLI binary, which must be installed separately and on PATH (Homebrew, etc.).
|
|
31
31
|
# pip cannot install that binary for you — see README.
|
|
32
32
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|