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

9 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-12-10 11:04 +0000

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

2 

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

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

5each entry: 

6 

7gui_default_settings['key'] = value 

8""" 

9import runpy 

10 

11gui_default_settings = { 

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

13 'gui_foreground_color': '#000000', 

14 'gui_background_color': '#ffffff', 

15 'covalent_radii': None, 

16 'radii_scale': 0.89, 

17 'force_vector_scale': 1.0, 

18 'velocity_vector_scale': 1.0, 

19 'show_unit_cell': True, 

20 'show_axes': True, 

21 'show_bonds': False, 

22 'shift_cell': False, 

23 'swap_mouse': False, 

24} 

25 

26 

27def read_defaults(): 

28 import os 

29 

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

31 # if 'XDG_CONFIG_HOME' in os.environ: 

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

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

34 config = gui_default_settings 

35 if os.path.exists(name): 

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

37 gui_default_settings}) 

38 return config