papers-cli 2.8__tar.gz → 2.9.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.
- {papers_cli-2.8 → papers_cli-2.9.1}/PKG-INFO +1 -1
- {papers_cli-2.8 → papers_cli-2.9.1}/papers/__main__.py +22 -2
- {papers_cli-2.8 → papers_cli-2.9.1}/papers/_version.py +2 -2
- {papers_cli-2.8 → papers_cli-2.9.1}/papers/encoding.py +3 -3
- {papers_cli-2.8 → papers_cli-2.9.1}/papers/utils.py +15 -3
- {papers_cli-2.8 → papers_cli-2.9.1}/papers_cli.egg-info/PKG-INFO +1 -1
- {papers_cli-2.8 → papers_cli-2.9.1}/.gitattributes +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/.github/workflows/pypi.yml +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/.github/workflows/tests.yml +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/.gitignore +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/LICENSE +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/README.md +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/papers/__init__.py +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/papers/bib.py +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/papers/config.py +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/papers/duplicate.py +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/papers/extract.py +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/papers/filename.py +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/papers/latexenc.py +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/papers_cli.egg-info/SOURCES.txt +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/papers_cli.egg-info/dependency_links.txt +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/papers_cli.egg-info/entry_points.txt +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/papers_cli.egg-info/requires.txt +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/papers_cli.egg-info/top_level.txt +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/pyproject.toml +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/requirements.txt +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/setup.cfg +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/setup.py +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/tests/__init__.py +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/tests/common.py +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/tests/config.py +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/tests/download.py +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/tests/downloadedpapers/.gitignore +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/tests/downloadedpapers/bg-8-515-2011.txt +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/tests/test_add.py +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/tests/test_biblio.py +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/tests/test_duplicates.py +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/tests/test_encoding.py +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/tests/test_extract.py +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/tests/test_filecheck.py +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/tests/test_install.py +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/tests/test_list.py +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/tests/test_misc.py +0 -0
- {papers_cli-2.8 → papers_cli-2.9.1}/tests/test_undo.py +0 -0
|
@@ -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)
|
|
@@ -1132,7 +1152,7 @@ def get_parser(config=None):
|
|
|
1132
1152
|
|
|
1133
1153
|
grp = listp.add_argument_group('action on listed results (pipe)')
|
|
1134
1154
|
grp.add_argument('--delete', action='store_true')
|
|
1135
|
-
grp.add_argument('--edit', action='store_true', help='interactive edit text file with entries, and re-insert them')
|
|
1155
|
+
grp.add_argument('-e', '--edit', action='store_true', help='interactive edit text file with entries, and re-insert them')
|
|
1136
1156
|
grp.add_argument('--fetch', action='store_true', help='fetch and fix metadata')
|
|
1137
1157
|
grp.add_argument('--add-keywords', '--add-tag', nargs='+', help='add keywords to the selected entries')
|
|
1138
1158
|
grp.add_argument('--add-files', nargs='+', help='add files to the selected entries (only one entry must be listed)')
|
|
@@ -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.")
|
|
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
|
|
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
|