Coverage for ase/_4/plugins/wrappers.py: 100.00%

11 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-11-27 15:21 +0000

1from __future__ import annotations 

2 

3import sys 

4 

5from ase._4.plugins.io import LegacyIOFormatPlugin 

6from ase._4.plugins.viewer import ViewerPlugin 

7from ase.io.formats import ioformats 

8from ase.visualize.viewers import CLI_VIEWERS, PY_VIEWERS 

9 

10_this_module = sys.modules[__name__] 

11 

12wrapped_ioformats = { 

13 # Wrap all _internal_ formats from ase.io.formats; 

14 # skip formats from legacy entry-point, they are handled in legacy_plugins 

15 LegacyIOFormatPlugin.from_legacy_io_format(ioformat, module=_this_module) 

16 for ioformat in ioformats.values() 

17 if ioformat.module_name[:7] == 'ase.io.' 

18} 

19 

20wrapped_cli_viewers = { 

21 ViewerPlugin( 

22 name=key, 

23 module=_this_module, 

24 citation='imported from ase.visualize.viewers.CLI_VIEWERS', 

25 implementation=(lambda: value), 

26 ) 

27 for key, value in CLI_VIEWERS.items() 

28} 

29 

30wrapped_py_viewers = { 

31 ViewerPlugin( 

32 name=key, 

33 module=_this_module, 

34 citation='imported from ase.visualize.viewers.PY_VIEWERS', 

35 implementation=(lambda: value), 

36 ) 

37 for key, value in PY_VIEWERS.items() 

38} 

39 

40__ase_plugins__ = wrapped_ioformats | wrapped_cli_viewers | wrapped_py_viewers