23
23
24
24
def get_model (source , data_only = False , curdir = None ):
25
25
tokens = get_tokens (source , data_only )
26
- return _build_model (get_statements (tokens , curdir ))
26
+ return _build_model (source , get_statements (tokens , curdir ))
27
27
28
28
29
29
def get_resource_model (source , data_only = False , curdir = None ):
30
30
tokens = get_resource_tokens (source , data_only )
31
- return _build_model (get_statements (tokens , curdir ))
31
+ return _build_model (source , get_statements (tokens , curdir ))
32
32
33
33
34
- def _build_model (statements ):
35
- builder = FileBuilder ()
34
+ def _build_model (source , statements ):
35
+ builder = FileBuilder (source )
36
36
stack = [builder ]
37
37
for statement in statements :
38
38
while not stack [- 1 ].handles (statement ):
@@ -57,8 +57,8 @@ def statement(self, statement):
57
57
58
58
class FileBuilder (Builder ):
59
59
60
- def __init__ (self , model = None ):
61
- Builder .__init__ (self , model or File ())
60
+ def __init__ (self , source = None ):
61
+ Builder .__init__ (self , File (source ))
62
62
63
63
def statement (self , statement ):
64
64
try :
@@ -90,6 +90,8 @@ class TestCaseSectionBuilder(SectionBuilder):
90
90
91
91
def statement (self , statement ):
92
92
if statement .type == Token .EOL :
93
+ if self .model .body .items :
94
+ self .model .body .add (statement )
93
95
return self
94
96
model = TestCase (statement )
95
97
self .model .body .add (model )
@@ -100,6 +102,8 @@ class KeywordSectionBuilder(SectionBuilder):
100
102
101
103
def statement (self , statement ):
102
104
if statement .type == Token .EOL :
105
+ if self .model .body .items :
106
+ self .model .body .add (statement )
103
107
return self
104
108
model = Keyword (statement )
105
109
self .model .body .add (model )
0 commit comments