mirror of
https://github.com/rjNemo/fastapi
synced 2026-06-11 13:06:43 +00:00
✨ Update tutorial renamer to exclude files
This commit is contained in:
parent
00e2e544c7
commit
e9f2a3c291
1 changed files with 8 additions and 2 deletions
|
|
@ -3,7 +3,9 @@ from pathlib import Path, PurePath
|
||||||
from string import digits
|
from string import digits
|
||||||
|
|
||||||
directory = Path("./docs/tutorial/src")
|
directory = Path("./docs/tutorial/src")
|
||||||
dirs = sorted([Path(f) for f in directory.iterdir()])
|
skip_names = {"bigger_applications"}
|
||||||
|
skip_dirs = {directory / name for name in skip_names}
|
||||||
|
dirs = sorted([Path(f) for f in directory.iterdir() if f not in skip_dirs])
|
||||||
d: PurePath
|
d: PurePath
|
||||||
sufix = "__out__"
|
sufix = "__out__"
|
||||||
for d in dirs:
|
for d in dirs:
|
||||||
|
|
@ -13,9 +15,13 @@ for d in dirs:
|
||||||
output_directory = directory / output_dir_name
|
output_directory = directory / output_dir_name
|
||||||
output_directory.mkdir(exist_ok=True)
|
output_directory.mkdir(exist_ok=True)
|
||||||
files = sorted([Path(f) for f in d.iterdir()])
|
files = sorted([Path(f) for f in d.iterdir()])
|
||||||
|
f: PurePath
|
||||||
for i, f in enumerate(files):
|
for i, f in enumerate(files):
|
||||||
index = str(i + 1).zfill(3)
|
index = str(i + 1).zfill(3)
|
||||||
new_name = output_directory / f"tutorial{index}.py"
|
if f.name != "__init__.py" and f.name.endswith(".py"):
|
||||||
|
new_name = output_directory / f"tutorial{index}.py"
|
||||||
|
else:
|
||||||
|
new_name = output_directory / f.name
|
||||||
print(new_name)
|
print(new_name)
|
||||||
f.rename(new_name)
|
f.rename(new_name)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue