• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.is_iterable_typed函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中b2.util.is_iterable_typed函数的典型用法代码示例。如果您正苦于以下问题:Python is_iterable_typed函数的具体用法?Python is_iterable_typed怎么用?Python is_iterable_typed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: convert_multiple_sources_to_consumable_types

    def convert_multiple_sources_to_consumable_types (self, project, prop_set, sources):
        """ Converts several files to consumable types.
        """
        consumed = []
        bypassed = []
        if __debug__:
            from .targets import ProjectTarget

            assert isinstance(project, ProjectTarget)
            assert isinstance(prop_set, property_set.PropertySet)
            assert is_iterable_typed(sources, virtual_target.VirtualTarget)

        assert isinstance(project, ProjectTarget)
        assert isinstance(prop_set, property_set.PropertySet)
        assert is_iterable_typed(sources, virtual_target.VirtualTarget)
        # We process each source one-by-one, trying to convert it to
        # a usable type.
        for s in sources:
            # TODO: need to check for failure on each source.
            (c, b) = self.convert_to_consumable_types (project, None, prop_set, [s], True)
            if not c:
                project.manager ().logger ().log (__name__, " failed to convert ", s)

            consumed.extend (c)
            bypassed.extend (b)

        return (consumed, bypassed)
开发者ID:zjutjsj1004,项目名称:third,代码行数:27,代码来源:generators.py


示例2: create

def create (raw_properties = []):
    """ Creates a new 'PropertySet' instance for the given raw properties,
        or returns an already existing one.
    """
    assert (is_iterable_typed(raw_properties, property.Property)
            or is_iterable_typed(raw_properties, basestring))
    # FIXME: propagate to callers.
    if len(raw_properties) > 0 and isinstance(raw_properties[0], property.Property):
        x = raw_properties
    else:
        x = [property.create_from_string(ps) for ps in raw_properties]

    # These two lines of code are optimized to the current state
    # of the Property class. Since this function acts as the caching
    # frontend to the PropertySet class modifying these two lines
    # could have a severe performance penalty. Be careful.
    # It would be faster to sort by p.id, but some projects may rely
    # on the fact that the properties are ordered alphabetically. So,
    # we maintain alphabetical sorting so as to maintain backward compatibility.
    x = sorted(set(x), key=lambda p: (p.feature.name, p.value, p.condition))
    key = tuple(p.id for p in x)

    if key not in __cache:
        __cache [key] = PropertySet(x)

    return __cache [key]
开发者ID:DanielaE,项目名称:boost.build,代码行数:26,代码来源:property_set.py


示例3: construct_types

def construct_types (project, name, target_types, prop_set, sources):

    if __debug__:
        from .targets import ProjectTarget
        assert isinstance(project, ProjectTarget)
        assert isinstance(name, basestring) or name is None
        assert is_iterable_typed(target_types, basestring)
        assert isinstance(prop_set, property_set.PropertySet)
        assert is_iterable_typed(sources, virtual_target.VirtualTarget)

    result = []
    usage_requirements = property_set.empty()

    for t in target_types:
        r = construct (project, name, t, prop_set, sources)

        if r:
            (ur, targets) = r
            usage_requirements = usage_requirements.add(ur)
            result.extend(targets)

    # TODO: have to introduce parameter controlling if
    # several types can be matched and add appropriate
    # checks

    # TODO: need to review the documentation for
    # 'construct' to see if it should return $(source) even
    # if nothing can be done with it. Currents docs seem to
    # imply that, contrary to the behaviour.
    if result:
        return (usage_requirements, result)

    else:
        return (usage_requirements, sources)
开发者ID:zjutjsj1004,项目名称:third,代码行数:34,代码来源:generators.py


示例4: refine

def refine (properties, requirements):
    """ Refines 'properties' by overriding any non-free properties
        for which a different value is specified in 'requirements'.
        Conditional requirements are just added without modification.
        Returns the resulting list of properties.
    """
    assert is_iterable_typed(properties, Property)
    assert is_iterable_typed(requirements, Property)
    # The result has no duplicates, so we store it in a set
    result = set()

    # Records all requirements.
    required = {}

    # All the elements of requirements should be present in the result
    # Record them so that we can handle 'properties'.
    for r in requirements:
        # Don't consider conditional requirements.
        if not r.condition:
            required[r.feature] = r

    for p in properties:
        # Skip conditional properties
        if p.condition:
            result.add(p)
        # No processing for free properties
        elif p.feature.free:
            result.add(p)
        else:
            if p.feature in required:
                result.add(required[p.feature])
            else:
                result.add(p)

    return sequence.unique(list(result) + requirements)
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:35,代码来源:property.py


