Content of the configuration file
Different configuration settings will eventually be stored in the configuration file (for now vicodepy/config/config.ini
), in the future. For now, only the name and the color of the annotations are stored in the configuration file. We should also make provisions for storing information for the different timelines and the specific annotation types (now called “groups”) in the configuration file.
Here is a possible file, in the INI format, that could store this information:
[timeline]
names = gaze phase
[group.gaze]
names = left right
[property.gaze.left]
color = cyan
[property.gaze.right]
color = pink
[group.phase]
name = fam test
[property.phase.fam]
color = yellow
[property.phase.test]
color = green
This is the Python program to read the file above and to show the color of the first group of the first timeline:
import configparser
config = configparser.ConfigParser()
config.read('test.ini')
timelines = config['timeline']['names'].split(" ")
groups = config[f'group.{timelines[0]}']['names'].split(" ")
config[f'property.{timelines[0]}.{groups[0]}']['color']
Here is the same thing for a YAML file:
timelines:
- name: gaze
groups:
- name: left
color: cyan
- name: right
color: pink
- name: phase
groups:
- name: fam
color: yellow
- name: test
color: green
from yaml import load, Loader
config = load(open('test.yml', 'r'), Loader=Loader)
config['timelines'][0]['groups'][0]['color']