|
|
|
@ -15,7 +15,7 @@ __author__ = "Michał Słomkowski"
|
|
|
|
|
__license__ = "Apache 2.0"
|
|
|
|
|
__version__ = "1.0.2"
|
|
|
|
|
|
|
|
|
|
INDENTATION = ' ' * 4
|
|
|
|
|
INDENTATION = ' '
|
|
|
|
|
|
|
|
|
|
TEMPLATE_VARIABLE_OPENING_TAG = '___TEMPLATE_VARIABLE_OPENING_TAG___'
|
|
|
|
|
TEMPLATE_VARIABLE_CLOSING_TAG = '___TEMPLATE_VARIABLE_CLOSING_TAG___'
|
|
|
|
@ -171,12 +171,21 @@ def perform_indentation(lines):
|
|
|
|
|
"""Indents the lines according to their nesting level determined by curly brackets."""
|
|
|
|
|
indented_lines = []
|
|
|
|
|
current_indent = 0
|
|
|
|
|
current_line = ""
|
|
|
|
|
|
|
|
|
|
for line in lines:
|
|
|
|
|
if not line.startswith("#") and line.endswith('}') and current_indent > 0:
|
|
|
|
|
current_indent -= 1
|
|
|
|
|
|
|
|
|
|
if line != "":
|
|
|
|
|
directive = line.split(' ', maxsplit=1)
|
|
|
|
|
if directive[0] == '}' or directive[0] == 'if' or directive[0] == 'location':
|
|
|
|
|
indented_lines.append(current_indent * INDENTATION + line)
|
|
|
|
|
elif directive[1] == '{':
|
|
|
|
|
indented_lines.append(current_indent * INDENTATION + line)
|
|
|
|
|
else:
|
|
|
|
|
directive_split_space = int( ( 40 - (current_indent * 8) - len(directive[0]) ) / 8 ) + 1
|
|
|
|
|
indented_lines.append(current_indent * INDENTATION + directive[0] + directive_split_space * INDENTATION + directive[1])
|
|
|
|
|
else:
|
|
|
|
|
indented_lines.append("")
|
|
|
|
|
|
|
|
|
|