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

9 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-02-04 10:20 +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 'movie_rate': 'auto', # can set to float 

28 'movie_skip': 'auto', # can set to int 

29 'movie_rock': False, 

30} 

31 

32 

33def read_defaults(): 

34 import os 

35 

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

37 # if 'XDG_CONFIG_HOME' in os.environ: 

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

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

40 config = gui_default_settings 

41 if os.path.exists(name): 

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

43 gui_default_settings}) 

44 return config