citeget 0.2.26__tar.gz → 0.2.27__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.
Files changed (86) hide show
  1. {citeget-0.2.26 → citeget-0.2.27}/.claude/skills/acquire-references/SKILL.md +1 -1
  2. {citeget-0.2.26 → citeget-0.2.27}/.claude/skills/fetch-resources/SKILL.md +1 -1
  3. {citeget-0.2.26 → citeget-0.2.27}/PKG-INFO +5 -3
  4. {citeget-0.2.26 → citeget-0.2.27}/README.md +2 -0
  5. {citeget-0.2.26 → citeget-0.2.27}/citeget/cli.py +7 -2
  6. {citeget-0.2.26 → citeget-0.2.27}/citeget/netguard.py +29 -0
  7. {citeget-0.2.26 → citeget-0.2.27}/citeget/resolve.py +17 -0
  8. {citeget-0.2.26 → citeget-0.2.27}/pyproject.toml +3 -3
  9. {citeget-0.2.26 → citeget-0.2.27}/tests/test_resolve.py +21 -0
  10. citeget-0.2.27/tests/test_response_charset.py +40 -0
  11. {citeget-0.2.26 → citeget-0.2.27}/.claude/skills/add-references/SKILL.md +0 -0
  12. {citeget-0.2.26 → citeget-0.2.27}/.claude/skills/add-references/add-references.skill +0 -0
  13. {citeget-0.2.26 → citeget-0.2.27}/.claude/skills/add-references/references/TEMPLATE.md +0 -0
  14. {citeget-0.2.26 → citeget-0.2.27}/.claude/skills/add-references/references/ai-ml.md +0 -0
  15. {citeget-0.2.26 → citeget-0.2.27}/.claude/skills/add-references/references/math-combinatorics.md +0 -0
  16. {citeget-0.2.26 → citeget-0.2.27}/.claude/skills/add-references/references/parameters.md +0 -0
  17. {citeget-0.2.26 → citeget-0.2.27}/.claude/skills/add-references/references/social-sciences.md +0 -0
  18. {citeget-0.2.26 → citeget-0.2.27}/.claude/skills/add-references/references/tech-blog.md +0 -0
  19. {citeget-0.2.26 → citeget-0.2.27}/.claude/skills/check-submission-fit/SKILL.md +0 -0
  20. {citeget-0.2.26 → citeget-0.2.27}/.claude/skills/format-for-journal/SKILL.md +0 -0
  21. {citeget-0.2.26 → citeget-0.2.27}/.claude/skills/get-books/SKILL.md +0 -0
  22. {citeget-0.2.26 → citeget-0.2.27}/.claude/skills/prepare-submission/SKILL.md +0 -0
  23. {citeget-0.2.26 → citeget-0.2.27}/.claude/skills/research-topic/SKILL.md +0 -0
  24. {citeget-0.2.26 → citeget-0.2.27}/.claude/skills/review-article/SKILL.md +0 -0
  25. {citeget-0.2.26 → citeget-0.2.27}/.editorconfig +0 -0
  26. {citeget-0.2.26 → citeget-0.2.27}/.gitattributes +0 -0
  27. {citeget-0.2.26 → citeget-0.2.27}/.github/workflows/ci.yml +0 -0
  28. {citeget-0.2.26 → citeget-0.2.27}/.gitignore +0 -0
  29. {citeget-0.2.26 → citeget-0.2.27}/CHANGELOG.md +0 -0
  30. {citeget-0.2.26 → citeget-0.2.27}/CLAUDE.md +0 -0
  31. {citeget-0.2.26 → citeget-0.2.27}/LICENSE +0 -0
  32. {citeget-0.2.26 → citeget-0.2.27}/citeget/__init__.py +0 -0
  33. {citeget-0.2.26 → citeget-0.2.27}/citeget/__main__.py +0 -0
  34. {citeget-0.2.26 → citeget-0.2.27}/citeget/acquire_references.py +0 -0
  35. {citeget-0.2.26 → citeget-0.2.27}/citeget/article_pub/__init__.py +0 -0
  36. {citeget-0.2.26 → citeget-0.2.27}/citeget/article_pub/data/journal_profiles.json +0 -0
  37. {citeget-0.2.26 → citeget-0.2.27}/citeget/article_pub/scripts/check_article.py +0 -0
  38. {citeget-0.2.26 → citeget-0.2.27}/citeget/article_pub/scripts/extract_references.py +0 -0
  39. {citeget-0.2.26 → citeget-0.2.27}/citeget/article_pub/scripts/word_count.py +0 -0
  40. {citeget-0.2.26 → citeget-0.2.27}/citeget/content.py +0 -0
  41. {citeget-0.2.26 → citeget-0.2.27}/citeget/core.py +0 -0
  42. {citeget-0.2.26 → citeget-0.2.27}/citeget/data/libgen_vg_report.md +0 -0
  43. {citeget-0.2.26 → citeget-0.2.27}/citeget/extract.py +0 -0
  44. {citeget-0.2.26 → citeget-0.2.27}/citeget/fetch.py +0 -0
  45. {citeget-0.2.26 → citeget-0.2.27}/citeget/joblimit.py +0 -0
  46. {citeget-0.2.26 → citeget-0.2.27}/citeget/merge_keyed.py +0 -0
  47. {citeget-0.2.26 → citeget-0.2.27}/citeget/names.py +0 -0
  48. {citeget-0.2.26 → citeget-0.2.27}/citeget/rank.py +0 -0
  49. {citeget-0.2.26 → citeget-0.2.27}/citeget/validate.py +0 -0
  50. {citeget-0.2.26 → citeget-0.2.27}/cookies.txt +0 -0
  51. {citeget-0.2.26 → citeget-0.2.27}/tests/__init__.py +0 -0
  52. {citeget-0.2.26 → citeget-0.2.27}/tests/cli_goldens/citeget.json +0 -0
  53. {citeget-0.2.26 → citeget-0.2.27}/tests/cli_goldens/citeget_module.json +0 -0
  54. {citeget-0.2.26 → citeget-0.2.27}/tests/conftest.py +0 -0
  55. {citeget-0.2.26 → citeget-0.2.27}/tests/fixtures/pages/danluu_wat.full.md +0 -0
  56. {citeget-0.2.26 → citeget-0.2.27}/tests/fixtures/pages/danluu_wat.html +0 -0
  57. {citeget-0.2.26 → citeget-0.2.27}/tests/fixtures/pages/idlewords_haunted_by_data.full.md +0 -0
  58. {citeget-0.2.26 → citeget-0.2.27}/tests/fixtures/pages/idlewords_haunted_by_data.html +0 -0
  59. {citeget-0.2.26 → citeget-0.2.27}/tests/fixtures/pages/joelonsoftware_talmud.full.md +0 -0
  60. {citeget-0.2.26 → citeget-0.2.27}/tests/fixtures/pages/joelonsoftware_talmud.html +0 -0
  61. {citeget-0.2.26 → citeget-0.2.27}/tests/fixtures/pages/make_fixtures.py +0 -0
  62. {citeget-0.2.26 → citeget-0.2.27}/tests/fixtures/pages/paulgraham_avg.full.md +0 -0
  63. {citeget-0.2.26 → citeget-0.2.27}/tests/fixtures/pages/paulgraham_avg.html +0 -0
  64. {citeget-0.2.26 → citeget-0.2.27}/tests/fixtures/pages/wayback_nytimes_federer.full.md +0 -0
  65. {citeget-0.2.26 → citeget-0.2.27}/tests/fixtures/pages/wayback_nytimes_federer.html +0 -0
  66. {citeget-0.2.26 → citeget-0.2.27}/tests/test_browser_session.py +0 -0
  67. {citeget-0.2.26 → citeget-0.2.27}/tests/test_browserguard.py +0 -0
  68. {citeget-0.2.26 → citeget-0.2.27}/tests/test_cli_surface.py +0 -0
  69. {citeget-0.2.26 → citeget-0.2.27}/tests/test_core_mirrors.py +0 -0
  70. {citeget-0.2.26 → citeget-0.2.27}/tests/test_download_paths.py +0 -0
  71. {citeget-0.2.26 → citeget-0.2.27}/tests/test_extract.py +0 -0
  72. {citeget-0.2.26 → citeget-0.2.27}/tests/test_fetch_ownership_and_extraction.py +0 -0
  73. {citeget-0.2.26 → citeget-0.2.27}/tests/test_fetch_query_collision.py +0 -0
  74. {citeget-0.2.26 → citeget-0.2.27}/tests/test_fetch_retry_titles.py +0 -0
  75. {citeget-0.2.26 → citeget-0.2.27}/tests/test_finalize.py +0 -0
  76. {citeget-0.2.26 → citeget-0.2.27}/tests/test_html_to_markdown.py +0 -0
  77. {citeget-0.2.26 → citeget-0.2.27}/tests/test_job_budget.py +0 -0
  78. {citeget-0.2.26 → citeget-0.2.27}/tests/test_joblimit.py +0 -0
  79. {citeget-0.2.26 → citeget-0.2.27}/tests/test_main_content.py +0 -0
  80. {citeget-0.2.26 → citeget-0.2.27}/tests/test_main_content_pages.py +0 -0
  81. {citeget-0.2.26 → citeget-0.2.27}/tests/test_merge_keyed.py +0 -0
  82. {citeget-0.2.26 → citeget-0.2.27}/tests/test_names.py +0 -0
  83. {citeget-0.2.26 → citeget-0.2.27}/tests/test_netguard.py +0 -0
  84. {citeget-0.2.26 → citeget-0.2.27}/tests/test_rank.py +0 -0
  85. {citeget-0.2.26 → citeget-0.2.27}/tests/test_search_retries.py +0 -0
  86. {citeget-0.2.26 → citeget-0.2.27}/tests/test_validate.py +0 -0
