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")
예제 #2
0
 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")
예제 #5
0
def test_exception():
    e = _io.UnsupportedOperation("seek")
예제 #6
0
 def tell(self, *args):
     raise _io.UnsupportedOperation("not seekable")