Coverage for laskea/laskea.py: 74.36%

29 statements  

« prev     ^ index     » next       coverage.py v7.3.0, created at 2023-08-17 13:24:57 +00:00

1"""Calculate (Finnish: laskea) some parts.""" 

2import sys 

3from typing import Mapping, Sequence 

4 

5from atlassian import Jira # type: ignore # noqa 

6from cogapp import Cog, CogUsageError # type: ignore 

7 

8import laskea 

9import laskea.config as cfg 

10 

11 

12def process(command: str, transaction_mode: str, paths: Sequence[str], options: Mapping[str, bool]) -> int: 

13 """Drive the lookup.""" 

14 

15 if command != 'update' or not paths: 

16 print('Usage: laskea update [--help] [-v] [-c config-path] [-n] [-i] source-files*md [other.md]') 

17 sys.exit(2) 

18 

19 quiet = bool(options.get('quiet', '')) 

20 verbose = bool(options.get('verbose', '')) 

21 

22 vector = [ 

23 laskea.APP_ALIAS, 

24 '-P', 

25 '-c', 

26 f'--markers={laskea.BASE_MARKERS}', 

27 '-p', 

28 'from laskea import *', 

29 ] 

30 if transaction_mode == 'commit': 30 ↛ 32line 30 didn't jump to line 32, because the condition on line 30 was never false

31 vector.append('-r') 

32 if quiet: 32 ↛ 33line 32 didn't jump to line 33, because the condition on line 32 was never true

33 vector.append('--verbosity=0') 

34 

35 cog = Cog() 

36 

37 if laskea.DEBUG or verbose: 37 ↛ 38line 37 didn't jump to line 38, because the condition on line 37 was never true

38 cfg.report_context(command, transaction_mode, vector) 

39 

40 for path in paths: 40 ↛ 48line 40 didn't jump to line 48, because the loop on line 40 didn't complete

41 single_vector = vector + [path] 

42 try: 

43 cog.callableMain(single_vector) 

44 except CogUsageError as err: 

45 print('CodeGen processing usage error:', file=sys.stderr) 

46 print(str(err)) 

47 return 1 

48 return 0