未提供项目说明

fireball的Python项目详细描述


火球

python-fire上构建,使绑定和调试更容易。在

安装

pip install fireball

使用

在命令行中调用Python函数

基本用法:

^{pr2}$

帮助文档:

❯ fireball base64:b64encode -- --help
NAME
    b64encode - Encode the bytes-like object s using Base64 and return a bytes object.

SYNOPSIS
    b64encode S <flags>

DESCRIPTION
    Optional altchars should be a byte string of length 2 which specifies an
    alternative alphabet for the '+' and '/' characters.  This allows an
    application to e.g. generate url or filesystem safe Base64 strings.

POSITIONAL ARGUMENTS
    S

FLAGS
    --altchars=ALTCHARS
    --pdb_=PDB_
    --show_params_=SHOW_PARAMS_
    --show_params_mtl_=SHOW_PARAMS_MTL_

NOTES
    You can also use flags syntax for POSITIONAL ARGUMENTS

显示参数模板:

❯ fireball base64:b64encode --show_params_tpl_
Show parameters:

fireball base64:b64encode --s="<required>" --altchars="None"

❯ fireball base64:b64encode --show_params_tpl_mtl_
Show parameters:

fireball base64:b64encode \
  --s="<required>"\
  --altchars="None"

PDB后现代:

