pyzotero 1.7.1__py3-none-any.whl → 1.7.3__py3-none-any.whl
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.
- pyzotero/cli.py +50 -2
- {pyzotero-1.7.1.dist-info → pyzotero-1.7.3.dist-info}/METADATA +2 -2
- {pyzotero-1.7.1.dist-info → pyzotero-1.7.3.dist-info}/RECORD +5 -5
- {pyzotero-1.7.1.dist-info → pyzotero-1.7.3.dist-info}/WHEEL +0 -0
- {pyzotero-1.7.1.dist-info → pyzotero-1.7.3.dist-info}/entry_points.txt +0 -0
pyzotero/cli.py
CHANGED
|
@@ -4,8 +4,9 @@ import json
|
|
|
4
4
|
import sys
|
|
5
5
|
|
|
6
6
|
import click
|
|
7
|
+
import httpx
|
|
7
8
|
|
|
8
|
-
from pyzotero import zotero
|
|
9
|
+
from pyzotero import __version__, zotero
|
|
9
10
|
from pyzotero.zotero import chunks
|
|
10
11
|
|
|
11
12
|
|
|
@@ -15,6 +16,7 @@ def _get_zotero_client(locale="en-US"):
|
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
@click.group()
|
|
19
|
+
@click.version_option(version=__version__, prog_name="pyzotero")
|
|
18
20
|
@click.option(
|
|
19
21
|
"--locale",
|
|
20
22
|
default="en-US",
|
|
@@ -210,7 +212,11 @@ def search(ctx, query, fulltext, itemtype, collection, limit, output_json): # n
|
|
|
210
212
|
|
|
211
213
|
# Output results
|
|
212
214
|
if output_json:
|
|
213
|
-
click.echo(
|
|
215
|
+
click.echo(
|
|
216
|
+
json.dumps(
|
|
217
|
+
{"count": len(output_items), "items": output_items}, indent=2
|
|
218
|
+
)
|
|
219
|
+
)
|
|
214
220
|
else:
|
|
215
221
|
click.echo(f"\nFound {len(results)} items:\n")
|
|
216
222
|
for idx, item_obj in enumerate(output_items, 1):
|
|
@@ -348,5 +354,47 @@ def itemtypes(ctx):
|
|
|
348
354
|
sys.exit(1)
|
|
349
355
|
|
|
350
356
|
|
|
357
|
+
@main.command()
|
|
358
|
+
@click.pass_context
|
|
359
|
+
def test(ctx):
|
|
360
|
+
"""Test connection to local Zotero instance.
|
|
361
|
+
|
|
362
|
+
This command checks whether Zotero is running and accepting local connections.
|
|
363
|
+
|
|
364
|
+
Examples:
|
|
365
|
+
pyzotero test
|
|
366
|
+
|
|
367
|
+
"""
|
|
368
|
+
try:
|
|
369
|
+
locale = ctx.obj.get("locale", "en-US")
|
|
370
|
+
zot = _get_zotero_client(locale)
|
|
371
|
+
|
|
372
|
+
# Call settings() to test the connection
|
|
373
|
+
# This should return {} if Zotero is running and listening
|
|
374
|
+
result = zot.settings()
|
|
375
|
+
|
|
376
|
+
# If we get here, the connection succeeded
|
|
377
|
+
click.echo("✓ Connection successful: Zotero is running and listening locally.")
|
|
378
|
+
if result == {}:
|
|
379
|
+
click.echo(" Received expected empty settings response.")
|
|
380
|
+
else:
|
|
381
|
+
click.echo(f" Received response: {json.dumps(result)}")
|
|
382
|
+
|
|
383
|
+
except httpx.ConnectError:
|
|
384
|
+
click.echo(
|
|
385
|
+
"✗ Connection failed: Could not connect to Zotero.\n\n"
|
|
386
|
+
"Possible causes:\n"
|
|
387
|
+
" • Zotero might not be running\n"
|
|
388
|
+
" • Local connections might not be enabled\n\n"
|
|
389
|
+
"To enable local connections:\n"
|
|
390
|
+
" Zotero > Settings > Advanced > Allow other applications on this computer to communicate with Zotero",
|
|
391
|
+
err=True,
|
|
392
|
+
)
|
|
393
|
+
sys.exit(1)
|
|
394
|
+
except Exception as e:
|
|
395
|
+
click.echo(f"Error: {e!s}", err=True)
|
|
396
|
+
sys.exit(1)
|
|
397
|
+
|
|
398
|
+
|
|
351
399
|
if __name__ == "__main__":
|
|
352
400
|
main()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: pyzotero
|
|
3
|
-
Version: 1.7.
|
|
3
|
+
Version: 1.7.3
|
|
4
4
|
Summary: Python wrapper for the Zotero API
|
|
5
5
|
Keywords: Zotero,DH
|
|
6
6
|
Author: Stephan Hügel
|
|
@@ -149,7 +149,7 @@ Use the `--json` flag to output structured JSON.
|
|
|
149
149
|
|
|
150
150
|
## Optional: Command-Line Interface
|
|
151
151
|
|
|
152
|
-
Pyzotero includes an optional command-line interface for searching and querying your local Zotero library.
|
|
152
|
+
Pyzotero includes an optional command-line interface for searching and querying your local Zotero library. As it uses the local API server introduced in Zotero 7, it requires "Allow other applications on this computer to communicate with Zotero" to be enabled in Zotero's Settings > Advanced.
|
|
153
153
|
|
|
154
154
|
### Installing the CLI
|
|
155
155
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
pyzotero/__init__.py,sha256=5QI4Jou9L-YJAf_oN9TgRXVKgt_Unc39oADo2Ch8bLI,243
|
|
2
|
-
pyzotero/cli.py,sha256=
|
|
2
|
+
pyzotero/cli.py,sha256=t88ENb-7zydV1GFMf4Attj4wBYgM84eY2Ck5jSFO3Fc,12596
|
|
3
3
|
pyzotero/filetransport.py,sha256=umLik1LLmrpgaNmyjvtBoqqcaMgIq79PYsTvN5vG-gY,5530
|
|
4
4
|
pyzotero/zotero.py,sha256=4qb7jLl1lNkDv3WpEPLW2L0SbleTtGYlQ6Rloz-hmN0,76497
|
|
5
5
|
pyzotero/zotero_errors.py,sha256=6obx9-pBO0z1bxt33vuzDluELvA5kSLCsfc-uGc3KNw,2660
|
|
6
|
-
pyzotero-1.7.
|
|
7
|
-
pyzotero-1.7.
|
|
8
|
-
pyzotero-1.7.
|
|
9
|
-
pyzotero-1.7.
|
|
6
|
+
pyzotero-1.7.3.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
|
|
7
|
+
pyzotero-1.7.3.dist-info/entry_points.txt,sha256=MzN7IMRj_oPNmDCsseYFPum3bHWE1gFxywhlbFbcn2k,48
|
|
8
|
+
pyzotero-1.7.3.dist-info/METADATA,sha256=pCuO1_RfFP50-HU9P0PzyEvcL3Dpl5U8bFZMwIRNFXI,9962
|
|
9
|
+
pyzotero-1.7.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|