我有一个目录,并且想要像Ant一样排除一些文件,对于webassets,这可能吗?
或者捆绑包可以接受列表或元组,这似乎不是这样的?
发布于 2012-11-16 13:34:36
(来自the source at github的) Bundle构造函数签名如下:
def __init__(self, *contents, **options):这意味着可以将内容指定为一系列位置参数,如the example in the documentation中所示
Bundle('common/inheritance.js', 'portal/js/common.js',
'portal/js/plot.js', 'portal/js/ticker.js',
filters='jsmin',
output='gen/packed.js')但这也意味着您可以使用Python的功能unpack argument lists。从该页面:
当参数已经在列表或元组中,但需要为需要单独位置参数的函数调用解包时,就会发生相反的情况。例如,内置的range()函数需要单独的start和stop参数。如果它们不可单独使用,请编写带有*-运算符的函数调用,以将参数从列表或元组中解包出来
所以你可以很容易的把上面的例子写成:
files = ['common/inheritance.js', 'portal/js/common.js',
'portal/js/plot.js', 'portal/js/ticker.js']
Bundle(*files, filters='jsmin', output='gen/packed.js')当然,在捆绑之前,您可以过滤/切片/骰子列表到您的核心内容。
https://stackoverflow.com/questions/13406301
复制相似问题