本文整理汇总了Python中bento.commands.options.OptionsContext.from_command方法的典型用法代码示例。如果您正苦于以下问题:Python OptionsContext.from_command方法的具体用法?Python OptionsContext.from_command怎么用?Python OptionsContext.from_command使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bento.commands.options.OptionsContext
的用法示例。
在下文中一共展示了OptionsContext.from_command方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_extra_source_registration
# 需要导入模块: from bento.commands.options import OptionsContext [as 别名]
# 或者: from bento.commands.options.OptionsContext import from_command [as 别名]
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)
示例2: test_simple_package
# 需要导入模块: from bento.commands.options import OptionsContext [as 别名]
# 或者: from bento.commands.options.OptionsContext import from_command [as 别名]
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)
示例3: register_options
# 需要导入模块: from bento.commands.options import OptionsContext [as 别名]
# 或者: from bento.commands.options.OptionsContext import from_command [as 别名]
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)
示例4: test_compiled_library
# 需要导入模块: from bento.commands.options import OptionsContext [as 别名]
# 或者: from bento.commands.options.OptionsContext import from_command [as 别名]
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")
示例5: test_template_filling
# 需要导入模块: from bento.commands.options import OptionsContext [as 别名]
# 或者: from bento.commands.options.OptionsContext import from_command [as 别名]
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)
示例6: test_simple_package
# 需要导入模块: from bento.commands.options import OptionsContext [as 别名]
# 或者: from bento.commands.options.OptionsContext import from_command [as 别名]
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)
示例7: test_extra_source_registration
# 需要导入模块: from bento.commands.options import OptionsContext [as 别名]
# 或者: from bento.commands.options.OptionsContext import from_command [as 别名]
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)
示例8: test_template_filling
# 需要导入模块: from bento.commands.options import OptionsContext [as 别名]
# 或者: from bento.commands.options.OptionsContext import from_command [as 别名]
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,))
示例9: _run_configure_and_build
# 需要导入模块: from bento.commands.options import OptionsContext [as 别名]
# 或者: from bento.commands.options.OptionsContext import from_command [as 别名]
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
示例10: prepare_options
# 需要导入模块: from bento.commands.options import OptionsContext [as 别名]
# 或者: from bento.commands.options.OptionsContext import from_command [as 别名]
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
示例11: test_simple_distutils
# 需要导入模块: from bento.commands.options import OptionsContext [as 别名]
# 或者: from bento.commands.options.OptionsContext import from_command [as 别名]
def test_simple_distutils(self):
top_node = self.top_node
create_fake_package_from_bento_info(top_node, BENTO_INFO_WITH_EXT)
conf, configure = prepare_configure(top_node, BENTO_INFO_WITH_EXT, DistutilsConfigureContext)
run_command_in_context(conf, configure)
build = BuildCommand()
opts = OptionsContext.from_command(build)
bld = DistutilsBuildContext(None, [], opts, conf.pkg, top_node)
run_command_in_context(bld, build)
示例12: _test_run
# 需要导入模块: from bento.commands.options import OptionsContext [as 别名]
# 或者: from bento.commands.options.OptionsContext import from_command [as 别名]
def _test_run(self, bento_info):
install_prefix = tempfile.mkdtemp()
try:
conf, configure, bld, build = self._run_configure_and_build(bento_info, install_prefix)
install = InstallCommand()
opts = OptionsContext.from_command(install)
inst = CmdContext(None, [], opts, conf.pkg, self.top_node)
install.run(inst)
finally:
shutil.rmtree(install_prefix)
示例13: _test_dry_run
# 需要导入模块: from bento.commands.options import OptionsContext [as 别名]
# 或者: from bento.commands.options.OptionsContext import from_command [as 别名]
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)
示例14: test_simple_yaku
# 需要导入模块: from bento.commands.options import OptionsContext [as 别名]
# 或者: from bento.commands.options.OptionsContext import from_command [as 别名]
def test_simple_yaku(self):
top_node = self.top_node
create_fake_package_from_bento_info(top_node, BENTO_INFO_WITH_EXT)
conf, configure = prepare_configure(top_node, BENTO_INFO_WITH_EXT, ConfigureYakuContext)
configure.run(conf)
conf.shutdown()
build = BuildCommand()
opts = OptionsContext.from_command(build)
bld = BuildYakuContext([], opts, conf.pkg, top_node)
build.run(bld)
示例15: _run_command
# 需要导入模块: from bento.commands.options import OptionsContext [as 别名]
# 或者: from bento.commands.options.OptionsContext import from_command [as 别名]
def _run_command(self):
setup_node = self.top_node.make_node("setup.py")
setup_node.safe_write("")
create_fake_package_from_bento_info(self.top_node, "")
package = PackageDescription.from_string("")
cmd = DetectTypeCommand()
opts = OptionsContext.from_command(cmd)
context = CmdContext(None, [], opts, package, self.run_node)
cmd.run(context)
cmd.finish(context)
context.finish()