1# http://pyrocko.org - GPLv3 

2# 

3# The Pyrocko Developers, 21st Century 

4# ---|P------/S----------~Lg---------- 

5 

6DOWNLOAD_CALLBACK = None 

7 

8 

9def set_download_callback(callback): 

10 global DOWNLOAD_CALLBACK 

11 

12 if not callable(callback): 

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

14 DOWNLOAD_CALLBACK = callback 

15 

16 

17def get_download_callback(context_str): 

18 if not DOWNLOAD_CALLBACK: 

19 return None 

20 

21 def callback(args): 

22 return DOWNLOAD_CALLBACK(context_str, args) 

23 

24 return callback