From d481e397dfa29c47afe639ae31505c751c66c29c Mon Sep 17 00:00:00 2001 From: Frisk Date: Mon, 17 May 2021 16:42:54 +0200 Subject: [PATCH] Added #208 --- extensions/base/mediawiki.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/extensions/base/mediawiki.py b/extensions/base/mediawiki.py index 977f786..54743d8 100644 --- a/extensions/base/mediawiki.py +++ b/extensions/base/mediawiki.py @@ -813,10 +813,16 @@ def compact_import_interwiki(ctx, change): # rights/rights - Assigning rights groups def get_changed_groups(change: dict, separator: str) -> [str, str]: """Creates strings comparing the changes between the user groups for the user""" + def expiry_parse_time(passed_time): + try: + return " (until " + datetime.datetime.strptime(passed_time, "%Y-%m-%dT%H:%M:%SZ").strftime("%Y-%m-%d %H:%M:%S UTC") + ")" + except ValueError: + return "" + new_group_meta = {_(t["group"]): expiry_parse_time(t.get("expiry", "infinity")) for t in change["logparams"].get("newmetadata", [])} old_groups = {_(x) for x in change["logparams"]["oldgroups"]} # translate all groups and pull them into a set new_groups = {_(x) for x in change["logparams"]["newgroups"]} added = separator.join( - ["+ " + x for x in new_groups - old_groups]) # add + before every string and join them with separator + ["+ " + x + new_group_meta.get(x, "") for x in new_groups - old_groups]) # add + before every string and join them with separator removed = separator.join(["- " + x for x in old_groups - new_groups]) return added, removed