本文整理汇总了Python中webassets.Environment.debug方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.debug方法的具体用法?Python Environment.debug怎么用?Python Environment.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webassets.Environment
的用法示例。
在下文中一共展示了Environment.debug方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _init_webassets
# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import debug [as 别名]
def _init_webassets(debug=False):
assets_env = Environment(directory=SITE_ASSET_DIR,
url=SITE_ASSET_URL_PREFIX,
cache=WEBASSETS_CACHE_DIR,
load_path=[SITE_ASSET_SRC_DIR])
assets_env.debug = debug
js = Bundle('js/*.js', filters='uglifyjs', output='js/app.js')
css = Bundle('sass/*.scss', filters='scss,cssmin', output='css/app.css')
assets_env.register('app_js', js)
assets_env.register('app_css', css)
cmd = CommandLineEnvironment(assets_env, log)
p = Process(target=lambda: cmd.watch())
def signal_handler(sig, frame):
try:
p.terminate()
except Exception:
pass
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
p.start()
return assets_env
示例2: _setup_env
# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import debug [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: webassets_init
# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import debug [as 别名]
def webassets_init():
global env
static_path = get_webassets_path()
public = config.get(u'ckan.base_public_folder')
public_folder = os.path.abspath(os.path.join(
os.path.dirname(__file__), u'..', public))
base_path = os.path.join(public_folder, u'base')
env = Environment()
env.directory = static_path
env.debug = config.get(u'debug', False)
env.url = u'/webassets/'
env.append_path(base_path, u'/base/')
logger.debug(u'Base path {0}'.format(base_path))
create_library(u'vendor', os.path.join(
base_path, u'vendor'))
create_library(u'base', os.path.join(base_path, u'javascript'))
create_library(u'datapreview', os.path.join(base_path, u'datapreview'))
create_library(u'css', os.path.join(base_path, u'css'))
示例4: _setup_env
# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import debug [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
示例5: register_assets
# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import debug [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
示例6: register_assets
# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import debug [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
示例7: get_webassets_env
# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import debug [as 别名]
def get_webassets_env(conf):
'''Get a preconfigured WebAssets environment'''
# Configure webassets
assets_environment = AssetsEnvironment(conf.get('static_files_dir', DEFAULT_STATIC), '/')
assets_environment.debug = conf.get('debug', False)
assets_environment.auto_build = conf.get('debug', False)
assets_environment.config['less_paths'] = (
'bower/bootstrap/less',
'bower/etalab-assets/less',
'bower/bootstrap-markdown/less',
)
# Load bundle from yaml file
loader = YAMLLoader(resource_stream(__name__, '../assets.yaml'))
bundles = loader.load_bundles()
for name, bundle in bundles.items():
assets_environment.register(name, bundle)
return assets_environment
示例8: _init_webassets
# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import debug [as 别名]
def _init_webassets(debug=False, generate=False):
assets_env = Environment(directory=SITE_ASSET_DIR,
url=SITE_ASSET_URL_PREFIX,
cache=WEBASSETS_CACHE_DIR,
load_path=[SITE_ASSET_SRC_DIR])
assets_env.debug = debug
js = Bundle('js/*.js', filters='uglifyjs', output='js/app.js')
css = Bundle('sass/*.scss', filters='scss,cssmin', output='css/app.css')
assets_env.register('app_js', js)
assets_env.register('app_css', css)
cmd = CommandLineEnvironment(assets_env, log)
if generate:
cmd.build()
return assets_env
Process(target=lambda: cmd.watch()).start()
return assets_env
示例9: Environment
# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import debug [as 别名]
#! /usr/bin/env python
#-*- coding: utf-8 -*-
from webassets import Environment, Bundle
environment = Environment('static', '')
environment.debug = True
css_map_bundle = Bundle(
'css/style.css',
'map/leaflet/leaflet.css',
'map/leaflet-sidebar/src/L.Control.Sidebar.css',
'map/leaflet-control-geocoder/Control.Geocoder.css',
'map/Osmose.Editor.css',
'map/style.css',
'map/Osmose.Menu.css',
filters='cssrewrite,cssmin', output='gen/map-%(version)s.css')
environment.register('css_map', css_map_bundle)
js_map_bundle = Bundle(
'js/jquery-1.7.2.js',
'js/jquery-ui-1.10.4.dialog.js',
'js/mustache.js',
'map/leaflet/leaflet-src.js',
'map/leaflet-plugins/control/Permalink.js',
'map/leaflet-plugins/control/Permalink.Layer.js',
'map/Permalink.Overlay.js',
'map/Permalink.Item.js',
'map/leaflet-plugins/layer/tile/Bing.js',
'map/layers.js',
'map/leaflet.active-layers.min.js',
示例10: Environment
# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import debug [as 别名]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import web
from webassets import Bundle
from webassets import Environment
env = Environment('./static', '/static')
env.debug = web.debug
## Register your budles here!
#env.register('base_css',
# Bundle("bootstrap/css/bootstrap.min.css",
# "bootstrap/css/bootstrap-responsive.min.css",
# "bootstrap-datepicker/css/datepicker.css",
# "bootstrap-fileupload/css/bootstrap-fileupload.min.css",
# "css/main.css"))
示例11: Bundle
# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import debug [as 别名]
output="public/js/common.js"
)
js_bottom = Bundle(
# Vendorized libraries loaded at the bottom of the page
"vendor/bower_components/x-editable/dist/bootstrap3-editable/js/bootstrap-editable.min.js",
"vendor/bower_components/jquery.tagsinput/jquery.tagsinput.min.js",
"vendor/jquery-blockui/jquery.blockui.js",
"vendor/bower_components/bootstrap.growl/bootstrap-growl.min.js",
# 'vendor/dropzone/dropzone.js',
# 'vendor/hgrid/hgrid.js',
'vendor/bower_components/jquery-autosize/jquery.autosize.min.js',
# Site-specific JS
Bundle(
'js/project.js',
'js/addons.js',
# 'js/dropzone-patch.js',
# 'js/rubeus.js'
),
filters='jsmin',
output='public/js/site.js'
)
logger.debug('Registering asset bundles')
env.register('js', js)
env.register('css', css)
env.register('js_bottom', js_bottom)
# Don't bundle in debug mode
env.debug = settings.DEBUG_MODE
示例12: Environment
# 需要导入模块: from webassets import Environment [as 别名]
# 或者: from webassets.Environment import debug [as 别名]
from os.path import join, exists, expandvars
import flask
import qrcode
import requests
from webassets_babel import BabelFilter
from webassets import Environment, Bundle
from webassets.exceptions import FilterError
from webassets.filter import register_filter
logging.basicConfig(level=logging.DEBUG)
app = flask.Flask(__name__)
my_env = Environment(directory='static/', url='static/')
my_env.debug = 'HEROKU' not in os.environ
if platform.system() == 'Windows':
npm = expandvars('%AppData%/npm')
my_env.config.setdefault('BABEL_BIN', join(npm, 'babel.cmd'))
PRESET_PATH = join(npm, "node_modules/RedQR/")
else:
PRESET_PATH = "/app/"
PRESET_PATH = join(PRESET_PATH, "node_modules")
assert exists(PRESET_PATH)
PRESETS = ['react', 'es2015']
PRESETS = ','.join(
join(PRESET_PATH, 'babel-preset-{}'.format(name))
for name in PRESETS
)