Print more information on xml parsing error plus minor cleanup
- Also fix some tabbing style issues
- Remove unused file core/iniparser.py
- Remove unused file core/dicttoobject.py
- Remove unused file core/jsonparser.py and reference in teston.cfg
Change-Id: I6e14bb75650c6a516cfb15fe7aec8aa396c18f04
diff --git a/TestON/core/dicttoobject.py b/TestON/core/dicttoobject.py
deleted file mode 100644
index 13c2aa6..0000000
--- a/TestON/core/dicttoobject.py
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/usr/bin/env python
-
-class DictToObject( dict ):
- def __init__( self, data = None ):
- super( DictToObject, self ).__init__()
- if data:
- self.__update( data, {} )
-
- def __update( self, data, did ):
- dataid = id(data)
- did[ dataid ] = self
-
- for k in data:
- dkid = id(data[k])
- if did.has_key(dkid):
- self[k] = did[dkid]
- elif isinstance( data[k], DictToObject ):
- self[k] = data[k]
- elif isinstance( data[k], dict ):
- obj = DictToObject()
- obj.__update( data[k], did )
- self[k] = obj
- obj = None
- else:
- self[k] = data[k]
-
- def __getattr__( self, key ):
- return self.get( key, None )
-
- def __setattr__( self, key, value ):
- if isinstance(value,dict):
- self[key] = DictToObject( value )
- else:
- self[key] = value
-
- def update( self, *args ):
- for obj in args:
- for k in obj:
- if isinstance(obj[k],dict):
- self[k] = DictToObject( obj[k] )
- else:
- self[k] = obj[k]
- return self
-
- def merge( self, *args ):
- for obj in args:
- for k in obj:
- if self.has_key(k):
- if isinstance(self[k],list) and isinstance(obj[k],list):
- self[k] += obj[k]
- elif isinstance(self[k],list):
- self[k].append( obj[k] )
- elif isinstance(obj[k],list):
- self[k] = [self[k]] + obj[k]
- elif isinstance(self[k],DictToObject) and isinstance(obj[k],Object):
- self[k].merge( obj[k] )
- elif isinstance(self[k],DictToObject) and isinstance(obj[k],dict):
- self[k].merge( obj[k] )
- else:
- self[k] = [ self[k], obj[k] ]
- else:
- if isinstance(obj[k],dict):
- self[k] = DictToObject( obj[k] )
- else:
- self[k] = obj[k]
- return self
-
diff --git a/TestON/core/iniparser.py b/TestON/core/iniparser.py
deleted file mode 100644
index c416b4f..0000000
--- a/TestON/core/iniparser.py
+++ /dev/null
@@ -1,77 +0,0 @@
-#/usr/bin/env python
-'''
-Created on 07-Jan-2013
-
-@author: Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
-
- TestON is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- TestON is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
-
-
-'''
-
-import re
-from configobj import ConfigObj
-class iniparser:
- '''
- Manages authoring, parsing and execution of the test. Sub components are
- Test-Topology parser
- Module that parses the test from plain English and topology
- from a specification file and prepares for execution.
- Test sequencer
- Module that executes the tests case by case,
- step by step adding ability for step by step pause and debug later.
- Object loader
- Module that connects and loads all the component connection objects
- for access in the test
- '''
- def __init__(self) :
- self.default = ''
-
- 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(r'(.*)\.(params|topo)',self.fileName,re.M|re.I)
- if matchFileName:
- try :
- parsedInfo = ConfigObj(self.fileName)
- return parsedInfo
- except Exception:
- print "There is no such file to parse "+fileName
- else:
- return 0
-
- def parseParams(self,paramsPath):
- '''
- It will take the params file path and will return the params dictionary
- '''
-
- paramsPath = re.sub("\.","/",paramsPath)
- paramsPath = re.sub("tests|examples","",paramsPath)
- #print main.tests_path+"/"+paramsPath+".params"
- params = self.parse(main.tests_path+paramsPath+".params")
- paramsAsString = str(params)
- return eval(paramsAsString)
-
- def parseTopology(self,topologyPath):
- '''
- It will take topology file path and will return topology dictionary
- '''
- topologyPath = re.sub("\.","/",topologyPath)
- topologyPath = re.sub("tests|examples","",topologyPath)
- topology = self.parse(main.tests_path+"/"+topologyPath+".topo")
- topoAsString = str(topology)
- return eval(topoAsString)
-
diff --git a/TestON/core/jsonparser.py b/TestON/core/jsonparser.py
deleted file mode 100644
index c33a9b0..0000000
--- a/TestON/core/jsonparser.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#/usr/bin/env python
-'''
-Created on 07-Jan-2013
-
-@author: Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
-
- TestON is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- TestON is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
-
- You should have received a copy of the GNU General Public License
- along with TestON. If not, see <http://www.gnu.org/licenses/>.
-
-
-'''
-
-import json
-class JsonParser:
- '''
- Module that parses the response Json to Dictionary and Vice versa.
- '''
- def __init__(self) :
- self.default = ''
-
- def response_parse(self,json_response):
- '''
- This will parse the json formatted string and return content as Dictionary
- '''
- response_dict = {}
- try :
- response_dict = json.loads(json_response)
- except Exception:
- main.log.error("Json Parser is unable to parse the string")
- return response_dict
-
- '''
-
- def dict_json(self,response_dict):
-
- # This will parse the Python Dictionary and return content as Json string.
-
- json_response = {}
- try :
- json_response = json.dumps(response_dict)
- except Exception:
- main.log.error("Json Parser is unable to parse the string")
- return json_response
- '''
diff --git a/TestON/core/xmlparser.py b/TestON/core/xmlparser.py
index fea0ce9..e2cfb1d 100644
--- a/TestON/core/xmlparser.py
+++ b/TestON/core/xmlparser.py
@@ -39,10 +39,10 @@
try :
parsedInfo = xmldict.xml_to_dict(xml)
return parsedInfo
- except Exception:
- print "There is no such file to parse " + fileName
+ except Exception as e:
+ print "Error parsing file " + fileName + ": " + e.message
else :
- print "file name is not correct"
+ print "File name is not correct"
def parseParams(self,paramsPath):
'''