From f8ea4e0c5020eeaf0a7563a18fa0a1a427c708d8 Mon Sep 17 00:00:00 2001 From: Florian Obersteiner Date: Wed, 16 Mar 2022 21:47:36 +0100 Subject: [PATCH] revision of nlines method --- src/icartt/dataset.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/icartt/dataset.py b/src/icartt/dataset.py index 5e7f023..b124165 100644 --- a/src/icartt/dataset.py +++ b/src/icartt/dataset.py @@ -189,13 +189,13 @@ class StandardNormalComments(collections.UserList): @property def nlines(self): """calculates the number of lines in the normal comments section""" - n = 1 # shortnames line - n += len(self.freeform) # freeform comment + # shortnames line is always there: + n = 1 + # freeform comment might or might not be there: + n += sum(len(s.split('\n')) for s in self.freeform) + # tagged comments have at least one line: for k in self.keywords.values(): - try: - n += len(k.data[0].split("\n")) # and keywords might be multiline... - except IndexError: # ok we have no list, - n += 1 # just add 1 + n += sum(len(s.split('\n')) for s in k.data) or 1 return n @property -- GitLab