scitex 2.15.3__py3-none-any.whl → 2.15.4__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.
@@ -1,142 +1,41 @@
1
1
  #!/usr/bin/env python3
2
- # Timestamp: 2026-01-24
2
+ # Timestamp: 2026-01-29
3
3
  # File: src/scitex/cli/scholar/_crossref_scitex.py
4
- """CrossRef-SciTeX CLI commands for scitex scholar.
4
+ """CrossRef-SciTeX CLI - Thin wrapper delegating to crossref-local.
5
5
 
6
- Provides access to the local CrossRef database (167M+ papers) via crossref-local.
7
- Branded as crossref-scitex to distinguish from official CrossRef API.
6
+ This module provides access to the local CrossRef database (167M+ papers)
7
+ by delegating directly to crossref-local CLI without any modifications.
8
8
  """
9
9
 
10
10
  from __future__ import annotations
11
11
 
12
- import json
13
12
  import sys
14
13
 
15
14
  import click
16
15
 
17
16
 
18
- @click.group("crossref-scitex")
19
- def crossref_scitex():
20
- """
21
- CrossRef-SciTeX database search (167M+ papers)
22
-
23
- \b
24
- Search and query the local CrossRef database via crossref-local.
25
- Supports both direct DB access and HTTP API mode.
26
-
27
- \b
28
- Examples:
29
- scitex scholar crossref-scitex search "deep learning"
30
- scitex scholar crossref-scitex get 10.1038/nature12373
31
- scitex scholar crossref-scitex count "epilepsy seizure"
32
- scitex scholar crossref-scitex info
33
- """
34
- pass
35
-
36
-
37
- @crossref_scitex.command("search")
38
- @click.argument("query")
39
- @click.option("-n", "--limit", default=20, help="Maximum results (default: 20)")
40
- @click.option("--offset", default=0, help="Skip N results for pagination")
41
- @click.option("--year-min", type=int, help="Minimum publication year")
42
- @click.option("--year-max", type=int, help="Maximum publication year")
43
- @click.option("--enrich", is_flag=True, help="Add citation counts and references")
44
- @click.option("--json", "as_json", is_flag=True, help="Output as JSON")
45
- def search_cmd(query, limit, offset, year_min, year_max, enrich, as_json):
46
- """
47
- Search for papers in CrossRef database.
17
+ @click.command(
18
+ "crossref-scitex",
19
+ context_settings={"ignore_unknown_options": True, "allow_extra_args": True},
20
+ )
21
+ @click.option("--help-recursive", is_flag=True, help="Show help for all commands")
22
+ @click.pass_context
23
+ def crossref_scitex(ctx, help_recursive):
24
+ r"""CrossRef-SciTeX database search (167M+ papers).
48
25
 
49
26
  \b
50
- Examples:
51
- scitex scholar crossref-scitex search "hippocampal sharp wave ripples"
52
- scitex scholar crossref search "deep learning" --limit 50
53
- scitex scholar crossref search "CRISPR" --year-min 2020 --enrich
54
- """
55
- try:
56
- from scitex.scholar import crossref_scitex as crossref
57
- except ImportError:
58
- click.secho(
59
- "crossref-local not installed. Install with: pip install crossref-local",
60
- fg="red",
61
- )
62
- sys.exit(1)
63
-
64
- try:
65
- results = crossref.search(query, limit=limit, offset=offset)
66
-
67
- if enrich:
68
- results = crossref.enrich(results)
69
-
70
- papers = []
71
- for work in results:
72
- if year_min and work.year and work.year < year_min:
73
- continue
74
- if year_max and work.year and work.year > year_max:
75
- continue
76
- papers.append(work)
77
- if len(papers) >= limit:
78
- break
79
-
80
- if as_json:
81
- output = {
82
- "query": query,
83
- "total": results.total,
84
- "count": len(papers),
85
- "papers": [
86
- {
87
- "doi": p.doi,
88
- "title": p.title,
89
- "authors": p.authors,
90
- "year": p.year,
91
- "journal": p.journal,
92
- "citation_count": p.citation_count,
93
- }
94
- for p in papers
95
- ],
96
- }
97
- click.echo(json.dumps(output, indent=2))
98
- else:
99
- click.secho(
100
- f"Found {results.total} papers for: {query}", fg="green", bold=True
101
- )
102
- click.echo()
103
-
104
- for i, paper in enumerate(papers, 1):
105
- authors = ", ".join(paper.authors[:3]) if paper.authors else "Unknown"
106
- if paper.authors and len(paper.authors) > 3:
107
- authors += " et al."
108
-
109
- click.secho(f"{i}. {paper.title}", fg="cyan", bold=True)
110
- click.echo(f" Authors: {authors}")
111
- click.echo(
112
- f" Year: {paper.year or 'N/A'} | Journal: {paper.journal or 'N/A'}"
113
- )
114
- click.echo(f" DOI: {paper.doi}")
115
- if paper.citation_count:
116
- click.echo(f" Citations: {paper.citation_count}")
117
- click.echo()
118
-
119
- except Exception as e:
120
- click.secho(f"Error: {e}", fg="red")
121
- sys.exit(1)
122
-
123
-
124
- @crossref_scitex.command("get")
125
- @click.argument("doi")
126
- @click.option("--citations", is_flag=True, help="Include citing papers")
127
- @click.option("--references", is_flag=True, help="Include referenced papers")
128
- @click.option("--json", "as_json", is_flag=True, help="Output as JSON")
129
- def get_cmd(doi, citations, references, as_json):
130
- """
131
- Get paper details by DOI.
27
+ Thin wrapper for crossref-local. All arguments passed directly.
28
+ Run 'crossref-local --help' for full options.
132
29
 
133
30
  \b
134
31
  Examples:
135
- scitex scholar crossref get 10.1038/nature12373
136
- scitex scholar crossref get 10.1126/science.aax0758 --citations
32
+ scitex scholar crossref-scitex search "deep learning" --abstracts
33
+ scitex scholar crossref-scitex search-by-doi 10.1038/nature12373
34
+ scitex scholar crossref-scitex status
35
+ scitex scholar crossref-scitex cache query "neural networks"
137
36
  """
