'Checks if the bundle contains any sass/less content, then compiles it to css.
Returns the bundle\'s flat css.'

def preprocess_css(self, debug=False):

    for atype in (SassStylesheetAsset, LessStylesheetAsset):
        assets = [asset for asset in self.stylesheets if isinstance(asset, atype)]
        if assets:
            cmd = assets[0].get_command()
            source = '\n'.join([asset.get_source() for asset in assets])
            compiled = self.compile_css(cmd, source)
            fragments = self.rx_css_split.split(compiled)
            at_rules = fragments.pop(0)
            if at_rules:
                self.stylesheets.insert(0, StylesheetAsset(self, inline=at_rules))
            while fragments:
                asset_id = fragments.pop(0)
                asset = next((asset for asset in self.stylesheets if (asset.id == asset_id)))
                asset._content = fragments.pop(0)
                if debug:
                    try:
                        fname = os.path.basename(asset.url)
                        url = asset.html_url
                        with self.env.cr.savepoint():
                            self.env['ir.attachment'].sudo().create(dict(datas=asset.content.encode('utf8').encode('base64'), mimetype='text/css', type='binary', name=url, url=url, datas_fname=fname, res_model=False, res_id=False))
                        if (self.env.context.get('commit_assetsbundle') is True):
                            self.env.cr.commit()
                    except psycopg2.Error:
                        pass
    return '\n'.join((asset.minify() for asset in self.stylesheets))
