argcomplete 项目使用教程

随笔3周前发布 软软
33 0 0

argcomplete 项目使用教程

argcompletePython and tab completion, better together.项目地址:https://gitcode.com/gh_mirrors/ar/argcomplete

项目的目录结构及介绍

argcomplete 项目的目录结构如下:

  1. argcomplete/

  2. ├── argcomplete/

  3. │ ├── __init__.py

  4. │ ├── __main__.py

  5. │ ├── completers.py

  6. │ ├── shells.py

  7. │ └── tests/

  8. │ ├── __init__.py

  9. │ ├── test_argcomplete.py

  10. │ └── test_shells.py

  11. ├── docs/

  12. │ ├── conf.py

  13. │ ├── index.rst

  14. │ └── ...

  15. ├── examples/

  16. │ ├── example.py

  17. │ └── ...

  18. ├── .gitignore

  19. ├── LICENSE

  20. ├── README.md

  21. ├── setup.cfg

  22. ├── setup.py

  23. └── tox.ini

目录结构介绍

  • argcomplete/: 项目的主要代码目录,包含核心功能实现。
    • __init__.py: 包的初始化文件。
    • __main__.py: 主程序入口文件。
    • completers.py: 完成器相关功能实现。
    • shells.py: 支持的 shell 相关功能实现。
    • tests/: 测试代码目录。
      • test_argcomplete.py: 针对 argcomplete 功能的测试。
      • test_shells.py: 针对 shells 功能的测试。
  • docs/: 项目文档目录,包含 Sphinx 文档配置和源文件。
  • examples/: 示例代码目录,包含使用 argcomplete 的示例程序。
  • .gitignore: Git 忽略文件配置。
  • LICENSE: 项目许可证文件。
  • README.md: 项目说明文档。
  • setup.cfg: 安装配置文件。
  • setup.py: 安装脚本。
  • tox.ini: 自动化测试配置文件。

项目的启动文件介绍

项目的启动文件是 argcomplete/__main__.py。这个文件定义了 argcomplete 的主入口点,可以通过 python -m argcomplete 来运行。

启动文件内容

  1. # argcomplete/__main__.py

  2. from . import main

  3. if __name__ == "__main__":

  4. main()

这个文件导入了 main 函数并作为程序的入口点。main 函数定义在 argcomplete/__init__.py 中,负责处理命令行参数和启动 argcomplete 的功能。

项目的配置文件介绍

项目的配置文件主要包括 setup.cfgtox.ini

setup.cfg

setup.cfg 是用于配置 setuptools 的文件,定义了项目的元数据、依赖关系和安装选项。

  1. [metadata]

  2. name = argcomplete

  3. version = attr: argcomplete.__version__

  4. description = Bash tab completion for argparse

  5. long_description = file: README.md

  6. long_description_content_type = text/markdown

  7. author = Andrey Kislyuk

  8. author_email = kislyuk@gmail.com

  9. url = https://github.com/kislyuk/argcomplete

  10. license = Apache Software License

  11. classifiers =

  12. Development Status :: 5 - Production/Stable

  13. Intended Audience :: Developers

  14. License :: OSI Approved :: Apache Software License

  15. Operating System :: MacOS :: MacOS X

  16. Operating System :: POSIX

  17. Programming Language :: Python

  18. Programming Language :: Python :: 3

  19. Programming Language :: Python :: 3.6

  20. Programming Language :: Python :: 3.7

  21. Programming Language :: Python :: 3.8

  22. Programming Language :: Python :: 3.9

  23. Topic :: Software Development :: Libraries :: Python Modules

  24. [options]

  25. packages = find:

  26. install_requires =

  27. importlib-metadata >= 0.23; python_version < "3.8"

  28. [options.entry_points]

  29. console_scripts =

  30. activate-global-python-argcomplete = argcomplete.shell:main

  31. [flake8]

  32. max-line-length = 100

  33. ignore = E203, E266, E501, W503

tox.ini

tox.ini 是用于配置 tox 的文件,定义了自动化测试的环境和命令。

  1. [tox]

  2. envlist = py36,py37,py38,py39

  3. skipsdist = true

  4. [testenv]

  5. deps =

  6. pytest

argcompletePython and tab completion, better together.项目地址:https://gitcode.com/gh_mirrors/ar/argcomplete

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...