def write(self):
        """
        Write the file, forcing the proper permissions
        """
        with root():
            self._write_log()
            with open(self.path, 'w') as f:
                # file owner
                os.chown(self.path, self.uid(), self.gid())

                # mode
                if self.mode:
                    oldmask = os.umask(0)
                    os.chmod(self.path, self.mode)
                    os.umask(oldmask)

                f.write(self.contents())
def write ( self ) : with root ( ) : self . _write_log ( ) with open ( self . path , 'w' ) as f : os . chown ( self . path , self . uid ( ) , self . gid ( ) ) if self . mode : oldmask = os . umask ( 0 ) os . chmod ( self . path , self . mode ) os . umask ( oldmask ) f . write ( self . contents ( ) )
Write the file, forcing the proper permissions