Merge pull request #4 from eigenmagic/comment-join

Change comment merge join to use ', ' not '\n'.
This commit is contained in:
Justin Warren 2022-12-21 09:08:29 +11:00 committed by GitHub
commit 4bf68019fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -148,7 +148,7 @@ def merge_blocklists(blocklists: dict, mergeplan: str='max') -> dict:
def apply_mergeplan(oldblock: dict, newblock: dict, mergeplan: str='max') -> dict: def apply_mergeplan(oldblock: dict, newblock: dict, mergeplan: str='max') -> dict:
"""Use a mergeplan to decide how to merge two overlapping block definitions """Use a mergeplan to decide how to merge two overlapping block definitions
@param oldblock: The exist block definition. @param oldblock: The existing block definition.
@param newblock: The new block definition we want to merge in. @param newblock: The new block definition we want to merge in.
@param mergeplan: How to merge. Choices are 'max', the default, and 'min'. @param mergeplan: How to merge. Choices are 'max', the default, and 'min'.
""" """
@ -156,13 +156,13 @@ def apply_mergeplan(oldblock: dict, newblock: dict, mergeplan: str='max') -> dic
blockdata = oldblock.copy() blockdata = oldblock.copy()
# If the public or private comment is different, # If the public or private comment is different,
# append it to the existing comment, joined with a newline # append it to the existing comment, joined with ', '
# unless the comment is None or an empty string # unless the comment is None or an empty string
keylist = ['public_comment', 'private_comment'] keylist = ['public_comment', 'private_comment']
for key in keylist: for key in keylist:
try: try:
if oldblock[key] != newblock[key] and newblock[key] not in ['', None]: if oldblock[key] != newblock[key] and newblock[key] not in ['', None]:
blockdata[key] = '\n'.join([oldblock[key], newblock[key]]) blockdata[key] = ', '.join([oldblock[key], newblock[key]])
except KeyError: except KeyError:
log.debug(f"Key '{key}' missing from block definition so cannot compare. Continuing...") log.debug(f"Key '{key}' missing from block definition so cannot compare. Continuing...")
continue continue