Skip to content

Commit 34ed50c

Browse files
committed
Refactor get_parsed_tokens() some more
1 parent f5284d5 commit 34ed50c

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

Python/ini_converting/ini_parser.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,19 @@ def get_parsed_tokens(tokens, parsed=None, token_idx=None, depth=0):
5353
return parsed
5454

5555

56+
def is_deeper(depth, token):
57+
if token["type"] != "TABS":
58+
return False
59+
60+
new_depth = get_depth(token)
61+
62+
if new_depth > depth + 1:
63+
line, column = get_token_position(token)
64+
raise ValueError(f"Too many tabs found at line {line}, column {column} in {token['filepath']}")
65+
66+
return new_depth > depth
67+
68+
5669
def get_depth(token):
5770
return len(token["content"])
5871

@@ -78,20 +91,7 @@ def is_shallower(depth, token, tokens, next_token_idx):
7891
return False # Reached when the while-loop read the last character of the file and didn't return.
7992

8093

81-
def is_deeper(depth, token):
82-
if token["type"] != "TABS":
83-
return False
84-
85-
new_depth = get_depth(token)
86-
87-
if new_depth > depth + 1:
88-
line, column = get_token_pos(token)
89-
raise ValueError(f"Too many tabs found at line {line}, column {column} in {token['filepath']}")
90-
91-
return new_depth > depth
92-
93-
94-
def get_token_pos(token):
94+
def get_token_position(token):
9595
with open(token["filepath"], "r") as f:
9696
text = f.read()
9797

0 commit comments

Comments
 (0)