1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

DOWNLOAD_CALLBACK = None 

 

 

def set_download_callback(callback): 

global DOWNLOAD_CALLBACK 

 

if not callable(callback): 

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

DOWNLOAD_CALLBACK = callback 

 

 

def get_download_callback(context_str): 

if not DOWNLOAD_CALLBACK: 

return None 

 

def callback(args): 

return DOWNLOAD_CALLBACK(context_str, args) 

 

return callback