From 6a4bb7c1782d9dbb43bd263cdb51c5d4d681b46a Mon Sep 17 00:00:00 2001 From: Simon Ebner Date: Tue, 29 Jan 2019 11:46:29 +0100 Subject: [PATCH] hacked comment parsing --- .gitignore | 1 + cadump/cadump.py | 2 ++ tests/channels.txt | 3 ++- tests/test_download_data.py | 4 +--- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 77d9edc..3ed1302 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +build __pycache__ .idea .pytest_cache diff --git a/cadump/cadump.py b/cadump/cadump.py index 6f0de0e..6d54b27 100644 --- a/cadump/cadump.py +++ b/cadump/cadump.py @@ -8,6 +8,7 @@ import dateutil.parser import pytz import datetime import time +import re import logging logger = logging.getLogger("logger") @@ -78,6 +79,7 @@ def read_channels(filename): channels = [] for line in lines: + line = re.sub(r'\w*#.*', "", line) line = line.strip() if line: # if not empty line channels.append(line) # remove all leading and trailing spaces diff --git a/tests/channels.txt b/tests/channels.txt index 7033f9e..63868d2 100644 --- a/tests/channels.txt +++ b/tests/channels.txt @@ -2,4 +2,5 @@ S10-CPCL-VM1MGC:LOAD ONE TWO -THREE +# Comment that need to be removed +THREE # one more comment at the end that need to be removed diff --git a/tests/test_download_data.py b/tests/test_download_data.py index e5e30e1..b85e1a0 100644 --- a/tests/test_download_data.py +++ b/tests/test_download_data.py @@ -27,9 +27,7 @@ class TestDownloadData(TestCase): def test_read_channels(self): channels = cadump.read_channels("channels.txt") logging.info(channels) - self.assertEqual(len(channels), 3) - - + self.assertEqual(len(channels), 4) if __name__ == '__main__':