Coverage for src/code_beatrix/jsscripts/__init__.py: 67%

15 statements  

« prev     ^ index     » next       coverage.py v7.1.0, created at 2023-04-29 13:45 +0200

1""" 

2@file 

3@brief Copies files to the proper location. 

4""" 

5 

6import os 

7from pyquickhelper.filehelper import synchronize_folder 

8 

9 

10def copy_jstool2notebook(tool, force=False): 

11 """ 

12 Copies a tool to :epkg:`notebook` folder. 

13 

14 @param tool tool name (snap for example) 

15 @param force do the copy even if the destination folder exists 

16 @return list of copied files 

17 """ 

18 import notebook 

19 dest = os.path.join(os.path.dirname(notebook.__file__), "static") 

20 src = os.path.join(os.path.dirname(__file__), tool) 

21 if not os.path.exists(src): 

22 raise FileNotFoundError("unable to find tool: " + tool) 

23 dest = os.path.join(dest, tool) 

24 if not os.path.exists(dest): 

25 os.mkdir(dest) 

26 return synchronize_folder(src, dest) 

27 elif force: 

28 return synchronize_folder(src, dest) 

29 else: 

30 return None