user [email protected]
usertags 1145151 python3.15
tags 1145151 patch
thanks

Hi!

While rebuilding the python related packages against the Python 3.15rc2 version 
I ran into this FTBFS [1].

The problem was caused by citeproc moving hardvard1 to harvard-cite-them-right. 
This is not a drop in replacement, but I have created a patch that adapts 
duecredit's tests to this new style.

This patch should probably be forwarded upstream.

I've applied this fix in the sandbox [2] to verify that duecredit builds 
successfully, it should also be applied in Debian to get the package back to a 
healthy state.

Happy hacking,

[1]: https://debusine.debian.net/debian/r-python-python3.15/artifact/4437035/
[2]: https://debusine.debian.net/debian/r-python-python3.15/

--
"Can you imagine what I would do if I could do all I can?" -- Sun Tzu
Saludos /\/\ /\ >< `/
Description: Use harvard-cite-them-right style instead of harvard1
 citeproc-py replaced the bundled harvard1 CSL style with harvard-cite-them-right.
Author: Debian Python Team <[email protected]>
Forwarded: no
--- a/duecredit/cmdline/cmd_summary.py
+++ b/duecredit/cmdline/cmd_summary.py
@@ -34,8 +34,8 @@ def setup_parser(parser: argparse.ArgumentParser) -> None:
 
     parser.add_argument(
         "--style",
-        choices=("apa", "harvard1"),
-        default="harvard1",
+        choices=("apa", "harvard-cite-them-right"),
+        default="harvard-cite-them-right",
         help="Style to be used for listing citations",
     )
 
--- a/duecredit/io.py
+++ b/duecredit/io.py
@@ -174,7 +174,7 @@ class TextOutput(Output):
         if "DUECREDIT_STYLE" in os.environ:
             self.style = os.environ["DUECREDIT_STYLE"]
         else:
-            self.style = "harvard1"
+            self.style = "harvard-cite-them-right"
 
     @staticmethod
     def _format_citations(citations, citation_nr) -> str:
@@ -244,7 +244,9 @@ class TextOutput(Output):
             self.fd.write("\n")
 
 
-def get_text_rendering(entry: DueCreditEntry, style: str = "harvard1") -> str:
+def get_text_rendering(
+    entry: DueCreditEntry, style: str = "harvard-cite-them-right"
+) -> str:
     if isinstance(entry, Doi):
         return format_bibtex(get_bibtex_rendering(entry), style=style)
     elif isinstance(entry, BibTeX):
@@ -290,7 +292,9 @@ def condition_bibtex(bibtex: str) -> bytes:
 
 
 def format_bibtex(
-    bibtex_entry: BibTeX, style: str = "harvard1", formatter: str = "plain"
+    bibtex_entry: BibTeX,
+    style: str = "harvard-cite-them-right",
+    formatter: str = "plain",
 ) -> str:
     """Format a BibTeX entry as a citation string.
 
@@ -299,7 +303,7 @@ def format_bibtex(
     bibtex_entry : BibTeX
         The BibTeX entry to format.
     style : str, optional
-        Citation style (default: "harvard1").
+        Citation style (default: "harvard-cite-them-right").
     formatter : str, optional
         Output format: "plain" (default), "html", or "rst".
 
--- a/duecredit/tests/test_io.py
+++ b/duecredit/tests/test_io.py
@@ -322,7 +322,9 @@ def test_text_output() -> None:
     assert "1 module cited" in value, f"value was {value}"
     assert "0 functions cited" in value, f"value was {value}"
     assert "Halchenko, Y.O." in value, f"value was {value}"
-    assert value.strip().endswith("Frontiers in Neuroinformatics, 6(22).")
+    assert value.strip().endswith(
+        "Frontiers in Neuroinformatics, 6(22). Available at: https://doi.org/10.3389/fninf.2012.00022.";
+    )
 
     # in this case, we should be citing the package since we are also citing a
     # submodule
@@ -567,13 +569,13 @@ def test_get_text_rendering(monkeypatch: MonkeyPatch) -> None:
     # test if bibtex type is passed
     bibtex_output = get_text_rendering(sample_bibtex)
     assert fmt_args["entry"] == sample_bibtex
-    assert fmt_args["style"] == "harvard1"
+    assert fmt_args["style"] == "harvard-cite-them-right"
     fmt_args.clear()
 
     # test if doi type is passed
     doi_output = get_text_rendering(Doi(_sample_doi))
     assert fmt_args["entry"] == sample_bibtex
-    assert fmt_args["style"] == "harvard1"
+    assert fmt_args["style"] == "harvard-cite-them-right"
 
     assert bibtex_output == doi_output
 
@@ -611,7 +613,7 @@ def test_format_bibtex_zenodo_doi() -> None:
     """
     assert (
         format_bibtex(BibTeX(bibtex_zenodo))
-        == """Ghosh, S. et al., 2016. nipype: Release candidate 1 for version 0.12.0."""
+        == """Ghosh, S. et al. (2016) “nipype: Release candidate 1 for version 0.12.0”. Zenodo. Available at: https://doi.org/10.5281/zenodo.50186.""";
     )
 
 
@@ -633,7 +635,8 @@ def test_format_bibtex_with_utf_characters() -> None:
         "2.0.1},\n  publisher = {Zenodo},\n  year = {2015}\n} "
     )
     assert (
-        format_bibtex(BibTeX(bibtex_utf8)) == "Brótt, M. et al., 2015. nibabel 2.0.1."
+        format_bibtex(BibTeX(bibtex_utf8))
+        == "Brótt, M. et al. (2015) “nibabel 2.0.1”. Zenodo. Available at: https://doi.org/10.5281/zenodo.60847.";
     )
 
 

Reply via email to