Changeset View
Changeset View
Standalone View
Standalone View
test/lint/lint-python-format.py
Show First 20 Lines • Show All 157 Lines • ▼ Show 20 Lines | def build_replacement(error): | ||||
replacement = re.sub(r"\xec\xec", "%", replacement, re.MULTILINE) | replacement = re.sub(r"\xec\xec", "%", replacement, re.MULTILINE) | ||||
return replacement | return replacement | ||||
def find_snippets(file): | def find_snippets(file): | ||||
"""Find code snippets in the source file that contains the percent ('%') | """Find code snippets in the source file that contains the percent ('%') | ||||
character""" | character""" | ||||
with open(file, 'r') as f: | with open(file, 'r', encoding='utf-8') as f: | ||||
snippet_line = "" | snippet_line = "" | ||||
snippets = {} | snippets = {} | ||||
for line_number, line in enumerate(f): | for line_number, line in enumerate(f): | ||||
# Skip comments | # Skip comments | ||||
if not line.strip().startswith('#'): | if not line.strip().startswith('#'): | ||||
# If we are not already in a snippet and the line contains a % | # If we are not already in a snippet and the line contains a % | ||||
# character, start saving the snippet | # character, start saving the snippet | ||||
▲ Show 20 Lines • Show All 109 Lines • Show Last 20 Lines |