本文整理汇总了Python中webassets.Environment.cache方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.cache方法的具体用法?Python Environment.cache怎么用?Python Environment.cache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webassets.Environment
的用法示例。
在下文中一共展示了Environment.cache方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _setup_env
# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import cache [as 别名]
def _setup_env(app='', debug=True, cache=True):
"""Setup the webassets environment."""
if app:
app_path = path.join('..', '..', app, 'static')
env = Environment(
path.join(INPUT_FILES, '..', '..', 'skel', 'assets'),
path.join(BASE_LOCATION, '..'))
else:
app_path = path.join('..', 'static')
env = Environment(
path.join(INPUT_FILES, '..', '..', 'skel', 'assets'),
path.join(BASE_LOCATION))
# We use underscore's templates by default.
env.config['JST_COMPILER'] = '_.template'
if debug:
env.config['CLOSURE_COMPRESSOR_OPTIMIZATION'] = 'WHITESPACE_ONLY'
env.manifest = False
else:
env.config['CLOSURE_COMPRESSOR_OPTIMIZATION'] = 'ADVANCED_OPTIMIZATIONS'
env.debug = False
env.cache = cache
#javascript
_bundle_app_coffee(app_path, env, debug)
_bundle_3rd_party_js(app_path, env, debug)
#css
_bundle_3rd_party_css(app_path, env, debug)
#images
_bundle_images(app, env, is_skel=True)
return env
示例2: _setup_env
# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import cache [as 别名]
def _setup_env(debug=True, cache=True):
"""Setup the webassets environment."""
env = Environment(INPUT_FILES, OUTPUT_FILES)
# We use underscore's templates by default.
env.config['JST_COMPILER'] = '_.template'
if debug:
env.config['CLOSURE_COMPRESSOR_OPTIMIZATION'] = 'WHITESPACE_ONLY'
env.manifest = False
else:
env.config['CLOSURE_COMPRESSOR_OPTIMIZATION'] = 'ADVANCED_OPTIMIZATIONS'
env.debug = False
env.cache = cache
#javascript
_bundle_app_jsts(env, debug)
_bundle_app_coffee(env, debug)
_bundle_3rd_party_js(env, debug)
#css
_bundle_app_less(env, debug)
_bundle_3rd_party_css(env, debug)
#images
_bundle_images(env)
return env
示例3: _set_env
# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import cache [as 别名]
def _set_env(debug=True, cache=False):
env = Environment(BASE_PATH)
if debug:
env.manifest = False
env.cache = cache
return env
示例4: register_assets
# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import cache [as 别名]
def register_assets(settings):
"""
Initialize webassets environment and its bundles.
Arguments:
settings (conf.model.SettingsModel): Settings registry instance.
Returns:
webassets.Environment: New configured Webasset environment.
"""
logger = logging.getLogger('optimus')
if not settings.ENABLED_BUNDLES:
logger.warning(("Asset registering skipped as there are no enabled "
"bundle"))
return None
logger.info("Starting asset registering")
# Assets bundles
AVAILABLE_BUNDLES = getattr(settings, 'BUNDLES', {})
# Initialize webassets environment
assets_env = AssetsEnvironment()
assets_env.debug = settings.DEBUG
assets_env.url = settings.STATIC_URL
assets_env.directory = settings.STATIC_DIR
assets_env.load_path = [settings.SOURCES_DIR]
assets_env.cache = settings.WEBASSETS_CACHE
assets_env.url_expire = settings.WEBASSETS_URLEXPIRE
#
assets_env.optimus_registry = AssetRegistry()
# Register enabled assets bundles
for bundle_name in settings.ENABLED_BUNDLES:
logger.debug("Registering bundle: {}".format(bundle_name))
assets_env.register(bundle_name, AVAILABLE_BUNDLES[bundle_name])
assets_env.optimus_registry.add_bundle(bundle_name,
AVAILABLE_BUNDLES[bundle_name])
# When after bundle has been registered we can resolve it
for bundle_name in settings.ENABLED_BUNDLES:
logger.info(" Processing: {}".format(
assets_env[bundle_name].resolve_output()
))
# Avoid to loop on every bundle part if we are not in debug logger
if logger.getEffectiveLevel() == logging.DEBUG:
for url in assets_env[bundle_name].urls():
logger.debug(" - {}".format(url))
return assets_env
示例5: register_assets
# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import cache [as 别名]
def register_assets():
"""
Initialize webassets environment and its bundles
NOTE: The asset bundles building is lazy, webassets only do building when he is
invoked by his template tag **assets** and if it detect that a file in a
bundle has changed.
"""
logger = logging.getLogger('optimus')
if not settings.ENABLED_BUNDLES:
logger.warning("Asset registering skipped as there are no enabled bundles")
return None
logger.info("Starting asset registering")
# Assets bundles
AVAILABLE_BUNDLES = copy.deepcopy(COMMON_BUNDLES)
AVAILABLE_BUNDLES.update(getattr(settings, 'EXTRA_BUNDLES', {}))
# Initialize webassets environment
assets_env = AssetsEnvironment()
assets_env.debug = settings.DEBUG
assets_env.url = settings.STATIC_URL
assets_env.directory = settings.STATIC_DIR
assets_env.load_path = [settings.SOURCES_DIR]
assets_env.cache = settings.WEBASSETS_CACHE
#
assets_env.optimus_registry = AssetRegistry()
# Register enabled assets bundles
for bundle_name in settings.ENABLED_BUNDLES:
logger.debug("Registering bundle: %s", bundle_name)
# Little trick because Bundle does not know their used name in the webassets
# environment
AVAILABLE_BUNDLES[bundle_name]._internal_env_name = bundle_name
assets_env.register(bundle_name, AVAILABLE_BUNDLES[bundle_name])
assets_env.optimus_registry.add_bundle(AVAILABLE_BUNDLES[bundle_name])
# for debugging purpopse
for bundle_name in settings.ENABLED_BUNDLES:
logger.info(" Processing: %s", assets_env[bundle_name].resolve_output())
# TODO: conditionnal on the log level to avoid to loop on multiple items if not
# in a debug log level
for url in assets_env[bundle_name].urls():
logger.debug(" - %s", url)
return assets_env
示例6: run
# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import cache [as 别名]
def run(self):
from webassets import Bundle
from webassets import Environment
from webassets.script import CommandLineEnvironment
css = Bundle('curious/src/css/app.css', output='curious/dist/curious.css')
js = Bundle('curious/src/js/*.js', output='curious/dist/curious.js')
jsmin = Bundle('curious/src/js/*.js', filters='jsmin', output='curious/dist/curious.min.js')
jst = Bundle('curious/src/html/*.html', filters='jst', output='curious/dist/curious_jst.js')
assets_env = Environment('./curious/static')
assets_env.cache = self.cache_dir
assets_env.register('css', css)
assets_env.register('js', js)
assets_env.register('jsmin', jsmin)
assets_env.register('jst', jst)
log = logging.getLogger('webassets')
log.addHandler(logging.StreamHandler())
log.setLevel(logging.DEBUG)
cmdenv = CommandLineEnvironment(assets_env, log)
cmdenv.build()
示例7: Bundle
# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import cache [as 别名]
js = Bundle('src/js/*.js',
output='dist/exotic.js')
jsm = Bundle('src/js/*.js', filters='jsmin',
output='dist/exotic.min.js')
jst = Bundle('src/html/*.html', filters='jst',
output='dist/exotic_jst.js')
assets_env = Environment('.')
try:
os.mkdir('.webassets-cache')
except:
pass
assets_env.cache = '.webassets-cache'
assets_env.register('css', css)
assets_env.register('js', js)
assets_env.register('jsmin', jsm)
assets_env.register('jst', jst)
if __name__ == "__main__":
from webassets.script import CommandLineEnvironment
import logging
log = logging.getLogger('webassets')
log.addHandler(logging.StreamHandler())
log.setLevel(logging.DEBUG)
cmdenv = CommandLineEnvironment(assets_env, log)
cmdenv.build()
示例8: Environment
# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import cache [as 别名]
from webassets import Environment
from webassets import Bundle
static = Environment('./www', '/')
static.cache = False
header_js = Bundle(
'js/lib/jquery-1.8.1.min.js',
'js/lib/modernizr.js',
'js/responsive-ad.js',
filters='uglifyjs',
output='js/electris-header.min.js')
footer_js = Bundle(
'js/lib/underscore-min.js',
'js/lib/moment.min.js',
'js/lib/jquery.timeago.js',
'js/lib/jquery.touchclick.js',
'bootstrap/js/bootstrap.min.js',
'js/audio.js',
'js/app.js',
filters='uglifyjs',
output='js/electris-footer.min.js')
css = Bundle(
'bootstrap/css/bootstrap.min.css',
'bootstrap/css/bootstrap-responsive.min.css',
'css/template.css',
'css/app.css',
'css/sponsorship.css',
filters='yui_css',
示例9: Environment
# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import cache [as 别名]
import os
from werkzeug.wrappers import Request, Response
from werkzeug.wsgi import SharedDataMiddleware
from webassets import Environment, Bundle, ExternalAssets
environment = Environment('static', '/static')
environment.versions = 'hash'
manifest_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '.static-manifest'))
environment.manifest = 'file://%s' % manifest_path
environment.cache = False
environment.auto_build = True
environment.url = '//0.0.0.0:5001/static/'
#environment.debug = True
#less = Bundle('less/main.less', filters='less', output='gencss/less.css')
css = Bundle(
Bundle('less/main.less', filters='less', output='gencss/less.css'),
'css/main.css',
'css/sub/sub-main.css',
filters='cssrewrite',
output='gencss/css-merged.%(version)s.css'
)
external_solo = ExternalAssets('map.png')
external_main = ExternalAssets(
'css/img/*',