(self, monitorid=0)
return config
Get the configuration for the specified monitorid. Write config file if not found.
Get the configuration for the specified monitorid. Write config file if not found.
Get the configuration for the specified monitorid . Write config file if not found .
def _get_config(self, monitorid=0):
        """ Get the configuration for the specified monitorid. Write config file if not found. """
        config = copy.deepcopy(DEFAULT_CONFIG)['default']
        if os.path.exists(CONFIG_PATH):
            try:
                with open(CONFIG_PATH, 'r') as handle:
                    userconfig = json.load(handle)
                    config.update(userconfig.get('default', {}))
                    config.update(userconfig.get('monitor%s' % monitorid, {}))
                    config['keys'] = userconfig.get('keys', {})
            except Exception as err:
                print('Unable to parse userconfig: %s; %s' % (CONFIG_PATH, err))
        else:
            print('Writing default config: %s' % CONFIG_PATH)
            with open(CONFIG_PATH, 'w') as handle:
                json.dump(DEFAULT_CONFIG, handle, indent=2, sort_keys=True)
        return config
def _get_config ( self , monitorid = 0 ) : config = copy . deepcopy ( DEFAULT_CONFIG ) [ 'default' ] if os . path . exists ( CONFIG_PATH ) : try : with open ( CONFIG_PATH , 'r' ) as handle : userconfig = json . load ( handle ) config . update ( userconfig . get ( 'default' , { } ) ) config . update ( userconfig . get ( 'monitor%s' % monitorid , { } ) ) config [ 'keys' ] = userconfig . get ( 'keys' , { } ) except Exception as err : print ( 'Unable to parse userconfig: %s; %s' % ( CONFIG_PATH , err ) ) else : print ( 'Writing default config: %s' % CONFIG_PATH ) with open ( CONFIG_PATH , 'w' ) as handle : json . dump ( DEFAULT_CONFIG , handle , indent = 2 , sort_keys = True ) return config