papers-cli 2.8__tar.gz → 2.9__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.8 → papers_cli-2.9}/PKG-INFO +1 -1
  2. {papers_cli-2.8 → papers_cli-2.9}/papers/__main__.py +21 -1
  3. {papers_cli-2.8 → papers_cli-2.9}/papers/_version.py +2 -2
  4. {papers_cli-2.8 → papers_cli-2.9}/papers/encoding.py +3 -3
  5. {papers_cli-2.8 → papers_cli-2.9}/papers/utils.py +15 -3
  6. {papers_cli-2.8 → papers_cli-2.9}/papers_cli.egg-info/PKG-INFO +1 -1
  7. {papers_cli-2.8 → papers_cli-2.9}/.gitattributes +0 -0
  8. {papers_cli-2.8 → papers_cli-2.9}/.github/workflows/pypi.yml +0 -0
  9. {papers_cli-2.8 → papers_cli-2.9}/.github/workflows/tests.yml +0 -0
  10. {papers_cli-2.8 → papers_cli-2.9}/.gitignore +0 -0
  11. {papers_cli-2.8 → papers_cli-2.9}/LICENSE +0 -0
  12. {papers_cli-2.8 → papers_cli-2.9}/README.md +0 -0
  13. {papers_cli-2.8 → papers_cli-2.9}/papers/__init__.py +0 -0
  14. {papers_cli-2.8 → papers_cli-2.9}/papers/bib.py +0 -0
  15. {papers_cli-2.8 → papers_cli-2.9}/papers/config.py +0 -0
  16. {papers_cli-2.8 → papers_cli-2.9}/papers/duplicate.py +0 -0
  17. {papers_cli-2.8 → papers_cli-2.9}/papers/extract.py +0 -0
  18. {papers_cli-2.8 → papers_cli-2.9}/papers/filename.py +0 -0
  19. {papers_cli-2.8 → papers_cli-2.9}/papers/latexenc.py +0 -0
  20. {papers_cli-2.8 → papers_cli-2.9}/papers_cli.egg-info/SOURCES.txt +0 -0
  21. {papers_cli-2.8 → papers_cli-2.9}/papers_cli.egg-info/dependency_links.txt +0 -0
  22. {papers_cli-2.8 → papers_cli-2.9}/papers_cli.egg-info/entry_points.txt +0 -0
  23. {papers_cli-2.8 → papers_cli-2.9}/papers_cli.egg-info/requires.txt +0 -0
  24. {papers_cli-2.8 → papers_cli-2.9}/papers_cli.egg-info/top_level.txt +0 -0
  25. {papers_cli-2.8 → papers_cli-2.9}/pyproject.toml +0 -0
  26. {papers_cli-2.8 → papers_cli-2.9}/requirements.txt +0 -0
  27. {papers_cli-2.8 → papers_cli-2.9}/setup.cfg +0 -0
  28. {papers_cli-2.8 → papers_cli-2.9}/setup.py +0 -0
  29. {papers_cli-2.8 → papers_cli-2.9}/tests/__init__.py +0 -0
  30. {papers_cli-2.8 → papers_cli-2.9}/tests/common.py +0 -0
  31. {papers_cli-2.8 → papers_cli-2.9}/tests/config.py +0 -0
  32. {papers_cli-2.8 → papers_cli-2.9}/tests/download.py +0 -0
  33. {papers_cli-2.8 → papers_cli-2.9}/tests/downloadedpapers/.gitignore +0 -0
  34. {papers_cli-2.8 → papers_cli-2.9}/tests/downloadedpapers/bg-8-515-2011.txt +0 -0
  35. {papers_cli-2.8 → papers_cli-2.9}/tests/test_add.py +0 -0
  36. {papers_cli-2.8 → papers_cli-2.9}/tests/test_biblio.py +0 -0
  37. {papers_cli-2.8 → papers_cli-2.9}/tests/test_duplicates.py +0 -0
  38. {papers_cli-2.8 → papers_cli-2.9}/tests/test_encoding.py +0 -0
  39. {papers_cli-2.8 → papers_cli-2.9}/tests/test_extract.py +0 -0
  40. {papers_cli-2.8 → papers_cli-2.9}/tests/test_filecheck.py +0 -0
  41. {papers_cli-2.8 → papers_cli-2.9}/tests/test_install.py +0 -0
  42. {papers_cli-2.8 → papers_cli-2.9}/tests/test_list.py +0 -0
  43. {papers_cli-2.8 → papers_cli-2.9}/tests/test_misc.py +0 -0
  44. {papers_cli-2.8 → papers_cli-2.9}/tests/test_undo.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: papers-cli
3
- Version: 2.8
3
+ Version: 2.9
4
4
  Summary: utilities to keep your PDF library organized
5
5
  Author-email: Mahé Perrette <mahe.perrette@gmail.com>
