(self)
return self.ok()
Apply homebrew status changes.
Apply homebrew status changes.
Apply homebrew status changes .
def apply(self):
        """
        Apply homebrew status changes.
        """

        # removal ...

        if self.should('rm'):
            self.do('rm')
            Path(self.name).unlink()
            return self.ok()
        
        # fetch from url ...
        
        elif self.should('copy_url'):
            self.do('copy_url')
            self.run(['curl', self.from_url, '-o', self.name])
        
        # creation ...
        elif self.should('copy_file'):
            self.do('copy_file')
            self.copy_file(self.from_file, self.name)

        elif self.should('copy_template'):
            self.do('copy_template')
            data = open(self.name, "w")  
            data.write(self.evaluated_template)
            data.close()

        elif self.should('copy_content'):
            self.do('copy_content')
            data = open(self.name, "w")
            data.write(self.from_content)
            data.close()

        # metadata ...
        
        if self.should('chmod'):
            self.do('chmod')
            os.chmod(self.name, self.mode)

        if self.should('chown'):
            self.do('chown')
            try:
                shutil.chown(self.name, user=self.owner)
            except PermissionError:
                return self.fatal("chown failed")

        if self.should('chgrp'):
            self.do('chgrp')
            try:
                shutil.chown(self.name, group=self.group)
            except PermissionError:
                return self.fatal("chgrp failed")

        return self.ok()
def apply ( self ) : # removal ... if self . should ( 'rm' ) : self . do ( 'rm' ) Path ( self . name ) . unlink ( ) return self . ok ( ) # fetch from url ... elif self . should ( 'copy_url' ) : self . do ( 'copy_url' ) self . run ( [ 'curl' , self . from_url , '-o' , self . name ] ) # creation ... elif self . should ( 'copy_file' ) : self . do ( 'copy_file' ) self . copy_file ( self . from_file , self . name ) elif self . should ( 'copy_template' ) : self . do ( 'copy_template' ) data = open ( self . name , "w" ) data . write ( self . evaluated_template ) data . close ( ) elif self . should ( 'copy_content' ) : self . do ( 'copy_content' ) data = open ( self . name , "w" ) data . write ( self . from_content ) data . close ( ) # metadata ... if self . should ( 'chmod' ) : self . do ( 'chmod' ) os . chmod ( self . name , self . mode ) if self . should ( 'chown' ) : self . do ( 'chown' ) try : shutil . chown ( self . name , user = self . owner ) except PermissionError : return self . fatal ( "chown failed" ) if self . should ( 'chgrp' ) : self . do ( 'chgrp' ) try : shutil . chown ( self . name , group = self . group ) except PermissionError : return self . fatal ( "chgrp failed" ) return self . ok ( )