Home / File/ translate.py — fastapi Source File

translate.py — fastapi Source File

Architecture documentation for translate.py, a python file in the fastapi codebase. 16 imports, 0 dependents.

File python FastAPI Applications 16 imports 22 functions

Entity Profile

Dependency Diagram

graph LR
  6dda5e35_b655_8af3_cd89_8c1584a092c4["translate.py"]
  c1ef60e8_e635_2e82_29e5_a79e03e975d6["json"]
  6dda5e35_b655_8af3_cd89_8c1584a092c4 --> c1ef60e8_e635_2e82_29e5_a79e03e975d6
  05832956_b384_ff7e_ef60_abebb23f9723["secrets"]
  6dda5e35_b655_8af3_cd89_8c1584a092c4 --> 05832956_b384_ff7e_ef60_abebb23f9723
  c16959b6_d471_41f8_1c0e_2c4fe324727a["subprocess"]
  6dda5e35_b655_8af3_cd89_8c1584a092c4 --> c16959b6_d471_41f8_1c0e_2c4fe324727a
  07d79a2e_d4e9_0bbb_be90_936274444c8c["collections.abc"]
  6dda5e35_b655_8af3_cd89_8c1584a092c4 --> 07d79a2e_d4e9_0bbb_be90_936274444c8c
  958aa7af_9d63_fe0c_3544_91dd93294508["functools"]
  6dda5e35_b655_8af3_cd89_8c1584a092c4 --> 958aa7af_9d63_fe0c_3544_91dd93294508
  af9b440f_13c4_d91e_f8ae_bfe199b060d2["os"]
  6dda5e35_b655_8af3_cd89_8c1584a092c4 --> af9b440f_13c4_d91e_f8ae_bfe199b060d2
  b3e303a2_3f2d_638d_930c_3a5dcc2f5a42["pathlib"]
  6dda5e35_b655_8af3_cd89_8c1584a092c4 --> b3e303a2_3f2d_638d_930c_3a5dcc2f5a42
  0dda2280_3359_8460_301c_e98c77e78185["typing"]
  6dda5e35_b655_8af3_cd89_8c1584a092c4 --> 0dda2280_3359_8460_301c_e98c77e78185
  132d80d6_5330_7695_1cff_d4697a66b382["git"]
  6dda5e35_b655_8af3_cd89_8c1584a092c4 --> 132d80d6_5330_7695_1cff_d4697a66b382
  a73533d9_0a96_e8d9_5dcf_b4fd5359ebb5["typer"]
  6dda5e35_b655_8af3_cd89_8c1584a092c4 --> a73533d9_0a96_e8d9_5dcf_b4fd5359ebb5
  67785272_06f8_d6cb_1f4a_abf8bc11d004["yaml"]
  6dda5e35_b655_8af3_cd89_8c1584a092c4 --> 67785272_06f8_d6cb_1f4a_abf8bc11d004
  c463d6a9_085f_f272_b9fc_455b7e9b6a57["doc_parsing_utils.py"]
  6dda5e35_b655_8af3_cd89_8c1584a092c4 --> c463d6a9_085f_f272_b9fc_455b7e9b6a57
  63822d7d_03fc_4331_3f93_3026c9c03415["check_translation"]
  6dda5e35_b655_8af3_cd89_8c1584a092c4 --> 63822d7d_03fc_4331_3f93_3026c9c03415
  319484c7_306f_9ec1_3de4_788004953d77["github"]
  6dda5e35_b655_8af3_cd89_8c1584a092c4 --> 319484c7_306f_9ec1_3de4_788004953d77
  style 6dda5e35_b655_8af3_cd89_8c1584a092c4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import json
import secrets
import subprocess
from collections.abc import Iterable
from functools import lru_cache
from os import sep as pathsep
from pathlib import Path
from typing import Annotated

import git
import typer
import yaml
from doc_parsing_utils import check_translation
from github import Github
from pydantic_ai import Agent
from rich import print

non_translated_sections = (
    f"reference{pathsep}",
    "release-notes.md",
    "fastapi-people.md",
    "external-links.md",
    "newsletter.md",
    "management-tasks.md",
    "management.md",
    "contributing.md",
)

general_prompt_path = Path(__file__).absolute().parent / "general-llm-prompt.md"
general_prompt = general_prompt_path.read_text(encoding="utf-8")

app = typer.Typer()


@lru_cache
def get_langs() -> dict[str, str]:
    return yaml.safe_load(Path("docs/language_names.yml").read_text(encoding="utf-8"))


def generate_lang_path(*, lang: str, path: Path) -> Path:
    en_docs_path = Path("docs/en/docs")
    assert str(path).startswith(str(en_docs_path)), (
        f"Path must be inside {en_docs_path}"
    )
    lang_docs_path = Path(f"docs/{lang}/docs")
    out_path = Path(str(path).replace(str(en_docs_path), str(lang_docs_path)))
    return out_path


def generate_en_path(*, lang: str, path: Path) -> Path:
    en_docs_path = Path("docs/en/docs")
    assert not str(path).startswith(str(en_docs_path)), (
        f"Path must not be inside {en_docs_path}"
    )
    lang_docs_path = Path(f"docs/{lang}/docs")
    out_path = Path(str(path).replace(str(lang_docs_path), str(en_docs_path)))
    return out_path


@app.command()
// ... (396 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does translate.py do?
translate.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Applications subdomain.
What functions are defined in translate.py?
translate.py defines 22 function(s): add_missing, app, commands_json, generate_en_path, generate_lang_path, get_langs, get_llm_translatable, iter_all_en_paths, iter_en_paths_to_translate, list_all_removable, and 12 more.
What does translate.py depend on?
translate.py imports 16 module(s): check_translation, collections.abc, doc_parsing_utils.py, functools, git, github, json, os, and 8 more.
Where is translate.py in the architecture?
translate.py is located at scripts/translate.py (domain: FastAPI, subdomain: Applications, directory: scripts).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free