this does the work of rewriting elife title prefix json values
325419
def rewrite_elife_title_prefix_json(json_content, doi):
    
    if not json_content:
        return json_content

    # title prefix rewrites by article DOI
    title_prefix_values = {}
    title_prefix_values["10.7554/eLife.00452"] = "Point of View"
    title_prefix_values["10.7554/eLife.00615"] = "Point of View"
    title_prefix_values["10.7554/eLife.00639"] = "Point of View"
    title_prefix_values["10.7554/eLife.00642"] = "Point of View"
    title_prefix_values["10.7554/eLife.00856"] = "Point of View"
    title_prefix_values["10.7554/eLife.01061"] = "Point of View"
    title_prefix_values["10.7554/eLife.01138"] = "Point of View"
    title_prefix_values["10.7554/eLife.01139"] = "Point of View"
    title_prefix_values["10.7554/eLife.01820"] = "Animal Models of Disease"
    title_prefix_values["10.7554/eLife.02576"] = "Point of View"
    title_prefix_values["10.7554/eLife.04902"] = "Point of View"
    title_prefix_values["10.7554/eLife.05614"] = "Point of View"
    title_prefix_values["10.7554/eLife.05635"] = "The Natural History of Model Organisms"
    title_prefix_values["10.7554/eLife.05826"] = "The Natural History of Model Organisms"
    title_prefix_values["10.7554/eLife.05835"] = "The Natural History of Model Organisms"
    title_prefix_values["10.7554/eLife.05849"] = "The Natural History of Model Organisms"
    title_prefix_values["10.7554/eLife.05861"] = "The Natural History of Model Organisms"
    title_prefix_values["10.7554/eLife.05959"] = "The Natural History of Model Organisms"
    title_prefix_values["10.7554/eLife.06024"] = "The Natural History of Model Organisms"
    title_prefix_values["10.7554/eLife.06100"] = "The Natural History of Model Organisms"
    title_prefix_values["10.7554/eLife.06793"] = "The Natural History of Model Organisms"
    title_prefix_values["10.7554/eLife.06813"] = "The Natural History of Model Organisms"
    title_prefix_values["10.7554/eLife.06956"] = "The Natural History of Model Organisms"
    title_prefix_values["10.7554/eLife.09305"] = "Point of View"
    title_prefix_values["10.7554/eLife.10825"] = "Point of View"
    title_prefix_values["10.7554/eLife.11628"] = "Living Science"
    title_prefix_values["10.7554/eLife.12708"] = "Point of View"
    title_prefix_values["10.7554/eLife.12844"] = "Point of View"
    title_prefix_values["10.7554/eLife.13035"] = "Point of View"
    title_prefix_values["10.7554/eLife.14258"] = "Cutting Edge"
    title_prefix_values["10.7554/eLife.14424"] = "Point of View"
    title_prefix_values["10.7554/eLife.14511"] = "Cell Proliferation"
    title_prefix_values["10.7554/eLife.14721"] = "Intracellular Bacteria"
    title_prefix_values["10.7554/eLife.14790"] = "Decision Making"
    title_prefix_values["10.7554/eLife.14830"] = "Progenitor Cells"
    title_prefix_values["10.7554/eLife.14953"] = "Gene Expression"
    title_prefix_values["10.7554/eLife.14973"] = "Breast Cancer"
    title_prefix_values["10.7554/eLife.15352"] = "Autoimmune Disorders"
    title_prefix_values["10.7554/eLife.15438"] = "Motor Circuits"
    title_prefix_values["10.7554/eLife.15591"] = "Protein Tagging"
    title_prefix_values["10.7554/eLife.15928"] = "Point of View"
    title_prefix_values["10.7554/eLife.15938"] = "Cancer Metabolism"
    title_prefix_values["10.7554/eLife.15957"] = "Stem Cells"
    title_prefix_values["10.7554/eLife.15963"] = "Prediction Error"
    title_prefix_values["10.7554/eLife.16019"] = "Social Networks"
    title_prefix_values["10.7554/eLife.16076"] = "mRNA Decay"
    title_prefix_values["10.7554/eLife.16207"] = "Cardiac Development"
    title_prefix_values["10.7554/eLife.16209"] = "Neural Coding"
    title_prefix_values["10.7554/eLife.16393"] = "Neural Circuits"
    title_prefix_values["10.7554/eLife.16598"] = "RNA Localization"
    title_prefix_values["10.7554/eLife.16758"] = "Adaptive Evolution"
    title_prefix_values["10.7554/eLife.16800"] = "Point of View"
    title_prefix_values["10.7554/eLife.16846"] = "Living Science"
    title_prefix_values["10.7554/eLife.16931"] = "Point of View"
    title_prefix_values["10.7554/eLife.16964"] = "Ion Channels"
    title_prefix_values["10.7554/eLife.17224"] = "Host-virus Interactions"
    title_prefix_values["10.7554/eLife.17293"] = "Ion Channels"
    title_prefix_values["10.7554/eLife.17393"] = "Point of View"
    title_prefix_values["10.7554/eLife.17394"] = "p53 Family Proteins"
    title_prefix_values["10.7554/eLife.18203"] = "Antibody Engineering"
    title_prefix_values["10.7554/eLife.18243"] = "Host-virus Interactions"
    title_prefix_values["10.7554/eLife.18365"] = "DNA Repair"
    title_prefix_values["10.7554/eLife.18431"] = "Unfolded Protein Response"
    title_prefix_values["10.7554/eLife.18435"] = "Long Distance Transport"
    title_prefix_values["10.7554/eLife.18721"] = "Decision Making"
    title_prefix_values["10.7554/eLife.18753"] = "Resource Competition"
    title_prefix_values["10.7554/eLife.18871"] = "Mathematical Modeling"
    title_prefix_values["10.7554/eLife.18887"] = "Sensorimotor Transformation"
    title_prefix_values["10.7554/eLife.19285"] = "Genetic Screen"
    title_prefix_values["10.7554/eLife.19351"] = "Motor Control"
    title_prefix_values["10.7554/eLife.19405"] = "Membrane Structures"
    title_prefix_values["10.7554/eLife.19733"] = "Focal Adhesions"
    title_prefix_values["10.7554/eLife.20043"] = "Amyloid-beta Peptides"
    title_prefix_values["10.7554/eLife.20314"] = "Plant Reproduction"
    title_prefix_values["10.7554/eLife.20468"] = "Endoplasmic Reticulum"
    title_prefix_values["10.7554/eLife.20516"] = "Innate Like Lymphocytes"
    title_prefix_values["10.7554/eLife.21070"] = "Scientific Publishing"
    title_prefix_values["10.7554/eLife.21236"] = "Developmental Neuroscience"
    title_prefix_values["10.7554/eLife.21522"] = "Developmental Neuroscience"
    title_prefix_values["10.7554/eLife.21723"] = "Living Science"
    title_prefix_values["10.7554/eLife.21863"] = "Genetic Screening"
    title_prefix_values["10.7554/eLife.21864"] = "Evolutionary Biology"
    title_prefix_values["10.7554/eLife.22073"] = "Unfolded Protein Response"
    title_prefix_values["10.7554/eLife.22186"] = "Point of View"
    title_prefix_values["10.7554/eLife.22215"] = "Neural Wiring"
    title_prefix_values["10.7554/eLife.22256"] = "Molecular Communication"
    title_prefix_values["10.7554/eLife.22471"] = "Point of View"
    title_prefix_values["10.7554/eLife.22661"] = "Reproducibility in Cancer Biology"
    title_prefix_values["10.7554/eLife.22662"] = "Reproducibility in Cancer Biology"
    title_prefix_values["10.7554/eLife.22735"] = "Motor Networks"
    title_prefix_values["10.7554/eLife.22850"] = "Heat Shock Response"
    title_prefix_values["10.7554/eLife.22915"] = "Reproducibility in Cancer Biology"
    title_prefix_values["10.7554/eLife.22926"] = "Skeletal Stem Cells"
    title_prefix_values["10.7554/eLife.23375"] = "Social Evolution"
    title_prefix_values["10.7554/eLife.23383"] = "Reproducibility in Cancer Biology"
    title_prefix_values["10.7554/eLife.23447"] = "Genetic Rearrangement"
    title_prefix_values["10.7554/eLife.23693"] = "Reproducibility in Cancer Biology"
    title_prefix_values["10.7554/eLife.23804"] = "Point of View"
    title_prefix_values["10.7554/eLife.24038"] = "Cell Division"
    title_prefix_values["10.7554/eLife.24052"] = "DNA Replication"
    title_prefix_values["10.7554/eLife.24106"] = "Germ Granules"
    title_prefix_values["10.7554/eLife.24238"] = "Tumor Angiogenesis"
    title_prefix_values["10.7554/eLife.24276"] = "Stem Cells"
    title_prefix_values["10.7554/eLife.24611"] = "Point of View"
    title_prefix_values["10.7554/eLife.24896"] = "Visual Behavior"
    title_prefix_values["10.7554/eLife.25000"] = "Chromatin Mapping"
    title_prefix_values["10.7554/eLife.25001"] = "Cell Cycle"
    title_prefix_values["10.7554/eLife.25159"] = "Ion Channels"
    title_prefix_values["10.7554/eLife.25358"] = "Cell Division"
    title_prefix_values["10.7554/eLife.25375"] = "Membrane Phase Separation"
    title_prefix_values["10.7554/eLife.25408"] = "Plain-language Summaries of Research"
    title_prefix_values["10.7554/eLife.25410"] = "Plain-language Summaries of Research"
    title_prefix_values["10.7554/eLife.25411"] = "Plain-language Summaries of Research"
    title_prefix_values["10.7554/eLife.25412"] = "Plain-language Summaries of Research"
    title_prefix_values["10.7554/eLife.25431"] = "Genetic Diversity"
    title_prefix_values["10.7554/eLife.25654"] = "Systems Biology"
    title_prefix_values["10.7554/eLife.25669"] = "Paternal Effects"
    title_prefix_values["10.7554/eLife.25700"] = "TOR Signaling"
    title_prefix_values["10.7554/eLife.25835"] = "Cutting Edge"
    title_prefix_values["10.7554/eLife.25858"] = "Developmental Biology"
    title_prefix_values["10.7554/eLife.25956"] = "Point of View"
    title_prefix_values["10.7554/eLife.25996"] = "Cancer Therapeutics"
    title_prefix_values["10.7554/eLife.26295"] = "Point of View"
    title_prefix_values["10.7554/eLife.26401"] = "Object Recognition"
    title_prefix_values["10.7554/eLife.26775"] = "Human Evolution"
    title_prefix_values["10.7554/eLife.26787"] = "Cutting Edge"
    title_prefix_values["10.7554/eLife.26942"] = "Alzheimer’s Disease"
    title_prefix_values["10.7554/eLife.27085"] = "Translational Control"
    title_prefix_values["10.7554/eLife.27198"] = "Cell Signaling"
    title_prefix_values["10.7554/eLife.27438"] = "Point of View"
    title_prefix_values["10.7554/eLife.27467"] = "Evolutionary Developmental Biology"
    title_prefix_values["10.7554/eLife.27605"] = "Population Genetics"
    title_prefix_values["10.7554/eLife.27933"] = "Ion Channels"
    title_prefix_values["10.7554/eLife.27982"] = "Living Science"
    title_prefix_values["10.7554/eLife.28339"] = "Oncogene Regulation"
    title_prefix_values["10.7554/eLife.28514"] = "Maternal Behavior"
    title_prefix_values["10.7554/eLife.28699"] = "Point of View"
    title_prefix_values["10.7554/eLife.28757"] = "Mitochondrial Homeostasis"
    title_prefix_values["10.7554/eLife.29056"] = "Gene Variation"
    title_prefix_values["10.7554/eLife.29104"] = "Cardiac Hypertrophy"
    title_prefix_values["10.7554/eLife.29502"] = "Meiotic Recombination"
    title_prefix_values["10.7554/eLife.29586"] = "Virus Evolution"
    title_prefix_values["10.7554/eLife.29942"] = "Post-translational Modifications"
    title_prefix_values["10.7554/eLife.30076"] = "Scientific Publishing"
    title_prefix_values["10.7554/eLife.30183"] = "Point of View"
    title_prefix_values["10.7554/eLife.30194"] = "Organ Development"
    title_prefix_values["10.7554/eLife.30249"] = "Tissue Regeneration"
    title_prefix_values["10.7554/eLife.30280"] = "Adverse Drug Reactions"
    title_prefix_values["10.7554/eLife.30599"] = "Living Science"
    title_prefix_values["10.7554/eLife.30865"] = "Stone Tool Use"
    title_prefix_values["10.7554/eLife.31106"] = "Sensory Neurons"
    title_prefix_values["10.7554/eLife.31328"] = "Drought Stress"
    title_prefix_values["10.7554/eLife.31697"] = "Scientific Publishing"
    title_prefix_values["10.7554/eLife.31808"] = "Tissue Engineering"
    title_prefix_values["10.7554/eLife.31816"] = "Sound Processing"
    title_prefix_values["10.7554/eLife.32011"] = "Peer Review"
    title_prefix_values["10.7554/eLife.32012"] = "Peer Review"
    title_prefix_values["10.7554/eLife.32014"] = "Peer Review"
    title_prefix_values["10.7554/eLife.32015"] = "Peer Review"
    title_prefix_values["10.7554/eLife.32016"] = "Peer Review"
    title_prefix_values["10.7554/eLife.32715"] = "Point of View"

    # Edge case fix title prefix values
    if doi in title_prefix_values:
        # Do a quick sanity check, only replace if the lowercase comparison is equal
        #  just in case the value has been changed to something else we will not replace it
        if json_content.lower() == title_prefix_values[doi].lower():
            json_content = title_prefix_values[doi]

    return json_content
