Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate old reader names so they produce an exception #597

Merged
merged 5 commits into from Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 3 additions & 7 deletions satpy/readers/__init__.py
Expand Up @@ -556,13 +556,9 @@ def configs_for_reader(reader=None, ppp_config_dir=None):

new_name = OLD_READER_NAMES[reader_name]
# SatPy 0.11 only displays a warning
warnings.warn("Reader name '{}' has been deprecated, use '{}' instead.".format(reader_name, new_name),
DeprecationWarning)
# SatPy 0.12 will raise an exception
# raise ValueError("Reader name '{}' has been deprecated, use '{}' instead.".format(reader_name, new_name))
# SatPy 0.13 or 1.0, remove exception and mapping

new_readers.append(new_name)
# SatPy 0.13 will raise an exception
raise ValueError("Reader name '{}' has been deprecated, use '{}' instead.".format(reader_name, new_name))
# SatPy 0.15 or 1.0, remove exception and mapping

reader = new_readers
# given a config filename or reader name
Expand Down
17 changes: 3 additions & 14 deletions satpy/tests/test_readers.py
Expand Up @@ -287,9 +287,7 @@ def test_missing_requirements(self, *mocks):
epi_miss = epi_pro_miss + ['H-000-MSG4__-MSG4________-_________-PRO______-201809050900-__']
pro_miss = epi_pro_miss + ['H-000-MSG4__-MSG4________-_________-EPI______-201809050900-__']
for filenames in [epi_miss, pro_miss, epi_pro_miss]:
with mock.patch('warnings.warn') as warn_mock:
self.assertRaises(ValueError, load_readers, reader='hrit_msg', filenames=filenames)
warn_mock.assert_called()
self.assertRaises(ValueError, load_readers, reader='seviri_l1b_hrit', filenames=filenames)

# Filenames from multiple scans
at_least_one_complete = [
Expand All @@ -301,9 +299,7 @@ def test_missing_requirements(self, *mocks):
'H-000-MSG4__-MSG4________-IR_108___-000006___-201809051000-__',
]
try:
with mock.patch('warnings.warn') as warn_mock:
load_readers(filenames=at_least_one_complete, reader='hrit_msg')
warn_mock.assert_called()
load_readers(filenames=at_least_one_complete, reader='seviri_l1b_hrit')
except ValueError:
self.fail('If at least one set of filenames is complete, no '
'exception should be raised')
Expand Down Expand Up @@ -538,15 +534,8 @@ def test_reader_load_failed(self):

def test_old_reader_name_mapping(self):
"""Test that requesting old reader names raises a warning."""
import warnings
from satpy.readers import configs_for_reader
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
configs = list(configs_for_reader('hrit_jma'))[0]
self.assertIn('ahi_hrit', configs[0])
self.assertNotIn('hrit_jma', configs[0])
self.assertEqual(len(w), 1)
self.assertTrue(issubclass(w[0].category, DeprecationWarning))
self.assertRaises(ValueError, list, configs_for_reader('hrit_jma'))


class TestYAMLFiles(unittest.TestCase):
Expand Down