def __init__(self, filepath: str, mode: str) -> None: self.original_mode = stat(filepath)[ST_MODE] self.mode_changed = False if mode in ("w", "a", "wb", "ab"): if not self.original_mode & S_IWRITE: chmod(filepath, self.original_mode | S_IWRITE) self.mode_changed = True FileIO.__init__(self, filepath, mode)
def __init__(self, filepath, mode): self.original_mode = stat(filepath)[ST_MODE] self.mode_changed = False if mode in ('w', 'a', 'wb', 'ab'): if not self.original_mode & S_IWRITE: chmod(filepath, self.original_mode | S_IWRITE) self.mode_changed = True FileIO.__init__(self, filepath, mode)
def close(self) -> None: """restore mode before closing""" self._restore_mode() FileIO.close(self)
def close(self): """restore mode before closing""" self._restore_mode() FileIO.close(self)