tvaLib
Public Member Functions | Public Attributes | List of all members
include.config.ConfigValue Class Reference

Public Member Functions

def __init__ (self, section='section', name='name', default=None, value=None, c_struct='simple', comment='')
 
def setValue (self, value)
 
def parse (self, parser)
 

Public Attributes

 section
 
 name
 
 value
 
 default
 
 comment
 
 c_struct
 
 c_type
 

Detailed Description

Definition at line 208 of file config.py.

Constructor & Destructor Documentation

◆ __init__()

def include.config.ConfigValue.__init__ (   self,
  section = 'section',
  name = 'name',
  default = None,
  value = None,
  c_struct = 'simple',
  comment = '' 
)

Definition at line 209 of file config.py.

209  def __init__(self, section='section', name='name', default=None, value=None, c_struct='simple', comment=''):
210  self.section = section
211  self.name = name
212  self.value = value
213  self.default = default
214  self.comment = comment
215  self.c_struct = c_struct
216  if(self.c_struct=='list1D'): self.c_type = type(default[0])
217  else: self.c_type = type(default)
218 

Member Function Documentation

◆ parse()

def include.config.ConfigValue.parse (   self,
  parser 
)
Load configuration file values. 

Definition at line 221 of file config.py.

221  def parse(self, parser):
222  ''' Load configuration file values. '''
223  if(not parser.has_section(self.section)): parser.add_section(self.section)
224  if(not parser.has_option(self.section,self.name)): parser.set(self.section,self.name,str(self.default))
225  try:
226  if(self.c_type == int):
227  if(self.c_struct == 'list1D'): self.value = parse_list1D(parser.get(self.section, self.name))
228  else: self.value = parser.getint(self.section, self.name)
229  elif(self.c_type == float):
230  if(self.c_struct == 'list1D'): self.value = parse_list1D(parser.get(self.section, self.name), i_type='float')
231  else: self.value = parser.getfloat(self.section, self.name)
232  elif(self.c_type == bool):
233  if(self.c_struct == 'list1D'): self.value = parse_list1D(parser.get(self.section, self.name), i_type='bool')
234  else: self.value = parser.getboolean(self.section, self.name)
235  else:
236  if(self.c_struct == 'list1D'): self.value = parse_list1D(parser.get(self.section, self.name), i_type='string')
237  else: self.value = parser.get(self.section, self.name)
238  except ValueError: raise Exception, [1001, 'Invalid value in configuration for parameter "'+self.name+'"']
239  except TypeError: import pdb; pdb.set_trace()
240  return True
241 
242 
243 

◆ setValue()

def include.config.ConfigValue.setValue (   self,
  value 
)

Definition at line 219 of file config.py.

219  def setValue(self, value): self.value = value
220 

Member Data Documentation

◆ c_struct

include.config.ConfigValue.c_struct

Definition at line 215 of file config.py.

◆ c_type

include.config.ConfigValue.c_type

Definition at line 216 of file config.py.

◆ comment

include.config.ConfigValue.comment

Definition at line 214 of file config.py.

◆ default

include.config.ConfigValue.default

Definition at line 213 of file config.py.

◆ name

include.config.ConfigValue.name

Definition at line 211 of file config.py.

◆ section

include.config.ConfigValue.section

Definition at line 210 of file config.py.

◆ value

include.config.ConfigValue.value

Definition at line 212 of file config.py.


The documentation for this class was generated from the following file: