当前位置: 首页>>代码示例>>Python>>正文


Python ArgSplitter.split_args方法代码示例

本文整理汇总了Python中pants.option.arg_splitter.ArgSplitter.split_args方法的典型用法代码示例。如果您正苦于以下问题:Python ArgSplitter.split_args方法的具体用法?Python ArgSplitter.split_args怎么用?Python ArgSplitter.split_args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pants.option.arg_splitter.ArgSplitter的用法示例。


在下文中一共展示了ArgSplitter.split_args方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create

# 需要导入模块: from pants.option.arg_splitter import ArgSplitter [as 别名]
# 或者: from pants.option.arg_splitter.ArgSplitter import split_args [as 别名]
  def create(cls, env, config, known_scope_infos, args=None, bootstrap_option_values=None):
    """Create an Options instance.

    :param env: a dict of environment variables.
    :param :class:`pants.option.config.Config` config: data from a config file.
    :param known_scope_infos: ScopeInfos for all scopes that may be encountered.
    :param args: a list of cmd-line args; defaults to `sys.argv` if None is supplied.
    :param bootstrap_option_values: An optional namespace containing the values of bootstrap
           options. We can use these values when registering other options.
    """
    # We need parsers for all the intermediate scopes, so inherited option values
    # can propagate through them.
    complete_known_scope_infos = cls.complete_scopes(known_scope_infos)
    splitter = ArgSplitter(complete_known_scope_infos)
    args = sys.argv if args is None else args
    goals, scope_to_flags, target_specs, passthru, passthru_owner, unknown_scopes = splitter.split_args(args)

    option_tracker = OptionTracker()

    if bootstrap_option_values:
      target_spec_files = bootstrap_option_values.target_spec_files
      if target_spec_files:
        for spec in target_spec_files:
          with open(spec, 'r') as f:
            target_specs.extend([line for line in [line.strip() for line in f] if line])

    help_request = splitter.help_request

    parser_hierarchy = ParserHierarchy(env, config, complete_known_scope_infos, option_tracker)
    bootstrap_option_values = bootstrap_option_values
    known_scope_to_info = {s.scope: s for s in complete_known_scope_infos}
    return cls(goals, scope_to_flags, target_specs, passthru, passthru_owner, help_request,
               parser_hierarchy, bootstrap_option_values, known_scope_to_info,
               option_tracker, unknown_scopes)
开发者ID:jsirois,项目名称:pants,代码行数:36,代码来源:options.py

示例2: create

# 需要导入模块: from pants.option.arg_splitter import ArgSplitter [as 别名]
# 或者: from pants.option.arg_splitter.ArgSplitter import split_args [as 别名]
  def create(cls, env, config, known_scope_infos, args=None, bootstrap_option_values=None):
    """Create an Options instance.

    :param env: a dict of environment variables.
    :param config: data from a config file (must support config.get[list](section, name, default=)).
    :param known_scope_infos: ScopeInfos for all scopes that may be encountered.
    :param args: a list of cmd-line args; defaults to `sys.argv` if None is supplied.
    :param bootstrap_option_values: An optional namespace containing the values of bootstrap
           options. We can use these values when registering other options.
    """
    # We need parsers for all the intermediate scopes, so inherited option values
    # can propagate through them.
    complete_known_scope_infos = cls.complete_scopes(known_scope_infos)
    splitter = ArgSplitter(complete_known_scope_infos)
    args = sys.argv if args is None else args
    goals, scope_to_flags, target_specs, passthru, passthru_owner = splitter.split_args(args)

    if bootstrap_option_values:
      target_spec_files = bootstrap_option_values.target_spec_files
      if target_spec_files:
        for spec in target_spec_files:
          with open(spec) as f:
            target_specs.extend(filter(None, [line.strip() for line in f]))

    help_request = splitter.help_request

    parser_hierarchy = ParserHierarchy(env, config, complete_known_scope_infos)
    values_by_scope = {}  # Arg values, parsed per-scope on demand.
    bootstrap_option_values = bootstrap_option_values
    known_scope_to_info = {s.scope: s for s in complete_known_scope_infos}
    return cls(goals, scope_to_flags, target_specs, passthru, passthru_owner, help_request,
               parser_hierarchy, values_by_scope, bootstrap_option_values, known_scope_to_info)
开发者ID:areitz,项目名称:pants,代码行数:34,代码来源:options.py

示例3: __init__

# 需要导入模块: from pants.option.arg_splitter import ArgSplitter [as 别名]
# 或者: from pants.option.arg_splitter.ArgSplitter import split_args [as 别名]
  def __init__(self, env, config, known_scopes, args=sys.argv, bootstrap_option_values=None):
    """Create an Options instance.

    :param env: a dict of environment variables.
    :param config: data from a config file (must support config.get[list](section, name, default=)).
    :param known_scopes: a list of all possible scopes that may be encountered.
    :param args: a list of cmd-line args.
    :param bootstrap_option_values: An optional namespace containing the values of bootstrap
           options. We can use these values when registering other options.
    """
    splitter = ArgSplitter(known_scopes)
    self._goals, self._scope_to_flags, self._target_specs, self._passthru, self._passthru_owner = \
      splitter.split_args(args)

    if bootstrap_option_values:
      target_spec_files = bootstrap_option_values.target_spec_files
      if target_spec_files:
        for spec in target_spec_files:
          with open(spec) as f:
            self._target_specs.extend(filter(None, [line.strip() for line in f]))

    self._help_request = splitter.help_request
    self._parser_hierarchy = ParserHierarchy(env, config, known_scopes, self._help_request)
    self._values_by_scope = {}  # Arg values, parsed per-scope on demand.
    self._bootstrap_option_values = bootstrap_option_values
    self._known_scopes = set(known_scopes)
开发者ID:MathewJennings,项目名称:pants,代码行数:28,代码来源:options.py

示例4: _split

# 需要导入模块: from pants.option.arg_splitter import ArgSplitter [as 别名]
# 或者: from pants.option.arg_splitter.ArgSplitter import split_args [as 别名]
 def _split(self, args_str, expected_scope_to_flags, expected_target_specs, expected_help=False):
   splitter = ArgSplitter(ArgSplitterTest._known_scopes)
   args = shlex.split(str(args_str))
   scope_to_flags, target_specs = splitter.split_args(args)
   self.assertEquals(expected_scope_to_flags, scope_to_flags)
   self.assertEquals(expected_target_specs, target_specs)
   self.assertEquals(expected_help, splitter.is_help)
开发者ID:Yasumoto,项目名称:pants,代码行数:9,代码来源:test_arg_splitter.py

示例5: _split

# 需要导入模块: from pants.option.arg_splitter import ArgSplitter [as 别名]
# 或者: from pants.option.arg_splitter.ArgSplitter import split_args [as 别名]
 def _split(self, args_str, expected_goals, expected_scope_to_flags, expected_target_specs,
            expected_passthru=None, expected_passthru_owner=None, expected_is_help=False):
   expected_passthru = expected_passthru or []
   splitter = ArgSplitter(ArgSplitterTest._known_scopes)
   args = shlex.split(str(args_str))
   goals, scope_to_flags, target_specs, passthru, passthru_owner = splitter.split_args(args)
   self.assertEquals(expected_goals, goals)
   self.assertEquals(expected_scope_to_flags, scope_to_flags)
   self.assertEquals(expected_target_specs, target_specs)
   self.assertEquals(expected_passthru, passthru)
   self.assertEquals(expected_passthru_owner, passthru_owner)
   self.assertEquals(expected_is_help, splitter.is_help)
开发者ID:digideskio,项目名称:pants,代码行数:14,代码来源:test_arg_splitter.py

示例6: __init__

# 需要导入模块: from pants.option.arg_splitter import ArgSplitter [as 别名]
# 或者: from pants.option.arg_splitter.ArgSplitter import split_args [as 别名]
  def __init__(self, env, config, known_scopes, args=sys.argv, legacy_parser=None):
    """Create an Options instance.

    :param env: a dict of environment variables.
    :param config: data from a config file (must support config.get(section, name, default=)).
    :param known_scopes: a list of all possible scopes that may be encountered.
    :param args: a list of cmd-line args.
    :param legacy_parser: optional instance of optparse.OptionParser, used to register and access
           the old-style flags during migration.
    """
    splitter = ArgSplitter(known_scopes)
    self._scope_to_flags, self._target_specs, self._passthru = splitter.split_args(args)
    self._is_help = splitter.is_help
    self._parser_hierarchy = ParserHierarchy(env, config, known_scopes, legacy_parser)
    self._legacy_parser = legacy_parser  # Old-style options, used temporarily during transition.
    self._legacy_values = None  # Values parsed from old-stype options.
    self._values_by_scope = {}  # Arg values, parsed per-scope on demand.
开发者ID:rgbenson,项目名称:pants,代码行数:19,代码来源:options.py

示例7: _split

# 需要导入模块: from pants.option.arg_splitter import ArgSplitter [as 别名]
# 或者: from pants.option.arg_splitter.ArgSplitter import split_args [as 别名]
 def _split(self, args_str, expected_goals, expected_scope_to_flags, expected_target_specs,
            expected_passthru=None, expected_passthru_owner=None,
            expected_is_help=False, expected_help_advanced=False, expected_help_all=False):
   expected_passthru = expected_passthru or []
   splitter = ArgSplitter(ArgSplitterTest._known_scopes)
   args = shlex.split(str(args_str))
   goals, scope_to_flags, target_specs, passthru, passthru_owner = splitter.split_args(args)
   self.assertEquals(expected_goals, goals)
   self.assertEquals(expected_scope_to_flags, scope_to_flags)
   self.assertEquals(expected_target_specs, target_specs)
   self.assertEquals(expected_passthru, passthru)
   self.assertEquals(expected_passthru_owner, passthru_owner)
   self.assertEquals(expected_is_help, splitter.help_request is not None)
   self.assertEquals(expected_help_advanced,
                     splitter.help_request is not None and splitter.help_request.advanced)
   self.assertEquals(expected_help_all,
                     splitter.help_request is not None and splitter.help_request.all_scopes)
开发者ID:arloherrine,项目名称:pants,代码行数:19,代码来源:test_arg_splitter.py

示例8: _error_split

# 需要导入模块: from pants.option.arg_splitter import ArgSplitter [as 别名]
# 或者: from pants.option.arg_splitter.ArgSplitter import split_args [as 别名]
 def _error_split(self, args_str):
   parser = ArgSplitter(ArgSplitterTest._known_scopes)
   args = shlex.split(str(args_str))
   with pytest.raises(ArgSplitterError):
     parser.split_args(args)
开发者ID:Yasumoto,项目名称:pants,代码行数:7,代码来源:test_arg_splitter.py

示例9: _split_version

# 需要导入模块: from pants.option.arg_splitter import ArgSplitter [as 别名]
# 或者: from pants.option.arg_splitter.ArgSplitter import split_args [as 别名]
 def _split_version(self, args_str):
   splitter = ArgSplitter(ArgSplitterTest._known_scope_infos)
   args = shlex.split(args_str)
   splitter.split_args(args)
   self.assertTrue(splitter.help_request is not None and splitter.help_request.version)
开发者ID:digwanderlust,项目名称:pants,代码行数:7,代码来源:test_arg_splitter.py

示例10: _split_no_goal

# 需要导入模块: from pants.option.arg_splitter import ArgSplitter [as 别名]
# 或者: from pants.option.arg_splitter.ArgSplitter import split_args [as 别名]
 def _split_no_goal(self, args_str):
   splitter = ArgSplitter(ArgSplitterTest._known_scope_infos)
   splitter.split_args(shlex.split(args_str))
   self.assertTrue(isinstance(splitter.help_request, NoGoalHelp))
开发者ID:areitz,项目名称:pants,代码行数:6,代码来源:test_arg_splitter.py

示例11: _split_unknown_goal

# 需要导入模块: from pants.option.arg_splitter import ArgSplitter [as 别名]
# 或者: from pants.option.arg_splitter.ArgSplitter import split_args [as 别名]
 def _split_unknown_goal(self, args_str, unknown_goals):
   splitter = ArgSplitter(ArgSplitterTest._known_scope_infos)
   splitter.split_args(shlex.split(args_str))
   self.assertTrue(isinstance(splitter.help_request, UnknownGoalHelp))
   self.assertSetEqual(set(unknown_goals), set(splitter.help_request.unknown_goals))
开发者ID:areitz,项目名称:pants,代码行数:7,代码来源:test_arg_splitter.py

示例12: _split_version_request

# 需要导入模块: from pants.option.arg_splitter import ArgSplitter [as 别名]
# 或者: from pants.option.arg_splitter.ArgSplitter import split_args [as 别名]
 def _split_version_request(self, args_str):
   splitter = ArgSplitter(ArgSplitterTest._known_scope_infos)
   splitter.split_args(shlex.split(args_str))
   self.assertTrue(isinstance(splitter.help_request, VersionHelp))
开发者ID:foursquare,项目名称:pants,代码行数:6,代码来源:test_arg_splitter.py


注:本文中的pants.option.arg_splitter.ArgSplitter.split_args方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。