bakery/bakery.py
def _build_static(self):
        """ Create directories needed for the structure.
        This step is done before most of the resources is moved to the build
        directory. It involves creation of directories for the structure and
        copying of assets.
        """
        modified_files = []

        # Create assets directory
        mkdir_p(os.path.join(self.config.build_dir, self.config.paths['assets']))

        for root, dirs, files in os.walk(
                os.path.join(self.config.source_dir,
                             self.config.paths['assets']), topdown=True):
            for d in dirs:
                src = os.path.join(root, d)
                dst = os.path.join(self.config.build_dir, self.config.paths['assets'], d)
                if not os.path.exists(dst):
                    mkdir_p(dst)
                    shutil.copystat(src, dst)
            # Ignore files starting with dot.
            files[:] = [f for f in files if not f.startswith('.')]
            for f in files:
                srcname = os.path.join(root, f)
                dstname = srcname.replace(self.config.source_dir, self.config.build_dir, 1)
                # Copy file if does not exists in build dir or if it has changed.
                if not os.path.exists(dstname) \
                        or os.path.exists(dstname) \
                        and os.stat(srcname).st_mtime != os.stat(dstname).st_mtime:
                    shutil.copy2(srcname, dstname)
                    modified_files.append(dstname)

        # Compare the asset directory with source to build and remove files
        # and directories that does not match.
        # Adapt this be a more generic comparison so we can diff all
        # resources.
        asset_dir = os.path.join(self.config.build_dir, self.config.paths['assets'])
        for root, dirs, files in os.walk(asset_dir, topdown=True):
            for d in dirs:
                compare = filecmp.dircmp(
                    os.path.join(self.config.source_dir, self.config.paths['assets'], d),
                    os.path.join(root, d)
                )
                for diff in compare.right_only:
                    p = os.path.join(asset_dir, d, diff)
                    if os.path.isdir(p):
                        try:
                            shutil.rmtree(p)
                        except OSError, e:
                            _stderr('** Could not remove directory {0} {1}\n'.format(p, e))
                    else:
                        try:
                            os.remove(p)
                        except OSError, e:
                            _stderr('** Could not remove file {0} {1}\n'.format(p, e))

        # If compression is enabled run it.
        if self.config.compress:
            import yuicompressor
            _stdout('** With compressing\n')
            for root, dirs, files in os.walk(self.config.build_dir + os.sep + self.config.paths['assets'], topdown=True):
                for pat in self.config.compress:
                    for f in fnmatch.filter(files, pat):
                        if not f.endswith('min.js') or not f.endswith('min.css'):
                            _stdout('>> {0}\n'.format(f))
                            yuicompressor.run(
                                os.path.join(root, f),
                                "-o", os.path.join(root, f)
                            )
 Create directories needed for the structure.
        This step is done before most of the resources is moved to the build
        directory. It involves creation of directories for the structure and
        copying of assets.
        
