| Index: third_party/WebKit/Source/bindings/scripts/utilities.py
|
| diff --git a/third_party/WebKit/Source/bindings/scripts/utilities.py b/third_party/WebKit/Source/bindings/scripts/utilities.py
|
| index 2d812434f9be78697ee4a71d9e49fde892635fba..697ec8731c14eb21c7526fa63061659a7c841e44 100644
|
| --- a/third_party/WebKit/Source/bindings/scripts/utilities.py
|
| +++ b/third_party/WebKit/Source/bindings/scripts/utilities.py
|
| @@ -407,6 +407,43 @@ def shorten_union_name(union_type):
|
| return name
|
|
|
|
|
| +def format_remove_duplicates(text, patterns):
|
| + """Removes duplicated line-basis patterns.
|
| +
|
| + Based on simple pattern matching, removes duplicated lines in a block
|
| + of lines. Lines that match with a same pattern are considered as
|
| + duplicates.
|
| +
|
| + Designed to be used as a filter function for Jinja2.
|
| +
|
| + Args:
|
| + text: A str of multi-line text.
|
| + patterns: A list of str where each str represents a simple
|
| + pattern. The patterns are not considered as regexp, and
|
| + exact match is applied.
|
| +
|
| + Returns:
|
| + A formatted str with duplicates removed.
|
| + """
|
| + pattern_founds = [False] * len(patterns)
|
| + output = []
|
| + for line in text.split('\n'):
|
| + for i, pattern in enumerate(patterns):
|
| + if pattern not in line:
|
| + continue
|
| + if pattern_founds[i]:
|
| + line = ''
|
| + else:
|
| + pattern_founds[i] = True
|
| + output.append(line)
|
| +
|
| + # Let |'\n'.join| emit the last newline.
|
| + if output:
|
| + output.append('')
|
| +
|
| + return '\n'.join(output)
|
| +
|
| +
|
| def format_blink_cpp_source_code(text):
|
| """Formats C++ source code.
|
|
|
|
|