1261641
def fill_prefixes(key, value, prefix, prefixes)
      prefixes = {} if prefixes.nil?
      if prefix.size == 1
        pr = prefix.to_i
        prefixes[pr] ||= {}
        prefixes[pr][key] = value
      else
        pr = prefix[0].to_i
        prefixes[pr] = fill_prefixes(key, value, prefix[1..-1], prefixes[pr])
      end
      prefixes
    end
108037
def json2pattern(s):
    
    # make valid JSON by wrapping field names in quotes
    s, _ = re.subn(r'([{,])\s*([^,{\s\'"]+)\s*:', ' \\1 "\\2" : ', s)
    # handle shell values that are not valid JSON
    s = shell2json(s)
    # convert to 1 where possible, to get rid of things like new Date(...)
    s, n = re.subn(r'([:,\[])\s*([^{}\[\]"]+?)\s*([,}\]])', '\\1 1 \\3', s)
    # now convert to dictionary, converting unicode to ascii
    try:
        doc = json.loads(s, object_hook=_decode_pattern_dict)
        return json.dumps(doc, sort_keys=True, separators=(', ', ': '))
    except ValueError as ex:
        return None
315655
def rewrite_elife_editors_json(json_content, doi):
    

    # 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
236360
Map<String, String> processJsonInputs(Iterable<CompilerInput> inputsToProcess) {
    RewriteJsonToModule rewriteJson = new RewriteJsonToModule(this);
    for (CompilerInput input : inputsToProcess) {
      if (!input.getSourceFile().getOriginalPath().endsWith(".json")) {
        continue;
      }

      input.setCompiler(this);
      try {
        // JSON objects need wrapped in parens to parse properly
        input.getSourceFile().setCode("(" + input.getSourceFile().getCode() + ")");
      } catch (IOException e) {
        continue;
      }

      Node root = checkNotNull(input.getAstRoot(this));
      input.setJsModuleType(CompilerInput.ModuleType.JSON);
      rewriteJson.process(null, root);
    }
    return rewriteJson.getPackageJsonMainEntries();
  }
198057
function pickPrefix(prefix, object) {
    var length = prefix.length;
    var sub;
    return foldl(
      function(acc, val, key) {
        if (key.substr(0, length) === prefix) {
          sub = key.substr(length);
          acc[sub] = val;
        }
        return acc;
      },
      {},
      object
    );
  }
1251310
public function remakeJson()
    {
        $json = json_encode([
            'last_remote_check' => (!is_null($this->lastRemoteCheck) ? $this->lastRemoteCheck->timestamp : null),
            'hooks'             => $this->hooks(),
        ], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);

        file_put_contents(base_path('hooks/hooks.json'), $json);
    }
600577
function rewriteJSONFile(filePath, rewriteFile, generator) {
    const jsonObj = generator.fs.readJSON(filePath);
    rewriteFile(jsonObj, generator);
    generator.fs.writeJSON(filePath, jsonObj, null, 2);
}
6410
def _fix_json_agents(ag_obj):
    """"""
    if isinstance(ag_obj, str):
        logger.info("Fixing string agent: %s." % ag_obj)
        ret = {'name': ag_obj, 'db_refs': {'TEXT': ag_obj}}
    elif isinstance(ag_obj, list):
        # Recursive for complexes and similar.
        ret = [_fix_json_agents(ag) for ag in ag_obj]
    elif isinstance(ag_obj, dict) and 'TEXT' in ag_obj.keys():
        ret = deepcopy(ag_obj)
        text = ret.pop('TEXT')
        ret['db_refs']['TEXT'] = text
    else:
        ret = ag_obj
    return ret
