def atomHandler(self, avpName, avpValue, fileRec = None):
     if fileRec:
         index = self.getIndexFromHeader(avpName)
         if index is not None:
             #avpValue = utils.format(avpName, fileRec[index].strip()) #what if we want spaces ? 
             avpValue = utils.format(avpName, fileRec[index])
     try:
         self.formatter.addElement(avpName, avpValue)
     except Exception, e:
         print "ERROR for AVP {0}".format(avpName)
         print "Exception:\n{0}".format(str(e))
    def groupHandler(self, avpName, child, fileRec = None):
        grpAvp = Node.DiameterGroup(avpName) 

        for name, value in child.iteritems():
            if isinstance(value, dict):
                grpAVP_N = self.groupHandler(name, value, fileRec)
                try:
                    grpAvp.addItem(grpAVP_N)
                except Exception, e:
                    print "ERROR for AVP {0}".format(name)
                    print "Exception:\n{0}".format(str(e))
                pass
            else:
                if fileRec:
                    index = self.getIndexFromHeader(name)
                    if index is not None:
                        value = utils.format(name, fileRec[index].strip())
                try:
                    atmAvp = Node.DiameterAtom(name)
                    atmAvp.setContent(value)
                    grpAvp.addItem(atmAvp)
                except Exception, e:
                    print "ERROR for AVP {0}".format(name)
                    print "Exception:\n{0}".format(str(e))