rename bibtex_field_excludes
into exclude_bibtex_fields
This commit is contained in:
parent
a14d6441a4
commit
d9c8af7c9a
@ -117,7 +117,7 @@ def command(conf, args):
|
|||||||
ui.error('invalid bibfile {}.'.format(bibfile))
|
ui.error('invalid bibfile {}.'.format(bibfile))
|
||||||
|
|
||||||
# exclude bibtex fields if specified
|
# 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
|
# citekey
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ def command(conf, args):
|
|||||||
"edited.".format(color.dye_out(citekey, 'citekey'))))
|
"edited.".format(color.dye_out(citekey, 'citekey'))))
|
||||||
else:
|
else:
|
||||||
# exclude bibtex fields if specified
|
# 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,
|
new_paper = Paper.from_bibentry(content,
|
||||||
metadata=paper.metadata)
|
metadata=paper.metadata)
|
||||||
|
@ -54,7 +54,7 @@ def command(conf, args):
|
|||||||
bib[p.citekey] = p.bibdata
|
bib[p.citekey] = p.bibdata
|
||||||
|
|
||||||
# exclude bibtex fields if specified
|
# 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()
|
exporter = endecoder.EnDecoder()
|
||||||
bibdata_raw = exporter.encode_bibdata(bib, args.ignore_fields)
|
bibdata_raw = exporter.encode_bibdata(bib, args.ignore_fields)
|
||||||
|
@ -41,7 +41,7 @@ def parser(subparsers, conf):
|
|||||||
return parser
|
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.
|
"""Extract list of papers found in bibliographic files in path.
|
||||||
|
|
||||||
The behavior is to:
|
The behavior is to:
|
||||||
@ -65,7 +65,7 @@ def many_from_path(ui, bibpath, bibtex_field_excludes=[], ignore=False):
|
|||||||
try:
|
try:
|
||||||
bibentry = coder.decode_bibdata(read_text_file(filepath))
|
bibentry = coder.decode_bibdata(read_text_file(filepath))
|
||||||
# exclude bibtex fields if specified
|
# exclude bibtex fields if specified
|
||||||
remove_bibtex_fields(bibentry, bibtex_field_excludes)
|
remove_bibtex_fields(bibentry, exclude_bibtex_fields)
|
||||||
biblist.append(bibentry)
|
biblist.append(bibentry)
|
||||||
except coder.BibDecodingError:
|
except coder.BibDecodingError:
|
||||||
error = "Could not parse bibtex at {}.".format(filepath)
|
error = "Could not parse bibtex at {}.".format(filepath)
|
||||||
@ -105,7 +105,7 @@ def command(conf, args):
|
|||||||
rp = repo.Repository(conf)
|
rp = repo.Repository(conf)
|
||||||
# Extract papers from bib
|
# Extract papers from bib
|
||||||
papers = many_from_path(ui, bibpath,
|
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)
|
ignore=args.ignore_malformed)
|
||||||
keys = args.keys or papers.keys()
|
keys = args.keys or papers.keys()
|
||||||
for k in keys:
|
for k in keys:
|
||||||
|
@ -35,8 +35,10 @@ max_authors = integer(default=3)
|
|||||||
# the full python stack is printed.
|
# the full python stack is printed.
|
||||||
debug = boolean(default=False)
|
debug = boolean(default=False)
|
||||||
|
|
||||||
# which bibliographic fields to exclude from bibtex files.
|
# which bibliographic fields to exclude from bibtex files. By default, none.
|
||||||
bibtex_field_excludes = force_list(default=list())
|
# 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]
|
[formating]
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ edit_cmd = "vim"
|
|||||||
debug = False
|
debug = False
|
||||||
|
|
||||||
# which bibliographic fields to exclude from bibtex files.
|
# which bibliographic fields to exclude from bibtex files.
|
||||||
bibtex_field_excludes =
|
exclude_bibtex_fields =
|
||||||
|
|
||||||
[formating]
|
[formating]
|
||||||
|
|
||||||
|
@ -440,7 +440,7 @@ class TestAdd(URLContentTestCase):
|
|||||||
def test_add_excludes_bibtex_fields(self):
|
def test_add_excludes_bibtex_fields(self):
|
||||||
self.execute_cmds(['pubs init'])
|
self.execute_cmds(['pubs init'])
|
||||||
config = conf.load_conf()
|
config = conf.load_conf()
|
||||||
config['main']['bibtex_field_excludes'] = ['abstract', 'publisher']
|
config['main']['exclude_bibtex_fields'] = ['abstract', 'publisher']
|
||||||
conf.save_conf(config)
|
conf.save_conf(config)
|
||||||
self.execute_cmds(['pubs add data/pagerank.bib'])
|
self.execute_cmds(['pubs add data/pagerank.bib'])
|
||||||
with FakeFileOpen(self.fs)(self.default_pubs_dir + '/bib/Page99.bib', 'r') as buf:
|
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)
|
self.execute_cmds(cmds)
|
||||||
config = conf.load_conf()
|
config = conf.load_conf()
|
||||||
config['main']['bibtex_field_excludes'] = ['author']
|
config['main']['exclude_bibtex_fields'] = ['author']
|
||||||
conf.save_conf(config)
|
conf.save_conf(config)
|
||||||
cmds = [('pubs edit Page99', ['@misc{Page99, title="TTT", author="auth"}', 'n'])]
|
cmds = [('pubs edit Page99', ['@misc{Page99, title="TTT", author="auth"}', 'n'])]
|
||||||
self.execute_cmds(cmds)
|
self.execute_cmds(cmds)
|
||||||
@ -940,7 +940,7 @@ class TestUsecase(DataCommandTestCase):
|
|||||||
]
|
]
|
||||||
self.execute_cmds(cmds)
|
self.execute_cmds(cmds)
|
||||||
config = conf.load_conf()
|
config = conf.load_conf()
|
||||||
config['main']['bibtex_field_excludes'] = ['url']
|
config['main']['exclude_bibtex_fields'] = ['url']
|
||||||
conf.save_conf(config)
|
conf.save_conf(config)
|
||||||
outs = self.execute_cmds(['pubs export Page99'])
|
outs = self.execute_cmds(['pubs export Page99'])
|
||||||
for bib in endecoder.EnDecoder().decode_bibdata(outs[0]).values():
|
for bib in endecoder.EnDecoder().decode_bibdata(outs[0]).values():
|
||||||
@ -1011,7 +1011,7 @@ class TestUsecase(DataCommandTestCase):
|
|||||||
def test_import_excludes_bibtex_field(self):
|
def test_import_excludes_bibtex_field(self):
|
||||||
self.execute_cmds(['pubs init'])
|
self.execute_cmds(['pubs init'])
|
||||||
config = conf.load_conf()
|
config = conf.load_conf()
|
||||||
config['main']['bibtex_field_excludes'] = ['abstract']
|
config['main']['exclude_bibtex_fields'] = ['abstract']
|
||||||
conf.save_conf(config)
|
conf.save_conf(config)
|
||||||
self.execute_cmds(['pubs import data/ Page99'])
|
self.execute_cmds(['pubs import data/ Page99'])
|
||||||
with FakeFileOpen(self.fs)(self.default_pubs_dir + '/bib/Page99.bib', 'r') as buf:
|
with FakeFileOpen(self.fs)(self.default_pubs_dir + '/bib/Page99.bib', 'r') as buf:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user