1256124
function(prefix, f) {
    var retF = function(env) {
        Object.keys(env)
            .forEach(function(x) {
                var val = env[x];
                if ((typeof val === 'string') &&
                    (val.indexOf(prefix) === 0)) {
                    var propName = val.substring(prefix.length,
                                                 val.length);
                    env[x] = f(propName);
                } else if (Array.isArray(val)) {
                    retF(val);
                } else if (val && (typeof val === 'object')) {
                    retF(val);
                }
            });
    };
    return retF;
}
354437
def shell2json(s):
    """"""
    replace = {
        r'BinData\(.+?\)': '1',
        r'(new )?Date\(.+?\)': '1',
        r'Timestamp\(.+?\)': '1',
        r'ObjectId\(.+?\)': '1',
        r'DBRef\(.+?\)': '1',
        r'undefined': '1',
        r'MinKey': '1',
        r'MaxKey': '1',
        r'NumberLong\(.+?\)': '1',
        r'/.+?/\w*': '1'
    }

    for key, value in replace.items():
        s = re.sub(key, value, s)

    return s
1171023
def title_prefix(soup):
    ""
    prefix = None
    display_channel_match_list = ['feature article', 'insight', 'editorial']
    for d_channel in display_channel(soup):
        if d_channel.lower() in display_channel_match_list:
            if raw_parser.sub_display_channel(soup):
                prefix = node_text(first(raw_parser.sub_display_channel(soup)))
    return prefix
