Changeset View
Changeset View
Standalone View
Standalone View
test/lint/lint-python-format.py
Show First 20 Lines • Show All 188 Lines • ▼ Show 20 Lines | |||||
def find_errors(file): | def find_errors(file): | ||||
"""Extract snippets using the % symbol as a formatter with their line | """Extract snippets using the % symbol as a formatter with their line | ||||
number""" | number""" | ||||
pattern = re.compile(r"(?:\"|')\s*\\?\s+%\s+(?:\\\s+)?.+$", re.MULTILINE) | pattern = re.compile(r"(?:\"|')\s*\\?\s+%\s+(?:\\\s+)?.+$", re.MULTILINE) | ||||
snippets = find_snippets(file) | snippets = find_snippets(file) | ||||
return dict( | return dict( | ||||
[(l, s) for l, s in snippets.items() if pattern.search(s) is not None]) | [(line, snippet) for line, snippet in snippets.items() if pattern.search(snippet) is not None]) | ||||
def main(file): | def main(file): | ||||
r"""Print line number and code snippets using the % formatter from the file, | r"""Print line number and code snippets using the % formatter from the file, | ||||
and suggest a replacement using the .format() method. | and suggest a replacement using the .format() method. | ||||
Output format is : | Output format is : | ||||
(<line number>) <original snippet> | (<line number>) <original snippet> | ||||
=> <replacement snippet> | => <replacement snippet> | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |