From a30e75a5e6c0ab45fe580ae576e6f9bb56101ca8 Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Tue, 5 May 2020 01:11:07 +0900 Subject: [PATCH] support all one_liner + fix deprecation warnings in utils --- pubs/commands/add_cmd.py | 2 +- pubs/commands/tag_cmd.py | 2 +- pubs/config/spec.py | 3 ++- pubs/utils.py | 12 ++++++------ 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/pubs/commands/add_cmd.py b/pubs/commands/add_cmd.py index a2af9cd..74e5a46 100644 --- a/pubs/commands/add_cmd.py +++ b/pubs/commands/add_cmd.py @@ -147,7 +147,7 @@ def command(conf, args): doc_add = conf['main']['doc_add'] rp.push_paper(p) - ui.message('added to pubs:\n{}'.format(pretty.paper_oneliner(p))) + ui.message('added to pubs:\n{}'.format(pretty.paper_oneliner(p, n_authors=conf['main']['n_authors']))) if docfile is not None: rp.push_doc(p.citekey, docfile, copy=(doc_add in ('copy', 'move'))) if doc_add == 'move' and content.content_type(docfile) != 'url': diff --git a/pubs/commands/tag_cmd.py b/pubs/commands/tag_cmd.py index da656b4..90d6d9c 100644 --- a/pubs/commands/tag_cmd.py +++ b/pubs/commands/tag_cmd.py @@ -117,7 +117,7 @@ def command(conf, args): len(p.tags.intersection(excluded)) == 0): papers_list.append(p) - ui.message('\n'.join(pretty.paper_oneliner(p) + ui.message('\n'.join(pretty.paper_oneliner(p, n_authors=conf['main']['n_authors']) for p in papers_list)) rp.close() diff --git a/pubs/config/spec.py b/pubs/config/spec.py index a31d1b4..4aba92b 100644 --- a/pubs/config/spec.py +++ b/pubs/config/spec.py @@ -27,7 +27,8 @@ edit_cmd = string(default='') # Which default extension to use when creating a note file. note_extension = string(default='txt') -# How many authors to display in +# How many authors to display when displaying a citation. If there are more +# authors, only the first author is diplayed followed by 'et al.'. n_authors = integer(default=3) # If true debug mode is on which means exceptions are not catched and diff --git a/pubs/utils.py b/pubs/utils.py index eda7480..a7aceb1 100644 --- a/pubs/utils.py +++ b/pubs/utils.py @@ -33,7 +33,7 @@ def resolve_citekey(repo, citekey, ui=None, exit_on_fail=True): "citekeys:".format(citekey)) for c in citekeys: p = repo.pull_paper(c) - ui.message(' {}'.format(pretty.paper_oneliner(p))) + ui.message(' {}'.format(pretty.paper_oneliner(p, n_authors=conf['main']['n_authors']))) if exit_on_fail: ui.exit() return citekey @@ -73,11 +73,11 @@ def standardize_doi(doi): """ doi_regexes = ( - '(10\.\d{4,9}/[-._;()/:A-z0-9\>\<]+)', - '(10.1002/[^\s]+)', - '(10\.\d{4}/\d+-\d+X?(\d+)\d+<[\d\w]+:[\d\w]*>\d+.\d+.\w+;\d)', - '(10\.1021/\w\w\d+\+)', - '(10\.1207/[\w\d]+\&\d+_\d+)') + r'(10\.\d{4,9}/[-._;()/:A-z0-9\>\<]+)', + r'(10.1002/[^\s]+)', + r'(10\.\d{4}/\d+-\d+X?(\d+)\d+<[\d\w]+:[\d\w]*>\d+.\d+.\w+;\d)', + r'(10\.1021/\w\w\d+\+)', + r'(10\.1207/[\w\d]+\&\d+_\d+)') doi_pattern = re.compile('|'.join(doi_regexes)) match = doi_pattern.search(doi)