prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  [suggestion] use relative path in DIRECTORY.md
  when openning DIRECTORY.md in local machine, the links in it refers to https://github.com/TheAlgorithms/Python/blob/master/xxx.
  
  it's not convinient for reading locally.
  
  I suggest to make a new file "TOC.md", which removes "https://github.com/TheAlgorithms/Python/blob/master/" in every link.
  
  --- 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_file_paths(top_dir: str = ".") -> Iterator[str]:
  10     for dir_path, dir_names, filenames in os.walk(top_dir):
  11         dir_names[:] = [d for d in dir_names 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(dir_path, filename).lstrip("./")
  17 
  18 
  19 def md_prefix(i):
  20     return f"{i * '  '}*" if i else "\n##"
  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_file_paths(top_dir)):
  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("_", " ").title())[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()
  
  ```
  
golden_diff: 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
  @@ -3,8 +3,6 @@
   import os
   from typing import Iterator
   
  -URL_BASE = "https://github.com/TheAlgorithms/Python/blob/master"
  -
   
   def good_file_paths(top_dir: str = ".") -> Iterator[str]:
       for dir_path, dir_names, filenames in os.walk(top_dir):
  @@ -36,7 +34,7 @@
           if filepath != old_path:
               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")
  +        url = "/".join((filepath, filename)).replace(" ", "%20")
           filename = os.path.splitext(filename.replace("_", " ").title())[0]
           print(f"{md_prefix(indent)} [{filename}]({url})")
  
verification_info: {"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@@ -3,8 +3,6 @@\n import os\n from typing import Iterator\n \n-URL_BASE = \"https://github.com/TheAlgorithms/Python/blob/master\"\n-\n \n def good_file_paths(top_dir: str = \".\") -> Iterator[str]:\n     for dir_path, dir_names, filenames in os.walk(top_dir):\n@@ -36,7 +34,7 @@\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+        url = \"/\".join((filepath, filename)).replace(\" \", \"%20\")\n         filename = os.path.splitext(filename.replace(\"_\", \" \").title())[0]\n         print(f\"{md_prefix(indent)} [{filename}]({url})\")\n", "issue": "[suggestion] use relative path in DIRECTORY.md\nwhen openning DIRECTORY.md in local machine, the links in it refers to https://github.com/TheAlgorithms/Python/blob/master/xxx.\r\n\r\nit's not convinient for reading locally.\r\n\r\nI suggest to make a new file \"TOC.md\", which removes \"https://github.com/TheAlgorithms/Python/blob/master/\" in every link.\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_file_paths(top_dir: str = \".\") -> Iterator[str]:\n    for dir_path, dir_names, filenames in os.walk(top_dir):\n        dir_names[:] = [d for d in dir_names 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(dir_path, 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_file_paths(top_dir)):\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"}], "after_files": [{"content": "#!/usr/bin/env python3\n\nimport os\nfrom typing import Iterator\n\n\ndef good_file_paths(top_dir: str = \".\") -> Iterator[str]:\n    for dir_path, dir_names, filenames in os.walk(top_dir):\n        dir_names[:] = [d for d in dir_names 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(dir_path, 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_file_paths(top_dir)):\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((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"}]}