Skip to content

Commit

Permalink
Remove the spaces padding the connector in a hyphenated surname
Browse files Browse the repository at this point in the history
This fixes the previous code which replaced " - " with "-"
within the entire name.

Reverts 3c7d6eb

Fixes #13274.
  • Loading branch information
Nick-Hall committed May 4, 2024
1 parent aaa6b68 commit 0e13030
Showing 1 changed file with 25 additions and 32 deletions.
57 changes: 25 additions & 32 deletions gramps/gen/display/name.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,8 @@ def _raw_full_surname(raw_surn_data_list):
"""method for the 'l' symbol: full surnames"""
result = ""
for raw_surn_data in raw_surn_data_list:
result += "%s %s %s " % (
raw_surn_data[_PREFIX_IN_LIST],
raw_surn_data[_SURNAME_IN_LIST],
raw_surn_data[_CONNECTOR_IN_LIST],
)
return " ".join(result.split()).strip()
result += __format_raw_surname(raw_surn_data)
return result.strip()


def _raw_primary_surname(raw_surn_data_list):
Expand All @@ -189,12 +185,7 @@ def _raw_primary_surname(raw_surn_data_list):
):
return ""
else:
result = "%s %s %s" % (
raw_surn_data[_PREFIX_IN_LIST],
raw_surn_data[_SURNAME_IN_LIST],
raw_surn_data[_CONNECTOR_IN_LIST],
)
return " ".join(result.split())
return __format_raw_surname(raw_surn_data).strip()
return ""


Expand Down Expand Up @@ -265,12 +256,7 @@ def _raw_patro_surname(raw_surn_data_list):
raw_surn_data[_TYPE_IN_LIST][0] == _ORIGINPATRO
or raw_surn_data[_TYPE_IN_LIST][0] == _ORIGINMATRO
):
result = "%s %s %s" % (
raw_surn_data[_PREFIX_IN_LIST],
raw_surn_data[_SURNAME_IN_LIST],
raw_surn_data[_CONNECTOR_IN_LIST],
)
return " ".join(result.split())
return __format_raw_surname(raw_surn_data).strip()
return ""


Expand Down Expand Up @@ -321,26 +307,17 @@ def _raw_nonpatro_surname(raw_surn_data_list):
and raw_surn_data[_TYPE_IN_LIST][0] != _ORIGINPATRO
and raw_surn_data[_TYPE_IN_LIST][0] != _ORIGINMATRO
):
result += "%s %s %s " % (
raw_surn_data[_PREFIX_IN_LIST],
raw_surn_data[_SURNAME_IN_LIST],
raw_surn_data[_CONNECTOR_IN_LIST],
)
return " ".join(result.split()).strip()
result += __format_raw_surname(raw_surn_data)
return result.strip()


def _raw_nonprimary_surname(raw_surn_data_list):
"""method for the 'r' symbol: nonprimary surnames"""
result = ""
for raw_surn_data in raw_surn_data_list:
if not raw_surn_data[_PRIMARY_IN_LIST]:
result = "%s %s %s %s" % (
result,
raw_surn_data[_PREFIX_IN_LIST],
raw_surn_data[_SURNAME_IN_LIST],
raw_surn_data[_CONNECTOR_IN_LIST],
)
return " ".join(result.split())
result += __format_raw_surname(raw_surn_data)
return result.strip()


def _raw_prefix_surname(raw_surn_data_list):
Expand Down Expand Up @@ -373,7 +350,23 @@ def cleanup_name(namestring):
else:
result += " " + val

result = result.replace(" - ", "-")
return result


def __format_raw_surname(raw_surn_data):
"""
Return a formatted string representing one surname part.
If the connector is a hyphen, don't pad it with spaces.
"""
result = raw_surn_data[_PREFIX_IN_LIST]
if result:
result += " "
result += raw_surn_data[_SURNAME_IN_LIST]
if result and raw_surn_data[_CONNECTOR_IN_LIST] != "-":
result += " %s " % raw_surn_data[_CONNECTOR_IN_LIST]
else:
result += raw_surn_data[_CONNECTOR_IN_LIST]
return result


Expand Down

0 comments on commit 0e13030

Please sign in to comment.