本文整理汇总了Python中bento.commands.options.OptionsContext类的典型用法代码示例。如果您正苦于以下问题:Python OptionsContext类的具体用法?Python OptionsContext怎么用?Python OptionsContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OptionsContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_simple
def test_simple(self):
help = HelpCommand()
options = OptionsContext()
for option in HelpCommand.common_options:
options.add_option(option)
context = CmdContext([], options, None, None)
help.run(context)
示例2: test_command
def test_command(self):
help = HelpCommand()
options = OptionsContext()
for option in HelpCommand.common_options:
options.add_option(option)
context = CmdContext(["configure"], options, None, None)
context.options_registry = self.options_registry
help.run(context)
示例3: test_simple
def test_simple(self):
help = HelpCommand()
options = OptionsContext()
for option in HelpCommand.common_options:
options.add_option(option)
global_context = GlobalContext(self.registry, None, None, None)
context = HelpContext(global_context, [], options, None, None)
help.run(context)
示例4: test_simple
def test_simple(self):
help = HelpCommand()
options = OptionsContext()
for option in HelpCommand.common_options:
options.add_option(option)
global_context = GlobalContext(None,
commands_registry=self.registry,
options_registry=self.options_registry)
pkg = PackageDescription()
context = HelpContext(global_context, [], options, pkg, self.run_node)
run_command_in_context(context, help)
示例5: test_extra_source_registration
def test_extra_source_registration(self):
bento_info = """\
Name: foo
Version: 1.0
Library:
Modules: fubar
"""
archive_list = [op.join("foo-1.0", f) for f in ["fubar.py", "yeah.info"]]
extra_node = self.top_node.make_node("yeah.info")
extra_node.write("")
create_fake_package_from_bento_info(self.top_node, bento_info)
package = PackageDescription.from_string(bento_info)
sdist = SdistCommand()
opts = OptionsContext.from_command(sdist)
cmd_argv = ["--output-file=foo.zip", "--format=zip"]
context = SdistContext(None, cmd_argv, opts, package, self.run_node)
context.register_source_node(self.top_node.find_node("yeah.info"))
sdist.run(context)
sdist.shutdown(context)
context.shutdown()
archive = self.run_node.find_node(op.join("dist", "foo.zip"))
z = zipfile.ZipFile(archive.abspath(), "r")
for f in archive_list:
if not f in z.namelist():
self.failUnless(op.join("foo-1.0", f) in files)
示例6: test_simple_package
def test_simple_package(self):
bento_info = """\
Name: foo
Version: 1.0
ExtraSourceFiles: yeah.info
Library:
Packages: foo, foo.bar
Modules: fubar
"""
archive_list = [op.join("foo-1.0", f) for f in ["yeah.info",
op.join("foo", "__init__.py"),
op.join("foo", "bar", "__init__.py"),
"fubar.py"]]
create_fake_package_from_bento_info(self.top_node, bento_info)
package = PackageDescription.from_string(bento_info)
sdist = SdistCommand()
opts = OptionsContext.from_command(sdist)
cmd_argv = ["--output-file=foo.zip", "--format=zip"]
context = SdistContext(None, cmd_argv, opts, package, self.run_node)
sdist.run(context)
sdist.shutdown(context)
context.shutdown()
archive = self.run_node.find_node(op.join("dist", "foo.zip"))
z = zipfile.ZipFile(archive.abspath(), "r")
for f in archive_list:
if not f in z.namelist():
self.failUnless(op.join("foo-1.0", f) in files)
示例7: test_template_filling
def test_template_filling(self):
bento_info = """\
Name: foo
Version: 1.0
MetaTemplateFile: release.py.in
Library:
Modules: fubar
"""
archive_list = [op.join("foo-1.0", f) for f in ["fubar.py", "release.py.in", "release.py"]]
template = self.top_node.make_node("release.py.in")
template.write("""\
NAME = $NAME
VERSION = $VERSION
""")
create_fake_package_from_bento_info(self.top_node, bento_info)
package = PackageDescription.from_string(bento_info)
sdist = SdistCommand()
opts = OptionsContext.from_command(sdist)
cmd_argv = ["--output-file=foo.zip", "--format=zip"]
context = SdistContext(None, cmd_argv, opts, package, self.run_node)
sdist.run(context)
sdist.shutdown(context)
context.shutdown()
archive = self.run_node.find_node(op.join("dist", "foo.zip"))
z = zipfile.ZipFile(archive.abspath(), "r")
for f in archive_list:
if not f in z.namelist():
self.fail("File %s not found in archive" % (f,))
示例8: register_options
def register_options(global_context, cmd_name):
"""Register options for the given command."""
cmd = global_context.retrieve_command(cmd_name)
context = OptionsContext.from_command(cmd)
if not global_context.is_options_context_registered(cmd_name):
global_context.register_options_context(cmd_name, context)
示例9: test_template_filling
def test_template_filling(self):
bento_info = """\
Name: foo
Version: 1.0
MetaTemplateFile: release.py.in
Library:
Modules: fubar
"""
archive_list = [op.join("foo-1.0", f) for f in ["fubar.py", "release.py.in", "release.py"]]
template = self.top_node.make_node("release.py.in")
template.write("""\
NAME = $NAME
VERSION = $VERSION
""")
create_fake_package_from_bento_info(self.top_node, bento_info)
package = PackageDescription.from_string(bento_info)
sdist = SdistCommand()
opts = OptionsContext.from_command(sdist)
cmd_argv = ["--output-file=foo.zip", "--format=zip"]
context = SdistContext(None, cmd_argv, opts, package, self.run_node)
run_command_in_context(context, sdist)
self._assert_archive_equality(op.join("dist", "foo.zip"), archive_list)
示例10: test_compiled_library
def test_compiled_library(self):
from bento.backends.distutils_backend import DistutilsBuildContext
r_full_name = "lib/_foo"
bento_info = """\
Name: foo
Library:
CompiledLibrary: lib/_foo
Sources: foo.c
"""
package = PackageDescription.from_string(bento_info)
create_fake_package_from_bento_info(self.top_node, bento_info)
options = OptionsContext.from_command(BuildCommand())
context = DistutilsBuildContext(None, [], options, package, self.run_node)
context.pre_recurse(self.top_node)
try:
def builder(a):
self.assertEqual(a.name, r_full_name)
builder.is_called = True
builder.is_called = False
context.register_compiled_library_builder("lib/_foo", builder)
finally:
context.post_recurse()
context.compile()
self.assertTrue(builder.is_called, "registered builder not called")
示例11: test_simple_package
def test_simple_package(self):
bento_info = """\
Name: foo
Version: 1.0
ExtraSourceFiles: yeah.info
Library:
Packages: foo, foo.bar
Modules: fubar
"""
archive_list = [op.join("foo-1.0", f) for f in ["yeah.info",
op.join("foo", "__init__.py"),
op.join("foo", "bar", "__init__.py"),
"fubar.py"]]
create_fake_package_from_bento_info(self.top_node, bento_info)
package = PackageDescription.from_string(bento_info)
sdist = SdistCommand()
opts = OptionsContext.from_command(sdist)
cmd_argv = ["--output-file=foo.zip", "--format=zip"]
context = SdistContext(None, cmd_argv, opts, package, self.run_node)
run_command_in_context(context, sdist)
self._assert_archive_equality(op.join("dist", "foo.zip"), archive_list)
示例12: test_extra_source_registration
def test_extra_source_registration(self):
bento_info = """\
Name: foo
Version: 1.0
Library:
Modules: fubar
"""
archive_list = [op.join("foo-1.0", f) for f in ["fubar.py", "yeah.info"]]
extra_node = self.top_node.make_node("yeah.info")
extra_node.write("")
create_fake_package_from_bento_info(self.top_node, bento_info)
package = PackageDescription.from_string(bento_info)
sdist = SdistCommand()
opts = OptionsContext.from_command(sdist)
cmd_argv = ["--output-file=foo.zip", "--format=zip"]
context = SdistContext(None, cmd_argv, opts, package, self.run_node)
context.register_source_node(self.top_node.find_node("yeah.info"))
run_command_in_context(context, sdist)
self._assert_archive_equality(op.join("dist", "foo.zip"), archive_list)
示例13: _run_configure_and_build
def _run_configure_and_build(self, bento_info, install_prefix):
top_node = self.top_node
create_fake_package_from_bento_info(top_node, bento_info)
context = GlobalContext(None)
options = PackageOptions.from_string(bento_info)
context.register_package_options(options)
cmd_argv = ["--prefix=%s" % install_prefix, "--exec-prefix=%s" % install_prefix]
conf, configure = prepare_configure(top_node, bento_info, ConfigureYakuContext, cmd_argv)
context.register_command("configure", configure)
options_context = OptionsContext.from_command(configure)
if not context.is_options_context_registered("configure"):
context.register_options_context("configure", options_context)
context.save_command_argv("configure", cmd_argv)
run_command_in_context(conf, configure)
bld, build = prepare_build(top_node, bento_info)
run_command_in_context(bld, build)
return context, conf, configure, bld, build
示例14: prepare_options
def prepare_options(cmd_name, cmd, context_klass):
opts = OptionsContext.from_command(cmd)
g_context = FakeGlobalContext()
g_context._cmd_opts[cmd_name] = opts
# FIXME: the way new options are registered for custom contexts sucks:
# there should be a context class independent way to do it
if context_klass.__name__ == "BuildWafContext":
from bento.commands.extras.waf import register_options
register_options(g_context)
return opts
示例15: _test_dry_run
def _test_dry_run(self, bento_info):
install_prefix = tempfile.mkdtemp()
try:
context, conf, configure, bld, build = self._run_configure_and_build(bento_info, install_prefix)
install = InstallCommand()
opts = OptionsContext.from_command(install)
inst = ContextWithBuildDirectory(context, ["--list-files"], opts, conf.pkg, self.top_node)
run_command_in_context(inst, install)
finally:
shutil.rmtree(install_prefix)