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

fix generation of schema.org citation format #233

Merged
merged 1 commit into from
Dec 28, 2024
Merged
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
11 changes: 6 additions & 5 deletions src/PyPop/citation.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,17 @@ def convert_citation_formats(build_lib, citation_path):
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)
# use getattr to get the method based on the format string, remove periods in methods
convert_method = getattr(cff, f"as_{fmt.replace('.', '')}", None)
if callable(convert_method):
converted_content = convert_method()

# 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)
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__":

Expand Down
Loading