tools/lib: Text-wrap long lines exceeding 110.

This commit is contained in:
rht
2017-11-08 03:47:28 +01:00
committed by Tim Abbott
parent 53e37aa511
commit 7a96b8c7ad
4 changed files with 13 additions and 7 deletions

View File

@@ -94,8 +94,9 @@ def pretty_print_html(html, num_spaces=4):
ignore_lines=[]
)
stack.append(info)
elif token.kind in ('html_end', 'handlebars_end',
'html_singleton_end', 'django_end') and (stack[-1]['tag'] != 'pre' or token.tag == 'pre'):
elif (token.kind in ('html_end', 'handlebars_end', 'html_singleton_end',
'django_end') and
(stack[-1]['tag'] != 'pre' or token.tag == 'pre')):
info = stack.pop()
if info['block']:
# We are at the end of an indentation block. We
@@ -121,7 +122,8 @@ def pretty_print_html(html, num_spaces=4):
info['extra_indent_prev'])
elif (start_line + info['line_span'] - 1 == end_line and
info['line_span'] > 2 and token.kind != 'html_singleton_end'):
offsets[end_line] = (1 + info['extra_indent'] + (info['depth'] + 1) * num_spaces) - adjustment
offsets[end_line] = (1 + info['extra_indent'] +
(info['depth'] + 1) * num_spaces) - adjustment
elif token.line != info['line']:
offsets[end_line] = info['offset']
if token.tag != 'pre' and token.kind != 'html_singleton_end' and token.tag != 'script':
@@ -184,7 +186,8 @@ def validate_indent_html(fn):
temp_file = open('/var/tmp/pretty_html.txt', 'w')
temp_file.write(phtml)
temp_file.close()
print('Invalid Indentation detected in file: %s\nDiff for the file against expected indented file:' % (fn))
print('Invalid Indentation detected in file: '
'%s\nDiff for the file against expected indented file:' % (fn))
subprocess.call(['diff', fn, '/var/tmp/pretty_html.txt'], stderr=subprocess.STDOUT)
return 0
return 1