papers-cli 2.11__tar.gz → 2.12.1__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 (44) hide show
  1. {papers_cli-2.11 → papers_cli-2.12.1}/PKG-INFO +1 -1
  2. {papers_cli-2.11 → papers_cli-2.12.1}/papers/__main__.py +1 -1
  3. {papers_cli-2.11 → papers_cli-2.12.1}/papers/_version.py +2 -2
  4. {papers_cli-2.11 → papers_cli-2.12.1}/papers/extract.py +22 -1
  5. {papers_cli-2.11 → papers_cli-2.12.1}/papers_cli.egg-info/PKG-INFO +1 -1
  6. {papers_cli-2.11 → papers_cli-2.12.1}/.gitattributes +0 -0
  7. {papers_cli-2.11 → papers_cli-2.12.1}/.github/workflows/pypi.yml +0 -0
  8. {papers_cli-2.11 → papers_cli-2.12.1}/.github/workflows/tests.yml +0 -0
  9. {papers_cli-2.11 → papers_cli-2.12.1}/.gitignore +0 -0
  10. {papers_cli-2.11 → papers_cli-2.12.1}/LICENSE +0 -0
  11. {papers_cli-2.11 → papers_cli-2.12.1}/README.md +0 -0
  12. {papers_cli-2.11 → papers_cli-2.12.1}/papers/__init__.py +0 -0
  13. {papers_cli-2.11 → papers_cli-2.12.1}/papers/bib.py +0 -0
  14. {papers_cli-2.11 → papers_cli-2.12.1}/papers/config.py +0 -0
  15. {papers_cli-2.11 → papers_cli-2.12.1}/papers/duplicate.py +0 -0
  16. {papers_cli-2.11 → papers_cli-2.12.1}/papers/encoding.py +0 -0
  17. {papers_cli-2.11 → papers_cli-2.12.1}/papers/filename.py +0 -0
  18. {papers_cli-2.11 → papers_cli-2.12.1}/papers/latexenc.py +0 -0
  19. {papers_cli-2.11 → papers_cli-2.12.1}/papers/utils.py +0 -0
  20. {papers_cli-2.11 → papers_cli-2.12.1}/papers_cli.egg-info/SOURCES.txt +0 -0
  21. {papers_cli-2.11 → papers_cli-2.12.1}/papers_cli.egg-info/dependency_links.txt +0 -0
  22. {papers_cli-2.11 → papers_cli-2.12.1}/papers_cli.egg-info/entry_points.txt +0 -0
  23. {papers_cli-2.11 → papers_cli-2.12.1}/papers_cli.egg-info/requires.txt +0 -0
  24. {papers_cli-2.11 → papers_cli-2.12.1}/papers_cli.egg-info/top_level.txt +0 -0
  25. {papers_cli-2.11 → papers_cli-2.12.1}/pyproject.toml +0 -0
  26. {papers_cli-2.11 → papers_cli-2.12.1}/requirements.txt +0 -0
  27. {papers_cli-2.11 → papers_cli-2.12.1}/setup.cfg +0 -0
  28. {papers_cli-2.11 → papers_cli-2.12.1}/setup.py +0 -0
  29. {papers_cli-2.11 → papers_cli-2.12.1}/tests/__init__.py +0 -0
  30. {papers_cli-2.11 → papers_cli-2.12.1}/tests/common.py +0 -0
  31. {papers_cli-2.11 → papers_cli-2.12.1}/tests/config.py +0 -0
  32. {papers_cli-2.11 → papers_cli-2.12.1}/tests/download.py +0 -0
  33. {papers_cli-2.11 → papers_cli-2.12.1}/tests/downloadedpapers/.gitignore +0 -0
  34. {papers_cli-2.11 → papers_cli-2.12.1}/tests/downloadedpapers/bg-8-515-2011.txt +0 -0
  35. {papers_cli-2.11 → papers_cli-2.12.1}/tests/test_add.py +0 -0
  36. {papers_cli-2.11 → papers_cli-2.12.1}/tests/test_biblio.py +0 -0
  37. {papers_cli-2.11 → papers_cli-2.12.1}/tests/test_duplicates.py +0 -0
  38. {papers_cli-2.11 → papers_cli-2.12.1}/tests/test_encoding.py +0 -0
  39. {papers_cli-2.11 → papers_cli-2.12.1}/tests/test_extract.py +0 -0
  40. {papers_cli-2.11 → papers_cli-2.12.1}/tests/test_filecheck.py +0 -0
  41. {papers_cli-2.11 → papers_cli-2.12.1}/tests/test_install.py +0 -0
  42. {papers_cli-2.11 → papers_cli-2.12.1}/tests/test_list.py +0 -0
  43. {papers_cli-2.11 → papers_cli-2.12.1}/tests/test_misc.py +0 -0
  44. {papers_cli-2.11 → papers_cli-2.12.1}/tests/test_undo.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: papers-cli
3
- Version: 2.11
3
+ Version: 2.12.1
4
4
  Summary: utilities to keep your PDF library organized
5
5
  Author-email: Mahé Perrette <mahe.perrette@gmail.com>
6
6
  License: MIT
@@ -569,7 +569,7 @@ def addcmd(parser, o, config):
569
569
  logger.error("No entry added: use --doi, --metadata, --key, --attachment, --title, --author, --journal, --year to add a new entry")
570
570
  raise PapersExit()
571
571
 
572
- metadata.setdefault('ID', biblio.generate_key(metadata))
572
+ metadata.setdefault('ID', biblio.keyformat(metadata))
573
573
  metadata.setdefault('ENTRYTYPE', 'article')
574
574
  if o.edit:
575
575
  metadata = edit_entries(metadata)
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '2.11'
16
- __version_tuple__ = version_tuple = (2, 11)
15
+ __version__ = version = '2.12.1'
16
+ __version_tuple__ = version_tuple = (2, 12, 1)
@@ -4,6 +4,7 @@ import subprocess as sp
4
4
  import re
5
5
  import tempfile
6
6
 
7
+ import requests
7
8
  from crossref.restful import Works, Etiquette
8
9
  import bibtexparser
9
10
 
@@ -78,6 +79,7 @@ def readpdf_image(pdf, first=None, last=None):
78
79
  return txt
79
80
 
80
81
  REGEXP = re.compile(r'[doi,doi.org/][\s\.\:]{0,2}(10\.\d{4}[\d\:\.\-\/a-z]+)[A-Z\s,\n]')
82
+ ARXIV = re.compile(r'arxiv:\s*(\d{4}\.\d{4,5})')
81
83
 
82
84
  def parse_doi(txt):
83
85
  # based on: https://doeidoei.wordpress.com/2009/10/22/regular-expression-to-match-a-doi-digital-object-identifier/
@@ -94,7 +96,15 @@ def parse_doi(txt):
94
96
  matches = REGEXP.findall(' '+txt.lower()+' ')
95
97
 
96
98
  if not matches:
97
- raise DOIParsingError('parse_doi::no matches')
99
+
100
+ # try arxiv pattern
101
+ match = ARXIV.search(txt.lower())
102
+ if match:
103
+ arxiv_id = match.group(1)
104
+ matches = [ f"10.48550/arXiv.{arxiv_id}" ]
105
+
106
+ else:
107
+ raise DOIParsingError('parse_doi::no matches')
98
108
 
99
109
  match = matches[0]
100
110
 
@@ -218,8 +228,19 @@ def fetch_crossref_by_doi(doi):
218
228
  raise DOIRequestError(repr(doi)+': '+repr(error))
219
229
  return response.json()
220
230
 
231
+ @cached('arxiv.json')
232
+ def fetch_bibtex_by_arxiv(arxiv_id):
233
+ url = f"https://arxiv.org/bibtex/{arxiv_id}"
234
+ response = requests.get(url)
235
+ if response.status_code == 200:
236
+ return response.text
237
+ else:
238
+ return f"Error: Unable to fetch BibTeX (HTTP {response.status_code})"
239
+
221
240
  # @cached('crossref-bibtex.json')
222
241
  def fetch_bibtex_by_doi(doi):
242
+ if "arxiv" in doi.lower():
243
+ return fetch_bibtex_by_arxiv(doi.split("arXiv.")[1])
223
244
  json_data = fetch_crossref_by_doi(doi)
224
245
  return crossref_to_bibtex(json_data['message'])
225
246
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: papers-cli
3
- Version: 2.11
3
+ Version: 2.12.1
4
4
  Summary: utilities to keep your PDF library organized
5
5
  Author-email: Mahé Perrette <mahe.perrette@gmail.com>
6
6
  License: MIT
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