prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Correction to Anthology ID 2021.paclic-1
  In PACLIC 2021 proceedings (https://aclanthology.org/volumes/2021.paclic-1/), edit the indexed name for "Joseph Marvin R. Imperial" of paper 26 (https://aclanthology.org/2021.paclic-1.26/) to "Joseph Marvin Imperial" (no R.) to combine previously indexed papers with one author below:
  
  https://aclanthology.org/people/j/joseph-marvin-imperial/
  
  
  
  
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `bin/retract_paper.py`
  Content:
  ```
  1 #! /usr/bin/env python3
  2 # -*- coding: utf-8 -*-
  3 #
  4 # Copyright 2020 Matt Post <post@cs.jhu.edu>
  5 #
  6 # Licensed under the Apache License, Version 2.0 (the "License");
  7 # you may not use this file except in compliance with the License.
  8 # You may obtain a copy of the License at
  9 #
  10 #     http://www.apache.org/licenses/LICENSE-2.0
  11 #
  12 # Unless required by applicable law or agreed to in writing, software
  13 # distributed under the License is distributed on an "AS IS" BASIS,
  14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15 # See the License for the specific language governing permissions and
  16 # limitations under the License.
  17 
  18 """
  19 Takes an Anthology ID, downloads the PDF, and produces a revision PDF
  20 with a "RETRACTED" watermark, as well as a note at the top pointing
  21 to the paper page. Also revises the XML.
  22 """
  23 
  24 import argparse
  25 import os
  26 import shutil
  27 import subprocess
  28 import sys
  29 import tempfile
  30 
  31 from string import Template
  32 
  33 from anthology.utils import (
  34     retrieve_url,
  35     deconstruct_anthology_id,
  36     make_simple_element,
  37     get_xml_file,
  38     indent,
  39 )
  40 from anthology.data import CANONICAL_URL_TEMPLATE, PDF_LOCATION_TEMPLATE
  41 from add_revision import add_revision
  42 
  43 from datetime import datetime
  44 
  45 import lxml.etree as ET
  46 
  47 template = Template(
  48     r"""\documentclass{article}
  49 \usepackage[printwatermark]{xwatermark}
  50 \usepackage{xcolor}
  51 \usepackage{graphicx}
  52 \usepackage{pdfpages}
  53 \usepackage{hyperref}
  54 \hypersetup{plainpages=false,
  55             pdfpagemode=none,
  56             colorlinks=true,
  57             unicode=true
  58 }
  59 
  60 % "allpages" didn't work
  61 \newwatermark[pages=1-1000,color=red!80,angle=45,scale=3,xpos=-6,ypos=0]{RETRACTED}
  62 
  63 % set A4
  64 \setlength{\paperwidth}{21cm}
  65 \setlength{\paperheight}{29.7cm}
  66 
  67 \special{papersize=21cm,29.7cm}
  68 \pdfpageheight\paperheight
  69 \pdfpagewidth\paperwidth
  70 \pagestyle{plain}
  71 
  72 \begin{document}
  73 
  74 \AddToShipoutPicture{%
  75   \setlength{\unitlength}{1mm}
  76   % center box at (x, y) millimeters from bottom-left corner
  77   \put(105,290){\makebox(0,0){This paper was retracted. For more information, see \url{$url}.}}
  78 }
  79 
  80 \includepdf[pages=-]{$file}
  81 
  82 \end{document}"""
  83 )
  84 
  85 
  86 def add_watermark(anth_id, workdir="."):
  87     """
  88     Downloads an Anthology paper and adds a RETRACTED watermark.
  89     """
  90     page = CANONICAL_URL_TEMPLATE.format(anth_id)
  91     url = PDF_LOCATION_TEMPLATE.format(anth_id)
  92     orig_pdf = os.path.join(workdir, "tmp.pdf")
  93 
  94     retrieve_url(url, orig_pdf)
  95 
  96     tex_file = os.path.join(workdir, f"{anth_id}.tex")
  97     print("TEX_FILE", tex_file)
  98     with open(tex_file, "w") as f:
  99         print(template.substitute(file=orig_pdf, url=page), file=f)
  100 
  101     command = f"pdflatex {tex_file}"
  102     try:
  103         subprocess.call(
  104             command, shell=True, cwd=workdir, stdout=subprocess.DEVNULL, timeout=60
  105         )
  106     except TimeoutExpired:
  107         print(
  108             "pdflatex didn't finish within 60 seconds. Do you have the CTAN watermark package installed?",
  109             file=sys.stderr,
  110         )
  111         sys.exit(1)
  112 
  113     new_pdf = f"{tex_file}".replace(".tex", ".pdf")
  114 
  115     return new_pdf
  116 
  117 
  118 def main(args):
  119     """
  120     Downloads an Anthology paper and adds a RETRACTED watermark, then updates the XML
  121     with an appropriate <revision> and <retracted> tag.
  122     """
  123 
  124     with tempfile.TemporaryDirectory() as tempdir:
  125 
  126         new_pdf = add_watermark(args.anthology_id, workdir=tempdir)
  127 
  128         add_revision(
  129             args.anthology_id,
  130             new_pdf,
  131             explanation="Retracted.",
  132             change_type="revision",
  133             dry_run=False,
  134         )
  135 
  136         xml_file = get_xml_file(args.anthology_id)
  137         collection_id, volume_id, paper_id = deconstruct_anthology_id(args.anthology_id)
  138         tree = ET.parse(xml_file)
  139         if paper_id == "0":
  140             paper = tree.getroot().find(f"./volume[@id='{volume_id}']/frontmatter")
  141         else:
  142             paper = tree.getroot().find(
  143                 f"./volume[@id='{volume_id}']/paper[@id='{paper_id}']"
  144             )
  145 
  146         if paper is None:
  147             print(f"Couldn't find paper {args.anthology_id}!", file=sys.stderr)
  148             sys.exit(2)
  149 
  150         print("Modifying the XML", file=sys.stderr)
  151         now = datetime.now()
  152         date = f"{now.year}-{now.month:02d}-{now.day:02d}"
  153         retracted_node = make_simple_element(
  154             "retracted", args.explanation, attrib={"date": date}, parent=paper
  155         )
  156         indent(tree.getroot())
  157         tree.write(xml_file, encoding="UTF-8", xml_declaration=True)
  158 
  159 
  160 if __name__ == "__main__":
  161     parser = argparse.ArgumentParser()
  162     parser.add_argument("anthology_id")
  163     parser.add_argument("explanation", help="Brief description of the changes.")
  164     args = parser.parse_args()
  165 
  166     main(args)
  167
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/bin/retract_paper.py b/bin/retract_paper.py
  --- a/bin/retract_paper.py
  +++ b/bin/retract_paper.py
  @@ -1,4 +1,4 @@
  -#! /usr/bin/env python3
  +#!/usr/bin/env python3
   # -*- coding: utf-8 -*-
   #
   # Copyright 2020 Matt Post <post@cs.jhu.edu>
  @@ -46,20 +46,17 @@
   
   template = Template(
       r"""\documentclass{article}
  -\usepackage[printwatermark]{xwatermark}
  +\usepackage[text=RETRACTED,scale=3,color=red]{draftwatermark}
   \usepackage{xcolor}
   \usepackage{graphicx}
   \usepackage{pdfpages}
   \usepackage{hyperref}
   \hypersetup{plainpages=false,
  -            pdfpagemode=none,
  +            pdfpagemode=UseNone,
               colorlinks=true,
               unicode=true
   }
   
  -% "allpages" didn't work
  -\newwatermark[pages=1-1000,color=red!80,angle=45,scale=3,xpos=-6,ypos=0]{RETRACTED}
  -
   % set A4
   \setlength{\paperwidth}{21cm}
   \setlength{\paperheight}{29.7cm}
  @@ -101,11 +98,11 @@
       command = f"pdflatex {tex_file}"
       try:
           subprocess.call(
  -            command, shell=True, cwd=workdir, stdout=subprocess.DEVNULL, timeout=60
  +            command, shell=True, cwd=workdir, stdout=subprocess.DEVNULL, timeout=30
           )
  -    except TimeoutExpired:
  +    except subprocess.TimeoutExpired:
           print(
  -            "pdflatex didn't finish within 60 seconds. Do you have the CTAN watermark package installed?",
  +            "pdflatex didn't finish within 30 seconds. Do you have the CTAN watermark package installed?",
               file=sys.stderr,
           )
           sys.exit(1)
  
verification_info: {"golden_diff": "diff --git a/bin/retract_paper.py b/bin/retract_paper.py\n--- a/bin/retract_paper.py\n+++ b/bin/retract_paper.py\n@@ -1,4 +1,4 @@\n-#! /usr/bin/env python3\n+#!/usr/bin/env python3\n # -*- coding: utf-8 -*-\n #\n # Copyright 2020 Matt Post <post@cs.jhu.edu>\n@@ -46,20 +46,17 @@\n \n template = Template(\n     r\"\"\"\\documentclass{article}\n-\\usepackage[printwatermark]{xwatermark}\n+\\usepackage[text=RETRACTED,scale=3,color=red]{draftwatermark}\n \\usepackage{xcolor}\n \\usepackage{graphicx}\n \\usepackage{pdfpages}\n \\usepackage{hyperref}\n \\hypersetup{plainpages=false,\n-            pdfpagemode=none,\n+            pdfpagemode=UseNone,\n             colorlinks=true,\n             unicode=true\n }\n \n-% \"allpages\" didn't work\n-\\newwatermark[pages=1-1000,color=red!80,angle=45,scale=3,xpos=-6,ypos=0]{RETRACTED}\n-\n % set A4\n \\setlength{\\paperwidth}{21cm}\n \\setlength{\\paperheight}{29.7cm}\n@@ -101,11 +98,11 @@\n     command = f\"pdflatex {tex_file}\"\n     try:\n         subprocess.call(\n-            command, shell=True, cwd=workdir, stdout=subprocess.DEVNULL, timeout=60\n+            command, shell=True, cwd=workdir, stdout=subprocess.DEVNULL, timeout=30\n         )\n-    except TimeoutExpired:\n+    except subprocess.TimeoutExpired:\n         print(\n-            \"pdflatex didn't finish within 60 seconds. Do you have the CTAN watermark package installed?\",\n+            \"pdflatex didn't finish within 30 seconds. Do you have the CTAN watermark package installed?\",\n             file=sys.stderr,\n         )\n         sys.exit(1)\n", "issue": "Correction to Anthology ID 2021.paclic-1\nIn PACLIC 2021 proceedings (https://aclanthology.org/volumes/2021.paclic-1/), edit the indexed name for \"Joseph Marvin R. Imperial\" of paper 26 (https://aclanthology.org/2021.paclic-1.26/) to \"Joseph Marvin Imperial\" (no R.) to combine previously indexed papers with one author below:\r\n\r\nhttps://aclanthology.org/people/j/joseph-marvin-imperial/\r\n\r\n\r\n\r\n\r\n\n", "before_files": [{"content": "#! /usr/bin/env python3\n# -*- coding: utf-8 -*-\n#\n# Copyright 2020 Matt Post <post@cs.jhu.edu>\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"\nTakes an Anthology ID, downloads the PDF, and produces a revision PDF\nwith a \"RETRACTED\" watermark, as well as a note at the top pointing\nto the paper page. Also revises the XML.\n\"\"\"\n\nimport argparse\nimport os\nimport shutil\nimport subprocess\nimport sys\nimport tempfile\n\nfrom string import Template\n\nfrom anthology.utils import (\n    retrieve_url,\n    deconstruct_anthology_id,\n    make_simple_element,\n    get_xml_file,\n    indent,\n)\nfrom anthology.data import CANONICAL_URL_TEMPLATE, PDF_LOCATION_TEMPLATE\nfrom add_revision import add_revision\n\nfrom datetime import datetime\n\nimport lxml.etree as ET\n\ntemplate = Template(\n    r\"\"\"\\documentclass{article}\n\\usepackage[printwatermark]{xwatermark}\n\\usepackage{xcolor}\n\\usepackage{graphicx}\n\\usepackage{pdfpages}\n\\usepackage{hyperref}\n\\hypersetup{plainpages=false,\n            pdfpagemode=none,\n            colorlinks=true,\n            unicode=true\n}\n\n% \"allpages\" didn't work\n\\newwatermark[pages=1-1000,color=red!80,angle=45,scale=3,xpos=-6,ypos=0]{RETRACTED}\n\n% set A4\n\\setlength{\\paperwidth}{21cm}\n\\setlength{\\paperheight}{29.7cm}\n\n\\special{papersize=21cm,29.7cm}\n\\pdfpageheight\\paperheight\n\\pdfpagewidth\\paperwidth\n\\pagestyle{plain}\n\n\\begin{document}\n\n\\AddToShipoutPicture{%\n  \\setlength{\\unitlength}{1mm}\n  % center box at (x, y) millimeters from bottom-left corner\n  \\put(105,290){\\makebox(0,0){This paper was retracted. For more information, see \\url{$url}.}}\n}\n\n\\includepdf[pages=-]{$file}\n\n\\end{document}\"\"\"\n)\n\n\ndef add_watermark(anth_id, workdir=\".\"):\n    \"\"\"\n    Downloads an Anthology paper and adds a RETRACTED watermark.\n    \"\"\"\n    page = CANONICAL_URL_TEMPLATE.format(anth_id)\n    url = PDF_LOCATION_TEMPLATE.format(anth_id)\n    orig_pdf = os.path.join(workdir, \"tmp.pdf\")\n\n    retrieve_url(url, orig_pdf)\n\n    tex_file = os.path.join(workdir, f\"{anth_id}.tex\")\n    print(\"TEX_FILE\", tex_file)\n    with open(tex_file, \"w\") as f:\n        print(template.substitute(file=orig_pdf, url=page), file=f)\n\n    command = f\"pdflatex {tex_file}\"\n    try:\n        subprocess.call(\n            command, shell=True, cwd=workdir, stdout=subprocess.DEVNULL, timeout=60\n        )\n    except TimeoutExpired:\n        print(\n            \"pdflatex didn't finish within 60 seconds. Do you have the CTAN watermark package installed?\",\n            file=sys.stderr,\n        )\n        sys.exit(1)\n\n    new_pdf = f\"{tex_file}\".replace(\".tex\", \".pdf\")\n\n    return new_pdf\n\n\ndef main(args):\n    \"\"\"\n    Downloads an Anthology paper and adds a RETRACTED watermark, then updates the XML\n    with an appropriate <revision> and <retracted> tag.\n    \"\"\"\n\n    with tempfile.TemporaryDirectory() as tempdir:\n\n        new_pdf = add_watermark(args.anthology_id, workdir=tempdir)\n\n        add_revision(\n            args.anthology_id,\n            new_pdf,\n            explanation=\"Retracted.\",\n            change_type=\"revision\",\n            dry_run=False,\n        )\n\n        xml_file = get_xml_file(args.anthology_id)\n        collection_id, volume_id, paper_id = deconstruct_anthology_id(args.anthology_id)\n        tree = ET.parse(xml_file)\n        if paper_id == \"0\":\n            paper = tree.getroot().find(f\"./volume[@id='{volume_id}']/frontmatter\")\n        else:\n            paper = tree.getroot().find(\n                f\"./volume[@id='{volume_id}']/paper[@id='{paper_id}']\"\n            )\n\n        if paper is None:\n            print(f\"Couldn't find paper {args.anthology_id}!\", file=sys.stderr)\n            sys.exit(2)\n\n        print(\"Modifying the XML\", file=sys.stderr)\n        now = datetime.now()\n        date = f\"{now.year}-{now.month:02d}-{now.day:02d}\"\n        retracted_node = make_simple_element(\n            \"retracted\", args.explanation, attrib={\"date\": date}, parent=paper\n        )\n        indent(tree.getroot())\n        tree.write(xml_file, encoding=\"UTF-8\", xml_declaration=True)\n\n\nif __name__ == \"__main__\":\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\"anthology_id\")\n    parser.add_argument(\"explanation\", help=\"Brief description of the changes.\")\n    args = parser.parse_args()\n\n    main(args)\n", "path": "bin/retract_paper.py"}], "after_files": [{"content": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n#\n# Copyright 2020 Matt Post <post@cs.jhu.edu>\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"\nTakes an Anthology ID, downloads the PDF, and produces a revision PDF\nwith a \"RETRACTED\" watermark, as well as a note at the top pointing\nto the paper page. Also revises the XML.\n\"\"\"\n\nimport argparse\nimport os\nimport shutil\nimport subprocess\nimport sys\nimport tempfile\n\nfrom string import Template\n\nfrom anthology.utils import (\n    retrieve_url,\n    deconstruct_anthology_id,\n    make_simple_element,\n    get_xml_file,\n    indent,\n)\nfrom anthology.data import CANONICAL_URL_TEMPLATE, PDF_LOCATION_TEMPLATE\nfrom add_revision import add_revision\n\nfrom datetime import datetime\n\nimport lxml.etree as ET\n\ntemplate = Template(\n    r\"\"\"\\documentclass{article}\n\\usepackage[text=RETRACTED,scale=3,color=red]{draftwatermark}\n\\usepackage{xcolor}\n\\usepackage{graphicx}\n\\usepackage{pdfpages}\n\\usepackage{hyperref}\n\\hypersetup{plainpages=false,\n            pdfpagemode=UseNone,\n            colorlinks=true,\n            unicode=true\n}\n\n% set A4\n\\setlength{\\paperwidth}{21cm}\n\\setlength{\\paperheight}{29.7cm}\n\n\\special{papersize=21cm,29.7cm}\n\\pdfpageheight\\paperheight\n\\pdfpagewidth\\paperwidth\n\\pagestyle{plain}\n\n\\begin{document}\n\n\\AddToShipoutPicture{%\n  \\setlength{\\unitlength}{1mm}\n  % center box at (x, y) millimeters from bottom-left corner\n  \\put(105,290){\\makebox(0,0){This paper was retracted. For more information, see \\url{$url}.}}\n}\n\n\\includepdf[pages=-]{$file}\n\n\\end{document}\"\"\"\n)\n\n\ndef add_watermark(anth_id, workdir=\".\"):\n    \"\"\"\n    Downloads an Anthology paper and adds a RETRACTED watermark.\n    \"\"\"\n    page = CANONICAL_URL_TEMPLATE.format(anth_id)\n    url = PDF_LOCATION_TEMPLATE.format(anth_id)\n    orig_pdf = os.path.join(workdir, \"tmp.pdf\")\n\n    retrieve_url(url, orig_pdf)\n\n    tex_file = os.path.join(workdir, f\"{anth_id}.tex\")\n    print(\"TEX_FILE\", tex_file)\n    with open(tex_file, \"w\") as f:\n        print(template.substitute(file=orig_pdf, url=page), file=f)\n\n    command = f\"pdflatex {tex_file}\"\n    try:\n        subprocess.call(\n            command, shell=True, cwd=workdir, stdout=subprocess.DEVNULL, timeout=30\n        )\n    except subprocess.TimeoutExpired:\n        print(\n            \"pdflatex didn't finish within 30 seconds. Do you have the CTAN watermark package installed?\",\n            file=sys.stderr,\n        )\n        sys.exit(1)\n\n    new_pdf = f\"{tex_file}\".replace(\".tex\", \".pdf\")\n\n    return new_pdf\n\n\ndef main(args):\n    \"\"\"\n    Downloads an Anthology paper and adds a RETRACTED watermark, then updates the XML\n    with an appropriate <revision> and <retracted> tag.\n    \"\"\"\n\n    with tempfile.TemporaryDirectory() as tempdir:\n\n        new_pdf = add_watermark(args.anthology_id, workdir=tempdir)\n\n        add_revision(\n            args.anthology_id,\n            new_pdf,\n            explanation=\"Retracted.\",\n            change_type=\"revision\",\n            dry_run=False,\n        )\n\n        xml_file = get_xml_file(args.anthology_id)\n        collection_id, volume_id, paper_id = deconstruct_anthology_id(args.anthology_id)\n        tree = ET.parse(xml_file)\n        if paper_id == \"0\":\n            paper = tree.getroot().find(f\"./volume[@id='{volume_id}']/frontmatter\")\n        else:\n            paper = tree.getroot().find(\n                f\"./volume[@id='{volume_id}']/paper[@id='{paper_id}']\"\n            )\n\n        if paper is None:\n            print(f\"Couldn't find paper {args.anthology_id}!\", file=sys.stderr)\n            sys.exit(2)\n\n        print(\"Modifying the XML\", file=sys.stderr)\n        now = datetime.now()\n        date = f\"{now.year}-{now.month:02d}-{now.day:02d}\"\n        retracted_node = make_simple_element(\n            \"retracted\", args.explanation, attrib={\"date\": date}, parent=paper\n        )\n        indent(tree.getroot())\n        tree.write(xml_file, encoding=\"UTF-8\", xml_declaration=True)\n\n\nif __name__ == \"__main__\":\n    parser = argparse.ArgumentParser()\n    parser.add_argument(\"anthology_id\")\n    parser.add_argument(\"explanation\", help=\"Brief description of the changes.\")\n    args = parser.parse_args()\n\n    main(args)\n", "path": "bin/retract_paper.py"}]}