Append a brief reference entry to Endpoints.md, showing the usage example. First checks if the entry already exists to avoid duplicates.
(method, endpoint)
| 441 | |
| 442 | |
| 443 | def write_function_to_endpoints_md(method, endpoint): |
| 444 | """ |
| 445 | Append a brief reference entry to Endpoints.md, showing the usage example. |
| 446 | First checks if the entry already exists to avoid duplicates. |
| 447 | """ |
| 448 | function_name = convert_to_function_name(method, endpoint) |
| 449 | |
| 450 | # Check if the entry already exists |
| 451 | with open("Endpoints.md", "r", encoding="utf-8") as f: |
| 452 | content = f.read() |
| 453 | # Look for the exact method and endpoint |
| 454 | if f"**{method.upper()} {endpoint}" in content: |
| 455 | return False |
| 456 | |
| 457 | # Create the entry we want to add |
| 458 | md_entry = ( |
| 459 | f"\t- **{method} {endpoint}**\n" |
| 460 | f" ```python\n" |
| 461 | f" client.{function_name}(**params)\n" |
| 462 | f" ```\n\n" |
| 463 | ) |
| 464 | |
| 465 | # If we get here, the entry doesn't exist, so append it |
| 466 | with open("Endpoints.md", "a", encoding="utf-8") as f: |
| 467 | f.write(md_entry) |
| 468 | |
| 469 | return True |
| 470 | |
| 471 | |
| 472 | def main(): |
no test coverage detected
searching dependent graphs…