138
37
  try:
139
- from scitex.scholar import crossref_scitex as crossref
38
+ from crossref_local.cli import cli as crossref_cli
140
39
  except ImportError:
141
40
  click.secho(
142
41
  "crossref-local not installed. Install with: pip install crossref-local",
@@ -144,153 +43,13 @@ def get_cmd(doi, citations, references, as_json):
144
43
  )
145
44
  sys.exit(1)
146
45
 
147
- try:
148
- work = crossref.get(doi)
149
-
150
- if work is None:
151
- click.secho(f"DOI not found: {doi}", fg="red")
152
- sys.exit(1)
153
-
154
- if as_json:
155
- output = {
156
- "doi": work.doi,
157
- "title": work.title,
158
- "authors": work.authors,
159
- "year": work.year,
160
- "journal": work.journal,
161
- "abstract": work.abstract,
162
- "citation_count": work.citation_count,
163
- "reference_count": work.reference_count,
164
- "type": work.type,
165
- "publisher": work.publisher,
166
- }
167
- if citations:
168
- output["citing_dois"] = crossref.get_citing(doi)
169
- if references:
170
- output["referenced_dois"] = crossref.get_cited(doi)
171
- click.echo(json.dumps(output, indent=2))
172
- else:
173
- click.secho(work.title, fg="cyan", bold=True)
174
- click.echo()
175
-
176
- if work.authors:
177
- click.echo(f"Authors: {', '.join(work.authors)}")
178
- click.echo(f"Year: {work.year or 'N/A'}")
179
- click.echo(f"Journal: {work.journal or 'N/A'}")
180
- click.echo(f"DOI: {work.doi}")
181
- click.echo(f"Type: {work.type or 'N/A'}")
182
- click.echo(f"Publisher: {work.publisher or 'N/A'}")
183
- click.echo(f"Citations: {work.citation_count or 0}")
184
- click.echo(f"References: {work.reference_count or 0}")
185
-
186
- if work.abstract:
187
- click.echo()
188
- click.secho("Abstract:", bold=True)
189
- click.echo(
190
- work.abstract[:500] + "..."
191
- if len(work.abstract) > 500
192
- else work.abstract
193
- )
194
-
195
- if citations:
196
- citing = crossref.get_citing(doi)
197
- click.echo()
198
- click.secho(f"Citing papers ({len(citing)}):", bold=True)
199
- for c_doi in citing[:10]:
200
- click.echo(f" - {c_doi}")
201
- if len(citing) > 10:
202
- click.echo(f" ... and {len(citing) - 10} more")
203
-
204
- if references:
205
- cited = crossref.get_cited(doi)
206
- click.echo()
207
- click.secho(f"References ({len(cited)}):", bold=True)
208
- for r_doi in cited[:10]:
209
- click.echo(f" - {r_doi}")
210
- if len(cited) > 10:
211
- click.echo(f" ... and {len(cited) - 10} more")
212
-
213
- except Exception as e:
214
- click.secho(f"Error: {e}", fg="red")
215
- sys.exit(1)
46
+ # Handle --help-recursive by delegating to crossref-local
47
+ args = ctx.args
48
+ if help_recursive:
49
+ args = ["--help-recursive"]
216
50
 
