Coverage for laskea/env.py: 70.97%

25 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-12-10 22:19:18 +00:00

1"""Report environment to support resolution of user issues.""" 

2import sys 

3from typing import no_type_check 

4 

5import scooby 

6 

7 

8@no_type_check 

9def report(shallow: bool = False) -> str: 

10 """Return either text options for the user to report her env or the report of the environment for support.""" 

11 deep = True 

12 try: 

13 import pkg_resources # noqa 

14 except (ImportError, ModuleNotFoundError): 

15 if shallow: 

16 deep = False 

17 sys.stdout.write('\nInfo: No setuptools module found and shallow reporting requested. Continuing ...') 

18 else: 

19 message = ( 

20 '\n Report requires setuptools (to identify the version of atlassian-python-api).' 

21 '\n You may either add --shallow or install the module via `pip install setuptools`\n\n' 

22 ) 

23 return message 

24 

25 if deep: 25 ↛ 32line 25 didn't jump to line 32, because the condition on line 25 was never false

26 import atlassian # type: ignore # noqa 

27 

28 packages = pkg_resources.working_set # noqa 

29 monkey_atl = [p.version for p in packages if p.project_name == 'atlassian-python-api'][0] # noqa 

30 atlassian.__version__ = monkey_atl 

31 

32 class Report(scooby.Report): 

33 def __init__(self, additional=None, ncol=3, text_width=80, sort=False): 

34 """Initiate a scooby.Report instance.""" 

35 

36 # Mandatory packages. 

37 core = [ 

38 'laskea', 

39 'atlassian', # has version in VERSION text file in package info only? 

40 'cogapp.cogapp', 

41 'jmespath', 

42 'pydantic', 

43 'requests_cache', 

44 'scooby', 

45 'typer', 

46 ] 

47 

48 # Optional packages. 

49 optional: list[str] = [] 

50 

51 scooby.Report.__init__( 

52 self, additional=additional, core=core, optional=optional, ncol=ncol, text_width=text_width, sort=sort 

53 ) 

54 

55 return str(Report()) + '\n'