diff --git a/pubs/commands/add_cmd.py b/pubs/commands/add_cmd.py index 88091f6..b56927e 100644 --- a/pubs/commands/add_cmd.py +++ b/pubs/commands/add_cmd.py @@ -117,7 +117,7 @@ def command(conf, args): ui.error('invalid bibfile {}.'.format(bibfile)) # exclude bibtex fields if specified - utils.remove_bibtex_fields(bibentry, conf['main']['bibtex_field_excludes']) + utils.remove_bibtex_fields(bibentry, conf['main']['exclude_bibtex_fields']) # citekey diff --git a/pubs/commands/edit_cmd.py b/pubs/commands/edit_cmd.py index 591c2d1..3e52383 100644 --- a/pubs/commands/edit_cmd.py +++ b/pubs/commands/edit_cmd.py @@ -60,7 +60,7 @@ def command(conf, args): "edited.".format(color.dye_out(citekey, 'citekey')))) else: # exclude bibtex fields if specified - remove_bibtex_fields(content, conf['main']['bibtex_field_excludes']) + remove_bibtex_fields(content, conf['main']['exclude_bibtex_fields']) new_paper = Paper.from_bibentry(content, metadata=paper.metadata) diff --git a/pubs/commands/export_cmd.py b/pubs/commands/export_cmd.py index c3c3a89..9c3831b 100644 --- a/pubs/commands/export_cmd.py +++ b/pubs/commands/export_cmd.py @@ -54,7 +54,7 @@ def command(conf, args): bib[p.citekey] = p.bibdata # exclude bibtex fields if specified - remove_bibtex_fields(bib, conf['main']['bibtex_field_excludes']) + remove_bibtex_fields(bib, conf['main']['exclude_bibtex_fields']) exporter = endecoder.EnDecoder() bibdata_raw = exporter.encode_bibdata(bib, args.ignore_fields) diff --git a/pubs/commands/import_cmd.py b/pubs/commands/import_cmd.py index a33e467..775ae41 100644 --- a/pubs/commands/import_cmd.py +++ b/pubs/commands/import_cmd.py @@ -41,7 +41,7 @@ def parser(subparsers, conf): return parser -def many_from_path(ui, bibpath, bibtex_field_excludes=[], ignore=False): +def many_from_path(ui, bibpath, exclude_bibtex_fields=[], ignore=False): """Extract list of papers found in bibliographic files in path. The behavior is to: @@ -65,7 +65,7 @@ def many_from_path(ui, bibpath, bibtex_field_excludes=[], ignore=False): try: bibentry = coder.decode_bibdata(read_text_file(filepath)) # exclude bibtex fields if specified - remove_bibtex_fields(bibentry, bibtex_field_excludes) + remove_bibtex_fields(bibentry, exclude_bibtex_fields) biblist.append(bibentry) except coder.BibDecodingError: error = "Could not parse bibtex at {}.".format(filepath) @@ -105,7 +105,7 @@ def command(conf, args): rp = repo.Repository(conf) # Extract papers from bib papers = many_from_path(ui, bibpath, - bibtex_field_excludes=conf['main']['bibtex_field_excludes'], + exclude_bibtex_fields=conf['main']['exclude_bibtex_fields'], ignore=args.ignore_malformed) keys = args.keys or papers.keys() for k in keys: diff --git a/pubs/config/spec.py b/pubs/config/spec.py index ee8579d..a323ada 100644 --- a/pubs/config/spec.py +++ b/pubs/config/spec.py @@ -35,8 +35,10 @@ max_authors = integer(default=3) # the full python stack is printed. debug = boolean(default=False) -# which bibliographic fields to exclude from bibtex files. -bibtex_field_excludes = force_list(default=list()) +# which bibliographic fields to exclude from bibtex files. By default, none. +# Please note that excluding critical fields such as `title` or `author` +# will break many commands of pubs. +exclude_bibtex_fields = force_list(default=list()) [formating] diff --git a/tests/str_fixtures.py b/tests/str_fixtures.py index 2e79f52..7dfd5b8 100644 --- a/tests/str_fixtures.py +++ b/tests/str_fixtures.py @@ -139,7 +139,7 @@ edit_cmd = "vim" debug = False # which bibliographic fields to exclude from bibtex files. -bibtex_field_excludes = +exclude_bibtex_fields = [formating] diff --git a/tests/test_usecase.py b/tests/test_usecase.py index 20e8242..053543d 100644 --- a/tests/test_usecase.py +++ b/tests/test_usecase.py @@ -440,7 +440,7 @@ class TestAdd(URLContentTestCase): def test_add_excludes_bibtex_fields(self): self.execute_cmds(['pubs init']) config = conf.load_conf() - config['main']['bibtex_field_excludes'] = ['abstract', 'publisher'] + config['main']['exclude_bibtex_fields'] = ['abstract', 'publisher'] conf.save_conf(config) self.execute_cmds(['pubs add data/pagerank.bib']) with FakeFileOpen(self.fs)(self.default_pubs_dir + '/bib/Page99.bib', 'r') as buf: @@ -846,7 +846,7 @@ class TestUsecase(DataCommandTestCase): ] self.execute_cmds(cmds) config = conf.load_conf() - config['main']['bibtex_field_excludes'] = ['author'] + config['main']['exclude_bibtex_fields'] = ['author'] conf.save_conf(config) cmds = [('pubs edit Page99', ['@misc{Page99, title="TTT", author="auth"}', 'n'])] self.execute_cmds(cmds) @@ -940,7 +940,7 @@ class TestUsecase(DataCommandTestCase): ] self.execute_cmds(cmds) config = conf.load_conf() - config['main']['bibtex_field_excludes'] = ['url'] + config['main']['exclude_bibtex_fields'] = ['url'] conf.save_conf(config) outs = self.execute_cmds(['pubs export Page99']) for bib in endecoder.EnDecoder().decode_bibdata(outs[0]).values(): @@ -1011,7 +1011,7 @@ class TestUsecase(DataCommandTestCase): def test_import_excludes_bibtex_field(self): self.execute_cmds(['pubs init']) config = conf.load_conf() - config['main']['bibtex_field_excludes'] = ['abstract'] + config['main']['exclude_bibtex_fields'] = ['abstract'] conf.save_conf(config) self.execute_cmds(['pubs import data/ Page99']) with FakeFileOpen(self.fs)(self.default_pubs_dir + '/bib/Page99.bib', 'r') as buf: