diff --git a/cayennelpp/lpp_frame.py b/cayennelpp/lpp_frame.py index 2b6b8fa..487cd77 100644 --- a/cayennelpp/lpp_frame.py +++ b/cayennelpp/lpp_frame.py @@ -99,11 +99,12 @@ def size(self): def get_by_type(self, type_): """Return sub list of data with items matching given type.""" - return list(filter(lambda t: (int(t.type) == type_), self.data)) + return [d for d in self.data if int(d.type) == type_] def get_by_name(self, name): """Return sub list of data with items matching given name.""" - return list(filter(lambda t: (str(t.type).lower() == name.lower()), self.data)) + name = name.strip().lower() + return [d for d in self.data if str(d.type).lower().startswith(name)] def add_by_type(self, type_, channel, value_tuple): """Generic helper to add LppDate to this LppFrame.""" diff --git a/cayennelpp/tests/test_lpp_frame.py b/cayennelpp/tests/test_lpp_frame.py index 8c4a054..ae6396a 100644 --- a/cayennelpp/tests/test_lpp_frame.py +++ b/cayennelpp/tests/test_lpp_frame.py @@ -337,6 +337,7 @@ def test_get_by_name(frame_hlt): b_list = frame_hlt.get_by_name("Barometer") assert len(b_list) == 0 + def test_get_by_type_invalid(frame_hlt): p_list = frame_hlt.get_by_type(102) assert len(p_list) == 0