Coverage for /builds/ase/ase/ase/gui/defaults.py: 88.89%

9 statements  

« prev     ^ index     » next       coverage.py v7.5.3, created at 2025-08-02 00:12 +0000

1# fmt: off 

2 

3"""This is a module to handle generic ASE (gui) defaults ... 

4 

5... from a ~/.ase/gui.py configuration file, if it exists. It is imported when 

6opening ASE-GUI and can then be modified at runtime, if necessary. syntax for 

7each entry: 

8 

9gui_default_settings['key'] = value 

10""" 

11import runpy 

12 

13gui_default_settings = { 

14 'gui_graphs_string': 'i, e - E[-1]', # default for the graph command 

15 'gui_foreground_color': '#000000', 

16 'gui_background_color': '#ffffff', 

17 'covalent_radii': None, 

18 'radii_scale': 0.89, 

19 'force_vector_scale': 1.0, 

20 'velocity_vector_scale': 1.0, 

21 'magmom_vector_scale': 1.0, 

22 'show_unit_cell': True, 

23 'show_axes': True, 

24 'show_bonds': False, 

25 'shift_cell': False, 

26 'swap_mouse': False, 

27} 

28 

29 

30def read_defaults(): 

31 import os 

32 

33 # should look for .config/ase/gui.py 

34 # if 'XDG_CONFIG_HOME' in os.environ: 

35 # name = os.environ['XDG_CONFIG_HOME'] + '/ase/gui.py' 

36 name = os.path.expanduser('~/.ase/gui.py') 

37 config = gui_default_settings 

38 if os.path.exists(name): 

39 runpy.run_path(name, init_globals={'gui_default_settings': 

40 gui_default_settings}) 

41 return config