1
2
3class Hierarchy:
4    def __init__(self,name,subsections=None):
5        self._parent = None
6        self._name=name
7        self._sections = []
8        if subsections is not None:
9           for s in subsections:
10             self.addSection(s)
11
12    @property
13    def parent(self):
14        return(self._parent)
15
16    @property
17    def sections(self):
18        return(self._sections)
19
20    def addSection(self,section):
21        self._sections.append(section)
22
23    @property
24    def hasChildren(self):
25        return(len(self._sections)>0)
26
27    @property
28    def name(self):
29        return(self._name)
30
31
32
33class Document:
34    def __init__(self,runidHeader):
35        self._runidHeader = runidHeader
36        self._sections = []
37
38    @property
39    def runidHeader(self):
40        return(self._runidHeader)
41
42    @property
43    def date(self):
44        return(self._date)
45
46    @property
47    def sections(self):
48        return(self._sections)
49
50    def addSection(self,section):
51        self._sections.append(section)
52
53    def accept(self, visitor):
54      visitor.visitDocument(self)
55      for element in self._sections:
56          element.accept(visitor)
57      visitor.leaveDocument(self)
58
59class Section(Hierarchy):
60  def __init__(self,name):
61      super(Section, self).__init__(name)
62      self._content = []
63      self._testname=False
64
65  def addContent(self,content):
66      self._content.append(content)
67
68  @property
69  def isTest(self):
70    return(self._testname)
71
72  def setTest(self):
73    self._testname = True
74
75  @property
76  def hasContent(self):
77      return(len(self._content) > 0 or any([x.hasContent for x in self.sections]))
78
79
80  def accept(self, visitor):
81      if self.hasContent:
82         visitor.visitSection(self)
83         for element in self.sections:
84             element.accept(visitor)
85         for element in self._content:
86             element.accept(visitor)
87         visitor.leaveSection(self)
88
89class Table:
90    def __init__(self,params,cores):
91       self._params=params
92       self._cores=cores
93       self._rows=[]
94
95    def addRow(self,row):
96       self._rows.append(row)
97
98    @property
99    def columns(self):
100       return(self._params + self._cores)
101
102    @property
103    def params(self):
104       return(self._params)
105
106    @property
107    def cores(self):
108       return(self._cores)
109
110    @property
111    def rows(self):
112       return(self._rows)
113
114    def accept(self, visitor):
115      visitor.visitTable(self)
116
117class Text:
118    def __init__(self,text):
119       self._text = text
120
121    @property
122    def text(self):
123       return(self._text)
124
125    def accept(self, visitor):
126      visitor.visitText(self)
127
128class BarChart:
129    def __init__(self,data):
130       self._data = data
131
132    @property
133    def data(self):
134       return(self._data)
135
136    def accept(self, visitor):
137      visitor.visitBarChart(self)
138
139class History:
140    def __init__(self,data,runid):
141       self._data = data
142       minId = runid-9
143       if minId < 0:
144          minId = 0
145       self._runids = list(range(minId,runid+1))
146
147    @property
148    def data(self):
149       return(self._data)
150
151    @property
152    def runids(self):
153       return(self._runids)
154
155    def accept(self, visitor):
156      visitor.visitHistory(self)