pysilcam/config.py
def load_camera_config(filename, config=None):
    '''Load camera config file and validate content
    
    Args:
      filename (str)      : filename including path to camera config file
      config=None  (dict) : a dictionnary to store key-values. If config does not exist, an empty dict is created

    Returns:
      dict()              : with key value pairs of camera settings  
    
    '''

    if (config == None):
       config = dict()

    #Check that the file exists
    if (filename == None):
       return config

    filename = os.path.normpath(filename)

    if not os.path.exists(filename):
       logger.info('Camera config file not found: {0}'.format(filename))
       logger.debug('Camera config file not found: {0}'.format(filename))
       return config

    #Create SafeConfigParser and make it case sensitive
    config_parser = configparser.SafeConfigParser()
    config_parser.optionxform = str

    #Populate the parser from the file
    files_parsed = config_parser.read(filename)
    if filename not in files_parsed:
       logger.debug('Could not parse camera config file {0}'.format(filename))
       return config

    try:
       if not config_parser.has_section('Camera'):
          logger.debug('No Camera section in ini file: {0}'.format(filename))
          return config

       # File is read, find the camera section
       for k, v in config_parser.items('Camera'):
          try:
             parsed_val = ast.literal_eval(v)
          except:
             parsed_val = v
          config[k] = parsed_val

    except:
       logger.debug('Could not read camera config file: {0}'.format(filename))

    # return the configuration as a dict
    return config
Load camera config file and validate content
    
    Args:
      filename (str)      : filename including path to camera config file
      config=None  (dict) : a dictionnary to store key-values. If config does not exist, an empty dict is created

    Returns:
      dict()              : with key value pairs of camera settings  
    
    
Load camera config file and validate content
Load camera config file and validate content
def load_camera_config(filename, config=None):
    if (config == None):
       config = dict()
    if (filename == None):
       return config
    filename = os.path.normpath(filename)
    if not os.path.exists(filename):
       logger.info('Camera config file not found: {0}'.format(filename))
       logger.debug('Camera config file not found: {0}'.format(filename))
       return config
    config_parser = configparser.SafeConfigParser()
    config_parser.optionxform = str
    files_parsed = config_parser.read(filename)
    if filename not in files_parsed:
       logger.debug('Could not parse camera config file {0}'.format(filename))
       return config
    try:
       if not config_parser.has_section('Camera'):
          logger.debug('No Camera section in ini file: {0}'.format(filename))
          return config
       for k, v in config_parser.items('Camera'):
          try:
             parsed_val = ast.literal_eval(v)
          except:
             parsed_val = v
          config[k] = parsed_val
    except:
       logger.debug('Could not read camera config file: {0}'.format(filename))
    return config
def load_camera_config ( filename , config = None ) : if ( config == None ) : config = dict ( ) if ( filename == None ) : return config filename = os . path . normpath ( filename ) if not os . path . exists ( filename ) : logger . info ( 'Camera config file not found: {0}' . format ( filename ) ) logger . debug ( 'Camera config file not found: {0}' . format ( filename ) ) return config config_parser = configparser . SafeConfigParser ( ) config_parser . optionxform = str files_parsed = config_parser . read ( filename ) if filename not in files_parsed : logger . debug ( 'Could not parse camera config file {0}' . format ( filename ) ) return config try : if not config_parser . has_section ( 'Camera' ) : logger . debug ( 'No Camera section in ini file: {0}' . format ( filename ) ) return config for k , v in config_parser . items ( 'Camera' ) : try : parsed_val = ast . literal_eval ( v ) except : parsed_val = v config [ k ] = parsed_val except : logger . debug ( 'Could not read camera config file: {0}' . format ( filename ) ) return config
Load camera config file and validate content
Load camera config file and validate content
'''Load camera config file and validate content
    
    Args:
      filename (str)      : filename including path to camera config file
      config=None  (dict) : a dictionnary to store key-values. If config does not exist, an empty dict is created

    Returns:
      dict()              : with key value pairs of camera settings  
    
    ''' #Check that the file exists #Create SafeConfigParser and make it case sensitive #Populate the parser from the file # File is read, find the camera section # return the configuration as a dict
dict()              : with key value pairs of camera settings
dict () : with key value pairs of camera settings
filename
filename including path to camera config file
filename including path to camera config file
config
config=None
a dictionnary to store key-values. If config does not exist, an empty dict is created
a dictionnary to store key - values . If config does not exist an empty dict is created