-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CITATION.cff file with main contributors (#159)
* Add CITATION.cff file with main contributors * Add script to bump version in README.md and CITATION.cff
- Loading branch information
1 parent
c330a36
commit f5ff67d
Showing
5 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
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,67 @@ | ||
from datetime import datetime | ||
from typing import Callable, Dict | ||
import re | ||
|
||
citation_regex = lambda new_date, content: re.sub( | ||
r"date-released: \d{4}-\d{2}-\d{2}", f"date-released: {new_date}", content | ||
) | ||
|
||
readme_regexes = { | ||
"bibtex_year": lambda year, content: re.sub(r"\{\d{4}\}", str(year), content), # {2023} in bibtex | ||
"bibtex_month": lambda month, content: re.sub(r"\{\d{1,2}\}", str(month), content), # {5} or {12} in bibtex | ||
"plain_bib_year": lambda year, content: re.sub(r"(\d{4})", str(year), content), # (2023) in the plain bibliography | ||
} | ||
|
||
|
||
def bump_citation_file( | ||
new_date: str, | ||
filename: str = "CITATION.cff", | ||
regex_function: Callable = citation_regex, | ||
) -> None: | ||
""" | ||
Runs a specific regex function on the defined citation file | ||
""" | ||
with open(filename, "r") as f: | ||
content = f.read() | ||
|
||
with open(filename, "w") as f: | ||
content = regex_function(new_date, content) | ||
f.write(content) | ||
|
||
|
||
def bump_readme_file( | ||
year: str, | ||
month: str, | ||
regex_functions: Dict[str, Callable] = readme_regexes, | ||
filename: str = "README.md", | ||
) -> None: | ||
""" | ||
Runs the required regex functions on the README file | ||
""" | ||
with open(filename, "r") as f: | ||
content = f.read() | ||
|
||
with open(filename, "w") as f: | ||
content = regex_functions["bibtex_year"](year, content) | ||
content = regex_functions["bibtex_month"](month, content) | ||
content = regex_functions["plain_bib_year"](year, content) | ||
f.write(content) | ||
|
||
|
||
def bump_date() -> None: | ||
""" | ||
A developer function to bump the date when a version is bumped. | ||
Run after bump2version is run, since bump2version doesn't allow updating | ||
the date in e.g. README.md and CITATION.cff. | ||
""" | ||
new_date = datetime.now().strftime("%Y-%m-%d") | ||
year = str(datetime.now().year) | ||
month = str(datetime.now().month) | ||
|
||
bump_citation_file(new_date=new_date) | ||
bump_readme_file(year=year, month=month) | ||
|
||
|
||
if __name__ == "__main__": | ||
bump_date() |
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,21 @@ | ||
cff-version: 1.2.0 | ||
message: "If you use this software, please cite it as below." | ||
authors: | ||
- family-names: "Teuwen" | ||
given-names: "Jonas" | ||
orcid: "https://orcid.org/0000-0002-1825-1428" | ||
- family-names: "Romor" | ||
given-names: "Leonardo" | ||
- family-names: "Pai" | ||
given-names: "Ajey" | ||
orcid: "https://orcid.org/0009-0003-3970-9236" | ||
- family-names: "Schirris" | ||
given-names: "Yoni" | ||
orcid: "https://orcid.org/0000-0003-0217-8737" | ||
- family-names: "Marcus" | ||
given-names: "Eric" | ||
orchid: "https://orcid.org/0000-0002-3375-6248" | ||
title: "DLUP: Deep Learning Utilities for Pathology" | ||
version: 0.3.29 | ||
date-released: 2023-10-10 | ||
url: "https://github.com/nki-ai/dlup" |
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