1
2 '''
3 Created on 07-Jan-2013
4
5 @author: Raghav Kashyap(raghavkashyap@paxterrasolutions.com)
6 '''
7
8 import re
9 from configobj import ConfigObj
11 '''
12 Manages authoring, parsing and execution of the test. Sub components are
13 Test-Topology parser
14 Module that parses the test from plain English and topology
15 from a specification file and prepares for execution.
16 Test sequencer
17 Module that executes the tests case by case,
18 step by step adding ability for step by step pause and debug later.
19 Object loader
20 Module that connects and loads all the component connection objects
21 for access in the test
22 '''
25
26 - def parse(self,fileName):
27 '''
28 This will parse the params or topo or cfg file and return content in the file as Dictionary
29 '''
30 self.fileName = fileName
31 matchFileName = re.match(r'(.*)\.(params|topo)',self.fileName,re.M|re.I)
32 if matchFileName:
33 try :
34 parsedInfo = ConfigObj(self.fileName)
35 return parsedInfo
36 except :
37 print "There is no such file to parse "+fileName
38 else:
39 return 0
40
42 '''
43 It will take the params file path and will return the params dictionary
44 '''
45
46 paramsPath = re.sub("\.","/",paramsPath)
47 paramsPath = re.sub("tests|examples","",paramsPath)
48
49 params = self.parse(main.tests_path+paramsPath+".params")
50 paramsAsString = str(params)
51 return eval(paramsAsString)
52
54 '''
55 It will take topology file path and will return topology dictionary
56 '''
57 topologyPath = re.sub("\.","/",topologyPath)
58 topologyPath = re.sub("tests|examples","",topologyPath)
59 topology = self.parse(main.tests_path+"/"+topologyPath+".topo")
60 topoAsString = str(topology)
61 return eval(topoAsString)
62