code: def __parse_stream(self, stream, parse_line):
          
  
          if not stream:
              raise InvalidFormatError(cause='stream cannot be empty or None')
  
          nline = 0
          lines = stream.split('\n')
  
          for line in lines:
              nline += 1
  
              # Ignore blank lines and comments
              m = re.match(self.LINES_TO_IGNORE_REGEX, line, re.UNICODE)
              if m:
                  continue
  
              m = re.match(self.VALID_LINE_REGEX, line, re.UNICODE)
              if not m:
                  cause = "line %s: invalid format" % str(nline)
                  raise InvalidFormatError(cause=cause)
  
              try:
                  result = parse_line(m.group(1), m.group(2))
                  yield result
              except InvalidFormatError as e:
                  cause = "line %s: %s" % (str(nline), e)
                  raise InvalidFormatError(cause=cause)
docs: Generic method to parse gitdm streams