@@ -786,7 +786,18 @@ def build_workflow(opts, retval):
786
786
boilerplate = retval ['workflow' ].visit_desc ()
787
787
788
788
if boilerplate :
789
- (logs_path / 'CITATION.md' ).write_text (boilerplate )
789
+ # To please git-annex users and also to guarantee consistency
790
+ # among different renderings of the same file, first remove any
791
+ # existing one
792
+ citation_files = {
793
+ ext : logs_path / ('CITATION.%s' % ext )
794
+ for ext in ('bib' , 'tex' , 'md' , 'html' )
795
+ }
796
+ for citation_file in citation_files .values ():
797
+ if citation_file .exists () or citation_file .is_symlink ():
798
+ citation_file .unlink ()
799
+
800
+ citation_files ['md' ].write_text (boilerplate )
790
801
logger .log (25 , 'Works derived from this fMRIPrep execution should '
791
802
'include the following boilerplate:\n \n %s' , boilerplate )
792
803
@@ -795,8 +806,8 @@ def build_workflow(opts, retval):
795
806
pkgrf ('fmriprep' , 'data/boilerplate.bib' ),
796
807
'--filter' , 'pandoc-citeproc' ,
797
808
'--metadata' , 'pagetitle="fMRIPrep citation boilerplate"' ,
798
- str (logs_path / 'CITATION. md' ),
799
- '-o' , str (logs_path / 'CITATION. html' )]
809
+ str (citation_files [ ' md'] ),
810
+ '-o' , str (citation_files [ ' html'] )]
800
811
try :
801
812
check_call (cmd , timeout = 10 )
802
813
except (FileNotFoundError , CalledProcessError , TimeoutExpired ):
@@ -806,16 +817,16 @@ def build_workflow(opts, retval):
806
817
# Generate LaTex file resolving citations
807
818
cmd = ['pandoc' , '-s' , '--bibliography' ,
808
819
pkgrf ('fmriprep' , 'data/boilerplate.bib' ),
809
- '--natbib' , str (logs_path / 'CITATION. md' ),
810
- '-o' , str (logs_path / 'CITATION. tex' )]
820
+ '--natbib' , str (citation_files [ ' md'] ),
821
+ '-o' , str (citation_files [ ' tex'] )]
811
822
try :
812
823
check_call (cmd , timeout = 10 )
813
824
except (FileNotFoundError , CalledProcessError , TimeoutExpired ):
814
825
logger .warning ('Could not generate CITATION.tex file:\n %s' ,
815
826
' ' .join (cmd ))
816
827
else :
817
828
copyfile (pkgrf ('fmriprep' , 'data/boilerplate.bib' ),
818
- ( logs_path / 'CITATION. bib') )
829
+ citation_files [ ' bib'] )
819
830
820
831
return retval
821
832
0 commit comments