Example #1
0
def pick(v_dict):
    """
    Collapses an ambiguous series of objects bound to specific versions
    by interrogating the CFME Version and returning the correct item.
    """
    # convert keys to Versions
    v_dict = {get_version(k): v for (k, v) in v_dict.items()}
    versions = v_dict.keys()
    sorted_matching_versions = sorted(filter(lambda v: v <= current_version(), versions),
                                      reverse=True)
    return v_dict.get(sorted_matching_versions[0]) if sorted_matching_versions else None
Example #2
0
def pick(v_dict, active_version=None):
    """
    Collapses an ambiguous series of objects bound to specific versions
    by interrogating the CFME Version and returning the correct item.
    """
    # convert keys to Versions
    active_version = active_version or current_version()

    v_dict = {get_version(k): v for (k, v) in v_dict.items()}
    versions = v_dict.keys()
    sorted_matching_versions = sorted((v for v in versions if v <= active_version),
                                      reverse=True)
    return v_dict.get(sorted_matching_versions[0]) if sorted_matching_versions else None
Example #3
0
def pick(v_dict, active_version=None):
    """
    Collapses an ambiguous series of objects bound to specific versions
    by interrogating the CFME Version and returning the correct item.
    """
    # convert keys to Versions
    active_version = active_version or current_version()

    v_dict = {get_version(k): v for (k, v) in v_dict.items()}
    versions = v_dict.keys()
    sorted_matching_versions = sorted((v for v in versions if v <= active_version),
                                      reverse=True)
    return v_dict.get(sorted_matching_versions[0]) if sorted_matching_versions else None
Example #4
0
    def pick(self, active_version=None):
        """
        Collapses an ambiguous series of objects bound to specific versions
        by interrogating the CFME Version and returning the correct item.

        Args:
            active_version: a :py:class:`miq_version.Version` instance.

        Returns:
            A value from the version dictionary.
        """
        # convert keys to Versions
        active_version = active_version or current_version()

        v_dict = {get_version(k): v for (k, v) in self.version_dict.items()}
        versions = list(v_dict.keys())
        sorted_matching_versions = sorted((v for v in versions if v <= active_version),
                                          reverse=True)
        return v_dict.get(sorted_matching_versions[0]) if sorted_matching_versions else None
Example #5
0
    def pick(self, active_version=None):
        """
        Collapses an ambiguous series of objects bound to specific versions
        by interrogating the CFME Version and returning the correct item.

        Args:
            active_version: a :py:class:`miq_version.Version` instance.

        Returns:
            A value from the version dictionary.
        """
        # convert keys to Versions
        active_version = active_version or current_version()

        v_dict = {get_version(k): v for (k, v) in self.version_dict.items()}
        versions = v_dict.keys()
        sorted_matching_versions = sorted((v for v in versions if v <= active_version),
                                          reverse=True)
        return v_dict.get(sorted_matching_versions[0]) if sorted_matching_versions else None