[PATCH 3/3] Provide our own sorting functions for regions and timezones (#1025029)
Vratislav Podzimek
vpodzime at redhat.com
Mon Nov 4 15:52:51 UTC 2013
On Mon, 2013-11-04 at 10:45 -0500, Chris Lumens wrote:
> > +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.
I must say I like making explicit what are the parts returned from the
match, but I'll use a comment instead. Fixing locally.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list