def readline(self, line: Union[str, SimpleLine]) -> 'Formato': """ :param line: :return: """ if (isinstance(line, str) or isinstance(line, SimpleLine)) is False: raise TypeError(f"Expected a String or 'SimpleLine instance. Got {line} of type {type(line)} instead.") newline = SimpleLine(line) if (newline.gettipo().strip()).lower() == "format": newcols = [_.strip() for _ in newline.gettexto().split(",")] return self
def readevent(self, arg: Union[str, SimpleLine]) -> 'Evento': """ Read an event line and stores it's columns. :param arg: String or SimpleLine instance. :return: self. """ assert self.getformato() is not None, f"Format is not set" if (isinstance(arg, str) or isinstance(arg, SimpleLine)) is False: raise TypeError( f"{arg} must be a string or a 'SimpleLine' instance") # If it's a string, splits type from the text. If it's a SimpleLine, remains the same. __event = SimpleLine(arg) if __event.gettipo() is None: raise ValueError("Invalid Event") # This will raise ValueError if it is invalid self.seteventtype(__event.gettipo()) __values = [_.strip() for _ in __event.gettexto().split(",", 9)] if len(__values) != 10: raise ValueError( f"{len(__values)}: number of columns has to be 10.") return self.setvalues(__values)