| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,10 +1,66 @@ | |||
| 1 | + import os | ||
| 2 | + import pathlib | ||
| 3 | + import shutil | ||
| 4 | + import subprocess | ||
| 5 | + | ||
| 1 | 6 | import fire | |
| 2 | 7 | ||
| 8 | + MSG_DIR = pathlib.Path(__file__).parent.parent.parent | ||
| 9 | + | ||
| 10 | + | ||
| 11 | + def sh(cmd, capture=False, chdir=None): | ||
| 12 | + opts = { | ||
| 13 | + "shell": True, | ||
| 14 | + "stdin": subprocess.PIPE, | ||
| 15 | + } | ||
| 16 | + cwd = os.getcwd() if chdir else None | ||
| 17 | + if chdir: | ||
| 18 | + os.chdir(chdir) | ||
| 19 | + try: | ||
| 20 | + if capture: | ||
| 21 | + opts["stderr"] = subprocess.STDOUT | ||
| 22 | + opts["universal_newlines"] = True | ||
| 23 | + return subprocess.check_output(cmd, **opts) | ||
| 24 | + else: | ||
| 25 | + return subprocess.check_call(cmd, **opts) | ||
| 26 | + finally: | ||
| 27 | + if cwd: | ||
| 28 | + os.chdir(cwd) | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + def create_symlink(symlink, to): | ||
| 32 | + np = len(pathlib.Path(os.path.commonpath([symlink, to])).parts) | ||
| 33 | + parts = ("..",) * (len(symlink.parts) - np - 1) + to.parts[np:] | ||
| 34 | + relpath = os.path.sep.join(parts) | ||
| 35 | + symlink.parent.mkdir(parents=True, exist_ok=True) | ||
| 36 | + symlink.symlink_to(relpath, target_is_directory=to.is_dir()) | ||
| 37 | + | ||
| 38 | + | ||
| 39 | + def chdir_Doc(): | ||
| 40 | + os.chdir(MSG_DIR / "../cpython/Doc") | ||
| 41 | + | ||
| 3 | 42 | ||
| 4 | 43 | class Command: | |
| 5 | 44 | def init(self): | |
| 6 | 45 | """Initialize .pdk.""" | |
| 7 | - pass | ||
| 46 | + os.chdir(MSG_DIR / "..") | ||
| 47 | + if pathlib.Path("cpython").exists(): | ||
| 48 | + shutil.rmtree("cpython") | ||
| 49 | + sh(f"git clone --single-branch -b {os.environ['PDK_BRANCH']} https://github.com/python/cpython") | ||
| 50 | + sh(f"git checkout {os.environ['PDK_REVISION']}", chdir="cpython") | ||
| 51 | + LC_MESSAGES = pathlib.Path( | ||
| 52 | + "cpython/Doc/locales/ko/LC_MESSAGES").absolute() | ||
| 53 | + create_symlink(LC_MESSAGES, MSG_DIR) | ||
| 54 | + | ||
| 55 | + def build(self): | ||
| 56 | + """Build translated document.""" | ||
| 57 | + chdir_Doc() | ||
| 58 | + sh("make -e SPHINXOPTS=\"-D language='ko'\" html") | ||
| 59 | + | ||
| 60 | + def watch(self): | ||
| 61 | + """Rebuild translated document on changes, with hot reloading in the browser.""" | ||
| 62 | + chdir_Doc() | ||
| 63 | + sh("make -e SPHINXOPTS=\"-D language='ko'\" htmllive") | ||
| 8 | 64 | ||
| 9 | 65 | ||
| 10 | 66 | def main(): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,7 @@ authors = [ | |||
| 11 | 11 | ] | |
| 12 | 12 | dependencies = [ | |
| 13 | 13 | "blurb==2.0.0", | |
| 14 | - "fire>=0.7,<1", | ||
| 14 | + "fire==0.7.0", | ||
| 15 | 15 | "python-docs-theme==2025.2", | |
| 16 | 16 | "sphinx==8.2.3", | |
| 17 | 17 | "sphinx-intl==2.3.1", | |
| Back | FazBrowse Home | New Git URL |
0 commit comments