From 90adf26f78067cf0a6931fec2596bd006f550487 Mon Sep 17 00:00:00 2001 From: boyan Date: Fri, 28 Apr 2023 21:11:38 -0400 Subject: [PATCH 1/5] two comments, no functional changes --- papers/__main__.py | 5 ++++- papers/bib.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/papers/__main__.py b/papers/__main__.py index 20fbf0e..7cce6fa 100644 --- a/papers/__main__.py +++ b/papers/__main__.py @@ -31,6 +31,9 @@ def check_legacy_config(configfile): def get_biblio(config): + """ + Given a config, get the Biblio object associated with this run. If there's no Biblio object, will make a new one, silently. + """ if config.bibtex is None: raise ValueError('bibtex is not initialized') relative_to = os.path.sep if config.absolute_paths else (os.path.dirname(config.bibtex) if config.bibtex else None) @@ -1105,4 +1108,4 @@ class PapersExit(Exception): try: main() except PapersExit: - sys.exit(1) \ No newline at end of file + sys.exit(1) diff --git a/papers/bib.py b/papers/bib.py index da6bcc3..4271647 100644 --- a/papers/bib.py +++ b/papers/bib.py @@ -198,7 +198,7 @@ class DuplicateKeyError(ValueError): class Biblio: """ - main config + The bibtex object that we operate on, which is mainly used to read and write to dynamically, and can then send the changes to be stored in a specified bibtex file on disk. """ def __init__(self, db=None, filesdir=None, key_field='ID', nameformat=NAMEFORMAT, keyformat=KEYFORMAT, similarity=DEFAULT_SIMILARITY, relative_to=None): """ @@ -786,4 +786,4 @@ def entry_filecheck(e, delete_broken=False, fix_mendeley=False, newfiles.append(file) - e['file'] = format_file(newfiles, relative_to=relative_to) \ No newline at end of file + e['file'] = format_file(newfiles, relative_to=relative_to) From e64f0b75482d0b0ae5c55f673bce6b71b9c4c6d3 Mon Sep 17 00:00:00 2001 From: Boyan Penkov Date: Sat, 29 Apr 2023 21:49:22 -0400 Subject: [PATCH 2/5] comment --- papers/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/papers/__main__.py b/papers/__main__.py index 7cce6fa..e791533 100644 --- a/papers/__main__.py +++ b/papers/__main__.py @@ -1,4 +1,4 @@ -"""That is the script called by papers +"""That is the script called by the papers cli command. """ import os import sys From 6a4a58dbd101a1e193ff42ce0dd766b78b0b05c8 Mon Sep 17 00:00:00 2001 From: boyan Date: Thu, 4 May 2023 13:23:01 -0400 Subject: [PATCH 3/5] comments only --- papers/__main__.py | 3 +++ papers/bib.py | 3 +++ tests/__init__.py | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/papers/__main__.py b/papers/__main__.py index e791533..8a74d67 100644 --- a/papers/__main__.py +++ b/papers/__main__.py @@ -474,6 +474,9 @@ def addcmd(parser, o, config): savebib(biblio, config) def checkcmd(parser, o, config): + """ + Loops over the entire bib file that the Papers install sees, and checks each entry for formatting and for the existance of duplicates. Then writes the Biblio object back to your Bibtex file. + """ set_keyformat_config_from_cmd(o, config) biblio = get_biblio(config) diff --git a/papers/bib.py b/papers/bib.py index 4271647..ef3d01a 100644 --- a/papers/bib.py +++ b/papers/bib.py @@ -591,6 +591,9 @@ def rename_entries_files(self, copy=False, relative_to=None): def fix_entry(self, e, fix_doi=True, fetch=False, fetch_all=False, fix_key=False, auto_key=False, key_ascii=False, encoding=None, format_name=True, interactive=False): + """ + Given an entry in an existing Bilio object, checks the format name and encoding. Will fetch additional info if it's missing. + """ e_old = e.copy() diff --git a/tests/__init__.py b/tests/__init__.py index 587bfa5..65b05e2 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -2,4 +2,4 @@ # setup user name and user email if not set (otherwise commit will fail) sp.check_call('git config --list | grep user.name || git config --global user.name "Papers Tests"', shell=True) sp.check_call('git config --list | grep user.email || git config --global user.email "papers.tests@github.com"', shell=True) -del sp \ No newline at end of file +del sp From 4dc3184ff2827a2b4e695ac404688cfdc2041963 Mon Sep 17 00:00:00 2001 From: boyan Date: Tue, 9 May 2023 06:57:46 -0400 Subject: [PATCH 4/5] one more set here --- papers/__main__.py | 4 ++-- papers/bib.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/papers/__main__.py b/papers/__main__.py index 8a74d67..00abe8b 100644 --- a/papers/__main__.py +++ b/papers/__main__.py @@ -411,7 +411,7 @@ def check_install(parser, o, config): def addcmd(parser, o, config): """ - Given an options set and a config, sets up the function call to add the file or dir to the bibtex, and executes it. + Given an options set and a config, sets up the function call to add the file or all files in the directory to the bibtex, and executes it. """ set_nameformat_config_from_cmd(o, config) @@ -936,7 +936,7 @@ def get_parser(config=None): # list # ====== - listp = subparsers.add_parser('list', description='list (a subset of) entries', + listp = subparsers.add_parser('list', description='list (a subset of) entries in the existing bib file.', parents=[cfg]) listp.add_argument('fullsearch', nargs='*', help='''Search field. Usually no quotes required. See keywords to search specific fields. All words must find a match, unless --any is passed.''') diff --git a/papers/bib.py b/papers/bib.py index ef3d01a..c6dce03 100644 --- a/papers/bib.py +++ b/papers/bib.py @@ -716,6 +716,9 @@ def entry_filecheck_metadata(e, file, image=False): def entry_filecheck(e, delete_broken=False, fix_mendeley=False, check_hash=False, check_metadata=False, interactive=True, image=False, relative_to=None): + """ + Checks the bib entry file actually corresponds to an existing, correct file on disk. + """ if 'file' not in e: return From 9d195646e9e239de8c8a59f7e118298eb1a29797 Mon Sep 17 00:00:00 2001 From: Boyan Penkov Date: Sun, 26 May 2024 10:23:40 -0400 Subject: [PATCH 5/5] mahes comment is better --- papers/__main__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/papers/__main__.py b/papers/__main__.py index 00abe8b..3f8fe49 100644 --- a/papers/__main__.py +++ b/papers/__main__.py @@ -32,7 +32,9 @@ def check_legacy_config(configfile): def get_biblio(config): """ - Given a config, get the Biblio object associated with this run. If there's no Biblio object, will make a new one, silently. + This function initializes a Biblio object based on the bibtex file specified as command line argument or in config file. + + If no bibtex file is specified, it raises a ValueError(). """ if config.bibtex is None: raise ValueError('bibtex is not initialized')