def configparser(self,fileName): ''' It will parse the config file (ofa.cfg) and return as dictionary ''' matchFileName = re.match(r'(.*)\.cfg', fileName, re.M | re.I) if matchFileName: self.configFile = fileName try : xml = open(fileName).read() self.configDict = xmldict.xml_to_dict(xml) return self.configDict except : print "Error : Config file " + self.configFile + " not defined properly or file path error"
def configparser(self, fileName): ''' It will parse the config file (ofa.cfg) and return as dictionary ''' matchFileName = re.match(r'(.*)\.cfg', fileName, re.M | re.I) if matchFileName: self.configFile = fileName try: xml = open(fileName).read() self.configDict = xmldict.xml_to_dict(xml) return self.configDict except: print "Error : Config file " + self.configFile + " not defined properly or file path error"
def parse(self, fileName): ''' This will parse the params or topo or cfg file and return content in the file as Dictionary ''' self.fileName = fileName matchFileName = re.match("(.*)\.(params|topo|cfg)", self.fileName, re.M | re.I) print matchFileName.group(1) if matchFileName: xml = open(fileName).read() parsedInfo = xmldict.xml_to_dict(xml) return parsedInfo else: print "file name is not correct"
def __init__(self): self.default = '' self.LASTRSP = '' self.command_dictionary = {} self.config_details = {} self.last_sub_command = None self.commnads_ordered_list = [] filePath = "/home/paxterra/Documents/anilkumars_workspace/TestON/config/generatedriver.cfg" self.configFile = filePath try: xml = open(filePath).read() self.config_details = xmldict.xml_to_dict(xml) except: print "Error : Config file " + self.configFile + " not defined properly or file path error" sys.exit() print self.config_details self.device_name = ''
def __init__(self): self.default = '' self.prompt = '>' self.LASTRSP ='' self.command_dictionary = {} self.config_details = {} self.last_sub_command = None self.commnads_ordered_list = [] filePath = "generatedriver.cfg" self.configFile = filePath try : xml = open(filePath).read() self.config_details = xmldict.xml_to_dict(xml) except : print "Error : Config file " + self.configFile + " not defined properly or file path error" sys.exit() print self.config_details self.device_name = ''