INNER CODE UNIT · Python

update_toml_file

googleapis/mcp-toolbox · .ci/update_docs_versions.py:50

def update_toml_file(file_path, version, remove_oldest):
    print(f"Processing {file_path}...")
    with open(file_path, 'r') as f:
        content = f.read()

    # Check if version already exists
    version_pattern = f'version\\s*=\\s*"{re.escape(version)}"'
    if re.search(version_pattern, content):
        print(f"Version {version} already exists in {os.path.basename(file_path)}. No change needed.")
        return

    # Insert new version block right after the specific comment
    comment_marker = '# The order of versions in this file is mirrored into the dropdown'
    if comment_marker not in content:
        print(f"Error: Could not find comment marker in {os.path.basename(file_path)}.")
        sys.exit(1)

    new_block = f'[[params.versions]]\n  version = "{version}"\n  url = "https://mcp-toolbox.dev/{version}/"'

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…