本文整理汇总了Python中pants.option.options.Options.create方法的典型用法代码示例。如果您正苦于以下问题:Python Options.create方法的具体用法?Python Options.create怎么用?Python Options.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pants.option.options.Options
的用法示例。
在下文中一共展示了Options.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: bootstrap_options_from_config
# 需要导入模块: from pants.option.options import Options [as 别名]
# 或者: from pants.option.options.Options import create [as 别名]
def bootstrap_options_from_config(config):
bootstrap_options = Options.create(env=self._env, config=config,
known_scope_infos=[GlobalOptionsRegistrar.get_scope_info()], args=bargs)
def register_global(*args, **kwargs):
bootstrap_options.register(GLOBAL_SCOPE, *args, **kwargs)
GlobalOptionsRegistrar.register_bootstrap_options(register_global)
return bootstrap_options
示例2: test_env_type_int
# 需要导入模块: from pants.option.options import Options [as 别名]
# 或者: from pants.option.options.Options import create [as 别名]
def test_env_type_int(self):
options = Options.create(env={'PANTS_FOO_BAR': "['123','456']"},
config=self._create_config({}),
known_scope_infos=OptionsTest._known_scope_infos,
args=shlex.split('./pants'),
option_tracker=OptionTracker())
options.register(GLOBAL_SCOPE, '--foo-bar', type=list, member_type=int)
self.assertEqual([123, 456], options.for_global_scope().foo_bar)
options = Options.create(env={'PANTS_FOO_BAR': '123'},
config=self._create_config({}),
known_scope_infos=OptionsTest._known_scope_infos,
args=shlex.split('./pants'),
option_tracker=OptionTracker())
options.register(GLOBAL_SCOPE, '--foo-bar', type=int)
self.assertEqual(123, options.for_global_scope().foo_bar)
示例3: test_double_registration
# 需要导入模块: from pants.option.options import Options [as 别名]
# 或者: from pants.option.options.Options import create [as 别名]
def test_double_registration(self):
options = Options.create(env={},
config=self._create_config({}),
known_scope_infos=OptionsTest._known_scope_infos,
args=shlex.split('./pants'),
option_tracker=OptionTracker())
options.register(GLOBAL_SCOPE, '--foo-bar')
self.assertRaises(OptionAlreadyRegistered, lambda: options.register(GLOBAL_SCOPE, '--foo-bar'))
示例4: test_deprecated_option_past_removal
# 需要导入模块: from pants.option.options import Options [as 别名]
# 或者: from pants.option.options.Options import create [as 别名]
def test_deprecated_option_past_removal(self):
with self.assertRaises(PastRemovalVersionError):
options = Options.create(env={},
config=self._create_config({}),
known_scope_infos=OptionsTest._known_scope_infos,
args="./pants")
options.register(GLOBAL_SCOPE, '--too-old-option', deprecated_version='0.0.24',
deprecated_hint='The semver for this option has already passed.')
示例5: _parse
# 需要导入模块: from pants.option.options import Options [as 别名]
# 或者: from pants.option.options.Options import create [as 别名]
def _parse(self, args_str, env=None, config=None, bootstrap_option_values=None):
args = shlex.split(str(args_str))
options = Options.create(env=env or {},
config=self._create_config(config or {}),
known_scope_infos=OptionsTest._known_scope_infos,
args=args,
bootstrap_option_values=bootstrap_option_values)
self._register(options)
return options
示例6: _parse_type_int
# 需要导入模块: from pants.option.options import Options [as 别名]
# 或者: from pants.option.options.Options import create [as 别名]
def _parse_type_int(self, args_str, env=None, config=None, bootstrap_option_values=None,
action=None):
args = shlex.split(str(args_str))
options = Options.create(env=env or {},
config=self._create_config(config or {}),
known_scope_infos=OptionsTest._known_scope_infos,
args=args,
bootstrap_option_values=bootstrap_option_values)
options.register(GLOBAL_SCOPE, '--config-override', action=action, type=int)
return options
示例7: test_shadowing
# 需要导入模块: from pants.option.options import Options [as 别名]
# 或者: from pants.option.options.Options import create [as 别名]
def test_shadowing(self):
options = Options.create(
env={},
config=self._create_config({}),
known_scope_infos=[task("foo")],
args="./pants",
option_tracker=OptionTracker(),
)
options.register("", "--bar")
with self.assertRaises(RegistrationError):
options.register("foo", "--bar")
示例8: parse_bootstrap_options
# 需要导入模块: from pants.option.options import Options [as 别名]
# 或者: from pants.option.options.Options import create [as 别名]
def parse_bootstrap_options(env, args, config):
bootstrap_options = Options.create(
env=env,
config=config,
known_scope_infos=[GlobalOptionsRegistrar.get_scope_info()],
args=args,
)
def register_global(*args, **kwargs):
## Only use of Options.register?
bootstrap_options.register(GLOBAL_SCOPE, *args, **kwargs)
GlobalOptionsRegistrar.register_bootstrap_options(register_global)
return bootstrap_options
示例9: test_no_recursive_subsystem_options
# 需要导入模块: from pants.option.options import Options [as 别名]
# 或者: from pants.option.options.Options import create [as 别名]
def test_no_recursive_subsystem_options(self):
options = Options.create(env={},
config=self._create_config({}),
known_scope_infos=[subsystem('foo')],
args='./pants',
option_tracker=OptionTracker())
# All subsystem options are implicitly recursive (a subscope of subsystem scope represents
# a separate instance of the subsystem, so it needs all the options).
# We disallow explicit specification of recursive (even if set to True), to avoid confusion.
with self.assertRaises(RecursiveSubsystemOption):
options.register('foo', '--bar', recursive=False)
options.for_scope('foo')
with self.assertRaises(RecursiveSubsystemOption):
options.register('foo', '--baz', recursive=True)
options.for_scope('foo')
示例10: _full_options
# 需要导入模块: from pants.option.options import Options [as 别名]
# 或者: from pants.option.options.Options import create [as 别名]
def _full_options(self, known_scope_infos):
bootstrap_option_values = self.get_bootstrap_options().for_global_scope()
options = Options.create(self.env,
self.config,
known_scope_infos,
args=self.args,
bootstrap_option_values=bootstrap_option_values)
distinct_optionable_classes = set()
for ksi in sorted(known_scope_infos, key=lambda si: si.scope):
if not ksi.optionable_cls or ksi.optionable_cls in distinct_optionable_classes:
continue
distinct_optionable_classes.add(ksi.optionable_cls)
ksi.optionable_cls.register_options_on_scope(options)
return options
示例11: test_shadowing
# 需要导入模块: from pants.option.options import Options [as 别名]
# 或者: from pants.option.options.Options import create [as 别名]
def test_shadowing(self):
options = Options.create(env={},
config=self._create_config({}),
known_scope_infos=[task('bar'), intermediate('foo'), task('foo.bar')],
args='./pants',
option_tracker=OptionTracker())
options.register('', '--opt1')
options.register('foo', '-o', '--opt2')
with self.assertRaises(Shadowing):
options.register('bar', '--opt1')
with self.assertRaises(Shadowing):
options.register('foo.bar', '--opt1')
with self.assertRaises(Shadowing):
options.register('foo.bar', '--opt2')
with self.assertRaises(Shadowing):
options.register('foo.bar', '--opt1', '--opt3')
with self.assertRaises(Shadowing):
options.register('foo.bar', '--opt3', '--opt2')
示例12: get_full_options
# 需要导入模块: from pants.option.options import Options [as 别名]
# 或者: from pants.option.options.Options import create [as 别名]
def get_full_options(self, known_scope_infos):
"""Get the full Options instance bootstrapped by this object for the given known scopes.
:param known_scope_infos: ScopeInfos for all scopes that may be encountered.
:returns: A bootrapped Options instance that also carries options for all the supplied known
scopes.
:rtype: :class:`Options`
"""
key = frozenset(sorted(known_scope_infos))
if key not in self._full_options:
# Note: Don't inline this into the Options() call, as this populates
# self._post_bootstrap_config, which is another argument to that call.
bootstrap_option_values = self.get_bootstrap_options().for_global_scope()
self._full_options[key] = Options.create(self._env,
self._post_bootstrap_config,
known_scope_infos,
args=self._args,
bootstrap_option_values=bootstrap_option_values)
return self._full_options[key]
示例13: test_option_tracker_required
# 需要导入模块: from pants.option.options import Options [as 别名]
# 或者: from pants.option.options.Options import create [as 别名]
def test_option_tracker_required(self):
with self.assertRaises(Options.OptionTrackerRequiredError):
Options.create(None, None, [])
示例14: test_frozen_registration
# 需要导入模块: from pants.option.options import Options [as 别名]
# 或者: from pants.option.options.Options import create [as 别名]
def test_frozen_registration(self):
options = Options.create(args=[], env={}, config=self._create_config({}),
known_scope_infos=[task('foo')], option_tracker=OptionTracker())
options.register('foo', '--arg1')
with self.assertRaises(FrozenRegistration):
options.register(GLOBAL_SCOPE, '--arg2')
示例15: assertError
# 需要导入模块: from pants.option.options import Options [as 别名]
# 或者: from pants.option.options.Options import create [as 别名]
def assertError(expected_error, *args, **kwargs):
with self.assertRaises(expected_error):
options = Options.create(args=[], env={}, config=self._create_config({}),
known_scope_infos=[], option_tracker=OptionTracker())
options.register(GLOBAL_SCOPE, *args, **kwargs)
options.for_global_scope()