-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/output-citation' into citation-c…
…ff-zenodo
- Loading branch information
Showing
15 changed files
with
120 additions
and
566 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/usr/bin/env python | ||
|
||
# This file is part of PyPop | ||
|
||
# Copyright (C) 2017. | ||
# All Rights Reserved. | ||
|
||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2, or (at your option) | ||
# any later version. | ||
|
||
# This program is distributed in the hope that it will be useful, but | ||
# WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# General Public License for more details. | ||
|
||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | ||
# 02111-1307, USA. | ||
|
||
# IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, | ||
# INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING | ||
# LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS | ||
# DOCUMENTATION, EVEN IF REGENTS HAS BEEN ADVISED OF THE POSSIBILITY | ||
# OF SUCH DAMAGE. | ||
|
||
# REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT | ||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
# FOR A PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING | ||
# DOCUMENTATION, IF ANY, PROVIDED HEREUNDER IS PROVIDED "AS | ||
# IS". REGENTS HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, | ||
# UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | ||
|
||
import os | ||
import shutil | ||
|
||
citation_output_formats = ['apalike', 'bibtex', 'endnote', 'ris', 'codemeta', 'cff'] | ||
|
||
def convert_citation_formats(build_lib, citation_path): | ||
|
||
from cffconvert import Citation | ||
|
||
# target directory for the CITATION file within the build directory | ||
target_dir = os.path.join(build_lib, "PyPop", "citation") | ||
|
||
# create the citation directory if it doesn’t exist | ||
os.makedirs(target_dir, exist_ok=True) | ||
shutil.copy(citation_path, target_dir) | ||
|
||
# load the CITATION.cff content | ||
cff = Citation(cffstr=open(citation_path).read()) | ||
|
||
# remove 'cff' from generated list - since we don't generate that | ||
citation_output_formats.remove('cff') | ||
|
||
for fmt in citation_output_formats: | ||
# use getattr to get the method based on the format string | ||
convert_method = getattr(cff, f"as_{fmt}", None) | ||
if callable(convert_method): | ||
converted_content = convert_method() | ||
else: | ||
print(f"Conversion format '{fmt}' not supported.") | ||
|
||
# save the converted output (e.g., as CITATION.json) | ||
with open(os.path.join(target_dir, "CITATION." + fmt), "w") as f: | ||
f.write(converted_content) | ||
|
||
if __name__ == "__main__": | ||
|
||
convert_citation_formats("src", "CITATION.cff") | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.