supress warnings.warn for catalog.py
raybellwaves opened this issue · comments
I like the feature of parsing the URL and adding the catalog.xml.
It looks at though the warning messaged is displayed on the screen. I guess the string statement is suppose to not be printed.
from siphon.catalog import TDSCatalog
cat = TDSCatalog('https://thredds.ucar.edu/')
/home/ray/local/bin/anaconda3/envs/dev/lib/python3.8/site-packages/siphon/catalog.py:267: UserWarning: URL https://thredds.ucar.edu/thredds/catalog.html returned HTML. Changing to: https://thredds.ucar.edu/thredds/catalog.xml
warnings.warn('URL {} returned HTML. Changing to: {}'.format(self.catalog_url,
i.e. the warnings.warn('URL {} returned HTML. Changing to: {}'.format(self.catalog_url,
So that warning printing to screen is intentional. What it's saying that when you called:
cat = TDSCatalog('https://thredds.ucar.edu/')
the URL https://thredds.ucar.edu/thredds/catalog.html
returned HTML, whereas TDSCatalog
really wants a URL that returns XML. Now, it helpfully tries to open https://thredds.ucar.edu/thredds/catalog.xml
and that works. What you really should do to silence the warning is change your code to:
cat = TDSCatalog('https://thredds.ucar.edu/thredds/catalog.xml')
The reason we leave the warning is to encourage users to fix their code to the latter.