We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Make volumes adhere to the flat directory structure
All our files are relatively flat, but we still have nested structures for volumes (in the build dir under `anthology/papers/`).

This looks like an oversight from a previous change and noone has complained yet.
Make volumes adhere to the flat directory structure
All our files are relatively flat, but we still have nested structures for volumes (in the build dir under `anthology/papers/`).

This looks like an oversight from a previous change and noone has complained yet.

--- 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/create_hugo_pages.py`
Content:
```
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 #
4 # Copyright 2019 Marcel Bollmann <marcel@bollmann.me>
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 """Usage: create_hugo_pages.py [--dir=DIR] [-c] [--debug]
19 
20 Creates page stubs for the full anthology based on the YAML data files.
21 
22 This script can only be run after create_hugo_yaml.py!
23 
24 Options:
25   --dir=DIR                Hugo project directory. [default: {scriptdir}/../build/]
26   --debug                  Output debug-level log messages.
27   -c, --clean              Delete existing files in target directory before generation.
28   -h, --help               Display this helpful text.
29 """
30 
31 from docopt import docopt
32 from glob import glob
33 from slugify import slugify
34 from tqdm import tqdm
35 import logging as log
36 import os
37 import shutil
38 import yaml
39 
40 try:
41     from yaml import CLoader as Loader
42 except ImportError:
43     log.info("Can't load yaml C bindings, reverting to slow pure Python version")
44     from yaml import Loader
45 
46 from anthology.utils import SeverityTracker
47 
48 
49 def check_directory(cdir, clean=False):
50     if not os.path.isdir(cdir) and not os.path.exists(cdir):
51         os.mkdir(cdir)
52         return True
53     entries = os.listdir(cdir)
54     if "_index.md" in entries:
55         entries.remove("_index.md")
56     if entries and not clean:
57         log.critical("Directory already exists and has content files: {}".format(cdir))
58         log.info(
59             "Call this script with the -c/--clean flag to automatically DELETE existing files"
60         )
61         return False
62     for entry in entries:
63         entry = "{}/{}".format(cdir, entry)
64         if os.path.isdir(entry):
65             shutil.rmtree(entry)
66         else:
67             os.remove(entry)
68     return True
69 
70 
71 def create_papers(srcdir, clean=False):
72     """Creates page stubs for all papers in the Anthology."""
73     log.info("Creating stubs for papers...")
74     if not check_directory("{}/content/papers".format(srcdir), clean=clean):
75         return
76 
77     # Go through all paper volumes
78     for yamlfile in tqdm(glob("{}/data/papers/*.yaml".format(srcdir))):
79         log.debug("Processing {}".format(yamlfile))
80         with open(yamlfile, "r") as f:
81             data = yaml.load(f, Loader=Loader)
82         # Create a paper stub for each entry in the volume
83         for anthology_id, entry in data.items():
84             paper_dir = "{}/content/papers/{}".format(srcdir, anthology_id.split("-")[0])
85             if not os.path.exists(paper_dir):
86                 os.makedirs(paper_dir)
87             with open("{}/{}.md".format(paper_dir, anthology_id), "w") as f:
88                 print("---", file=f)
89                 yaml.dump(
90                     {"anthology_id": anthology_id, "title": entry["title"]},
91                     default_flow_style=False,
92                     stream=f,
93                 )
94                 print("---", file=f)
95 
96 
97 def create_volumes(srcdir, clean=False):
98     """Creates page stubs for all proceedings volumes in the Anthology."""
99     log.info("Creating stubs for volumes...")
100     if not check_directory("{}/content/volumes".format(srcdir), clean=clean):
101         return
102 
103     yamlfile = "{}/data/volumes.yaml".format(srcdir)
104     log.debug("Processing {}".format(yamlfile))
105     with open(yamlfile, "r") as f:
106         data = yaml.load(f, Loader=Loader)
107     # Create a paper stub for each proceedings volume
108     for anthology_id, entry in data.items():
109         with open("{}/content/volumes/{}.md".format(srcdir, anthology_id), "w") as f:
110             print("---", file=f)
111             paper_dir = "/papers/{}/{}/".format(anthology_id.split("-")[0], anthology_id)
112             yaml.dump(
113                 {
114                     "anthology_id": anthology_id,
115                     "title": entry["title"],
116                     "aliases": [
117                         paper_dir,
118                     ],
119                 },
120                 default_flow_style=False,
121                 stream=f,
122             )
123             print("---", file=f)
124 
125     return data
126 
127 
128 def create_people(srcdir, clean=False):
129     """Creates page stubs for all authors/editors in the Anthology."""
130     log.info("Creating stubs for people...")
131     if not check_directory("{}/content/people".format(srcdir), clean=clean):
132         return
133 
134     for yamlfile in tqdm(glob("{}/data/people/*.yaml".format(srcdir))):
135         log.debug("Processing {}".format(yamlfile))
136         with open(yamlfile, "r") as f:
137             data = yaml.load(f, Loader=Loader)
138         # Create a page stub for each person
139         for name, entry in data.items():
140             person_dir = "{}/content/people/{}".format(srcdir, name[0])
141             if not os.path.exists(person_dir):
142                 os.makedirs(person_dir)
143             yaml_data = {"name": name, "title": entry["full"], "lastname": entry["last"]}
144             with open("{}/{}.md".format(person_dir, name), "w") as f:
145                 print("---", file=f)
146                 # "lastname" is dumped to allow sorting by it in Hugo
147                 yaml.dump(yaml_data, default_flow_style=False, stream=f)
148                 print("---", file=f)
149 
150     return data
151 
152 
153 def create_venues_and_events(srcdir, clean=False):
154     """Creates page stubs for all venues and events in the Anthology."""
155     yamlfile = "{}/data/venues.yaml".format(srcdir)
156     log.debug("Processing {}".format(yamlfile))
157     with open(yamlfile, "r") as f:
158         data = yaml.load(f, Loader=Loader)
159 
160     log.info("Creating stubs for venues...")
161     if not check_directory("{}/content/venues".format(srcdir), clean=clean):
162         return
163     # Create a paper stub for each venue (e.g. ACL)
164     for venue, venue_data in data.items():
165         venue_str = venue_data["slug"]
166         with open("{}/content/venues/{}.md".format(srcdir, venue_str), "w") as f:
167             print("---", file=f)
168             yaml_data = {"venue": venue, "title": venue_data["name"]}
169             yaml.dump(yaml_data, default_flow_style=False, stream=f)
170             print("---", file=f)
171 
172     log.info("Creating stubs for events...")
173     if not check_directory("{}/content/events".format(srcdir), clean=clean):
174         return
175     # Create a paper stub for each event (= venue + year, e.g. ACL 2018)
176     for venue, venue_data in data.items():
177         venue_str = venue_data["slug"]
178         for year in venue_data["volumes_by_year"]:
179             with open(
180                 "{}/content/events/{}-{}.md".format(srcdir, venue_str, year), "w"
181             ) as f:
182                 print("---", file=f)
183                 yaml_data = {
184                     "venue": venue,
185                     "year": year,
186                     "title": "{} ({})".format(venue_data["name"], year),
187                 }
188                 yaml.dump(yaml_data, default_flow_style=False, stream=f)
189                 print("---", file=f)
190 
191 
192 def create_sigs(srcdir, clean=False):
193     """Creates page stubs for all SIGs in the Anthology."""
194     yamlfile = "{}/data/sigs.yaml".format(srcdir)
195     log.debug("Processing {}".format(yamlfile))
196     with open(yamlfile, "r") as f:
197         data = yaml.load(f, Loader=Loader)
198 
199     log.info("Creating stubs for SIGs...")
200     if not check_directory("{}/content/sigs".format(srcdir), clean=clean):
201         return
202     # Create a paper stub for each SIGS (e.g. SIGMORPHON)
203     for sig, sig_data in data.items():
204         sig_str = sig_data["slug"]
205         with open("{}/content/sigs/{}.md".format(srcdir, sig_str), "w") as f:
206             print("---", file=f)
207             yaml.dump(
208                 {
209                     "acronym": sig,
210                     "short_acronym": sig[3:] if sig.startswith("SIG") else sig,
211                     "title": sig_data["name"],
212                 },
213                 default_flow_style=False,
214                 stream=f,
215             )
216             print("---", file=f)
217 
218 
219 if __name__ == "__main__":
220     args = docopt(__doc__)
221     scriptdir = os.path.dirname(os.path.abspath(__file__))
222     if "{scriptdir}" in args["--dir"]:
223         args["--dir"] = args["--dir"].format(scriptdir=scriptdir)
224     dir_ = os.path.abspath(args["--dir"])
225 
226     log_level = log.DEBUG if args["--debug"] else log.INFO
227     log.basicConfig(format="%(levelname)-8s %(message)s", level=log_level)
228     tracker = SeverityTracker()
229     log.getLogger().addHandler(tracker)
230 
231     create_papers(dir_, clean=args["--clean"])
232     create_volumes(dir_, clean=args["--clean"])
233     create_people(dir_, clean=args["--clean"])
234     create_venues_and_events(dir_, clean=args["--clean"])
235     create_sigs(dir_, clean=args["--clean"])
236 
237     if tracker.highest >= log.ERROR:
238         exit(1)
239
```
--- 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()

```

diff --git a/bin/create_hugo_pages.py b/bin/create_hugo_pages.py
--- a/bin/create_hugo_pages.py
+++ b/bin/create_hugo_pages.py
@@ -108,14 +108,10 @@
     for anthology_id, entry in data.items():
         with open("{}/content/volumes/{}.md".format(srcdir, anthology_id), "w") as f:
             print("---", file=f)
-            paper_dir = "/papers/{}/{}/".format(anthology_id.split("-")[0], anthology_id)
             yaml.dump(
                 {
                     "anthology_id": anthology_id,
                     "title": entry["title"],
-                    "aliases": [
-                        paper_dir,
-                    ],
                 },
                 default_flow_style=False,
                 stream=f,

{"golden_diff": "diff --git a/bin/create_hugo_pages.py b/bin/create_hugo_pages.py\n--- a/bin/create_hugo_pages.py\n+++ b/bin/create_hugo_pages.py\n@@ -108,14 +108,10 @@\n     for anthology_id, entry in data.items():\n         with open(\"{}/content/volumes/{}.md\".format(srcdir, anthology_id), \"w\") as f:\n             print(\"---\", file=f)\n-            paper_dir = \"/papers/{}/{}/\".format(anthology_id.split(\"-\")[0], anthology_id)\n             yaml.dump(\n                 {\n                     \"anthology_id\": anthology_id,\n                     \"title\": entry[\"title\"],\n-                    \"aliases\": [\n-                        paper_dir,\n-                    ],\n                 },\n                 default_flow_style=False,\n                 stream=f,\n", "issue": "Make volumes adhere to the flat directory structure\nAll our files are relatively flat, but we still have nested structures for volumes (in the build dir under `anthology/papers/`).\r\n\r\nThis looks like an oversight from a previous change and noone has complained yet.\nMake volumes adhere to the flat directory structure\nAll our files are relatively flat, but we still have nested structures for volumes (in the build dir under `anthology/papers/`).\r\n\r\nThis looks like an oversight from a previous change and noone has complained yet.\n", "before_files": [{"content": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n#\n# Copyright 2019 Marcel Bollmann <marcel@bollmann.me>\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\"\"\"Usage: create_hugo_pages.py [--dir=DIR] [-c] [--debug]\n\nCreates page stubs for the full anthology based on the YAML data files.\n\nThis script can only be run after create_hugo_yaml.py!\n\nOptions:\n  --dir=DIR                Hugo project directory. [default: {scriptdir}/../build/]\n  --debug                  Output debug-level log messages.\n  -c, --clean              Delete existing files in target directory before generation.\n  -h, --help               Display this helpful text.\n\"\"\"\n\nfrom docopt import docopt\nfrom glob import glob\nfrom slugify import slugify\nfrom tqdm import tqdm\nimport logging as log\nimport os\nimport shutil\nimport yaml\n\ntry:\n    from yaml import CLoader as Loader\nexcept ImportError:\n    log.info(\"Can't load yaml C bindings, reverting to slow pure Python version\")\n    from yaml import Loader\n\nfrom anthology.utils import SeverityTracker\n\n\ndef check_directory(cdir, clean=False):\n    if not os.path.isdir(cdir) and not os.path.exists(cdir):\n        os.mkdir(cdir)\n        return True\n    entries = os.listdir(cdir)\n    if \"_index.md\" in entries:\n        entries.remove(\"_index.md\")\n    if entries and not clean:\n        log.critical(\"Directory already exists and has content files: {}\".format(cdir))\n        log.info(\n            \"Call this script with the -c/--clean flag to automatically DELETE existing files\"\n        )\n        return False\n    for entry in entries:\n        entry = \"{}/{}\".format(cdir, entry)\n        if os.path.isdir(entry):\n            shutil.rmtree(entry)\n        else:\n            os.remove(entry)\n    return True\n\n\ndef create_papers(srcdir, clean=False):\n    \"\"\"Creates page stubs for all papers in the Anthology.\"\"\"\n    log.info(\"Creating stubs for papers...\")\n    if not check_directory(\"{}/content/papers\".format(srcdir), clean=clean):\n        return\n\n    # Go through all paper volumes\n    for yamlfile in tqdm(glob(\"{}/data/papers/*.yaml\".format(srcdir))):\n        log.debug(\"Processing {}\".format(yamlfile))\n        with open(yamlfile, \"r\") as f:\n            data = yaml.load(f, Loader=Loader)\n        # Create a paper stub for each entry in the volume\n        for anthology_id, entry in data.items():\n            paper_dir = \"{}/content/papers/{}\".format(srcdir, anthology_id.split(\"-\")[0])\n            if not os.path.exists(paper_dir):\n                os.makedirs(paper_dir)\n            with open(\"{}/{}.md\".format(paper_dir, anthology_id), \"w\") as f:\n                print(\"---\", file=f)\n                yaml.dump(\n                    {\"anthology_id\": anthology_id, \"title\": entry[\"title\"]},\n                    default_flow_style=False,\n                    stream=f,\n                )\n                print(\"---\", file=f)\n\n\ndef create_volumes(srcdir, clean=False):\n    \"\"\"Creates page stubs for all proceedings volumes in the Anthology.\"\"\"\n    log.info(\"Creating stubs for volumes...\")\n    if not check_directory(\"{}/content/volumes\".format(srcdir), clean=clean):\n        return\n\n    yamlfile = \"{}/data/volumes.yaml\".format(srcdir)\n    log.debug(\"Processing {}\".format(yamlfile))\n    with open(yamlfile, \"r\") as f:\n        data = yaml.load(f, Loader=Loader)\n    # Create a paper stub for each proceedings volume\n    for anthology_id, entry in data.items():\n        with open(\"{}/content/volumes/{}.md\".format(srcdir, anthology_id), \"w\") as f:\n            print(\"---\", file=f)\n            paper_dir = \"/papers/{}/{}/\".format(anthology_id.split(\"-\")[0], anthology_id)\n            yaml.dump(\n                {\n                    \"anthology_id\": anthology_id,\n                    \"title\": entry[\"title\"],\n                    \"aliases\": [\n                        paper_dir,\n                    ],\n                },\n                default_flow_style=False,\n                stream=f,\n            )\n            print(\"---\", file=f)\n\n    return data\n\n\ndef create_people(srcdir, clean=False):\n    \"\"\"Creates page stubs for all authors/editors in the Anthology.\"\"\"\n    log.info(\"Creating stubs for people...\")\n    if not check_directory(\"{}/content/people\".format(srcdir), clean=clean):\n        return\n\n    for yamlfile in tqdm(glob(\"{}/data/people/*.yaml\".format(srcdir))):\n        log.debug(\"Processing {}\".format(yamlfile))\n        with open(yamlfile, \"r\") as f:\n            data = yaml.load(f, Loader=Loader)\n        # Create a page stub for each person\n        for name, entry in data.items():\n            person_dir = \"{}/content/people/{}\".format(srcdir, name[0])\n            if not os.path.exists(person_dir):\n                os.makedirs(person_dir)\n            yaml_data = {\"name\": name, \"title\": entry[\"full\"], \"lastname\": entry[\"last\"]}\n            with open(\"{}/{}.md\".format(person_dir, name), \"w\") as f:\n                print(\"---\", file=f)\n                # \"lastname\" is dumped to allow sorting by it in Hugo\n                yaml.dump(yaml_data, default_flow_style=False, stream=f)\n                print(\"---\", file=f)\n\n    return data\n\n\ndef create_venues_and_events(srcdir, clean=False):\n    \"\"\"Creates page stubs for all venues and events in the Anthology.\"\"\"\n    yamlfile = \"{}/data/venues.yaml\".format(srcdir)\n    log.debug(\"Processing {}\".format(yamlfile))\n    with open(yamlfile, \"r\") as f:\n        data = yaml.load(f, Loader=Loader)\n\n    log.info(\"Creating stubs for venues...\")\n    if not check_directory(\"{}/content/venues\".format(srcdir), clean=clean):\n        return\n    # Create a paper stub for each venue (e.g. ACL)\n    for venue, venue_data in data.items():\n        venue_str = venue_data[\"slug\"]\n        with open(\"{}/content/venues/{}.md\".format(srcdir, venue_str), \"w\") as f:\n            print(\"---\", file=f)\n            yaml_data = {\"venue\": venue, \"title\": venue_data[\"name\"]}\n            yaml.dump(yaml_data, default_flow_style=False, stream=f)\n            print(\"---\", file=f)\n\n    log.info(\"Creating stubs for events...\")\n    if not check_directory(\"{}/content/events\".format(srcdir), clean=clean):\n        return\n    # Create a paper stub for each event (= venue + year, e.g. ACL 2018)\n    for venue, venue_data in data.items():\n        venue_str = venue_data[\"slug\"]\n        for year in venue_data[\"volumes_by_year\"]:\n            with open(\n                \"{}/content/events/{}-{}.md\".format(srcdir, venue_str, year), \"w\"\n            ) as f:\n                print(\"---\", file=f)\n                yaml_data = {\n                    \"venue\": venue,\n                    \"year\": year,\n                    \"title\": \"{} ({})\".format(venue_data[\"name\"], year),\n                }\n                yaml.dump(yaml_data, default_flow_style=False, stream=f)\n                print(\"---\", file=f)\n\n\ndef create_sigs(srcdir, clean=False):\n    \"\"\"Creates page stubs for all SIGs in the Anthology.\"\"\"\n    yamlfile = \"{}/data/sigs.yaml\".format(srcdir)\n    log.debug(\"Processing {}\".format(yamlfile))\n    with open(yamlfile, \"r\") as f:\n        data = yaml.load(f, Loader=Loader)\n\n    log.info(\"Creating stubs for SIGs...\")\n    if not check_directory(\"{}/content/sigs\".format(srcdir), clean=clean):\n        return\n    # Create a paper stub for each SIGS (e.g. SIGMORPHON)\n    for sig, sig_data in data.items():\n        sig_str = sig_data[\"slug\"]\n        with open(\"{}/content/sigs/{}.md\".format(srcdir, sig_str), \"w\") as f:\n            print(\"---\", file=f)\n            yaml.dump(\n                {\n                    \"acronym\": sig,\n                    \"short_acronym\": sig[3:] if sig.startswith(\"SIG\") else sig,\n                    \"title\": sig_data[\"name\"],\n                },\n                default_flow_style=False,\n                stream=f,\n            )\n            print(\"---\", file=f)\n\n\nif __name__ == \"__main__\":\n    args = docopt(__doc__)\n    scriptdir = os.path.dirname(os.path.abspath(__file__))\n    if \"{scriptdir}\" in args[\"--dir\"]:\n        args[\"--dir\"] = args[\"--dir\"].format(scriptdir=scriptdir)\n    dir_ = os.path.abspath(args[\"--dir\"])\n\n    log_level = log.DEBUG if args[\"--debug\"] else log.INFO\n    log.basicConfig(format=\"%(levelname)-8s %(message)s\", level=log_level)\n    tracker = SeverityTracker()\n    log.getLogger().addHandler(tracker)\n\n    create_papers(dir_, clean=args[\"--clean\"])\n    create_volumes(dir_, clean=args[\"--clean\"])\n    create_people(dir_, clean=args[\"--clean\"])\n    create_venues_and_events(dir_, clean=args[\"--clean\"])\n    create_sigs(dir_, clean=args[\"--clean\"])\n\n    if tracker.highest >= log.ERROR:\n        exit(1)\n", "path": "bin/create_hugo_pages.py"}], "after_files": [{"content": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n#\n# Copyright 2019 Marcel Bollmann <marcel@bollmann.me>\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\"\"\"Usage: create_hugo_pages.py [--dir=DIR] [-c] [--debug]\n\nCreates page stubs for the full anthology based on the YAML data files.\n\nThis script can only be run after create_hugo_yaml.py!\n\nOptions:\n  --dir=DIR                Hugo project directory. [default: {scriptdir}/../build/]\n  --debug                  Output debug-level log messages.\n  -c, --clean              Delete existing files in target directory before generation.\n  -h, --help               Display this helpful text.\n\"\"\"\n\nfrom docopt import docopt\nfrom glob import glob\nfrom slugify import slugify\nfrom tqdm import tqdm\nimport logging as log\nimport os\nimport shutil\nimport yaml\n\ntry:\n    from yaml import CLoader as Loader\nexcept ImportError:\n    log.info(\"Can't load yaml C bindings, reverting to slow pure Python version\")\n    from yaml import Loader\n\nfrom anthology.utils import SeverityTracker\n\n\ndef check_directory(cdir, clean=False):\n    if not os.path.isdir(cdir) and not os.path.exists(cdir):\n        os.mkdir(cdir)\n        return True\n    entries = os.listdir(cdir)\n    if \"_index.md\" in entries:\n        entries.remove(\"_index.md\")\n    if entries and not clean:\n        log.critical(\"Directory already exists and has content files: {}\".format(cdir))\n        log.info(\n            \"Call this script with the -c/--clean flag to automatically DELETE existing files\"\n        )\n        return False\n    for entry in entries:\n        entry = \"{}/{}\".format(cdir, entry)\n        if os.path.isdir(entry):\n            shutil.rmtree(entry)\n        else:\n            os.remove(entry)\n    return True\n\n\ndef create_papers(srcdir, clean=False):\n    \"\"\"Creates page stubs for all papers in the Anthology.\"\"\"\n    log.info(\"Creating stubs for papers...\")\n    if not check_directory(\"{}/content/papers\".format(srcdir), clean=clean):\n        return\n\n    # Go through all paper volumes\n    for yamlfile in tqdm(glob(\"{}/data/papers/*.yaml\".format(srcdir))):\n        log.debug(\"Processing {}\".format(yamlfile))\n        with open(yamlfile, \"r\") as f:\n            data = yaml.load(f, Loader=Loader)\n        # Create a paper stub for each entry in the volume\n        for anthology_id, entry in data.items():\n            paper_dir = \"{}/content/papers/{}\".format(srcdir, anthology_id.split(\"-\")[0])\n            if not os.path.exists(paper_dir):\n                os.makedirs(paper_dir)\n            with open(\"{}/{}.md\".format(paper_dir, anthology_id), \"w\") as f:\n                print(\"---\", file=f)\n                yaml.dump(\n                    {\"anthology_id\": anthology_id, \"title\": entry[\"title\"]},\n                    default_flow_style=False,\n                    stream=f,\n                )\n                print(\"---\", file=f)\n\n\ndef create_volumes(srcdir, clean=False):\n    \"\"\"Creates page stubs for all proceedings volumes in the Anthology.\"\"\"\n    log.info(\"Creating stubs for volumes...\")\n    if not check_directory(\"{}/content/volumes\".format(srcdir), clean=clean):\n        return\n\n    yamlfile = \"{}/data/volumes.yaml\".format(srcdir)\n    log.debug(\"Processing {}\".format(yamlfile))\n    with open(yamlfile, \"r\") as f:\n        data = yaml.load(f, Loader=Loader)\n    # Create a paper stub for each proceedings volume\n    for anthology_id, entry in data.items():\n        with open(\"{}/content/volumes/{}.md\".format(srcdir, anthology_id), \"w\") as f:\n            print(\"---\", file=f)\n            yaml.dump(\n                {\n                    \"anthology_id\": anthology_id,\n                    \"title\": entry[\"title\"],\n                },\n                default_flow_style=False,\n                stream=f,\n            )\n            print(\"---\", file=f)\n\n    return data\n\n\ndef create_people(srcdir, clean=False):\n    \"\"\"Creates page stubs for all authors/editors in the Anthology.\"\"\"\n    log.info(\"Creating stubs for people...\")\n    if not check_directory(\"{}/content/people\".format(srcdir), clean=clean):\n        return\n\n    for yamlfile in tqdm(glob(\"{}/data/people/*.yaml\".format(srcdir))):\n        log.debug(\"Processing {}\".format(yamlfile))\n        with open(yamlfile, \"r\") as f:\n            data = yaml.load(f, Loader=Loader)\n        # Create a page stub for each person\n        for name, entry in data.items():\n            person_dir = \"{}/content/people/{}\".format(srcdir, name[0])\n            if not os.path.exists(person_dir):\n                os.makedirs(person_dir)\n            yaml_data = {\"name\": name, \"title\": entry[\"full\"], \"lastname\": entry[\"last\"]}\n            with open(\"{}/{}.md\".format(person_dir, name), \"w\") as f:\n                print(\"---\", file=f)\n                # \"lastname\" is dumped to allow sorting by it in Hugo\n                yaml.dump(yaml_data, default_flow_style=False, stream=f)\n                print(\"---\", file=f)\n\n    return data\n\n\ndef create_venues_and_events(srcdir, clean=False):\n    \"\"\"Creates page stubs for all venues and events in the Anthology.\"\"\"\n    yamlfile = \"{}/data/venues.yaml\".format(srcdir)\n    log.debug(\"Processing {}\".format(yamlfile))\n    with open(yamlfile, \"r\") as f:\n        data = yaml.load(f, Loader=Loader)\n\n    log.info(\"Creating stubs for venues...\")\n    if not check_directory(\"{}/content/venues\".format(srcdir), clean=clean):\n        return\n    # Create a paper stub for each venue (e.g. ACL)\n    for venue, venue_data in data.items():\n        venue_str = venue_data[\"slug\"]\n        with open(\"{}/content/venues/{}.md\".format(srcdir, venue_str), \"w\") as f:\n            print(\"---\", file=f)\n            yaml_data = {\"venue\": venue, \"title\": venue_data[\"name\"]}\n            yaml.dump(yaml_data, default_flow_style=False, stream=f)\n            print(\"---\", file=f)\n\n    log.info(\"Creating stubs for events...\")\n    if not check_directory(\"{}/content/events\".format(srcdir), clean=clean):\n        return\n    # Create a paper stub for each event (= venue + year, e.g. ACL 2018)\n    for venue, venue_data in data.items():\n        venue_str = venue_data[\"slug\"]\n        for year in venue_data[\"volumes_by_year\"]:\n            with open(\n                \"{}/content/events/{}-{}.md\".format(srcdir, venue_str, year), \"w\"\n            ) as f:\n                print(\"---\", file=f)\n                yaml_data = {\n                    \"venue\": venue,\n                    \"year\": year,\n                    \"title\": \"{} ({})\".format(venue_data[\"name\"], year),\n                }\n                yaml.dump(yaml_data, default_flow_style=False, stream=f)\n                print(\"---\", file=f)\n\n\ndef create_sigs(srcdir, clean=False):\n    \"\"\"Creates page stubs for all SIGs in the Anthology.\"\"\"\n    yamlfile = \"{}/data/sigs.yaml\".format(srcdir)\n    log.debug(\"Processing {}\".format(yamlfile))\n    with open(yamlfile, \"r\") as f:\n        data = yaml.load(f, Loader=Loader)\n\n    log.info(\"Creating stubs for SIGs...\")\n    if not check_directory(\"{}/content/sigs\".format(srcdir), clean=clean):\n        return\n    # Create a paper stub for each SIGS (e.g. SIGMORPHON)\n    for sig, sig_data in data.items():\n        sig_str = sig_data[\"slug\"]\n        with open(\"{}/content/sigs/{}.md\".format(srcdir, sig_str), \"w\") as f:\n            print(\"---\", file=f)\n            yaml.dump(\n                {\n                    \"acronym\": sig,\n                    \"short_acronym\": sig[3:] if sig.startswith(\"SIG\") else sig,\n                    \"title\": sig_data[\"name\"],\n                },\n                default_flow_style=False,\n                stream=f,\n            )\n            print(\"---\", file=f)\n\n\nif __name__ == \"__main__\":\n    args = docopt(__doc__)\n    scriptdir = os.path.dirname(os.path.abspath(__file__))\n    if \"{scriptdir}\" in args[\"--dir\"]:\n        args[\"--dir\"] = args[\"--dir\"].format(scriptdir=scriptdir)\n    dir_ = os.path.abspath(args[\"--dir\"])\n\n    log_level = log.DEBUG if args[\"--debug\"] else log.INFO\n    log.basicConfig(format=\"%(levelname)-8s %(message)s\", level=log_level)\n    tracker = SeverityTracker()\n    log.getLogger().addHandler(tracker)\n\n    create_papers(dir_, clean=args[\"--clean\"])\n    create_volumes(dir_, clean=args[\"--clean\"])\n    create_people(dir_, clean=args[\"--clean\"])\n    create_venues_and_events(dir_, clean=args[\"--clean\"])\n    create_sigs(dir_, clean=args[\"--clean\"])\n\n    if tracker.highest >= log.ERROR:\n        exit(1)\n", "path": "bin/create_hugo_pages.py"}]}