Repository: ioos/compliance-checker

Issue:
Checker fails downloading latest standard name table
**Version of compliance checker running:**
IOOS compliance checker version 5.0.2

**Describe the checker this affects:**
CF

**Attach a minimal CDL or NetCDF file which is able to reproduce the issue**
N/A

**To Reproduce:**
Run `compliance-checker -d latest`

_Expected result:_ 
update standard name list

_Actual result:_ 
```
Traceback (most recent call last):
  File "/Users/dnowacki/miniconda3/bin/compliance-checker", line 10, in <module>
    sys.exit(main())
  File "/Users/dnowacki/miniconda3/bin/cchecker.py", line 269, in main
    download_cf_standard_name_table(args.download_standard_names)
  File "/Users/dnowacki/miniconda3/lib/python3.10/site-packages/compliance_checker/cf/util.py", line 434, in download_cf_standard_name_table
    tables_tree = lxml.html.parse("http://cfconventions.org/documents.html")
  File "/Users/dnowacki/miniconda3/lib/python3.10/site-packages/lxml/html/__init__.py", line 937, in parse
    return etree.parse(filename_or_url, parser, base_url=base_url, **kw)
  File "src/lxml/etree.pyx", line 3538, in lxml.etree.parse
  File "src/lxml/parser.pxi", line 1876, in lxml.etree._parseDocument
  File "src/lxml/parser.pxi", line 1902, in lxml.etree._parseDocumentFromURL
  File "src/lxml/parser.pxi", line 1805, in lxml.etree._parseDocFromFile
  File "src/lxml/parser.pxi", line 1177, in lxml.etree._BaseParser._parseDocFromFile
  File "src/lxml/parser.pxi", line 615, in lxml.etree._ParserContext._handleParseResultDoc
  File "src/lxml/parser.pxi", line 725, in lxml.etree._handleParseResult
  File "src/lxml/parser.pxi", line 652, in lxml.etree._raiseParseError
OSError: Error reading file 'http://cfconventions.org/documents.html': failed to load HTTP resource
```

**Describe the issue below:**
documents.html does not exist anymore. The list of standard names has been moved to vocabularies.html. I will submit a PR fixing this issue momentarily.



Discussion:

Resolving patch:
diff --git a/compliance_checker/cf/util.py b/compliance_checker/cf/util.py
--- a/compliance_checker/cf/util.py
+++ b/compliance_checker/cf/util.py
@@ -7,7 +7,6 @@
 from pkgutil import get_data
 from urllib.parse import urljoin
 
-import lxml.html
 import requests
 from cf_units import Unit
 from lxml import etree
@@ -430,16 +429,7 @@ def download_cf_standard_name_table(version, location=None):
         )
 
     if version == "latest":
-        tables_tree = lxml.html.parse("http://cfconventions.org/documents.html")
-        end_str = "cf-standard-name-table.xml"
-        xpath_expr = (
-            "//a[substring(@href, string-length(@href) - "
-            "string-length('{0}') +1) "
-            " = '{0}'][1]".format(end_str)
-        )
-        latest_vers = tables_tree.xpath(xpath_expr)[0]
-
-        url = urljoin("http://cfconventions.org", latest_vers.attrib["href"])
+        url = "http://cfconventions.org/Data/cf-standard-names/current/src/cf-standard-name-table.xml"
     else:
         url = "http://cfconventions.org/Data/cf-standard-names/{0}/src/cf-standard-name-table.xml".format(
             version


Test patch: