Update old write_pyproject_toml

This commit is contained in:
Patrick Elmer 2024-03-11 15:05:22 +01:00
parent 60d428e388
commit 4029fb4b94

View File

@ -320,37 +320,47 @@ def load_pyproject_toml(dirname, maxdepth=3, filename='pyproject.toml'):
# def write_pyproject_toml(path):
# config = {
# 'Module name': '',
# 'Author': '',
# 'Author email': '',
# 'CLI command': '',
# 'CLI path': '',
# }
# name = prompt('Module name')
# author = prompt('Author')
# email = prompt('Author email')
# cli_name = prompt('CLI name', default=name)
# cli_path = prompt('CLI path')
# authors = '[{' + f'name = "{author}", email = "{email}"' + '}]'
# for key in config.keys():
# config[key] = input(f"{key}: ")
# with open(path, 'w', encoding='utf-8') as f:
# f.write(TEMPLATE.format(
# name=name,
# authors=authors,
# cli_name=cli_name,
# cli_path=cli_path,
# ))
# author_and_email = '{name = "' + config['Author'] + '", email = "' + config['Author email'] + '"}'
# with open(path, 'w') as f:
# f.write(f"""\
# def prompt(question, default=''):
# if response := input(f"{question} [{default}]: "):
# return response
# else:
# return default
# TEMPLATE = """\
# [build-system]
# requires = ["flit_core >=3.2,<4"]
# build-backend = "flit_core.buildapi"
# [project]
# name = "{config['Module name']}"
# authors = [{author_and_email}]
# name = "{name}"
# authors = [{authors}]
# dynamic = ["version", "description"]
# dependencies = ["magicli"]
# [project.scripts]
# {config['CLI command']} = "{config['CLI path']}"
# "{cli_name}" = "{cli_path}"
# [tool.magicli]
# test = "test"
# """)
# # Uncomment to add user configuration
# #[tool.magicli]
# #test = "test"
# """
def write_pyproject_toml(path):