6
6
  License: MIT
@@ -20,7 +20,7 @@ from papers.encoding import parse_file, format_file, family_names, format_entrie
20
20
  from papers.config import bcolors, Config, search_config, CONFIG_FILE, CONFIG_FILE_LOCAL, DATA_DIR, CONFIG_FILE_LEGACY, BACKUP_DIR
21
21
  from papers.duplicate import list_duplicates, list_uniques, edit_entries
22
22
  from papers.bib import Biblio, FUZZY_RATIO, DEFAULT_SIMILARITY, entry_filecheck, backupfile as backupfile_func, isvalidkey
23
- from papers.utils import move, checksum, view_pdf
23
+ from papers.utils import move, checksum, view_pdf, open_folder
24
24
  from papers import __version__
25
25
 
26
26
 
@@ -233,7 +233,27 @@ def savebib(biblio, config):
233
233
  # config.gitcommit()
234
234
 
235
235
 
236
+
237
+ def is_subdirectory(parent, child):
238
+ # Resolve paths to absolute paths
239
+ parent = Path(parent).resolve()
240
+ child = Path(child).resolve()
241
+
242
+ # Check if the child path is relative to the parent path
243
+ return parent in child.parents
244
+
245
+
236
246
  def view_entry_files(biblio, entry):
247
+ files = biblio.get_files(entry)
248
+
249
+ # in case several attachments are present and the files are ordered under filesdir,
250
+ # open the subfolder instead of the single files
251
+ if len(files) > 1:
252
+ parent = os.path.commonpath(files)
253
+ if is_subdirectory(biblio.filesdir, parent):
254
+ open_folder(parent)
255
+ return
256
+
237
257
  for f in biblio.get_files(entry):
238
258
  logger.info(f"opening {f} ...")
239
259
  view_pdf(f)
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '2.8'
16
- __version_tuple__ = version_tuple = (2, 8)
15
+ __version__ = version = '2.9'
16
+ __version_tuple__ = version_tuple = (2, 9)
@@ -109,12 +109,12 @@ def format_entry(biblio, e, no_key=False, prefix=""):
109
109
  info = []
110
110
  if e.get('doi',''):
111
111
  info.append(link(f"https://doi.org/{e['doi']}", 'doi:'+e['doi']))
112
-
112
+
113
113
  files = parse_file(e.get('file',''), relative_to=biblio.relative_to)
114
114
  n = len(files)
115
115
 
116
116
  if n:
117
- file_link = f"file:///{Path(files[0]).resolve()}"
117
+ file_link = f"file:///{Path(files[0]).resolve()}" if n == 1 else f"file:///{Path(os.path.commonpath(files)).resolve()}"
118
118
  ansi_link = link(file_link, f'{"file" if n == 1 else "files"}:{str(n)}')
119
119
  info.append(bcolors.OKGREEN+ansi_link+bcolors.ENDC)
120
120
 
@@ -127,7 +127,7 @@ def format_entry(biblio, e, no_key=False, prefix=""):
127
127
  prefixtag = f"{bcolors.WARNING}{prefix} -> {bcolors.ENDC}"
128
128
  else:
129
129
  prefixtag = ""
130
- return f"{prefixtag}{format_key(e, no_key=no_key)} {tit} {infotag}"
130
+ return f"{prefixtag}{format_key(e, no_key=no_key)} {tit} {infotag}"
131
131
 
132
132
 
133
133
  # Parse name entry
@@ -2,7 +2,7 @@ import os
2
2
  import re
3
3
  import shutil
4
4
  import hashlib
5
-
5
+ import subprocess, platform
6
6
  from contextlib import contextmanager
7
7
  from pathlib import Path
8
8
 
@@ -191,10 +191,22 @@ def view_pdf(filepath):
191
191
  """
192
192
  https://stackoverflow.com/questions/434597/open-document-with-default-os-application-in-python-both-in-windows-and-mac-os
193
193
  """
194
- import subprocess, os, platform
195
194
  if platform.system() == 'Darwin': # macOS
196
195
  subprocess.call(('open', filepath))
197
196
  elif platform.system() == 'Windows': # Windows
198
197
  os.startfile(filepath)
199
198
  else: # linux variants
200
- subprocess.call(('xdg-open', filepath))
199
+ subprocess.call(('xdg-open', filepath))
200
+
201
+
202
+ def open_folder(path):
203
+ system_platform = platform.system()
204
+
205
+ if system_platform == "Windows":
206
+ os.startfile(path)
207
+ elif system_platform == "Darwin": # macOS
208
+ os.system(f'open "{path}"')
209
+ elif system_platform == "Linux":
210
+ os.system(f'xdg-open "{path}"')
211
+ else:
212
+ print("Unsupported operating system.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: papers-cli
3
- Version: 2.8
3
+ Version: 2.9
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
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