From 98c55105079e2de40904bfad1131f6a5eed3e6bd Mon Sep 17 00:00:00 2001 From: John Siirola Date: Fri, 30 Aug 2024 12:34:36 -0600 Subject: [PATCH] Rework RTD URL to work with the url checker --- .github/workflows/url_check.yml | 2 +- pyomo/common/log.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/url_check.yml b/.github/workflows/url_check.yml index 2afb8c7e588..797574574b4 100644 --- a/.github/workflows/url_check.yml +++ b/.github/workflows/url_check.yml @@ -29,4 +29,4 @@ jobs: # Exclude: # - Jenkins because it's behind a firewall # - RTD because a magically-generated string triggers failures - exclude_urls: 'https://pyomo-jenkins.sandia.gov/,https://pyomo.readthedocs.io/en/%s/errors.html#%s' + exclude_urls: https://pyomo-jenkins.sandia.gov/,https://pyomo.readthedocs.io/en/%s/errors.html diff --git a/pyomo/common/log.py b/pyomo/common/log.py index 3bf0a70c072..c4218e4fbd3 100644 --- a/pyomo/common/log.py +++ b/pyomo/common/log.py @@ -33,14 +33,16 @@ _indentation_re = re.compile(r'\s*') +_RTD_URL = "https://pyomo.readthedocs.io/en/%s/errors.html" + def RTD(_id): _id = str(_id).lower() - assert _id[0] in 'wex' - return "https://pyomo.readthedocs.io/en/%s/errors.html#%s" % ( - 'stable' if (releaselevel == 'final' or in_testing_environment()) else 'latest', - _id, + _release = ( + 'stable' if releaselevel == 'final' or in_testing_environment() else 'latest' ) + assert _id[0] in 'wex' + return (_RTD_URL % (_release,)) + f"#{_id}" _DEBUG = logging.DEBUG