def mode(self, new_mode: str) -> None: """ Setter function for mode attribute - will only set mode initiatlly, cannot change file mode :param new_mode: New mode """ if not hasattr(self, '__mode'): if new_mode in self.HUFFMAN_FILE_MODES: self.__mode = new_mode else: raise ValueError("Invalid file mode. Please select either \'rb\' or \'wb\'") else: raise _io.UnsupportedOperation("unable to change file mode")
def test_exception(self): import _io e = _io.UnsupportedOperation("seek")
def function_wrapper(*args, **kwargs): if args[0].mode == 'rb': text = func(*args, **kwargs) return text else: raise _io.UnsupportedOperation("file not readable")
def function_wrapper(*args, **kwargs): if args[0].mode == 'wb': return_value = func(*args, **kwargs) return return_value else: raise _io.UnsupportedOperation("file not writable")
def test_exception(): e = _io.UnsupportedOperation("seek")
def tell(self, *args): raise _io.UnsupportedOperation("not seekable")