Create directories needed for the structure.
This step is done before most of the resources is moved to the build
directory. It involves creation of directories for the structure and
copying of assets.
Create directories needed for the structure . This step is done before most of the resources is moved to the build directory . It involves creation of directories for the structure and copying of assets .
def _build_static(self):
        modified_files = []
        mkdir_p(os.path.join(self.config.build_dir, self.config.paths['assets']))
        for root, dirs, files in os.walk(
                os.path.join(self.config.source_dir,
                             self.config.paths['assets']), topdown=True):
            for d in dirs:
                src = os.path.join(root, d)
                dst = os.path.join(self.config.build_dir, self.config.paths['assets'], d)
                if not os.path.exists(dst):
                    mkdir_p(dst)
                    shutil.copystat(src, dst)
            files[:] = [f for f in files if not f.startswith('.')]
            for f in files:
                srcname = os.path.join(root, f)
                dstname = srcname.replace(self.config.source_dir, self.config.build_dir, 1)
                if not os.path.exists(dstname) \
                        or os.path.exists(dstname) \
                        and os.stat(srcname).st_mtime != os.stat(dstname).st_mtime:
                    shutil.copy2(srcname, dstname)
                    modified_files.append(dstname)
        asset_dir = os.path.join(self.config.build_dir, self.config.paths['assets'])
        for root, dirs, files in os.walk(asset_dir, topdown=True):
            for d in dirs:
                compare = filecmp.dircmp(
                    os.path.join(self.config.source_dir, self.config.paths['assets'], d),
                    os.path.join(root, d)
                )
                for diff in compare.right_only:
                    p = os.path.join(asset_dir, d, diff)
                    if os.path.isdir(p):
                        try:
                            shutil.rmtree(p)
                        except OSError, e:
                            _stderr('** Could not remove directory {0} {1}\n'.format(p, e))
                    else:
                        try:
                            os.remove(p)
                        except OSError, e:
                            _stderr('** Could not remove file {0} {1}\n'.format(p, e))
        if self.config.compress:
            import yuicompressor
            _stdout('** With compressing\n')
            for root, dirs, files in os.walk(self.config.build_dir + os.sep + self.config.paths['assets'], topdown=True):
                for pat in self.config.compress:
                    for f in fnmatch.filter(files, pat):
                        if not f.endswith('min.js') or not f.endswith('min.css'):
                            _stdout('>> {0}\n'.format(f))
                            yuicompressor.run(
                                os.path.join(root, f),
                                "-o", os.path.join(root, f)
                            )
def _build_static ( self ) : modified_files = [ ] mkdir_p ( os . path . join ( self . config . build_dir , self . config . paths [ 'assets' ] ) ) for root , dirs , files in os . walk ( os . path . join ( self . config . source_dir , self . config . paths [ 'assets' ] ) , topdown = True ) : for d in dirs : src = os . path . join ( root , d ) dst = os . path . join ( self . config . build_dir , self . config . paths [ 'assets' ] , d ) if not os . path . exists ( dst ) : mkdir_p ( dst ) shutil . copystat ( src , dst ) files [ : ] = [ f for f in files if not f . startswith ( '.' ) ] for f in files : srcname = os . path . join ( root , f ) dstname = srcname . replace ( self . config . source_dir , self . config . build_dir , 1 ) if not os . path . exists ( dstname ) or os . path . exists ( dstname ) and os . stat ( srcname ) . st_mtime != os . stat ( dstname ) . st_mtime : shutil . copy2 ( srcname , dstname ) modified_files . append ( dstname ) asset_dir = os . path . join ( self . config . build_dir , self . config . paths [ 'assets' ] ) for root , dirs , files in os . walk ( asset_dir , topdown = True ) : for d in dirs : compare = filecmp . dircmp ( os . path . join ( self . config . source_dir , self . config . paths [ 'assets' ] , d ) , os . path . join ( root , d ) ) for diff in compare . right_only : p = os . path . join ( asset_dir , d , diff ) if os . path . isdir ( p ) : try : shutil . rmtree ( p ) except OSError , e : _stderr ( '** Could not remove directory {0} {1}\n' . format ( p , e ) ) else : try : os . remove ( p ) except OSError , e : _stderr ( '** Could not remove file {0} {1}\n' . format ( p , e ) ) if self . config . compress : import yuicompressor _stdout ( '** With compressing\n' ) for root , dirs , files in os . walk ( self . config . build_dir + os . sep + self . config . paths [ 'assets' ] , topdown = True ) : for pat in self . config . compress : for f in fnmatch . filter ( files , pat ) : if not f . endswith ( 'min.js' ) or not f . endswith ( 'min.css' ) : _stdout ( '>> {0}\n' . format ( f ) ) yuicompressor . run ( os . path . join ( root , f ) , "-o" , os . path . join ( root , f ) )
Create directories needed for the structure.
Create directories needed for the structure .
""" Create directories needed for the structure.
        This step is done before most of the resources is moved to the build
        directory. It involves creation of directories for the structure and
        copying of assets.
        """ # Create assets directory # Ignore files starting with dot. # Copy file if does not exists in build dir or if it has changed. # Compare the asset directory with source to build and remove files # and directories that does not match. # Adapt this be a more generic comparison so we can diff all # resources. # If compression is enabled run it.
self