Coverage for kysy/kysy.py: 87.10%

23 statements  

« prev     ^ index     » next       coverage.py v7.4.1, created at 2024-02-04 19:30:32 +00:00

1# -*- coding: utf-8 -*- 

2# pylint: disable=expression-not-assigned,line-too-long 

3"""Ask or know (kysy tai tiedä). API.""" 

4import os 

5import pathlib 

6import warnings 

7from typing import List, Union 

8 

9DEBUG_VAR = 'KYSY_DEBUG' 

10DEBUG = os.getenv(DEBUG_VAR) 

11 

12ENCODING = 'utf-8' 

13ENCODING_ERRORS_POLICY = 'ignore' 

14 

15 

16def main(argv: Union[List[str], None] = None) -> int: 

17 """Drive the analysis.""" 

18 # [('diff'|'label'), repo_root, target, template] 

19 if not argv or len(argv) != 4: 

20 warnings.warn('received wrong number of arguments') 

21 return 2 

22 

23 if argv[0] not in ('diff', 'label'): 23 ↛ 24line 23 didn't jump to line 24, because the condition on line 23 was never true

24 warnings.warn('received unknown command') 

25 return 2 

26 

27 command, repo_root, target, template = argv 

28 

29 if not pathlib.Path(str(repo_root)).is_dir(): 

30 warnings.warn('repository root is no directory') 

31 return 1 

32 

33 if template and target != 'STD_OUT': 33 ↛ 36line 33 didn't jump to line 36, because the condition on line 33 was never false

34 warnings.warn('templates not yet implemented') 

35 

36 return 0