Index based loops across the Gramps project
are mapped to their Pythonic equalivant.
Many of these improves radability, and a
some of them improves performance by being
lazy evaluated.
The NameDisplay class contains various methods
that interact with the dict holding the
name formats.
To enable further refactoring, these methods
have been brought under test for most of
their implementations.
This commit corrects the ordering to the one in
Gramps 5.1 when run on Python 3.3.
Unlike the implementation in 5.1, this
implementation does not rely on dict ordering
and will therefore be consistent across Python
versions.
The assumed order of ascending positives followed
by negatives in reverse order, was based on tests
run on Python 3.7. However, the current ordering
in Gramps 5.1 is depended on dict ordering which
has changed between Python versions.
The expected ordering is therefore taken as the
one in Gramps 5.1 run on Python 3.3, which is
what the CI environment tests on.
This ordering is positives followed by negatives
both in ascending order.
I.e. -2, -3, -1, 0, 1, 2, 3, 4, 5
=> 0, 1, 2, 3, 4, 5, -1, -2, -3
First, the simplification uses the
built-in cmp_to_key function from functools
to remove the duplicated function in the
class.
Second, the cmp function was reduced to
two cases:
1. When x and y is positive:
Here the st
2. When x or y is negative:
Here the sign of y determines the ordering,
which can be seen from the following cases:
1. x is negative, y is negative =>
their order needs to be, so y is considered
higher, which means x is considered lower
(negative).
2. x is negative, y is positive =>
x is considered higher (positive).
3. x is positive, y is negative =>
y is considered higher, which means x is
considered lower (negative).
Third, the sorting is abstracted away
behind a function declaring the sort order.
The test class enumaretes all possible
values for the three boolean arguments.
Some of the results is arguably wrong,
but since other classes depend on the
current semantics, these cases have
not been corrected.
Move the icons of MIME types in the same location/structure used for
the other hicolor icons (application icon, action icons).
This way, all the hicolor icons are logically in the same place.