705017
def update(self, title=None, body=None, state=None):
        
        data = {'title': title, 'body': body, 'state': state}
        json = None
        self._remove_none(data)

        if data:
            json = self._json(self._patch(self._api, data=dumps(data)), 200)

        if json:
            self._update_(json)
            return True
        return False
1075021
def _clean_name(self, prefix, obj):
        """"""
        return '{}{}_{}'.format(prefix, self._uid(), ''.join(c for c in obj.name if c.isalnum()))
304999
function(title, prefix) {
	      var base = mInstance.url || mInstance._url(prefix);
	      return base + '/wiki/' + title;
	    }
1133753
def flatten_json_request_body(prefix, dict_body, spec):
    """"""
    if len(spec) == 1 and 'type' in spec:
        return {prefix: to_str(dict_body, spec)}

    flat = {}
    for key, value in dict_body.items():
        node_type = spec[key]['type']
        if node_type == 'list':
            for idx, v in enumerate(value, 1):
                pref = key + '.member.' + str(idx)
                flat.update(flatten_json_request_body(
                    pref, v, spec[key]['member']))
        elif node_type == 'map':
            for idx, (k, v) in enumerate(value.items(), 1):
                pref = key + '.entry.' + str(idx)
                flat.update(flatten_json_request_body(
                    pref + '.key', k, spec[key]['key']))
                flat.update(flatten_json_request_body(
                    pref + '.value', v, spec[key]['value']))
        else:
            flat.update(flatten_json_request_body(key, value, spec[key]))

    if prefix:
        prefix = prefix + '.'
    return dict((prefix + k, v) for k, v in flat.items())
1247937
function makePrefixMap(styleProp, eventName) {
  const prefixes = {};

  prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();
  prefixes[`Webkit${styleProp}`] = `webkit${eventName}`;
  prefixes[`Moz${styleProp}`] = `moz${eventName}`;
  prefixes[`ms${styleProp}`] = `MS${eventName}`;
  prefixes[`O${styleProp}`] = `o${eventName.toLowerCase()}`;

  return prefixes;
}