217
-
218
- @crossref_scitex.command("count")
219
- @click.argument("query")
220
- def count_cmd(query):
221
- """
222
- Count papers matching a query.
223
-
224
- \b
225
- Examples:
226
- scitex scholar crossref count "machine learning"
227
- scitex scholar crossref count "CRISPR gene editing"
228
- """
229
- try:
230
- from scitex.scholar import crossref_scitex as crossref
231
- except ImportError:
232
- click.secho(
233
- "crossref-local not installed. Install with: pip install crossref-local",
234
- fg="red",
235
- )
236
- sys.exit(1)
237
-
238
- try:
239
- count = crossref.count(query)
240
- click.echo(f"{count:,} papers match: {query}")
241
- except Exception as e:
242
- click.secho(f"Error: {e}", fg="red")
243
- sys.exit(1)
244
-
245
-
246
- @crossref_scitex.command("info")
247
- @click.option("--json", "as_json", is_flag=True, help="Output as JSON")
248
- def info_cmd(as_json):
249
- """
250
- Show CrossRef database configuration and status.
251
-
252
- \b
253
- Examples:
254
- scitex scholar crossref info
255
- scitex scholar crossref info --json
256
- """
257
- try:
258
- from scitex.scholar import crossref_scitex as crossref
259
- except ImportError:
260
- click.secho(
261
- "crossref-local not installed. Install with: pip install crossref-local",
262
- fg="red",
263
- )
264
- sys.exit(1)
265
-
266
- try:
267
- info = crossref.info()
268
- mode = crossref.get_mode()
269
-
270
- if as_json:
271
- info["mode"] = mode
272
- click.echo(json.dumps(info, indent=2))
273
- else:
274
- click.secho("CrossRef Database Status", fg="cyan", bold=True)
275
- click.echo()
276
- click.echo(f"Mode: {mode}")
277
- click.echo(f"Status: {info.get('status', 'unknown')}")
278
-
279
- if "version" in info:
280
- click.echo(f"Version: {info['version']}")
281
-
282
- if "work_count" in info:
283
- click.echo(f"Papers: {info['work_count']:,}")
284
-
285
- if "db_path" in info:
286
- click.echo(f"Database: {info['db_path']}")
287
-
288
- if "api_url" in info:
289
- click.echo(f"API URL: {info['api_url']}")
290
-
291
- except Exception as e:
292
- click.secho(f"Error: {e}", fg="red")
293
- sys.exit(1)
51
+ # Delegate all arguments to crossref-local CLI
52
+ sys.exit(crossref_cli.main(args, standalone_mode=False))
294
53
 
295
54
 
