Ejemplo n.º 1
0
def __expand_subfeatures_aux (property, dont_validate = False):
    """ Helper for expand_subfeatures.
        Given a feature and value, or just a value corresponding to an
        implicit feature, returns a property set consisting of all component
        subfeatures and their values. For example:
        
          expand_subfeatures <toolset>gcc-2.95.2-linux-x86
              -> <toolset>gcc <toolset-version>2.95.2 <toolset-os>linux <toolset-cpu>x86
          equivalent to:
              expand_subfeatures gcc-2.95.2-linux-x86

        feature:        The name of the feature, or empty if value corresponds to an implicit property
        value:          The value of the feature.
        dont_validate:  If True, no validation of value string will be done.
    """
    f = property.feature()
    v = property.value()
    if not dont_validate:
        validate_value_string(f, v)

    components = v.split ("-")
    
    v = components[0]

    import property

    result = [property.Property(f, components[0])] 
    
    subvalues = components[1:]

    while len(subvalues) > 0:
        subvalue = subvalues [0]    # pop the head off of subvalues
        subvalues = subvalues [1:]
        
        subfeature = __find_implied_subfeature (f, subvalue, v)
        
        # If no subfeature was found, reconstitute the value string and use that
        if not subfeature:
            return [property.Property(f, '-'.join(components))]
            
        result.append(property.Property(subfeature, subvalue))
    
    return result
Ejemplo n.º 2
0
def __expand_subfeatures_aux(property, dont_validate=False):
    """ Helper for expand_subfeatures.
        Given a feature and value, or just a value corresponding to an
        implicit feature, returns a property set consisting of all component
        subfeatures and their values. For example:
        
          expand_subfeatures <toolset>gcc-2.95.2-linux-x86
              -> <toolset>gcc <toolset-version>2.95.2 <toolset-os>linux <toolset-cpu>x86
          equivalent to:
              expand_subfeatures gcc-2.95.2-linux-x86

        feature:        The name of the feature, or empty if value corresponds to an implicit property
        value:          The value of the feature.
        dont_validate:  If True, no validation of value string will be done.
    """
    f = property.feature()
    v = property.value()
    if not dont_validate:
        validate_value_string(f, v)

    components = v.split("-")

    v = components[0]

    import property

    result = [property.Property(f, components[0])]

    subvalues = components[1:]

    while len(subvalues) > 0:
        subvalue = subvalues[0]  # pop the head off of subvalues
        subvalues = subvalues[1:]

        subfeature = __find_implied_subfeature(f, subvalue, v)

        # If no subfeature was found, reconstitute the value string and use that
        if not subfeature:
            return [property.Property(f, '-'.join(components))]

        result.append(property.Property(subfeature, subvalue))

    return result