Debian Codegraph @

debian/tests/gir1.2-gst-plugins-bad-1.0

raw symbols SCIP
1 #!/usr/bin/env python3
2
3 import sys
4 import gi
5 import importlib
6
7
8 def simple_api_check(module: str, object_name: str, version='1.0'):
9 """
10 Ensure the GIR can be loaded and seen to contain basic types
11 for the specified module (e.g., GstWebRTC).
12 """
13 try:
14 gi.require_version(module, version)
15 full_module_name = f'gi.repository.{module}'
16 mod = importlib.import_module(full_module_name)
17
18 _ = getattr(mod, object_name)
19
20 print(f"OK: API objects are present for {module}")
21 return True
22
23 except ValueError as e:
24 print(f"FAILURE: Could not require {module} v{version}. "
25 "Library installation is broken.", file=sys.stderr)
26 print(f"Error details: {e}", file=sys.stderr)
27 return False
28
29 except (ImportError, ModuleNotFoundError) as e:
30 print(f"FAILURE: Could not dynamically import '{full_module_name}'.",
31 file=sys.stderr)
32 print(f"Error details: {e}", file=sys.stderr)
33 return False
34
35 except AttributeError:
36 print(f"FAILURE: Object '{object_name}' not found in module "
37 "'{module}'.", file=sys.stderr)
38 return False
39
40 except Exception as e:
41 print(f"FAILURE: Unexpected error: {e}", file=sys.stderr)
42 return False
43
44
45 tests = [
46 simple_api_check('GstWebRTC', 'WebRTCDataChannelClass', '1.0'),
47 simple_api_check('GstCuda', 'CudaContext', '1.0'),
48 simple_api_check('GstPlay', 'Play', '1.0'),
49 ]
50
51 all_ok = all([test for test in tests])
52 sys.exit(0 if all_ok else 1)