本文整理汇总了Python中webassets.bundle.get_all_bundle_files函数的典型用法代码示例。如果您正苦于以下问题:Python get_all_bundle_files函数的具体用法?Python get_all_bundle_files怎么用?Python get_all_bundle_files使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_all_bundle_files函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_directory_custom
def test_directory_custom(self):
"""A custom root directory is configured."""
self.env.load_path = [self.tempdir]
self.create_files(['foo', 'module/bar'])
print get_all_bundle_files(Bundle('foo'), self.env)
assert get_all_bundle_files(Bundle('foo'), self.env) == [self.path('foo')]
# We do not recognize references to modules.
assert get_all_bundle_files(Bundle('module/bar'), self.env) == [self.path('module/bar')]
示例2: test_custom_load_path
def test_custom_load_path(self):
"""A custom load_path is configured - this will affect how
we deal with source files.
"""
self.env.append_path(self.tempdir, "/custom/")
self.create_files(["foo", "module/bar"])
assert get_all_bundle_files(Bundle("foo"), self.env) == [self.path("foo")]
# We do not recognize references to modules.
assert get_all_bundle_files(Bundle("module/bar"), self.env) == [self.path("module/bar")]
assert Bundle("foo").urls(self.env) == ["/custom/foo"]
assert Bundle("module/bar").urls(self.env) == ["/custom/module/bar"]
示例3: test_duplicate_nested_bundles_removed
def test_duplicate_nested_bundles_removed(self):
nested = self.mkbundle('*.js')
bundle = self.mkbundle(nested, nested)
all_files = get_all_bundle_files(bundle)
all_files.sort()
assert all_files == [self.path('foo.js'), self.path('hubris.js'),
self.path('whimsy.js')]
示例4: test_globbed_load_path
def test_globbed_load_path(self):
"""The load path itself can contain globs."""
self.env.append_path(self.path('*'))
self.create_files({'a/foo': 'a', 'b/foo': 'b', 'dir/bar': 'dir'})
# With a non-globbed reference
bundle = self.mkbundle('foo', output='out')
assert set(get_all_bundle_files(bundle)) == set([
self.path('a/foo'), self.path('b/foo')
])
# With a globbed reference
bundle = self.mkbundle('???', output='out')
assert set(get_all_bundle_files(bundle)) == set([
self.path('a/foo'), self.path('b/foo'), self.path('dir/bar')
])
示例5: test_custom_load_path
def test_custom_load_path(self):
"""A custom load_path is configured - this will affect how
we deal with source files.
"""
self.env.append_path(self.tempdir, '/custom/')
self.create_files(['foo', 'module/bar'])
assert get_all_bundle_files(Bundle('foo'), self.env) == [self.path('foo')]
# We do not recognize references to modules.
assert get_all_bundle_files(Bundle('module/bar'), self.env) == [self.path('module/bar')]
assert Bundle('foo').urls(self.env) == ['/custom/foo']
assert Bundle('module/bar').urls(self.env) == ['/custom/module/bar']
# [Regression] With a load path configured, generating output
# urls still works, and it still uses the flask system.
self.env.debug = False
self.env.url_expire = False
assert Bundle('foo', output='out').urls(self.env) == ['/app_static/out']
示例6: test_directory_auto
def test_directory_auto(self):
"""Test how we handle file references if no root 'directory' is
configured manually.
"""
assert not 'directory' in self.env.config
root = self.app.root_path
assert get_all_bundle_files(Bundle('foo'), self.env) == [root + '/static/foo']
# Modules prefixes in paths are handled specifically.
assert get_all_bundle_files(Bundle('module/bar'), self.env) == [root + '/test_module/static/bar']
# Prefixes that aren't valid module names are just considered
# subfolders of the main app.
assert get_all_bundle_files(Bundle('nomodule/bar'), self.env) == [root + '/static/nomodule/bar']
# In case the name of a app-level subfolder conflicts with a
# module name, you can always use this hack:
assert get_all_bundle_files(Bundle('./module/bar'), self.env) == [root + '/static/module/bar']
# Custom static folder
self.app.static_folder = '/'
assert get_all_bundle_files(Bundle('foo'), self.env) == ['/foo']
示例7: test_directory_auto
def test_directory_auto(self):
"""Test how we resolve file references through the Flask static
system by default (if no custom 'env.directory' etc. values
have been configured manually).
"""
assert not "directory" in self.env.config
root = self.app.root_path
assert get_all_bundle_files(Bundle("foo"), self.env) == [root + "/static/foo"]
# Modules prefixes in paths are handled specifically.
assert get_all_bundle_files(Bundle("module/bar"), self.env) == [root + "/test_module/static/bar"]
# Prefixes that aren't valid module names are just considered
# subfolders of the main app.
assert get_all_bundle_files(Bundle("nomodule/bar"), self.env) == [root + "/static/nomodule/bar"]
# In case the name of a app-level subfolder conflicts with a
# module name, you can always use this hack:
assert get_all_bundle_files(Bundle("./module/bar"), self.env) == [root + "/static/module/bar"]
# Custom static folder
self.app.static_folder = "/"
assert get_all_bundle_files(Bundle("foo"), self.env) == ["/foo"]
示例8: test
def test(self):
"""Make sure the "url" and "directory" config values are
read from the Flask app.
"""
with self.app.test_request_context():
assert not "url" in self.env.config
assert Bundle("foo").urls(self.env) == ["/initapp_static/foo"]
assert not "directory" in self.env.config
root = self.app.root_path
assert get_all_bundle_files(Bundle("foo"), self.env) == [root + "/static/foo"]
示例9: test
def test(self):
"""Make sure the "url" and "directory" config values are
read from the Flask app.
"""
with self.app.test_request_context():
assert not 'url' in self.env.config
assert Bundle('foo', env=self.env).urls() == ['/initapp_static/foo']
assert not 'directory' in self.env.config
root = self.app.root_path
assert get_all_bundle_files(Bundle('foo'), self.env) == [root + '/static/foo']
示例10: find_recent_most_timestamp
def find_recent_most_timestamp(cls, bundle, env):
# Recurse through the bundle hierarchy. Check the timestamp of all
# the bundle source files, as well as any additional
# dependencies that we are supposed to watch.
most_recent = None
for filename in get_all_bundle_files(bundle, env):
if is_url(filename):
continue
timestamp = cls.get_timestamp(filename)
if most_recent is None or timestamp > most_recent:
most_recent = timestamp
return most_recent
示例11: test_globbing
def test_globbing(self):
"""When used with globbing."""
self.env.append_path(self.path('a'))
self.env.append_path(self.path('b'))
self.create_files({
'a/foo': 'a', 'b/foo': 'b', 'b/bar': '42'})
# Returns all files, even duplicate relative filenames in
# multiple load paths (foo in this case).
bundle = self.mkbundle('*', output='out')
assert set(get_all_bundle_files(bundle)) == set([
self.path('a/foo'), self.path('b/foo'), self.path('b/bar')
])
示例12: check_for_changes
def check_for_changes():
changed_bundles = []
for bundle in self.environment:
for filename in get_all_bundle_files(bundle):
stat = os.stat(filename)
mtime = stat.st_mtime
if _win:
mtime -= stat.st_ctime
if _mtimes.get(filename, mtime) != mtime:
changed_bundles.append(bundle)
_mtimes[filename] = mtime
break
_mtimes[filename] = mtime
return changed_bundles
示例13: check_for_changes
def check_for_changes():
# Do not update original mtimes dict right away, so that we detect
# all bundle changes if a file is in multiple bundles.
_new_mtimes = _mtimes.copy()
changed_bundles = []
for bundle in self.environment:
for filename in get_all_bundle_files(bundle):
stat = os.stat(filename)
mtime = stat.st_mtime
if _win:
mtime -= stat.st_ctime
if _mtimes.get(filename, mtime) != mtime:
changed_bundles.append(bundle)
_new_mtimes[filename] = mtime
break
_new_mtimes[filename] = mtime
_mtimes.update(_new_mtimes)
return changed_bundles
示例14: test_directory_custom
def test_directory_custom(self):
"""A custom root directory is configured."""
self.env.directory = '/tmp'
assert get_all_bundle_files(Bundle('foo'), self.env) == ['/tmp/foo']
# We do not recognize references to modules.
assert get_all_bundle_files(Bundle('module/bar'), self.env) == ['/tmp/module/bar']
示例15: test_do_not_glob_directories
def test_do_not_glob_directories(self):
"""[Regression] Glob should be smart enough not to pick
up directories."""
self.create_directories('subdir')
assert not [s for s in get_all_bundle_files(self.mkbundle('*')) if 'subdir' in s]