def rewrite_elife_editors_json(json_content, doi):
    """ this does the work of rewriting elife editors json """

    # Remove affiliations with no name value
    for i, ref in enumerate(json_content):
        if ref.get("affiliations"):
            for aff in ref.get("affiliations"):
                if "name" not in aff:
                    del(json_content[i]["affiliations"])

    # Add editor role
    editor_roles = {}
    editor_roles["10.7554/eLife.00534"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.09376"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.10056"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.11031"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.12081"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.12241"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.12509"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.13023"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.13053"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.13426"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.13620"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.13810"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.13828"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.13887"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.13905"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.14000"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.14155"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.14170"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.14226"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.14277"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.14315"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.14316"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.14530"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.14601"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.14618"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.14749"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.14814"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.15266"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.15275"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.15292"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.15316"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.15470"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.15545"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.15716"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.15747"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.15828"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.15833"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.15915"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.15986"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.16088"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.16093"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.16127"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.16159"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.16178"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.16309"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.16777"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.16793"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.16950"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.17101"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.17180"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.17240"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.17262"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.17282"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.17463"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.17551"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.17667"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.17681"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.17978"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.17985"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.18103"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.18207"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.18246"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.18249"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.18432"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.18447"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.18458"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.18491"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.18541"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.18542"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.18579"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.18605"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.18633"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.18657"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.18919"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.18970"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19027"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19088"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19089"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19295"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19377"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19406"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19466"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19484"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19505"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19535"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19568"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19573"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19662"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19671"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19686"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19695"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19720"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19749"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19766"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19804"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19809"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19887"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19976"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.19991"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20010"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20054"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20070"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20183"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20185"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20214"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20236"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20309"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20343"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20357"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20362"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20365"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20390"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20417"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20515"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20533"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20607"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20640"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20667"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20718"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20722"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20777"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20782"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20787"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20797"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20799"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20813"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20954"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20958"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.20985"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.21032"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.21049"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.21052"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.21170"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.21172"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.21290"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.21330"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.21394"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.21397"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.21455"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.21481"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.21491"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.21589"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.21598"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.21616"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.21635"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.21728"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.21771"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.21776"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.21855"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.21886"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.21920"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.21989"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.22028"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.22053"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.22170"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.22177"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.22280"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.22409"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.22429"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.22431"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.22467"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.22472"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.22502"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.22771"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.22784"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.22866"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.23156"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.23352"] = "Reviewing Editor"
    editor_roles["10.7554/eLife.23804"] = "Reviewing Editor"

    # Edge case fix an affiliation name
    if doi in editor_roles:
        for i, ref in enumerate(json_content):
            if not ref.get("role"):
                json_content[i]["role"] = editor_roles[doi]
            elif ref.get("role"):
                json_content[i]["role"] = "Reviewing Editor"
    else:
        # Fix capitalisation on exiting role values
        for i, ref in enumerate(json_content):
            if ref.get("role") == "Reviewing editor":
                json_content[i]["role"] = "Reviewing Editor"

    # Remove duplicates
    editors_kept = []
    for i, ref in enumerate(json_content):
        editor_values = OrderedDict()
        editor_values["role"] = ref.get("role")
        if ref.get("name"):
            editor_values["name"] = ref.get("name").get("index")
        if editor_values in editors_kept:
            # remove if one is already kept
            del json_content[i]
        else:
            editors_kept.append(editor_values)

    # Merge two role values
    role_replacements = [
        {
            "role_from": ["Senior Editor", "Reviewing Editor"],
            "role_to": "Senior and Reviewing Editor"}
    ]
    for replace_rule in role_replacements:
        same_name_map = person_same_name_map(json_content, replace_rule.get('role_from'))
        role_is_set = None
        for same_id_list in same_name_map.values():
            if not same_id_list or len(same_id_list) <= 1:
                # no more than one name match, nothing to replace
                continue
            deleted_count = 0
            for same_id in same_id_list:
                if not role_is_set:
                    # reset the role for the first person record
                    json_content[same_id]["role"] = replace_rule.get("role_to")
                    role_is_set = True
                else:
                    # first one is already set, remove the duplicates
                    del json_content[same_id-deleted_count]
                    deleted_count += 1

    return json_content
def rewrite_elife_editors_json ( json_content , doi ) : for i , ref in enumerate ( json_content ) : if ref . get ( "affiliations" ) : for aff in ref . get ( "affiliations" ) : if "name" not in aff : del ( json_content [ i ] [ "affiliations" ] ) editor_roles = { } editor_roles [ "10.7554/eLife.00534" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.09376" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.10056" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.11031" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.12081" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.12241" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.12509" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.13023" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.13053" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.13426" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.13620" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.13810" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.13828" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.13887" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.13905" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.14000" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.14155" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.14170" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.14226" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.14277" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.14315" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.14316" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.14530" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.14601" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.14618" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.14749" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.14814" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.15266" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.15275" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.15292" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.15316" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.15470" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.15545" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.15716" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.15747" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.15828" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.15833" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.15915" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.15986" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.16088" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.16093" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.16127" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.16159" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.16178" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.16309" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.16777" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.16793" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.16950" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.17101" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.17180" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.17240" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.17262" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.17282" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.17463" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.17551" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.17667" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.17681" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.17978" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.17985" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.18103" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.18207" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.18246" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.18249" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.18432" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.18447" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.18458" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.18491" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.18541" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.18542" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.18579" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.18605" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.18633" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.18657" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.18919" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.18970" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19027" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19088" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19089" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19295" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19377" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19406" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19466" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19484" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19505" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19535" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19568" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19573" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19662" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19671" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19686" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19695" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19720" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19749" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19766" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19804" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19809" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19887" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19976" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.19991" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20010" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20054" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20070" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20183" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20185" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20214" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20236" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20309" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20343" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20357" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20362" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20365" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20390" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20417" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20515" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20533" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20607" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20640" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20667" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20718" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20722" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20777" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20782" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20787" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20797" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20799" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20813" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20954" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20958" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.20985" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.21032" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.21049" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.21052" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.21170" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.21172" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.21290" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.21330" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.21394" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.21397" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.21455" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.21481" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.21491" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.21589" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.21598" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.21616" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.21635" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.21728" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.21771" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.21776" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.21855" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.21886" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.21920" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.21989" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.22028" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.22053" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.22170" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.22177" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.22280" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.22409" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.22429" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.22431" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.22467" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.22472" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.22502" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.22771" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.22784" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.22866" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.23156" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.23352" ] = "Reviewing Editor" editor_roles [ "10.7554/eLife.23804" ] = "Reviewing Editor" if doi in editor_roles : for i , ref in enumerate ( json_content ) : if not ref . get ( "role" ) : json_content [ i ] [ "role" ] = editor_roles [ doi ] elif ref . get ( "role" ) : json_content [ i ] [ "role" ] = "Reviewing Editor" else : for i , ref in enumerate ( json_content ) : if ref . get ( "role" ) == "Reviewing editor" : json_content [ i ] [ "role" ] = "Reviewing Editor" editors_kept = [ ] for i , ref in enumerate ( json_content ) : editor_values = OrderedDict ( ) editor_values [ "role" ] = ref . get ( "role" ) if ref . get ( "name" ) : editor_values [ "name" ] = ref . get ( "name" ) . get ( "index" ) if editor_values in editors_kept : del json_content [ i ] else : editors_kept . append ( editor_values ) role_replacements = [ { "role_from" : [ "Senior Editor" , "Reviewing Editor" ] , "role_to" : "Senior and Reviewing Editor" } ] for replace_rule in role_replacements : same_name_map = person_same_name_map ( json_content , replace_rule . get ( 'role_from' ) ) role_is_set = None for same_id_list in same_name_map . values ( ) : if not same_id_list or len ( same_id_list ) <= 1 : continue deleted_count = 0 for same_id in same_id_list : if not role_is_set : json_content [ same_id ] [ "role" ] = replace_rule . get ( "role_to" ) role_is_set = True else : del json_content [ same_id - deleted_count ] deleted_count += 1 return json_content
this does the work of rewriting elife editors json