本文整理汇总了Python中invoke.collection.Collection类的典型用法代码示例。如果您正苦于以下问题:Python Collection类的具体用法?Python Collection怎么用?Python Collection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Collection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup
def setup(self):
mod = load('explicit_root')
mod.ns.configure({'key': 'builtin', 'otherkey': 'yup'})
mod.ns.name = 'builtin_name'
self.unchanged = Collection.from_module(mod)
self.changed = Collection.from_module(
mod,
name='override_name',
config={'key': 'override'}
)
示例2: returns_unique_Collection_objects_for_same_input_module
def returns_unique_Collection_objects_for_same_input_module(self):
# Ignoring self.c for now, just in case it changes later.
# First, a module with no root NS
mod = load('integration')
c1 = Collection.from_module(mod)
c2 = Collection.from_module(mod)
assert c1 is not c2
# Now one *with* a root NS (which was previously buggy)
mod2 = load('explicit_root')
c3 = Collection.from_module(mod2)
c4 = Collection.from_module(mod2)
assert c3 is not c4
示例3: submodule_names_are_stripped_to_last_chunk
def submodule_names_are_stripped_to_last_chunk(self):
with support_path():
from package import module
c = Collection.from_module(module)
assert module.__name__ == 'package.module'
assert c.name == 'module'
assert 'mytask' in c # Sanity
示例4: name_docstring_default_and_tasks
def name_docstring_default_and_tasks(self):
expected = dict(
name="deploy",
help="How to deploy our code and configs.",
tasks=[
dict(
name="db",
help="Deploy to our database servers.",
aliases=["db-servers"],
),
dict(
name="everywhere",
help="Deploy to all targets.",
aliases=[],
),
dict(
name="web",
help="Update and bounce the webservers.",
aliases=[],
),
],
default="everywhere",
collections=[],
)
with support_path():
from tree import deploy
coll = Collection.from_module(deploy)
assert expected == coll.serialized()
示例5: honors_subcollection_default_tasks_on_subcollection_name
def honors_subcollection_default_tasks_on_subcollection_name(self):
sub = Collection.from_module(load('decorators'))
self.c.add_collection(sub)
# Sanity
assert self.c['decorators.biz'] is sub['biz']
# Real test
assert self.c['decorators'] is self.c['decorators.biz']
示例6: invalid_path
def invalid_path(self):
# This is really just testing Lexicon/dict behavior but w/e, good
# to be explicit, esp if we ever want this to become Exit or
# another custom exception. (For now most/all callers manually
# catch KeyError and raise Exit just to keep most Exit use high up
# in the stack...)
with raises(KeyError):
collection = Collection.from_module(load('tree'))
collection.subcollection_from_path('lol.whatever.man')
示例7: setup
def setup(self):
mod = load("explicit_root")
mod.ns.configure(
{
"key": "builtin",
"otherkey": "yup",
"subconfig": {"mykey": "myvalue"},
}
)
mod.ns.name = "builtin_name"
self.unchanged = Collection.from_module(mod)
self.changed = Collection.from_module(
mod,
name="override_name",
config={
"key": "override",
"subconfig": {"myotherkey": "myothervalue"},
},
)
示例8: is_valid_package
def is_valid_package(package_name):
"""
Checks if a package at site directory has tasks.
"""
try:
apackage = import_module('%s.tasks'%package_name)
except ImportError:
return False
tasks = Collection.from_module(apackage).task_names
if tasks == {}:
return False
return True
示例9: run_easypy_task
def run_easypy_task(argv):
"""
Run task in easypy.
"""
from easypy import tasks
tasks = Collection.from_module(tasks).task_names
if len(argv) == 1:
# the request is in the format $ py
# display available tasks in easypy
display_easypy_tasks()
else:
# the request is in the format $ py <task>
task = argv[1]
if not task in tasks.keys():
raise TaskNotAvailable(task)
cli.dispatch(prepare_args(argv))
示例10: transforms_are_applied_to_explicit_module_namespaces
def transforms_are_applied_to_explicit_module_namespaces(self):
# Symptom when bug present: Collection.to_contexts() dies
# because it iterates over .task_names (transformed) and then
# tries to use results to access __getitem__ (no auto
# transform...because in all other situations, task structure
# keys are already transformed; but this wasn't the case for
# from_module() with explicit 'ns' objects!)
namespace = self._nested_underscores()
class FakeModule(object):
__name__ = 'my_module'
ns = namespace
coll = Collection.from_module(
FakeModule(), auto_dash_names=False
)
# NOTE: underscores, not dashes
expected = {'my_task', 'inner_coll.inner_task'}
assert {x.name for x in coll.to_contexts()} == expected
示例11: honors_explicit_collections
def honors_explicit_collections(self):
coll = Collection.from_module(load("explicit_root"))
assert "top-level" in coll.tasks
assert "sub-level" in coll.collections
# The real key test
assert "sub-task" not in coll.tasks
示例12: name_docstring_default_tasks_and_collections
def name_docstring_default_tasks_and_collections(self):
docs = dict(
name="docs",
help="Tasks for managing Sphinx docs.",
tasks=[
dict(
name="all",
help="Build all doc formats.",
aliases=[],
),
dict(
name="html",
help="Build HTML output only.",
aliases=[],
),
dict(
name="pdf",
help="Build PDF output only.",
aliases=[],
),
],
default="all",
collections=[],
)
python = dict(
name="python",
help="PyPI/etc distribution artifacts.",
tasks=[
dict(
name="all",
help="Build all Python packages.",
aliases=[],
),
dict(
name="sdist",
help="Build classic style tar.gz.",
aliases=[],
),
dict(
name="wheel",
help="Build a wheel.",
aliases=[],
),
],
default="all",
collections=[],
)
expected = dict(
name="build",
help="Tasks for compiling static code and assets.",
tasks=[
dict(
name="all",
help="Build all necessary artifacts.",
aliases=["everything"],
),
dict(
name="c-ext",
help="Build our internal C extension.",
aliases=["ext"],
),
dict(
name="zap",
help="A silly way to clean.",
aliases=[],
),
],
default="all",
collections=[docs, python],
)
with support_path():
from tree import build
coll = Collection.from_module(build)
assert expected == coll.serialized()
示例13: top_level_path
def top_level_path(self):
collection = Collection.from_module(load("tree"))
build = collection.collections["build"]
assert collection.subcollection_from_path("build") is build
示例14: nested_path
def nested_path(self):
collection = Collection.from_module(load("tree"))
docs = collection.collections["build"].collections["docs"]
assert collection.subcollection_from_path("build.docs") is docs
示例15: setup
def setup(self):
self.c = Collection.from_module(load('explicit_root'))