Skip to content

Commit

Permalink
configure citations
Browse files Browse the repository at this point in the history
  • Loading branch information
shapiromatron committed Sep 11, 2024
1 parent 2ccba35 commit e19799c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
11 changes: 4 additions & 7 deletions bmds_ui/analysis/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import re
from textwrap import dedent

from django.conf import settings
from django.utils.timezone import now
Expand All @@ -13,14 +12,12 @@ def get_citation() -> str:
"""
Return a citation for the software.
"""
year = now().strftime("%Y")
year = "20" + __version__[:2]
accessed = now().strftime("%B %d, %Y")
version = get_version()
uri = settings.WEBSITE_URI
return dedent(
f"""\
United States Environmental Protection Agency. ({year}). BMDS Online ({__version__}; pybmds {version.python}; bmdscore {version.dll}) [Web App]. Available from {uri}. Accessed {accessed}."""
)
application = "BMDS Desktop" if settings.IS_DESKTOP else "BMDS Online"
uri = "https://pypi.org/project/bmds-ui/" if settings.IS_DESKTOP else settings.WEBSITE_URI
return f"U.S. Environmental Protection Agency. ({year}). {application} ({__version__}; pybmds {version.python}; bmdscore {version.dll}) [Software]. Available from {uri}. Accessed {accessed}."


re_hex_color = re.compile("^#(?:[0-9a-fA-F]{3}){1,2}$")
12 changes: 12 additions & 0 deletions tests/analysis/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from bmds_ui.analysis import utils


def test_get_citation(settings):
initial = settings.IS_DESKTOP
settings.IS_DESKTOP = False
assert "BMDS Online" in utils.get_citation()
print(utils.get_citation())
settings.IS_DESKTOP = True
assert "BMDS Desktop" in utils.get_citation()
print(utils.get_citation())
settings.IS_DESKTOP = initial

0 comments on commit e19799c

Please sign in to comment.