File tree Expand file tree Collapse file tree 2 files changed +31
-7
lines changed
Expand file tree Collapse file tree 2 files changed +31
-7
lines changed Original file line number Diff line number Diff line change @@ -67,13 +67,6 @@ def schema_to_node_tree(self, schema: str) -> DirPathNode:
6767 last_indentation = 0
6868
6969 for line_num , line in enumerate (schema .split ('\n ' )):
70- indentation = self ._indentation_count (line , line_num + 1 )
71-
72- if indentation > last_indentation + 1 :
73- raise SchemaError ('Inconsistent indentation.' , line_num + 1 )
74-
75- last_indentation = indentation
76-
7770 name = line .strip ()
7871 if len (name ) == 0 :
7972 continue
@@ -82,6 +75,13 @@ def schema_to_node_tree(self, schema: str) -> DirPathNode:
8275 if name .startswith (self .comment_token ):
8376 continue
8477
78+ indentation = self ._indentation_count (line , line_num + 1 )
79+
80+ if indentation > last_indentation + 1 :
81+ raise SchemaError ('Inconsistent indentation.' , line_num + 1 )
82+
83+ last_indentation = indentation
84+
8585 # add node
8686 if indentation == node_depth :
8787 pass
Original file line number Diff line number Diff line change @@ -218,6 +218,30 @@ def test_schema_to_node_tab_indentation_pass(self):
218218
219219 self .assertEqual (expected_tree , returned_tree )
220220
221+ def test_schema_to_node_indentation_empty_line_pass (self ):
222+ schema = 'Assets/\n '
223+ schema += ' *.txt\n '
224+ schema += ' Textures/\n '
225+ schema += ' *.png\n '
226+ schema += '\n '
227+ schema += ' *.jpg\n '
228+
229+ returned_tree = Parser ().schema_to_node_tree (schema )
230+
231+ expected_tree = DirPathNode (name = 'schema_root' ) \
232+ .add_child (DirPathNode (name = 'Assets' )
233+ .add_child (FilePathNode (name = '*.txt' ))
234+ .add_child (DirPathNode (name = 'Textures' )
235+ .add_child (FilePathNode (name = '*.png' ))
236+ .add_child (FilePathNode (name = '*.jpg' ))
237+ )
238+ )
239+
240+ print_node_tree (expected_tree )
241+ print_node_tree (returned_tree )
242+
243+ self .assertEqual (expected_tree , returned_tree )
244+
221245 def test_schema_to_node_inconsistent_indentation_one_fail (self ):
222246 """Uses 4 spaces instead of 2"""
223247 schema = 'Assets/\n '
You can’t perform that action at this time.
0 commit comments