<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

# This file is part of vitrine.
# https://github.com/globocom/vitrine

# Licensed under the MIT license:
# http://www.opensource.org/licenses/MIT-license
# Copyright (c) 2015, <EMAIL> <<EMAIL>>

import os
import re

from flask import json
from flask.ext import assets

from webassets.updater import TimestampUpdater


STATIC_PATH = os.path.join(os.path.dirname(__file__))
VENDOR_PATH = os.path.join(STATIC_PATH, 'vendor')
PACKAGE_REGEX = re.compile(r'(?:(?:[├│└──┬]+)\s*)+\s([^#]+(?!.+extraneous))')

assets_env = assets.Environment()


def init_app(app):
    assets_env.app = app
    assets_env.init_app(app)

    assets_env.manifest = "file:%s" % (os.path.join(STATIC_PATH, '.webassets-manifest'))
    cache_path = app.config['WEBASSETS_CACHE_PATH']
    if not app.debug and not os.path.exists(cache_path):
        os.makedirs(cache_path)
    assets_env.cache = cache_path

    assets_env.load_path = STATIC_PATH
    assets_env.versions = 'hash:32'
    assets_env.auto_build = app.config['WEBASSETS_AUTO_BUILD']
    assets_env.url_expire = False

    # Tell flask-assets where to look for our coffeescript and scss files.
    assets_env.load_path = [
        os.path.join(os.path.dirname(__file__), 'scss'),
        os.path.join(os.path.dirname(__file__), 'coffee'),
        VENDOR_PATH
    ]

    bower_dependencies = read_bower_json()
    js_files = bower_dependencies.get('.js', [])

    js_out = 'js/js_app.%(version)s.js'
    if app.debug:
        js_out = 'js/js_app.js'

    js_files.append(
        assets.Bundle(
            *get_coffee_files(),
            depends=('*.coffee'),
            # OTHER CONFIGS
            filters=['coffeescript'], output=js_out
        )
    )

    app.config['COMPASS_CONFIG'] = dict(
        encoding="utf-8",
        css_dir="css",
        fonts_dir="fonts",
        sass_dir="scss",
        images_dir="images",
        javascripts_dir="js",
        relative_assets=True,
    )

    js_out = 'js/js_all.%(version)s.js'
    if app.debug:
        js_out = 'js/js_all.js'

    js_all_bundle = assets.Bundle(
        *js_files,
        output=js_out
    )
    assets_env.register('js_all', js_all_bundle)

    css_out = 'css/css_all.%(version)s.css'
    if app.debug:
        css_out = 'css/css_all.css'

    css_all_bundle = assets.Bundle(
        'all.scss',
        depends=('_*.scss'),
        filters=['compass', 'cssmin'],
        output=css_out
    )
    assets_env.register('css_all', css_all_bundle)

    # css_out = 'css/base.%(version)s.css'
    # if app.debug:
    #     css_out = 'css/base.css'

    # css_files = bower_dependencies.get('.css', [])
    # css_base_bundle = assets.Bundle(
    #     *css_files,
    #     filters=['cssmin'],
    #     output=css_out
    # )
    # assets_env.register('css_base', css_base_bundle)

    if app.debug:
        assets_env.set_updater(TimestampUpdater())
        assets_env.cache = False<commit_msg>refact(assets): show version hash<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

# This file is part of vitrine.
# https://github.com/globocom/vitrine

# Licensed under the MIT license:
# http://www.opensource.org/licenses/MIT-license
# Copyright (c) 2015, <EMAIL> <<EMAIL>>

import logging
import os
import re

from flask import json
from flask.ext import assets

from webassets.updater import TimestampUpdater


STATIC_PATH = os.path.join(os.path.dirname(__file__))
VENDOR_PATH = os.path.join(STATIC_PATH, 'vendor')
PACKAGE_REGEX = re.compile(r'(?:(?:[├│└──┬]+)\s*)+\s([^#]+(?!.+extraneous))')

assets_env = assets.Environment()


def init_app(app):
    assets_env.app = app
    assets_env.init_app(app)

    assets_env.manifest = "file:%s" % (os.path.join(STATIC_PATH, '.webassets-manifest'))
    cache_path = app.config['WEBASSETS_CACHE_PATH']
    if not app.debug and not os.path.exists(cache_path):
        os.makedirs(cache_path)
    assets_env.cache = cache_path

    assets_env.load_path = STATIC_PATH
    assets_env.versions = 'hash:32'
    assets_env.auto_build = app.config['WEBASSETS_AUTO_BUILD']
    assets_env.url_expire = False

    # Tell flask-assets where to look for our coffeescript and scss files.
    assets_env.load_path = [
        os.path.join(os.path.dirname(__file__), 'scss'),
        os.path.join(os.path.dirname(__file__), 'coffee'),
        VENDOR_PATH
    ]

    bower_dependencies = read_bower_json()
    js_files = bower_dependencies.get('.js', [])

    js_out = 'js/js_app.%(version)s.js'
    if app.debug:
        js_out = 'js/js_app.js'

    js_files.append(
        assets.Bundle(
            *get_coffee_files(),
            depends=('*.coffee'),
            # OTHER CONFIGS
            filters=['coffeescript'], output=js_out
        )
    )

    app.config['COMPASS_CONFIG'] = dict(
        encoding="utf-8",
        css_dir="css",
        fonts_dir="fonts",
        sass_dir="scss",
        images_dir="images",
        javascripts_dir="js",
        relative_assets=True,
    )

    js_out = 'js/js_all.%(version)s.js'
    if app.debug:
        js_out = 'js/js_all.js'

    js_all_bundle = assets.Bundle(
        *js_files,
        output=js_out
    )
    asset = assets_env.register('js_all', js_all_bundle)

    logging.info('Version: %s', asset.get_version())

    css_out = 'css/css_all.%(version)s.css'
    if app.debug:
        css_out = 'css/css_all.css'

    css_all_bundle = assets.Bundle(
        'all.scss',
        depends=('_*.scss'),
        filters=['compass', 'cssmin'],
        output=css_out
    )
    assets_env.register('css_all', css_all_bundle)

    # css_out = 'css/base.%(version)s.css'
    # if app.debug:
    #     css_out = 'css/base.css'

    # css_files = bower_dependencies.get('.css', [])
    # css_base_bundle = assets.Bundle(
    #     *css_files,
    #     filters=['cssmin'],
    #     output=css_out
    # )
    # assets_env.register('css_base', css_base_bundle)

    if app.debug:
        assets_env.set_updater(TimestampUpdater())
        assets_env.cache = False
{'fraction_non_alphanumeric': 0.14575369785607445, 'fraction_numerical': 0.002659132458035566, 'mean_word_length': 2.8136882129277567, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '780685', 'n_tokens_mistral': 2209, 'n_tokens_neox': 2143, 'n_words': 340}