1from __future__ import division, print_function, unicode_literals
2
3from dune.common.utility import isString
4
5class Block:
6    def __init__(self):
7        self.content = []
8
9    def append(self, *objs):
10        for obj in objs:
11            if isinstance(obj, (list, set, tuple)):
12                self.content += [o for o in obj]
13            elif obj is not None:
14                self.content.append(obj)
15
16
17class Statement:
18    def __init__(self):
19        pass
20
21
22class UnformattedBlock():
23    def __init__(self, *lines):
24        self.lines = []
25        self.append(*lines)
26
27    def append(self, *lines):
28        for line in lines:
29            if isinstance(line, (list, tuple)):
30                self.append(*list(line))
31            elif isString(line):
32                self.lines += line.split('\n')
33            else:
34                raise Exception('Only strings (or lists of them) can be appended to an UnformattedBlock')
35