python - 获取诗歌脚本端点
问题描述
Poetry有一种很好的方式来使用poetry run <entrypoint>
. 使用 Python 或 Bash以编程方式获取列表的最佳方法是<entrypoints>
什么?pyproject.toml
例如,pyproject.toml
:
[tool.poetry]
name = "random-tool"
version = "1.0"
[tool.poetry.scripts]
tool = "tool.function:main"
other_tool = "other_tool.function:main"
all_the_tools = "other_tool.function:all"
输出为:
entrypoint = [ "tool", "other_tool", "all_the_tools" ]
解决方案
使用 python 这很容易,因为您可以使用toml将pyproject.toml
文件解析为字典:
import toml
pyproject = toml.load("pyproject.toml")
print(pyproject["tool"]["poetry"]["scripts"].keys())
推荐阅读
- python - Tesseract OCR - 指定模式
- scala - 隐式添加到集合
- recaptcha - 如何强制 Google reCaptcha 显示挑战图像?
- python - Python在Windows中更改目录
- batch-file - 通过批处理文件比较两个文件夹的内容而不是两个文件的内容
- angular6 - 无法在 Reactive Forms 角度 6 中获取值 select2 多项选择
- php - 如何利用浏览器缓存和 .htaccess 没有被我的清漆配置清除?
- python - 如何使用 for 循环从其他迭代创建特定字典?
- c++ - 如何将 cin>> 与初始化的 char* 一起使用为 NULL
- javascript - 使用自定义域重置 Firebase 密码不起作用