Skip to content

Commit

Permalink
🎉 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed Jun 25, 2022
1 parent b516e33 commit 0a97d5f
Show file tree
Hide file tree
Showing 58 changed files with 2,861 additions and 2,879 deletions.
6 changes: 3 additions & 3 deletions README-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ cmd = Alconna(
)

result = cmd.parse("/pip install cesloi --upgrade") # This method returns an 'Arpamar' class instance.
print(result.get('install')) # Or result.install
print(result.query('install')) # Or result.install
```

Output as follows:
```
{'pak_name': 'cesloi', 'upgrade': Ellipsis}
{'value': None, 'args': {'pak_name': 'cesloi'}, 'options': {'upgrade': Ellipsis}}
```


Expand Down Expand Up @@ -83,7 +83,7 @@ QQ Group: [Link](https://jq.qq.com/?_wv=1027&k=PUPOnCSH)

## Features

* High Performance. On i5-10210U, performance is about `41000~101000 msg/s`; test script: [benchmark](dev_tools/benchmark.py)
* High Performance. On i5-10210U, performance is about `41000~101000 msg/s`; test script: [benchmark](benchmark.py)
* Simple and Flexible Constructor
* Powerful Automatic Type Parse and Conversion
* Support Synchronous and Asynchronous Actions
Expand Down
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,22 @@

## 关于

`Alconna` 隶属于 `ArcletProject`, `CommandAnalysis` 的重构版,是一个简单、灵活、高效的命令参数解析器, 并不局限于解析字符串
`Alconna` 隶属于 `ArcletProject`, 是一个简单、灵活、高效的命令参数解析器, 并且不局限于解析命令式字符串

`Alconna` 拥有复杂的解析功能与命令组件,但 一般情况下请当作~~奇妙~~简易的消息链解析器/命令解析器(雾)

## 安装

pip
```
```bash
pip install --upgrade arclet-alconna
```

完整安装
```bash
pip install --upgrade arclet-alconna[full]
```

## 文档

文档链接: [👉指路](https://arcletproject.github.io/docs/alconna/tutorial)
Expand All @@ -48,11 +53,11 @@ cmd = Alconna(
)

result = cmd.parse("/pip install cesloi --upgrade") # 该方法返回一个Arpamar类的实例
print(result.get('install')) # 或者 result.install
print(result.query('install')) # 或者 result.install
```
其结果为
```
{'pak_name': 'cesloi', 'upgrade': Ellipsis}
{'value': None, 'args': {'pak_name': 'cesloi'}, 'options': {'upgrade': Ellipsis}}
```

### 搭配响应函数
Expand Down Expand Up @@ -82,7 +87,7 @@ QQ 交流群: [链接](https://jq.qq.com/?_wv=1027&k=PUPOnCSH)

## 特点

* 高效. 在 i5-10210U 处理器上, 性能大约为 `41000~101000 msg/s`; 测试脚本: [benchmark](dev_tools/benchmark.py)
* 高效. 在 i5-10210U 处理器上, 性能大约为 `41000~101000 msg/s`; 测试脚本: [benchmark](benchmark.py)
* 精简、多样的构造方法
* 强大的类型解析与转换功能
* 可传入同步与异步的 action 函数
Expand Down
7 changes: 3 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

**English**: `README <README-EN.md>`__

``Alconna`` 隶属于 ``ArcletProject``, 是 ``CommandAnalysis``
的高级版, 支持解析消息链或者其他原始消息数据
``Alconna`` 隶属于 ``ArcletProject``, 是一个简单、灵活、高效的命令参数解析器, 并且不局限于解析命令式字符串。

``Alconna`` 拥有复杂的解析功能与命令组件,但
一般情况下请当作\ [STRIKEOUT:奇妙]\ 简易的消息链解析器/命令解析器(雾)
Expand Down Expand Up @@ -46,13 +45,13 @@ pip
)
result = cmd.parse("/pip install cesloi --upgrade") # 该方法返回一个Arpamar类的实例
print(result.get('install')) # 或者 result.install
print(result.query('install')) # 或者 result.install
其结果为

::

{'pak_name': 'cesloi', 'upgrade': Ellipsis}
{'value': None, 'args': {'pak_name': 'cesloi'}, 'options': {'upgrade': Ellipsis}}

讨论
----
Expand Down
906 changes: 462 additions & 444 deletions alconna.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 72 additions & 0 deletions benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import time
from arclet.alconna import Alconna, Args, AnyOne, compile, command_manager, config
import cProfile
import pstats


class Plain:
type = "Plain"
text: str

def __init__(self, t: str):
self.text = t


class At:
type = "At"
target: int

def __init__(self, t: int):
self.target = t


alc = Alconna(
headers=["."],
command="test",
main_args=Args["bar", AnyOne]
)
compile_alc = compile(alc)

msg = [Plain(".test"), At(124)]
count = 20000

config.enable_message_cache = True

if __name__ == "__main__":

sec = 0.0
for _ in range(count):
st = time.time()
compile_alc.process_message(msg)
compile_alc.analyse()
ed = time.time()
sec += ed - st
print(f"Alconna: {count / sec:.2f}msg/s")

print("RUN 2:")
li = []

pst = time.time()
for _ in range(count):
st = time.thread_time_ns()
compile_alc.process_message(msg)
compile_alc.analyse()
ed = time.thread_time_ns()
li.append(ed - st)
led = time.time()

print(f"Alconna: {sum(li) / count} ns per loop with {count} loops")

command_manager.records.clear()

prof = cProfile.Profile()
prof.enable()
for _ in range(count):
compile_alc.process_message(msg)
compile_alc.analyse()
prof.create_stats()

stats = pstats.Stats(prof)
stats.strip_dirs()
stats.sort_stats('tottime')
stats.print_stats(20)
24 changes: 24 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
# Alconna 1.0.x:

\^o^/

## Alconna 1.0.0:
1.`lang`迁移到新增的`config`中,并为`config`加入了如全局分隔、开启缓存等选项
2. 压缩代码量并规范化
3. `--help` 选项允许在命令任何部位生效, 并且会根据当前命令选择是否展示选项的帮助信息
4. `Args` name 的flag附加现在不需要以`|`分隔
5. `Args` name 允许用`#...`为单个Arg提供注释, 其会展示在帮助信息内
6. `Args` 允许传入 `Callable[[A], B]` 作为表达, 会自动解析输入类型与输出类型
7. 完善了测试代码, 位于[测试文件夹](test_alconna)内, 通过[入口文件](test_alconna/entry_test.py)可执行全部测试
8. 加入一个类似`beartype`[`checker`](src/arclet/alconna/builtin/checker.py)
9. 命令头部允许使用非str类型, 即可以`Alconna(int)`
10. 解析器增加预处理器选项, 允许在分划数据单元前进行转化处理
11. 性能提升, 理想情况最快约为 20w msg/s
12. 删除`Alconna.set_action`
13. 重构 `ObjectPattern`
14. 增加 `datetime`的 BasePattern, 支持传入时间戳或日期文字
15. `Analyser` 的字段修改, `next_data` -> `popitem`, `reduce_data` -> `pushback`
16. `output_send` 合并到 `output_manager`
17. `Option` 添加参数`priority`, 仅在需要选项重载时安排优先级
18. 修复bugs

# Alconna 0.9.x:

## Alconna 0.9.0 - 0.9.0.3:
Expand Down
142 changes: 0 additions & 142 deletions commander/broadcast.py

This file was deleted.

Loading

0 comments on commit 0a97d5f

Please sign in to comment.