Autopopulate module name in cli init (#12814)

This commit is contained in:
Erick Friis 2023-11-02 23:45:38 -07:00 committed by GitHub
parent 98aff29fbd
commit 0da75b9ebd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -67,6 +67,11 @@ def new(
package_dir = destination_dir / module_name
shutil.move(destination_dir / "package_template", package_dir)
# update init
init = package_dir / "__init__.py"
init_contents = init.read_text()
init.write_text(init_contents.replace("__module_name__", module_name))
# replace readme
readme = destination_dir / "README.md"
readme_contents = readme.read_text()

View File

@ -1,3 +1,3 @@
from chain import chain
from __module_name__.chain import chain
__all__ = ["chain"]