当前位置: 首页>>代码示例>>Python>>正文


Python CommandLineEnvironment.invoke方法代码示例

本文整理汇总了Python中webassets.script.CommandLineEnvironment.invoke方法的典型用法代码示例。如果您正苦于以下问题:Python CommandLineEnvironment.invoke方法的具体用法?Python CommandLineEnvironment.invoke怎么用?Python CommandLineEnvironment.invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在webassets.script.CommandLineEnvironment的用法示例。


在下文中一共展示了CommandLineEnvironment.invoke方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle

# 需要导入模块: from webassets.script import CommandLineEnvironment [as 别名]
# 或者: from webassets.script.CommandLineEnvironment import invoke [as 别名]
    def handle(self, *args, **options):
        valid_commands = CommandLineEnvironment.Commands
        if len(args) > 1:
            raise CommandError('Invalid number of subcommands passed: %s' %
                ", ".join(args))
        elif len(args) == 0:
            raise CommandError('You need to specify a subcommand: %s' %
                               ', '.join(valid_commands))

        # Create log
        log = logging.getLogger('django-assets')
        log.setLevel({0: logging.WARNING, 1: logging.INFO, 2: logging.DEBUG}[int(options.get('verbosity', 1))])
        log.addHandler(logging.StreamHandler())

        # If the user requested it, search for bundles defined in templates
        if options.get('parse_templates'):
            log.info('Searching templates...')
            # Note that we exclude container bundles. By their very nature,
            # they are guaranteed to have been created by solely referencing
            # other bundles which are already registered.
            get_env().add(*[b for b in self.load_from_templates()
                            if not b.is_container])

        if len(get_env()) == 0:
            raise CommandError('No asset bundles were found. '
                'If you are defining assets directly within your '
                'templates, you want to use the --parse-templates '
                'option.')

        # Execute the requested subcommand
        cmd = CommandLineEnvironment(get_env(), log)
        try:
            cmd.invoke(args[0])
        except AssetCommandError, e:
            raise CommandError(e)
开发者ID:lyschoening,项目名称:webassets,代码行数:37,代码来源:assets.py

示例2: build

# 需要导入模块: from webassets.script import CommandLineEnvironment [as 别名]
# 或者: from webassets.script.CommandLineEnvironment import invoke [as 别名]
    def build(self):
        logger = getLogger('webassets')
        logger.addHandler(StreamHandler())
        logger.setLevel(DEBUG)

        cli_environment = CommandLineEnvironment(self.env, logger)
        cli_environment.invoke("build", args={})
开发者ID:rembish,项目名称:rembish-org,代码行数:9,代码来源:assets_ext.py

示例3: handle

# 需要导入模块: from webassets.script import CommandLineEnvironment [as 别名]
# 或者: from webassets.script.CommandLineEnvironment import invoke [as 别名]
 def handle(self, app, **kwargs):
     assets = Environment(app)
     assets.url = app.static_url_path# = os.path.join(_appdir, 'static')
     assets.register('all_css', app.bundles['all_css_min'])
     assets.register('all_js', app.bundles['all_js_min'])
     log = logging.getLogger('webassets')
     log.addHandler(logging.StreamHandler())
     log.setLevel(logging.DEBUG)
     cmdenv = CommandLineEnvironment(assets, log)
     cmdenv.invoke('build', kwargs)
开发者ID:gloaec,项目名称:bamboo,代码行数:12,代码来源:assets.py

示例4: rebuild_assets

# 需要导入模块: from webassets.script import CommandLineEnvironment [as 别名]
# 或者: from webassets.script.CommandLineEnvironment import invoke [as 别名]
def rebuild_assets(config):
    config = config.copy()
    config['assets.debug'] = True
    assets = make_assets(config)
    assets_dir = assets.env.directory
    # Remove existing assets
    for name, bundle in assets.env._named_bundles.items():
        path = os.path.join(assets_dir, bundle.output) % {'version': '*'}
        for p in glob.iglob(path):
            os.unlink(p)
    cmdenv = CommandLineEnvironment(assets.env, logging.getLogger('assets'))
    cmdenv.invoke('build', {})
开发者ID:Outernet-Project,项目名称:broadcast-portal,代码行数:14,代码来源:static.py

示例5: action

# 需要导入模块: from webassets.script import CommandLineEnvironment [as 别名]
# 或者: from webassets.script.CommandLineEnvironment import invoke [as 别名]
    def action(rebuild=False, watch=False, clean=False, quiet=('q', False),
               verbose=('v', False)):
        if len(filter(bool, [rebuild, watch, clean])) != 1:
            print "Error: exactly one of --rebuild, --watch or --clean must be given"
            return 1

        if rebuild:
            command = 'rebuild'
        elif watch:
            command = 'watch'
        elif clean:
            command = 'clean'

        log.setLevel(logging.DEBUG if verbose else (logging.WARNING if quiet else logging.INFO))

        cmdenv = CommandLineEnvironment(environment, log)
        if loaders:
            log.info('Finding bundles...')
            for loader in loaders:
                environment.add(*[b for b in loader.load_bundles() if not b.is_container])

        cmdenv.invoke(command)
开发者ID:lyschoening,项目名称:webassets,代码行数:24,代码来源:werkzeug.py

示例6: PythonLoader

# 需要导入模块: from webassets.script import CommandLineEnvironment [as 别名]
# 或者: from webassets.script.CommandLineEnvironment import invoke [as 别名]
log.setLevel(logging.__dict__[args.loglevel])

loader = PythonLoader('webassets_config')
assets_env = loader.load_environment()
assets_env.debug = args.debug

cmdenv = CommandLineEnvironment(assets_env, log)
cmdenv.build()

if args.debug:
    print("The following files are produced by assets pipeline:")
    print(assets_env['js'].urls())
    print(assets_env['css'].urls())

if args.command != 'build':
    cmdenv.invoke(args.command, {})

if args.reference:
    index = open(args.reference_tmpl, 'r')
    index_contents = index.read()
    index.close()

    js_prepped = ['<link rel="stylesheet" href="%s" type="text/css" />' % url for url in assets_env['css'].urls()]
    css_prepped = ['<script src="%s" type="text/javascript"></script>' % url for url in assets_env['js'].urls()]
    index_contents = index_contents\
        .replace('<!--JS_ASSETS-->', "\n".join(css_prepped))\
        .replace('<!--CSS_ASSETS-->', "\n".join(js_prepped))

    patched = open(args.reference_output ,'w+')
    patched.write(index_contents)
    patched.close()
开发者ID:synchrone,项目名称:sandstorm-radicale,代码行数:33,代码来源:assets.py


注:本文中的webassets.script.CommandLineEnvironment.invoke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。