296
55
  # EOF
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env python3
2
+ # Timestamp: 2026-01-29
3
+ # File: src/scitex/cli/scholar/_openalex_scitex.py
4
+ """OpenAlex-SciTeX CLI - Thin wrapper delegating to openalex-local.
5
+
6
+ This module provides access to the local OpenAlex database (284M+ works)
7
+ by delegating directly to openalex-local CLI without any modifications.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import sys
13
+
14
+ import click
15
+
16
+
17
+ @click.command(
18
+ "openalex-scitex",
19
+ context_settings={"ignore_unknown_options": True, "allow_extra_args": True},
20
+ )
21
+ @click.option("--help-recursive", is_flag=True, help="Show help for all commands")
22
+ @click.pass_context
23
+ def openalex_scitex(ctx, help_recursive):
24
+ """
25
+ OpenAlex-SciTeX database search (284M+ works)
26
+
27
+ \b
28
+ Thin wrapper for openalex-local. All arguments passed directly.
29
+ Run 'openalex-local --help' for full options.
30
+
31
+ \b
32
+ Examples:
33
+ scitex scholar openalex-scitex search "machine learning"
34
+ scitex scholar openalex-scitex search-by-doi 10.1038/nature12373
35
+ scitex scholar openalex-scitex status
36
+ """
37
+ try:
38
+ from openalex_local.cli import cli as openalex_cli
39
+ except ImportError:
40
+ click.secho(
41
+ "openalex-local not installed. Install with: pip install openalex-local",
42
+ fg="red",
43
+ )
44
+ sys.exit(1)
45
+
46
+ # Handle --help-recursive by delegating to openalex-local
47
+ args = ctx.args
48
+ if help_recursive:
49
+ args = ["--help-recursive"]
50
+
51
+ # Delegate all arguments to openalex-local CLI
52
+ sys.exit(openalex_cli.main(args, standalone_mode=False))
53
+
54
+
55
+ # EOF
@@ -1,5 +1,4 @@
1
- """
2
- SciTeX Scholar - Scientific Literature Management Made Simple
1
+ """SciTeX Scholar - Scientific Literature Management Made Simple.
3
2
 
4
3
  This module provides a unified interface for:
5
4
  - Searching scientific literature across multiple sources
@@ -27,17 +26,17 @@ _missing = warn_module_deps("scholar")
27
26
  try:
28
27
  from scitex.scholar.auth import ScholarAuthManager
29
28
  except ImportError:
30
- ScholarAuthManager = None
29
+ ScholarAuthManager = None # type: ignore[misc,assignment]
31
30
 
32
31
  try:
33
32
  from scitex.scholar.browser import ScholarBrowserManager
34
33
  except ImportError:
35
- ScholarBrowserManager = None
34
+ ScholarBrowserManager = None # type: ignore[misc,assignment]
36
35
 
37
36
  try:
38
37
  from scitex.scholar.config import ScholarConfig
39
38
  except ImportError:
40
- ScholarConfig = None
39
+ ScholarConfig = None # type: ignore[misc,assignment]
41
40
 
42
41
  try:
43
42
  from scitex.scholar.core import Paper, Papers, Scholar
@@ -71,12 +70,17 @@ try:
71
70
  except ImportError:
72
71
  utils = None
73
72
 
74
- # CrossRef integration via crossref-local delegation (branded as crossref-scitex)
73
+ # Local database integrations (crossref-local, openalex-local)
75
74
  try:
76
- from . import crossref_scitex
75
+ from .local_dbs import crossref_scitex
77
76
  except ImportError:
78
77
  crossref_scitex = None
79
78
 
79
+ try:
80
+ from .local_dbs import openalex_scitex
81
+ except ImportError:
82
+ openalex_scitex = None
83
+
80
84
  __all__ = [
81
85
  "ScholarConfig",
82
86
  "ScholarEngine",
@@ -87,8 +91,9 @@ __all__ = [
87
91
  "Papers",
88
92
  "Scholar",
89
93
  "utils",
90
- # CrossRef integration (167M+ papers via crossref-local)
91
- "crossref_scitex",
94
+ # Local database integrations
95
+ "crossref_scitex", # CrossRef (167M+ papers via crossref-local)
96
+ "openalex_scitex", # OpenAlex (284M+ works via openalex-local)
92
97
  ]
93
98
 
94
99
  # # Import core classes for advanced users
@@ -0,0 +1,133 @@
1
+ #!/usr/bin/env python3
2
+ # Timestamp: 2026-01-29
3
+ # File: src/scitex/scholar/_mcp/crossref_tool_schemas.py
4
+ """CrossRef-Local tool schemas for MCP server.
5
+
6
+ Provides access to 167M+ papers via crossref-local database.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import mcp.types as types
12
+
13
+ __all__ = ["get_crossref_tool_schemas"]
14
+
15
+
16
+ def get_crossref_tool_schemas() -> list[types.Tool]:
17
+ """Return CrossRef-Local tool schemas."""
18
+ return [
19
+ types.Tool(
20
+ name="crossref_search",
21
+ description=(
22
+ "Search CrossRef database (167M+ papers) via crossref-local. "
23
+ "Fast full-text search with year filtering and citation enrichment."
24
+ ),
25
+ inputSchema={
26
+ "type": "object",
27
+ "properties": {
28
+ "query": {
29
+ "type": "string",
30
+ "description": "Search query string (full-text search)",
31
+ },
32
+ "limit": {
33
+ "type": "integer",
34
+ "description": "Maximum number of results",
35
+ "default": 20,
36
+ },
37
+ "offset": {
38
+ "type": "integer",
39
+ "description": "Number of results to skip for pagination",
40
+ "default": 0,
41
+ },
42
+ "year_min": {
43
+ "type": "integer",
44
+ "description": "Minimum publication year filter",
45
+ },
46
+ "year_max": {
47
+ "type": "integer",
48
+ "description": "Maximum publication year filter",
49
+ },
50
+ "enrich": {
51
+ "type": "boolean",
52
+ "description": "Add citation counts and references",
53
+ "default": False,
54
+ },
55
+ },
56
+ "required": ["query"],
57
+ },
58
+ ),
59
+ types.Tool(
60
+ name="crossref_get",
61
+ description="Get a paper by DOI from CrossRef database with optional citation data.",
62
+ inputSchema={
63
+ "type": "object",
64
+ "properties": {
65
+ "doi": {
66
+ "type": "string",
67
+ "description": "DOI of the paper (e.g., '10.1038/nature12373')",
68
+ },
69
+ "include_citations": {
70
+ "type": "boolean",
71
+ "description": "Include list of DOIs that cite this paper",
72
+ "default": False,
73
+ },
74
+ "include_references": {
75
+ "type": "boolean",
76
+ "description": "Include list of DOIs this paper references",
77
+ "default": False,
78
+ },
79
+ },
80
+ "required": ["doi"],
81
+ },
82
+ ),
83
+ types.Tool(
84
+ name="crossref_count",
85
+ description="Count papers matching a search query in CrossRef database.",
86
+ inputSchema={
87
+ "type": "object",
88
+ "properties": {
89
+ "query": {
90
+ "type": "string",
91
+ "description": "Search query string",
92
+ },
93
+ },
94
+ "required": ["query"],
95
+ },
96
+ ),
97
+ types.Tool(
98
+ name="crossref_citations",
99
+ description="Get citation relationships for a paper (citing papers and/or references).",
100
+ inputSchema={
101
+ "type": "object",
102
+ "properties": {
103
+ "doi": {
104
+ "type": "string",
105
+ "description": "DOI of the paper",
106
+ },
107
+ "direction": {
108
+ "type": "string",
109
+ "description": "Citation direction: 'citing', 'cited', or 'both'",
110
+ "enum": ["citing", "cited", "both"],
111
+ "default": "citing",
112
+ },
113
+ "limit": {
114
+ "type": "integer",
115
+ "description": "Maximum results per direction",
116
+ "default": 100,
117
+ },
118
+ },
119
+ "required": ["doi"],
120
+ },
121
+ ),
122
+ types.Tool(
123
+ name="crossref_info",
124
+ description="Get CrossRef database configuration and status.",
125
+ inputSchema={
126
+ "type": "object",
127
+ "properties": {},
128
+ },
129
+ ),
130
+ ]
131
+
132
+
133
+ # EOF