From 5a45d7b7bb6b2b1490e4b99d209dcc1cb81625b4 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 28 Jan 2019 20:35:07 +0100 Subject: [PATCH] Remove commented lines when reading file in raw mode --- package_linter.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/package_linter.py b/package_linter.py index 4710163..454c778 100755 --- a/package_linter.py +++ b/package_linter.py @@ -87,14 +87,15 @@ def check_file_exist(file_path): def read_file(file_path): f = open(file_path) - # remove every comments and empty lines from the file content to avoid - # false positives file = shlex.shlex(f, False) - #file = filter(None, re.sub("#.*[^\n]", "", f.read()).splitlines()) return file def read_file_raw(file_path): - return open(file_path).read() + # remove every comments and empty lines from the file content to avoid + # false positives + f = open(file_path) + file = "\n".join(filter(None, re.sub("#.*[^\n]", "", f.read()).splitlines())) + return file def check_source_management(app_path):