[PATCH 3/3] Provide our own sorting functions for regions and timezones (#1025029)

Chris Lumens clumens at redhat.com
Mon Nov 4 15:45:42 UTC 2013


> +def _compare_cities(model, itr1, itr2, data=None):
> +    """Compare two cities from given model and iterators."""
> +
> +    # if there are "cities" ending with numbers (like GMT+-X), we need to sort
> +    # them based on their numbers
> +    val1 = model[itr1][1]
> +    val2 = model[itr2][1]
> +
> +    match1 = SPLIT_NUMBER_SUFFIX_RE.match(val1)
> +    match2 = SPLIT_NUMBER_SUFFIX_RE.match(val2)
> +
> +    if match1 is None and match2 is None:
> +        # no +-X suffix, just compare the strings
> +        return locale_mod.strcoll(val1, val2)
> +
> +    if match1 is None or match2 is None:
> +        # one with the +-X suffix, compare the prefixes
> +        if match1:
> +            prefix, sign, suffix = match1.groups()
> +            return locale_mod.strcoll(prefix, val2)
> +        else:
> +            prefix, sign, suffix = match2.groups()
> +            return locale_mod.strcoll(val1, prefix)

Oh, I believe sign and suffix here will be unused, so this will cause a
problem with pylint.

- Chris


More information about the anaconda-patches mailing list