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
« prev ^ index » next coverage.py v7.15.4, created at 2026-10-18 15:02 +0000
1#!/usr/bin/env python3
3# Standard libraries
4from re import error, escape, search
5from typing import List
7# Lists class, pylint: disable=too-few-public-methods
8class Lists:
10 # Match
11 @staticmethod
12 def match(items: List[str], name: str, ignore_case: bool, no_regex: bool) -> bool:
14 # Search without regex
15 if name in items:
16 return True
18 # Search with regex
19 if not no_regex:
20 for item in items:
22 # Search with string inclusion
23 if item in name:
24 return True
26 # Search with string case insensitive inclusion
27 if ignore_case and item.lower() in name.lower():
28 return True
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
39 # Result
40 return False