Coverage for src/types/lists.py: 100.00%

19 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-10-18 15:02 +0000

1#!/usr/bin/env python3 

2 

3# Standard libraries 

4from re import error, escape, search 

5from typing import List 

6 

7# Lists class, pylint: disable=too-few-public-methods 

8class Lists: 

9 

10 # Match 

11 @staticmethod 

12 def match(items: List[str], name: str, ignore_case: bool, no_regex: bool) -> bool: 

13 

14 # Search without regex 

15 if name in items: 

16 return True 

17 

18 # Search with regex 

19 if not no_regex: 

20 for item in items: 

21 

22 # Search with string inclusion 

23 if item in name: 

24 return True 

25 

26 # Search with string case insensitive inclusion 

27 if ignore_case and item.lower() in name.lower(): 

28 return True 

29 

30 # Search with real regex 

31 try: 

32 if search(item, escape(name)): 

33 return True 

34 if ignore_case and search(item.lower(), escape(name.lower())): 

35 return True 

36 except error: # pragma: no cover 

37 pass 

38 

39 # Result 

40 return False