#Zen
#
#Config manager 2

import pickle

class Config2:
    name = 'Config Manager v2'
    
    config_path = '{home}/sys/boot/config/config.pkl'
    
    def __init__(self,kernel):
        self.kernel = kernel
        
        self.fs = self.kernel.get_service('fs')
        
        self.data = pickle.load(self.fs.open(self.config_path,'rb'))
        
    def get(self,option):
        return self.data[option]
    
    def set(self,option,value):
        self.data[option] = value
        
    def save(self):
        f = self.fs.open(self.config_path,'wb')
        pickle.dump(self.data,f)
        
    
    
APPLICATION = []
SERVICE = {'config':Config2}