We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
DIRECTORY.md not being updated by TravisCI
- [x] .travis.yml isn't updating DIRECTORY.md automatically as it should
- [x] scripts/build_directory_md.py needs can have some minor changes too.  #1461

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `scripts/build_directory_md.py`
Content:
```
1 #!/usr/bin/env python3
2 
3 import os
4 from typing import Iterator
5 
6 URL_BASE = "https://github.com/TheAlgorithms/Python/blob/master"
7 
8 
9 def good_filepaths(top_dir: str = ".") -> Iterator[str]:
10     for dirpath, dirnames, filenames in os.walk(top_dir):
11         dirnames[:] = [d for d in dirnames if d != "scripts" and d[0] not in "._"]
12         for filename in filenames:
13             if filename == "__init__.py":
14                 continue
15             if os.path.splitext(filename)[1] in (".py", ".ipynb"):
16                 yield os.path.join(dirpath, filename).lstrip("./")
17 
18 
19 def md_prefix(i):
20     return f"{i * '  '}*" if i else "##"
21 
22 
23 def print_path(old_path: str, new_path: str) -> str:
24     old_parts = old_path.split(os.sep)
25     for i, new_part in enumerate(new_path.split(os.sep)):
26         if i + 1 > len(old_parts) or old_parts[i] != new_part:
27             if new_part:
28                 print(f"{md_prefix(i)} {new_part.replace('_', ' ').title()}")
29     return new_path
30 
31 
32 def print_directory_md(top_dir: str = ".") -> None:
33     old_path = ""
34     for filepath in sorted(good_filepaths()):
35         filepath, filename = os.path.split(filepath)
36         if filepath != old_path:
37             old_path = print_path(old_path, filepath)
38         indent = (filepath.count(os.sep) + 1) if filepath else 0
39         url = "/".join((URL_BASE, filepath, filename)).replace(" ", "%20")
40         filename = os.path.splitext(filename.replace("_", " "))[0]
41         print(f"{md_prefix(indent)} [{filename}]({url})")
42 
43 
44 if __name__ == "__main__":
45     print_directory_md(".")
46
```
--- 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/scripts/build_directory_md.py b/scripts/build_directory_md.py
--- a/scripts/build_directory_md.py
+++ b/scripts/build_directory_md.py
@@ -17,7 +17,7 @@
 
 
 def md_prefix(i):
-    return f"{i * '  '}*" if i else "##"
+    return f"{i * '  '}*" if i else "\n##"
 
 
 def print_path(old_path: str, new_path: str) -> str:
@@ -37,7 +37,7 @@
             old_path = print_path(old_path, filepath)
         indent = (filepath.count(os.sep) + 1) if filepath else 0
         url = "/".join((URL_BASE, filepath, filename)).replace(" ", "%20")
-        filename = os.path.splitext(filename.replace("_", " "))[0]
+        filename = os.path.splitext(filename.replace("_", " ").title())[0]
         print(f"{md_prefix(indent)} [{filename}]({url})")

{"golden_diff": "diff --git a/scripts/build_directory_md.py b/scripts/build_directory_md.py\n--- a/scripts/build_directory_md.py\n+++ b/scripts/build_directory_md.py\n@@ -17,7 +17,7 @@\n \n \n def md_prefix(i):\n-    return f\"{i * '  '}*\" if i else \"##\"\n+    return f\"{i * '  '}*\" if i else \"\\n##\"\n \n \n def print_path(old_path: str, new_path: str) -> str:\n@@ -37,7 +37,7 @@\n             old_path = print_path(old_path, filepath)\n         indent = (filepath.count(os.sep) + 1) if filepath else 0\n         url = \"/\".join((URL_BASE, filepath, filename)).replace(\" \", \"%20\")\n-        filename = os.path.splitext(filename.replace(\"_\", \" \"))[0]\n+        filename = os.path.splitext(filename.replace(\"_\", \" \").title())[0]\n         print(f\"{md_prefix(indent)} [{filename}]({url})\")\n", "issue": "DIRECTORY.md not being updated by TravisCI\n- [x] .travis.yml isn't updating DIRECTORY.md automatically as it should\r\n- [x] scripts/build_directory_md.py needs can have some minor changes too.  #1461\n", "before_files": [{"content": "#!/usr/bin/env python3\n\nimport os\nfrom typing import Iterator\n\nURL_BASE = \"https://github.com/TheAlgorithms/Python/blob/master\"\n\n\ndef good_filepaths(top_dir: str = \".\") -> Iterator[str]:\n    for dirpath, dirnames, filenames in os.walk(top_dir):\n        dirnames[:] = [d for d in dirnames if d != \"scripts\" and d[0] not in \"._\"]\n        for filename in filenames:\n            if filename == \"__init__.py\":\n                continue\n            if os.path.splitext(filename)[1] in (\".py\", \".ipynb\"):\n                yield os.path.join(dirpath, filename).lstrip(\"./\")\n\n\ndef md_prefix(i):\n    return f\"{i * '  '}*\" if i else \"##\"\n\n\ndef print_path(old_path: str, new_path: str) -> str:\n    old_parts = old_path.split(os.sep)\n    for i, new_part in enumerate(new_path.split(os.sep)):\n        if i + 1 > len(old_parts) or old_parts[i] != new_part:\n            if new_part:\n                print(f\"{md_prefix(i)} {new_part.replace('_', ' ').title()}\")\n    return new_path\n\n\ndef print_directory_md(top_dir: str = \".\") -> None:\n    old_path = \"\"\n    for filepath in sorted(good_filepaths()):\n        filepath, filename = os.path.split(filepath)\n        if filepath != old_path:\n            old_path = print_path(old_path, filepath)\n        indent = (filepath.count(os.sep) + 1) if filepath else 0\n        url = \"/\".join((URL_BASE, filepath, filename)).replace(\" \", \"%20\")\n        filename = os.path.splitext(filename.replace(\"_\", \" \"))[0]\n        print(f\"{md_prefix(indent)} [{filename}]({url})\")\n\n\nif __name__ == \"__main__\":\n    print_directory_md(\".\")\n", "path": "scripts/build_directory_md.py"}], "after_files": [{"content": "#!/usr/bin/env python3\n\nimport os\nfrom typing import Iterator\n\nURL_BASE = \"https://github.com/TheAlgorithms/Python/blob/master\"\n\n\ndef good_filepaths(top_dir: str = \".\") -> Iterator[str]:\n    for dirpath, dirnames, filenames in os.walk(top_dir):\n        dirnames[:] = [d for d in dirnames if d != \"scripts\" and d[0] not in \"._\"]\n        for filename in filenames:\n            if filename == \"__init__.py\":\n                continue\n            if os.path.splitext(filename)[1] in (\".py\", \".ipynb\"):\n                yield os.path.join(dirpath, filename).lstrip(\"./\")\n\n\ndef md_prefix(i):\n    return f\"{i * '  '}*\" if i else \"\\n##\"\n\n\ndef print_path(old_path: str, new_path: str) -> str:\n    old_parts = old_path.split(os.sep)\n    for i, new_part in enumerate(new_path.split(os.sep)):\n        if i + 1 > len(old_parts) or old_parts[i] != new_part:\n            if new_part:\n                print(f\"{md_prefix(i)} {new_part.replace('_', ' ').title()}\")\n    return new_path\n\n\ndef print_directory_md(top_dir: str = \".\") -> None:\n    old_path = \"\"\n    for filepath in sorted(good_filepaths()):\n        filepath, filename = os.path.split(filepath)\n        if filepath != old_path:\n            old_path = print_path(old_path, filepath)\n        indent = (filepath.count(os.sep) + 1) if filepath else 0\n        url = \"/\".join((URL_BASE, filepath, filename)).replace(\" \", \"%20\")\n        filename = os.path.splitext(filename.replace(\"_\", \" \").title())[0]\n        print(f\"{md_prefix(indent)} [{filename}]({url})\")\n\n\nif __name__ == \"__main__\":\n    print_directory_md(\".\")\n", "path": "scripts/build_directory_md.py"}]}