Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: remove all prior existing citation files first #1567

Merged
merged 3 commits into from
Apr 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@
"affiliation": "University College London",
"orcid": "0000-0002-9699-9052"
},
{
"name": "Halchenko, Yaroslav O.",
"affiliation": "Dartmouth College: Hanover, NH, United States",
"orcid": "0000-0003-3456-2493"
},
{
"name": "Poldrack, Russell A.",
"affiliation": "Department of Psychology, Stanford University",
Expand Down
23 changes: 17 additions & 6 deletions fmriprep/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,18 @@ def build_workflow(opts, retval):
boilerplate = retval['workflow'].visit_desc()

if boilerplate:
(logs_path / 'CITATION.md').write_text(boilerplate)
# To please git-annex users and also to guarantee consistency
# among different renderings of the same file, first remove any
# existing one
citation_files = {
ext: logs_path / ('CITATION.%s' % ext)
for ext in ('bib', 'tex', 'md', 'html')
}
for citation_file in citation_files.values():
if citation_file.exists() or citation_file.is_symlink():
citation_file.unlink()

citation_files['md'].write_text(boilerplate)
logger.log(25, 'Works derived from this fMRIPrep execution should '
'include the following boilerplate:\n\n%s', boilerplate)

Expand All @@ -795,8 +806,8 @@ def build_workflow(opts, retval):
pkgrf('fmriprep', 'data/boilerplate.bib'),
'--filter', 'pandoc-citeproc',
'--metadata', 'pagetitle="fMRIPrep citation boilerplate"',
str(logs_path / 'CITATION.md'),
'-o', str(logs_path / 'CITATION.html')]
str(citation_files['md']),
'-o', str(citation_files['html'])]
try:
check_call(cmd, timeout=10)
except (FileNotFoundError, CalledProcessError, TimeoutExpired):
Expand All @@ -806,16 +817,16 @@ def build_workflow(opts, retval):
# Generate LaTex file resolving citations
cmd = ['pandoc', '-s', '--bibliography',
pkgrf('fmriprep', 'data/boilerplate.bib'),
'--natbib', str(logs_path / 'CITATION.md'),
'-o', str(logs_path / 'CITATION.tex')]
'--natbib', str(citation_files['md']),
'-o', str(citation_files['tex'])]
try:
check_call(cmd, timeout=10)
except (FileNotFoundError, CalledProcessError, TimeoutExpired):
logger.warning('Could not generate CITATION.tex file:\n%s',
' '.join(cmd))
else:
copyfile(pkgrf('fmriprep', 'data/boilerplate.bib'),
(logs_path / 'CITATION.bib'))
citation_files['bib'])

return retval

Expand Down