Coverage for pyquickhelper/cli/code_cli.py: 93%

14 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-03 02:21 +0200

1""" 

2@file 

3@brief Command line about transfering files. 

4""" 

5import importlib 

6 

7 

8def code_stat(names, output=None, fLOG=print): 

9 """ 

10 Returns statistics about the documentation of a module. 

11 

12 :param names: module name comma separated value 

13 :param output: output file name 

14 :param fLOG: logging function 

15 :return: status 

16 

17 .. cmdref:: 

18 :title: Returns statistics about the documentation of a module 

19 :cmd: -m pyquickhelper code_stat --help 

20 

21 The command line returns a table with the number of lines of code 

22 and documentatation. 

23 """ 

24 from ..texthelper.code_helper import measure_documentation_module 

25 if not isinstance(names, list): 

26 names = names.split(',') 

27 mods = [importlib.import_module(name) for name in names] 

28 stat = measure_documentation_module(mods, ratio=True, as_df=True) 

29 

30 if output is None: 

31 fLOG(stat) 

32 return None 

33 if output.endswith(".xlsx"): 

34 stat.to_excel(output, index=False) 

35 else: 

36 stat.to_csv(output, index=False) 

37 return stat