@@ -18,7 +18,7 @@ finding paper PDFs in libgen / arxiv / sci-hub, which won't help for web
18
18
  content.
19
19
 
20
20
  **For a list of book titles** (a reading list, "get me these books") use
21
- `/get-books`. This skill is built around a document's reference section; it
21
+ `/get-books` (`skills/get-books/SKILL.md` in this repository; link it into `~/.claude/skills/` to install). This skill is built around a document's reference section; it
22
22
  does not know which book you asked for, so it cannot check that the file it
23
23
  got is that book. `/get-books` can.
24
24
 
@@ -113,7 +113,7 @@ Every Markdown file starts with a `<!-- Source: URL -->` line, and that line, no
113
113
 
114
114
  - `skip_existing` (the default) skips a URL only when a file of the same format already belongs to it, so a `SKIP` really means "already have this page". A folder saved by an older citeget, under older names, is matched by those headers too: the page is skipped, not saved twice.
115
115
  - Two different URLs never share a file. When the preferred name is taken by another URL, the query is folded in, else a short hash of the URL.
116
- - PDFs and other non-Markdown files carry no source record. Within one run they are still kept apart. Across runs, an existing PDF of the same name is taken to be the same document and skipped: [thorwhalen/citeget#32](https://github.com/thorwhalen/citeget/issues/32) tracks that case.
116
+ - PDFs and other non-Markdown files carry no source record. Within one run they are still kept apart. Across runs, an existing PDF of the same name is taken to be the same document and skipped: [thorwhalen/citeget#32](https://github.com/addaix/citeget/issues/32) tracks that case.
117
117
 
118
118
  ## Format choice (`--prefer` / `prefer=`)
119
119
 
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: citeget
3
- Version: 0.2.26
3
+ Version: 0.2.27
4
4
  Summary: Find, acquire, and manage academic references — for AI agents and humans.
5
- Project-URL: Homepage, https://github.com/thorwhalen/citeget
6
- Project-URL: Repository, https://github.com/thorwhalen/citeget
5
+ Project-URL: Homepage, https://github.com/addaix/citeget
6
+ Project-URL: Repository, https://github.com/addaix/citeget
7
7
  Author: Thor Whalen
8
8
  License-Expression: Apache-2.0
9
9
  License-File: LICENSE
@@ -278,6 +278,8 @@ Available skills:
278
278
 
279
279
  ## Acquisition strategy
280
280
 
281
+ Which commands can touch which sources: `citeget fetch` only reads the URLs you give it. `citeget acquire` runs the chain below by default; `--strategy open_access` (Python: `acquire_reference(..., strategy="open_access")`) restricts it to the reference's own URL, Unpaywall, arXiv and Semantic Scholar, with no libgen or sci-hub step and no mirror contact. `citeget download` and `citeget get-book` search libgen only and have no open-access mode.
282
+
281
283
  For each reference, `citeget` tries these sources in order:
282
284
 
283
285
  1. **Direct URL** — if the reference includes an arxiv, OpenReview, or other
@@ -241,6 +241,8 @@ Available skills:
241
241
 
242
242
  ## Acquisition strategy
243
243
 
244
+ Which commands can touch which sources: `citeget fetch` only reads the URLs you give it. `citeget acquire` runs the chain below by default; `--strategy open_access` (Python: `acquire_reference(..., strategy="open_access")`) restricts it to the reference's own URL, Unpaywall, arXiv and Semantic Scholar, with no libgen or sci-hub step and no mirror contact. `citeget download` and `citeget get-book` search libgen only and have no open-access mode.
245
+
244
246
  For each reference, `citeget` tries these sources in order:
245
247
 
246
248
  1. **Direct URL** — if the reference includes an arxiv, OpenReview, or other
@@ -137,8 +137,10 @@ def acquire(
137
137
  delay: Seconds between operations (rate limiting).
138
138
  max_refs: Max references to process (0 = all).
139
139
  extractor: Named extractor to use (default, standard, broad, bold, ai).
140
- strategy: Named acquisition strategy (default, direct, doi, arxiv_search,
141
- semantic_scholar, libgen, scihub). Empty uses legacy chain.
140
+ strategy: Named acquisition strategy (default, open_access, direct, doi,
141
+ arxiv_search, semantic_scholar, libgen, scihub). Empty uses the legacy
142
+ chain, which includes libgen and sci-hub; ``open_access`` stays with
143
+ author, publisher and open-access copies.
142
144
  preview: Show extracted references and ask for confirmation.
143
145
  auto: Skip confirmation even in preview mode.
144
146
  """
@@ -329,6 +331,9 @@ def get_book(
329
331
  for and downloads the best candidate that validates as a complete book,
330
332
  falling through to the next one if it turns out to be an excerpt or a stub.
331
333
 
334
+ This command searches libgen only and has no open-access mode. To stay with
335
+ open sources use ``citeget acquire --strategy open_access`` or ``citeget fetch``.
336
+
332
337
  Args:
333
338
  title: The book's title.
334
339
  authors: The author(s), if known — strongly improves matching.
@@ -47,8 +47,10 @@ citeget.netguard.UnsafeURLError: Refused file:///etc/passwd: scheme 'file' is no
47
47
 
48
48
  from __future__ import annotations
49
49
 
50
+ import codecs
50
51
  import ipaddress
51
52
  import os
53
+ import re
52
54
  import socket
53
55
  from contextlib import contextmanager
54
56
  from contextvars import ContextVar
@@ -476,6 +478,13 @@ except ImportError: # pragma: no cover - requests is a hard dependency
476
478
  _requests = None
477
479
 
478
480
 
481
+ #: How much of a body is searched for a ``<meta charset>`` declaration.
482
+ _META_SNIFF_BYTES = 4096
483
+ _META_CHARSET = re.compile(
484
+ rb"""<meta[^>]+charset\s*=\s*["']?\s*([A-Za-z0-9_.:-]+)""", re.I
485
+ )
486
+
487
+
479
488
  class GuardedResponse(_requests.Response if _requests else object):
480
489
  """A ``requests.Response`` that honours a :class:`NetPolicy`'s ceilings.
481
490
 
@@ -537,9 +546,29 @@ class GuardedResponse(_requests.Response if _requests else object):
537
546
  f"for text ({MAX_TEXT_BYTES_ENV_VAR})",
538
547
  )
539
548
 
549
+ def _sniff_encoding(self) -> Optional[str]:
550
+ """The encoding of a body whose ``Content-Type`` names no charset.
551
+
552
+ ``requests`` decodes a bare ``text/html`` as Latin-1 (RFC 2616 era), which turns
553
+ UTF-8 ``é`` into two wrong characters. Prefer what the page says about itself
554
+ (``<meta charset>`` / ``http-equiv``), then a guess from the bytes.
555
+ """
556
+ head = self.content[:_META_SNIFF_BYTES]
557
+ match = _META_CHARSET.search(head)
558
+ if match:
559
+ declared = match.group(1).decode("ascii", "ignore")
560
+ try:
561
+ codecs.lookup(declared)
562
+ return declared
563
+ except LookupError:
564
+ pass
565
+ return self.apparent_encoding
566
+
540
567
  @property
541
568
  def text(self):
542
569
  self._check_text_size()
570
+ if "charset" not in (self.headers.get("content-type") or "").lower():
571
+ self.encoding = self._sniff_encoding() or "utf-8"
543
572
  return super().text
544
573
 
545
574
  def json(self, **kwargs):
@@ -748,6 +748,23 @@ def _build_default_strategy() -> AcquisitionStrategy:
748
748
  register_strategy("default", _build_default_strategy())
749
749
 
750
750
 
751
+ def _build_open_access_strategy() -> AcquisitionStrategy:
752
+ """Author, publisher and open-access copies only: no libgen, no sci-hub.
753
+
754
+ ``direct`` (the reference's own URL), ``doi`` (Unpaywall), ``arxiv_search`` and
755
+ ``semantic_scholar`` (open-access PDFs), in that order. No mirror is ever contacted.
756
+ """
757
+ return chain(
758
+ STRATEGIES["direct"],
759
+ STRATEGIES["doi"],
760
+ STRATEGIES["arxiv_search"],
761
+ STRATEGIES["semantic_scholar"],
762
+ )
763
+
764
+
765
+ register_strategy("open_access", _build_open_access_strategy())
766
+
767
+
751
768
  # ---------------------------------------------------------------------------
752
769
  # Main entry point
753
770
  # ---------------------------------------------------------------------------
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
6
6
 
7
7
  [project]
8
8
  name = "citeget"
9
- version = "0.2.26"
9
+ version = "0.2.27"
10
10
  description = "Find, acquire, and manage academic references — for AI agents and humans."
11
11
  readme = "README.md"
12
12
  requires-python = ">=3.10"
@@ -45,8 +45,8 @@ dependencies = [
45
45
  citeget = "citeget.cli:main"
46
46
 
47
47
  [project.urls]
48
- Homepage = "https://github.com/thorwhalen/citeget"
49
- Repository = "https://github.com/thorwhalen/citeget"
48
+ Homepage = "https://github.com/addaix/citeget"
49
+ Repository = "https://github.com/addaix/citeget"
50
50
 
51
51
  [project.optional-dependencies]
52
52
  dev = [
@@ -161,3 +161,24 @@ def test_chain_resolvers_deduplicates():
161
161
  ref = Reference(number=1, raw="test")
162
162
  urls = combined(ref)
163
163
  assert urls == ["http://a.com", "http://b.com", "http://c.com"]
164
+
165
+
166
+ def test_open_access_strategy_never_reaches_libgen_or_scihub(monkeypatch, tmp_path):
167
+ """`open_access` is the open sources only: a miss there is a miss, not a shadow-library try."""
168
+ from citeget import resolve
169
+
170
+ called = []
171
+
172
+ def stub(name, result=None):
173
+ def strategy(ref, filepath):
174
+ called.append(name)
175
+ return result
176
+ return strategy
177
+
178
+ for name in ("direct", "doi", "arxiv_search", "semantic_scholar", "libgen", "scihub"):
179
+ monkeypatch.setitem(resolve.STRATEGIES, name, stub(name))
180
+ assert "open_access" in list_strategies()
181
+ strategy = resolve._build_open_access_strategy()
182
+ ref = Reference(number=1, raw="test", url="")
183
+ assert strategy(ref, tmp_path / "x.pdf") is None
184
+ assert called == ["direct", "doi", "arxiv_search", "semantic_scholar"]
@@ -0,0 +1,40 @@
1
+ """A body whose Content-Type names no charset is decoded by what the page says, not as Latin-1."""
2
+
3
+ from citeget.netguard import GuardedResponse
4
+
5
+
6
+ def _response(body: bytes, content_type: str | None) -> GuardedResponse:
7
+ r = GuardedResponse()
8
+ r._content = body
9
+ r._content_consumed = True
10
+ r.status_code = 200
11
+ if content_type:
12
+ r.headers["Content-Type"] = content_type
13
+ # what requests does: the header's charset, else Latin-1 for a bare text/*
14
+ r.encoding = (
15
+ content_type.split("charset=")[1] if "charset" in content_type else "ISO-8859-1"
16
+ )
17
+ return r
18
+
19
+
20
+ def test_meta_charset_beats_the_latin1_default():
21
+ body = '<html><head><meta charset="utf-8"></head><body>passé</body></html>'.encode()
22
+ assert "passé" in _response(body, "text/html").text
23
+
24
+
25
+ def test_http_equiv_meta_is_read_too():
26
+ body = (
27
+ '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'
28
+ "<p>café</p>"
29
+ ).encode()
30
+ assert "café" in _response(body, "text/html").text
31
+
32
+
33
+ def test_bytes_are_guessed_when_the_page_declares_nothing():
34
+ body = ("<p>" + "passé, où, déjà, très, façon. " * 20 + "</p>").encode()
35
+ assert "passé" in _response(body, "text/html").text
36
+
37
+
38
+ def test_a_declared_charset_is_respected():
39
+ body = "<p>passé</p>".encode("latin-1")
40
+ assert "passé" in _response(body, "text/html; charset=iso-8859-1").text
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes