Coverage for src/wiktextract/import_utils.py: 69%

11 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-10-25 10:11 +0000

1import importlib 

2import importlib.util 

3import types 

4 

5 

6def import_extractor_module( 

7 lang_code: str, module_name: str 

8) -> types.ModuleType | None: 

9 try: 

10 full_module_name = f"wiktextract.extractor.{lang_code}.{module_name}" 

11 if importlib.util.find_spec(full_module_name) is not None: 11 ↛ 15line 11 didn't jump to line 15 because the condition on line 11 was always true

12 return importlib.import_module(full_module_name) 

13 except ModuleNotFoundError: 

14 return None 

15 return None