Coverage for /usr/local/lib/python3.11/dist-packages/pyrocko/client/base_catalog.py: 87%
15 statements
« prev ^ index » next coverage.py v6.5.0, created at 2024-03-07 11:54 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2024-03-07 11:54 +0000
1# http://pyrocko.org - GPLv3
2#
3# The Pyrocko Developers, 21st Century
4# ---|P------/S----------~Lg----------
6'''
7Base class for earthquake catalog clients.
8'''
11class EarthquakeCatalog(object):
12 '''
13 Base class for Pyrocko's earthquake catalog clients.
14 '''
16 def get_event(self, name):
17 raise NotImplementedError
19 def iter_event_names(self, time_range, **kwargs):
20 raise NotImplementedError
22 def get_event_names(self, time_range, **kwargs):
23 return list(self.iter_event_names(time_range, **kwargs))
25 def get_events(self, time_range, **kwargs):
26 return list(self.iter_events(time_range, **kwargs))
28 def iter_events(self, time_range, **kwargs):
29 for name in self.iter_event_names(time_range, **kwargs):
30 yield self.get_event(name)
33class NotFound(Exception):
34 def __init__(self, url=None):
35 Exception.__init__(self)
36 self._url = url
38 def __str__(self):
39 if self._url:
40 return 'No results for request %s' % self._url
41 else:
42 return 'No results for request'