Coverage for /usr/local/lib/python3.11/dist-packages/pyrocko/dataset/util.py: 100%

11 statements  

« 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---------- 

5 

6''' 

7Registry for dataset download progress notifications. 

8''' 

9 

10DOWNLOAD_CALLBACK = None 

11 

12 

13def set_download_callback(callback): 

14 global DOWNLOAD_CALLBACK 

15 

16 if not callable(callback): 

17 raise AttributeError('Callback has to be a function') 

18 DOWNLOAD_CALLBACK = callback 

19 

20 

21def get_download_callback(context_str): 

22 if not DOWNLOAD_CALLBACK: 

23 return None 

24 

25 def callback(args): 

26 return DOWNLOAD_CALLBACK(context_str, args) 

27 

28 return callback