The calendar year can be divided into four quarters, often abbreviated
as Q1, Q2, Q3, and Q4. Q1 is 1 January to 31 March, Q2 1 April to
30 June, Q3 is 1 July to 30 September and Q4 is 1 October to 31 December
This commit teaches DateParser to parse quarter dates and represet them
as a date range. An example quarter date is "Q2 2020" which is converted
to "between 1 April 2020 and 30 June 2020". This is a one way conversion
Only about 1% of strings have been translated, so we won't make
it active yet. At some point we need to update the LINGUAS file
and add a classifier in the setup script.
Partially revert commit 7248f073f0.
Deleting items during list iteration can lead to problems. In this
case an infinite loop was introduced in PR #975.
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.