diff --git a/src/icartt/dataset.py b/src/icartt/dataset.py index b1241657ade224502987a4ec4b9007260134155e..563d2b189dfd12372bfd0a2d785ddbdb54c1b9c0 100644 --- a/src/icartt/dataset.py +++ b/src/icartt/dataset.py @@ -216,26 +216,26 @@ class StandardNormalComments(collections.UserList): # in the order listed in the ICARTT documentation. currentKeyword = None + keywordLine = False for l in raw: possibleKeyword = l.split(":")[0].strip() - if possibleKeyword in self.keywords or re.match( - "R[a-zA-Z0-9]{1,2}[ ]*", possibleKeyword - ): + if possibleKeyword in self.keywords or re.match("R[a-zA-Z0-9]{1,2}[ ]*", possibleKeyword): currentKeyword = possibleKeyword + keywordLine = True if not currentKeyword in self.keywords: # for the revisions only... - self.keywords[currentKeyword] = KeywordComment( - currentKeyword, False - ) + self.keywords[currentKeyword] = KeywordComment(currentKeyword, False) + else: + keywordLine = False if currentKeyword is None: self.freeform.append(l) + elif keywordLine: + self.keywords[currentKeyword].append(l.replace(l.split(":")[0] + ":", "").strip()) else: - self.keywords[currentKeyword].append( - l.replace(l.split(":")[0] + ":", "").strip() - ) + self.keywords[currentKeyword].append(l.strip()) for key in self.keywords: - if self.keywords[key].data == []: + if not self.keywords[key].data: warnings.warn( f"Normal comments: required keyword {str(key)} is missing." )