❯ fireball base64:b64encode 'test' --pdb_
ERROR:root:Traceback (most recent call last):
  File "/Users/huntzhan/.pyenv/versions/fireball/bin/fireball", line 6, in <module>
    sys.exit(import_module('fireball').exec())
  File "/Users/huntzhan/Data/Project/personal/fireball/fireball/__init__.py", line 169, in exec
    func_cli()
  File "/Users/huntzhan/Data/Project/personal/fireball/fireball/__init__.py", line 114, in <lambda>
    return lambda: fire.Fire(wrapper)
  File "/Users/huntzhan/.pyenv/versions/fireball/lib/python3.8/site-packages/fire/core.py", line 138, in Fire
    component_trace= _Fire(component, args, parsed_flag_args, context, name)
  File "/Users/huntzhan/.pyenv/versions/fireball/lib/python3.8/site-packages/fire/core.py", line 463, in _Fire
    component, remaining_args= _CallAndUpdateTrace(
  File "/Users/huntzhan/.pyenv/versions/fireball/lib/python3.8/site-packages/fire/core.py", line 672, in _CallAndUpdateTrace
    component= fn(*varargs, **kwargs)
  File "/Users/huntzhan/Data/Project/personal/fireball/fireball/__init__.py", line 85, in wrapper
    return func(*bound_args.args, **bound_args.kwargs)
  File "/Users/huntzhan/.pyenv/versions/3.8.2/lib/python3.8/base64.py", line 58, in b64encode
    encoded= binascii.b2a_base64(s, newline=False)
TypeError: a bytes-like object is required, not 'str'[7] > /Users/huntzhan/.pyenv/versions/3.8.2/lib/python3.8/base64.py(58)b64encode()
-> encoded= binascii.b2a_base64(s, newline=False)(Pdb++) ll
  51     def b64encode(s, altchars=None):
  52"""Encode the bytes-like object s using Base64 and return a bytes object.  53  54         Optional altchars should be a byte string of length 2 which specifies an  55         alternative alphabet for the '+' and '/' characters.  This allows an  56         application to e.g. generate url or filesystem safe Base64 strings.  57         """58  ->     encoded= binascii.b2a_base64(s, newline=False)59if altchars is not None:
  60             assert len(altchars)==2, repr(altchars)61return encoded.translate(bytes.maketrans(b'+/', altchars))62return encoded
(Pdb++)

定义项目入口点

示例:

# app.pyimportfireballdeffoo(a,b=2):print('foo',a,b)assert0foo_cli=fireball.cli(foo)

绑定为入口点:

# pyproject.toml.[tool.poetry.scripts]foo="path.to.app:foo_cli"# setup.pysetup(...entry_points={'console_scripts':['foo_cli = path.to.app:foo_cli',],},...)

激活shell中的入口点,然后调用:

❯ foo_cli --help
NAME
    foo

SYNOPSIS
    foo A <flags>

POSITIONAL ARGUMENTS
    A

FLAGS
    --b=B
    --pdb_=PDB_

NOTES
    You can also use flags syntax for POSITIONAL ARGUMENTS

❯ foo_cli this_is_a this_is_b
foo this_is_a this_is_b
Traceback (most recent call last):
  File "/Users/huntzhan/.pyenv/versions/fireball/bin/fireball", line 6, in <module>
    sys.exit(import_module('fireball').exec())
  File "/Users/huntzhan/Data/Project/personal/fireball/fireball/__init__.py", line 135, in execreturn func_cli()
  File "/Users/huntzhan/Data/Project/personal/fireball/fireball/__init__.py", line 80, in <lambda>
    return lambda: fire.Fire(wrapper)
  File "/Users/huntzhan/.pyenv/versions/fireball/lib/python3.8/site-packages/fire/core.py", line 138, in Fire
    component_trace= _Fire(component, args, parsed_flag_args, context, name)
  File "/Users/huntzhan/.pyenv/versions/fireball/lib/python3.8/site-packages/fire/core.py", line 463, in _Fire
    component, remaining_args= _CallAndUpdateTrace(
  File "/Users/huntzhan/.pyenv/versions/fireball/lib/python3.8/site-packages/fire/core.py", line 672, in _CallAndUpdateTrace
    component= fn(*varargs, **kwargs)
  File "/Users/huntzhan/Data/Project/personal/fireball/fireball/__init__.py", line 61, in wrapper
    return func(**bound_args.arguments)
  File "/Users/huntzhan/Data/Project/personal/fireball/tools/debug_import.py", line 3, in foo
    assert 0
AssertionError

❯ foo_cli this_is_a this_is_b --pdb_
[fireball] pdb_: Setup successfully.
foo this_is_a this_is_b
Traceback (most recent call last):
  File "/Users/huntzhan/.pyenv/versions/fireball/bin/fireball", line 6, in <module>
    sys.exit(import_module('fireball').exec())
  File "/Users/huntzhan/Data/Project/personal/fireball/fireball/__init__.py", line 135, in execreturn func_cli()
  File "/Users/huntzhan/Data/Project/personal/fireball/fireball/__init__.py", line 80, in <lambda>
    return lambda: fire.Fire(wrapper)
  File "/Users/huntzhan/.pyenv/versions/fireball/lib/python3.8/site-packages/fire/core.py", line 138, in Fire
    component_trace= _Fire(component, args, parsed_flag_args, context, name)
  File "/Users/huntzhan/.pyenv/versions/fireball/lib/python3.8/site-packages/fire/core.py", line 463, in _Fire
    component, remaining_args= _CallAndUpdateTrace(
  File "/Users/huntzhan/.pyenv/versions/fireball/lib/python3.8/site-packages/fire/core.py", line 672, in _CallAndUpdateTrace
    component= fn(*varargs, **kwargs)
  File "/Users/huntzhan/Data/Project/personal/fireball/fireball/__init__.py", line 61, in wrapper
    return func(**bound_args.arguments)
  File "/Users/huntzhan/Data/Project/personal/fireball/tools/debug_import.py", line 3, in foo
    assert 0
AssertionError
[7] > /Users/huntzhan/Data/Project/personal/fireball/tools/debug_import.py(3)foo()
-> assert 0(Pdb++) ll
   1     def foo(a, b=2):
   2         print('foo', a, b)3  ->     assert 0(Pdb++)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
带Maven的Eclipse Java存储库:缺少工件:compile   java如何以编程方式停止RMI服务器并通知所有客户端   java Roboguice抛出ClassNotFoundException:AnnotationDatabaseImpl   java为什么lucene 4.0删除IndexWriter类的两个构造函数?   nls如何避免java项目上不需要的日志消息?   测试无法在Selenium Webdriver(java)中定位iframe   使用XML的java servlet   java如何使用jxl用****屏蔽单元格   java使用SQLite从数据库中选择“没有这样的列”   导入扫描程序后出现java编译错误   插入查询的java空指针异常   使用创建PostgreSQL数据库。Java应用中的sql脚本   java使用jsoup将HTML解析为格式化的明文