示例5: lib

def lib(names, sources=[], requirements=[], default_build=[], usage_requirements=[]):
    """The implementation of the 'lib' rule. Beyond standard syntax that rule allows
    simplified: 'lib a b c ;'."""
    assert is_iterable_typed(names, basestring)
    assert is_iterable_typed(sources, basestring)
    assert is_iterable_typed(requirements, basestring)
    assert is_iterable_typed(default_build, basestring)
    assert is_iterable_typed(usage_requirements, basestring)
    if len(names) > 1:
        if any(r.startswith("<name>") for r in requirements):
            get_manager().errors()(
                "When several names are given to the 'lib' rule\n" + "it is not allowed to specify the <name> feature."
            )

        if sources:
            get_manager().errors()(
                "When several names are given to the 'lib' rule\n" + "it is not allowed to specify sources."
            )

    project = get_manager().projects().current()
    result = []

    for name in names:
        r = requirements[:]

        # Support " lib a ; " and " lib a b c ; " syntax.
        if (
            not sources
            and not any(r.startswith("<name>") for r in requirements)
            and not any(r.startswith("<file") for r in requirements)
        ):
            r.append("<name>" + name)

        result.append(targets.create_typed_metatarget(name, "LIB", sources, r, default_build, usage_requirements))
    return result
开发者ID:boostorg,项目名称:build,代码行数:35,代码来源:builtin.py


示例6: use_project

 def use_project(self, id, where):
     # See comment in 'load' for explanation why we record the
     # parameters as opposed to loading the project now.
     assert is_iterable_typed(id, basestring)
     assert is_iterable_typed(where, basestring)
     m = self.registry.current().project_module()
     self.registry.used_projects[m].append((id[0], where[0]))
开发者ID:Cabriter,项目名称:abelkhan,代码行数:7,代码来源:project.py


示例7: inherit_generators

def inherit_generators (toolset, properties, base, generators_to_ignore = []):
    assert isinstance(toolset, basestring)
    assert is_iterable_typed(properties, basestring)
    assert isinstance(base, basestring)
    assert is_iterable_typed(generators_to_ignore, basestring)
    if not properties:
        properties = [replace_grist (toolset, '<toolset>')]

    base_generators = generators.generators_for_toolset(base)

    for g in base_generators:
        id = g.id()

        if not id in generators_to_ignore:
            # Some generator names have multiple periods in their name, so
            # $(id:B=$(toolset)) doesn't generate the right new_id name.
            # e.g. if id = gcc.compile.c++, $(id:B=darwin) = darwin.c++,
            # which is not what we want. Manually parse the base and suffix
            # (if there's a better way to do this, I'd love to see it.)
            # See also register in module generators.
            (base, suffix) = split_action_id(id)

            new_id = toolset + '.' + suffix

            generators.register(g.clone(new_id, properties))
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:25,代码来源:toolset.py


示例8: constant

 def constant(self, name, value):
     """Declare and set a project global constant.
     Project global constants are normal variables but should
     not be changed. They are applied to every child Jamfile."""
     assert is_iterable_typed(name, basestring)
     assert is_iterable_typed(value, basestring)
     self.registry.current().add_constant(name[0], value)
开发者ID:Cabriter,项目名称:abelkhan,代码行数:7,代码来源:project.py


示例9: get_invocation_command

def get_invocation_command(toolset, tool, user_provided_command = [],
                           additional_paths = [], path_last = False):
    """ Same as get_invocation_command_nodefault, except that if no tool is found,
        returns either the user-provided-command, if present, or the 'tool' parameter.
    """
    assert isinstance(toolset, basestring)
    assert isinstance(tool, basestring)
    assert is_iterable_typed(user_provided_command, basestring)
    assert is_iterable_typed(additional_paths, basestring) or additional_paths is None
    assert isinstance(path_last, (int, bool))

    result = get_invocation_command_nodefault(toolset, tool,
                                              user_provided_command,
                                              additional_paths,
                                              path_last)

    if not result:
        if user_provided_command:
            result = user_provided_command[0]
        else:
            result = tool

    assert(isinstance(result, str))

    return result
开发者ID:Cabriter,项目名称:abelkhan,代码行数:25,代码来源:common.py


示例10: make_test

def make_test(target_type, sources, requirements, target_name=None):
    assert isinstance(target_type, basestring)
    assert is_iterable_typed(sources, basestring)
    assert is_iterable_typed(requirements, basestring)
    assert isinstance(target_type, basestring) or target_type is None
    if not target_name:
        target_name = stem(os.path.basename(sources[0]))

    # Having periods (".") in the target name is problematic because the typed
    # generator will strip the suffix and use the bare name for the file
    # targets. Even though the location-prefix averts problems most times it
    # does not prevent ambiguity issues when referring to the test targets. For
    # example when using the XML log output. So we rename the target to remove
    # the periods, and provide an alias for users.
    real_name = target_name.replace(".", "~")

    project = get_manager().projects().current()
    # The <location-prefix> forces the build system for generate paths in the
    # form '$build_dir/array1.test/gcc/debug'. This is necessary to allow
    # post-processing tools to work.
    t = get_manager().targets().create_typed_target(
        type.type_from_rule_name(target_type), project, real_name, sources,
        requirements + ["<location-prefix>" + real_name + ".test"], [], [])

    # The alias to the real target, per period replacement above.
    if real_name != target_name:
        get_manager().projects().project_rules().all_names_["alias"](
            target_name, [t])

    # Remember the test (for --dump-tests). A good way would be to collect all
    # given a project. This has some technical problems: e.g. we can not call
    # this dump from a Jamfile since projects referred by 'build-project' are
    # not available until the whole Jamfile has been loaded.
    __all_tests.append(t)
    return t
开发者ID:zjutjsj1004,项目名称:third,代码行数:35,代码来源:testing.py


示例11: take

def take(attributes, properties):
    """Returns a property set which include all
    properties in 'properties' that have any of 'attributes'."""
    assert is_iterable_typed(attributes, basestring)
    assert is_iterable_typed(properties, basestring)
    result = []
    for e in properties:
        if b2.util.set.intersection(attributes, feature.attributes(get_grist(e))):
            result.append(e)
    return result
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:10,代码来源:property.py


示例12: path_constant

 def path_constant(self, name, value):
     """Declare and set a project global constant, whose value is a path. The
     path is adjusted to be relative to the invocation directory. The given
     value path is taken to be either absolute, or relative to this project
     root."""
     assert is_iterable_typed(name, basestring)
     assert is_iterable_typed(value, basestring)
     if len(value) > 1:
         self.registry.manager.error()("path constant should have one element")
     self.registry.current().add_constant(name[0], value[0], path=1)
开发者ID:Cabriter,项目名称:abelkhan,代码行数:10,代码来源:project.py


示例13: capture_output_setup

def capture_output_setup(target, sources, ps):
    if __debug__:
        from ..build.property_set import PropertySet
        assert is_iterable_typed(target, basestring)
        assert is_iterable_typed(sources, basestring)
        assert isinstance(ps, PropertySet)
    run_path_setup(target[0], sources, ps)

    if ps.get('preserve-test-targets') == ['off']:
        bjam.call("set-target-variable", target, "REMOVE_TEST_TARGETS", "1")
开发者ID:zjutjsj1004,项目名称:third,代码行数:10,代码来源:testing.py


示例14: __init__

 def __init__(self, name, values, attributes):
     assert isinstance(name, basestring)
     assert is_iterable_typed(values, basestring)
     assert is_iterable_typed(attributes, basestring)
     self._name = name
     self._values = values
     self._default = None
     self._attributes = 0
     for a in attributes:
         self._attributes = self._attributes | Feature._attribute_name_to_integer[a]
     self._attributes_string_list = attributes
     self._subfeatures = []
     self._parent = None
开发者ID:Cabriter,项目名称:abelkhan,代码行数:13,代码来源:feature.py


示例15: register_type

def register_type (type, suffixes, base_type = None, os = []):
    """ Register the given type on the specified OSes, or on remaining OSes
        if os is not specified.  This rule is injected into each of the type
        modules for the sake of convenience.
    """
    assert isinstance(type, basestring)
    assert is_iterable_typed(suffixes, basestring)
    assert isinstance(base_type, basestring) or base_type is None
    assert is_iterable_typed(os, basestring)
    if registered (type):
        return

    if not os or os_name () in os:
        register (type, suffixes, base_type)
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:14,代码来源:type.py


示例16: conditional

    def conditional(self, condition, requirements):
        """Calculates conditional requirements for multiple requirements
        at once. This is a shorthand to be reduce duplication and to
        keep an inline declarative syntax. For example:

            lib x : x.cpp : [ conditional <toolset>gcc <variant>debug :
                <define>DEBUG_EXCEPTION <define>DEBUG_TRACE ] ;
        """
        assert is_iterable_typed(condition, basestring)
        assert is_iterable_typed(requirements, basestring)
        c = string.join(condition, ",")
        if c.find(":") != -1:
            return [c + r for r in requirements]
        else:
            return [c + ":" + r for r in requirements]
开发者ID:Cabriter,项目名称:abelkhan,代码行数:15,代码来源:project.py


示例17: alias

def alias(name, sources=[], requirements=[], default_build=[], usage_requirements=[]):
    assert isinstance(name, basestring)
    assert is_iterable_typed(sources, basestring)
    assert is_iterable_typed(requirements, basestring)
    assert is_iterable_typed(default_build, basestring)
    assert is_iterable_typed(usage_requirements, basestring)
    project = get_manager().projects().current()
    targets = get_manager().targets()

    targets.main_target_alternative(AliasTarget(
        name, project,
        targets.main_target_sources(sources, name, no_renaming=True),
        targets.main_target_requirements(requirements or [], project),
        targets.main_target_default_build(default_build, project),
        targets.main_target_usage_requirements(usage_requirements or [], project)))
开发者ID:zjutjsj1004,项目名称:third,代码行数:15,代码来源:alias.py


示例18: translate_dependencies

def translate_dependencies(properties, project_id, location):
    assert is_iterable_typed(properties, Property)
    assert isinstance(project_id, basestring)
    assert isinstance(location, basestring)
    result = []
    for p in properties:

        if not p.feature.dependency:
            result.append(p)
        else:
            v = p.value
            m = re.match("(.*)//(.*)", v)
            if m:
                rooted = m.group(1)
                if rooted[0] == '/':
                    # Either project id or absolute Linux path, do nothing.
                    pass
                else:
                    rooted = os.path.join(os.getcwd(), location, rooted)

                result.append(Property(p.feature, rooted + "//" + m.group(2), p.condition))

            elif os.path.isabs(v):
                result.append(p)
            else:
                result.append(Property(p.feature, project_id + "//" + v, p.condition))

    return result
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:28,代码来源:property.py


示例19: evaluate_conditionals_in_context

def evaluate_conditionals_in_context (properties, context):
    """ Removes all conditional properties which conditions are not met
        For those with met conditions, removes the condition. Properties
        in conditions are looked up in 'context'
    """
    if __debug__:
        from .property_set import PropertySet
        assert is_iterable_typed(properties, Property)
        assert isinstance(context, PropertySet)
    base = []
    conditional = []

    for p in properties:
        if p.condition:
            conditional.append (p)
        else:
            base.append (p)

    result = base[:]
    for p in conditional:

        # Evaluate condition
        # FIXME: probably inefficient
        if all(x in context for x in p.condition):
            result.append(Property(p.feature, p.value))

    return result
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:27,代码来源:property.py


示例20: expand_subfeatures_in_conditions

def expand_subfeatures_in_conditions (properties):
    assert is_iterable_typed(properties, Property)
    result = []
    for p in properties:

        if not p.condition:
            result.append(p)
        else:
            expanded = []
            for c in p.condition:
                # It common that condition includes a toolset which
                # was never defined, or mentiones subfeatures which
                # were never defined. In that case, validation will
                # only produce an spirious error, so don't validate.
                expanded.extend(feature.expand_subfeatures ([c], True))

            # we need to keep LazyProperties lazy
            if isinstance(p, LazyProperty):
                value = p.value
                feature_name = get_grist(value)
                value = value.replace(feature_name, '')
                result.append(LazyProperty(feature_name, value, condition=expanded))
            else:
                result.append(Property(p.feature, p.value, expanded))

    return result
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:26,代码来源:property.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sequence.unique函数代码示例发布时间:2022-05-24
下一篇:
Python util.is_iterable函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap