From eda138343bdb5bbc2ddea12c04c10ff698cc33ee Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Sat, 10 Nov 2018 18:58:28 +0000 Subject: [PATCH] lint: Extract get_line_info_from_file(). --- tools/linter_lib/custom_check.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tools/linter_lib/custom_check.py b/tools/linter_lib/custom_check.py index 1e715a6a54..f7247e9b1d 100644 --- a/tools/linter_lib/custom_check.py +++ b/tools/linter_lib/custom_check.py @@ -63,13 +63,7 @@ FILES_WITH_LEGACY_SUBJECT = { 'zerver/tests/test_narrow.py', } -def custom_check_file(fn: str, - identifier: str, - rules: RuleList, - color: Optional[Iterable[str]], - max_length: Optional[int]=None) -> bool: - failed = False - +def get_line_info_from_file(fn: str) -> List[LineTup]: line_tups = [] for i, line in enumerate(open(fn)): line_newline_stripped = line.strip('\n') @@ -78,6 +72,16 @@ def custom_check_file(fn: str, continue tup = (i, line, line_newline_stripped, line_fully_stripped) line_tups.append(tup) + return line_tups + +def custom_check_file(fn: str, + identifier: str, + rules: RuleList, + color: Optional[Iterable[str]], + max_length: Optional[int]=None) -> bool: + failed = False + + line_tups = get_line_info_from_file(fn=fn) rules_to_apply = [] for rule in rules: