return repr(dump)
#------------------------------------------------------
- def __init__( self, logger = None ):
+ def __init__( self, logger = None, , ignore_empty_object_props = True ):
"Constructor."
# Logging-Setup
else:
self.logger = logger
+ self.ignore_empty_object_props = ignore_empty_object_props
+
#------------------------------------------------------
def __del__( self ):
"Destructor"
return result
# Split line into key and value
- match = re.search( r'^\s*(\w+)\s+(.*)', line )
+ match = re.search( r'^\s*(\w+)(?:\s+(.*))?', line )
if match is None:
raise NagiosConfigStructError( "Couldn't evaluate line {0!r}.".format( line ) )
key = match.group(1)
value = match.group(2)
+ if value is None:
+ if not self.ignore_empty_object_props:
+ raise NagiosConfigStructError( "No value given for key {0!r}.".format( key ) )
+
# User defined definitions
if re.match( r'^_', key ):
key_upper = key.upper()
return repr(dump)
#------------------------------------------------------
- def __init__( self, new_file = file_name ):
+ def __init__( self, new_file = file_name, ignore_empty_object_props = True ):
"Konstruktor."
# Logging-Setup
self.objects = {}
self.config_objects = {}
self.objects_read = {}
+ self.ignore_empty_object_props = ignore_empty_object_props
#------------------------------------------------------
def __del__( self ):