Skip to content

Commit

Permalink
Merge pull request #106 from HowieHz/dev
Browse files Browse the repository at this point in the history
1.7.1
  • Loading branch information
HowieHz authored Jul 6, 2022
2 parents a339959 + 0d351c9 commit 8261547
Show file tree
Hide file tree
Showing 26 changed files with 233 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .idea/hpyculator.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 文档

咋用这个文档嘞
如何在本地启动这个文档

很简单

Expand All @@ -27,5 +27,3 @@
make html

就好了

还不会可以看看这篇[教程](https://zhuanlan.zhihu.com/p/264647009)
12 changes: 10 additions & 2 deletions docs/source/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@
Fixed - 解决的问题
Others - 性能优化和安全性增强等改进

v1.7.1(草稿)
v1.7.1

锐意开发中
Added
文档修改,补充
添加hpyc_cli v1.0.0
Changed
修改一些插件的处理算法
Fixed
hpyc_pyside_ui达到输出上限不能正常停止消息监听线程的问题
Others
对模块名称进行了区分,防止意外的导入操作

v1.7.0

Expand Down
4 changes: 3 additions & 1 deletion docs/source/core_api/message.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@

达到输出上限,仅选择 ”从缓冲区中返回,但是有返回上限“ 模式才会触发的消息

此时运算线程停止
此时运算线程停止,但此时不能推出消息监听

因为接下来还有一条 ``CalculationProgramIsFinished`` 消息

("MESSAGE", "CalculationProgramIsRunning")
----------------------------------------------
Expand Down
5 changes: 3 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
本文档是 `hpyculator <https://github.com/HowieHz/hpyculator>`_ 系列项目的说明及帮助文档

文档api版本
- `hpyculator <https://github.com/HowieHz/hpyculatorPackage>`_ == 1.5.0
- `hpyc_pyside_ui <https://github.com/HowieHz/hpyculator/tree/main/hpyc_pyside_ui>`_ == 1.7.0
- `hpyc_core <https://github.com/HowieHz/hpyculator/tree/main/hpyc_core>`_ == 1.0.0
- `hpyculator <https://github.com/HowieHz/hpyculatorPackage>`_ == 1.5.0
- `hpyc_pyside_ui <https://github.com/HowieHz/hpyculator/tree/main/hpyc_pyside_ui>`_ == 1.7.1
- `hpyc_cli <https://github.com/HowieHz/hpyculator/tree/main/hpyc_cli>`_ == 1.0.0

.. image:: images/ico.ico

Expand Down
57 changes: 48 additions & 9 deletions docs/source/plugin_dev/Metadata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@

.. code-block:: python
from typing import TypedDict, Literal
import hpyculator as hpyc
class MetadataDict(TypedDict, total=False):
input_mode: str
"""插件元数据数据类型"""
input_mode: Literal[hpyc.STRING, hpyc.NUM, hpyc.FLOAT]
id: str
option: str
version: str
Expand All @@ -22,8 +28,13 @@
author: str | list
help: str
output_end: str
return_mode: int
fullwidth_symbol: int
return_mode: Literal[
hpyc.RETURN_ONCE,
hpyc.RETURN_ITERABLE,
hpyc.NO_RETURN,
hpyc.NO_RETURN_SINGLE_FUNCTION,
]
fullwidth_symbol: Literal[hpyc.ON, hpyc.OFF]
以下是一段示例元数据

Expand Down Expand Up @@ -60,19 +71,47 @@
"fullwidth_symbol": hpyc.OFF # 懒人专用,默认是0,开1之后help段符号全部转换成全角(可选)
}
数据类型要求
数据类型要求和说明

- 作者名author支持的形式
- 字符串类型,如:"作者名"
- 列表,如:["作者名1", "作者名2"]
- 标签tag支持的形式
.. code-block:: python
import hpyculator as hpyc
- 输入数据类型 ``input_mode`` , 会将原始输入转换成对应类型, 要求在以下常量中选择一个
- `hpyc.STRING` -> 对应 `str` 类型
- `hpyc.NUM` -> 对应 `int` 类型
- `hpyc.FLOAT` -> 对应 `float` 类型
- 插件 ``id``
- `str` 类型, 要求于文件名(单文件插件)/文件夹名(文件夹插件)一致, 否则无法正常加载插件
- 选项名 `option`
- `str` 类型, 给用户展示选项所用
- 版本号 `version`
- `str` 类型, 建议使用语义化版本
- 标签 ``tag`` 支持的形式
- 列表,如:["标签1","标签2"] ["标签1"]
- 字符串,如:"标签"
- 返回模式return_mode要求在以下常量中选择一个
- 保存所用名称 ``save_name``
- `str` 类型
- 量词, 保存用 ``quantifier``
- `str` 类型
- 输出头 ``output_start``
- `str` 类型, 一般与 ``help `` 同时输出
- 输出名 ``output_name``
- `str` 类型, 一般与 ``help `` 同时输出
- 作者名 ``author`` 支持的形式
- 字符串类型,如:"作者名"
- 列表,如:["作者名1", "作者名2"]
- 详细介绍, 帮助, 介绍正文 ``help``
- `str` 类型
- 输出尾 ``output_end``
- `str` 类型, 一般与 ``help `` 同时输出
- 返回模式 ``return_mode`` 要求在以下常量中选择一个
- `hpyc.RETURN_ONCE`
- `hpyc.RETURN_ITERABLE`
- `hpyc.NO_RETURN`
- `hpyc.NO_RETURN_SINGLE_FUNCTION`
- 全角模式 ``fullwidth_symbol``
- 会将 ``help`` 字段值中的半角符号转换为全角符号

参数会影响什么
----------------------------------------------------------------------------
Expand Down
23 changes: 14 additions & 9 deletions docs/source/project_structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
分别是
- [hpyc_core](https://github.com/HowieHz/hpyculator/tree/main/hpyc_core) 核心SDK
- [hpyc_pyside_ui](https://github.com/HowieHz/hpyculator/tree/main/hpyc_pyside_ui) 基于pyside6的应用程序
- [hpyc_cli](https://github.com/HowieHz/hpyculator/tree/main/hpyc_cli) 尽可能小的实现功能的应用程序

[hpyculatorPackage](https://github.com/HowieHz/hpyculatorPackage)仓库内存放着hpyculator模块 可通过pip获取

Expand All @@ -30,6 +31,16 @@ pip install hpyculator
- [data_structure](https://github.com/HowieHz/hpyculator/tree/main/hpyc_core/data_structure) -> 数据结构
- [settings](https://github.com/HowieHz/hpyculator/tree/main/hpyc_core/settings) -> 管理设置文件

### [hpyculatorPackage](https://github.com/HowieHz/hpyculatorPackage)

作为包使用

- [tests](https://github.com/HowieHz/hpyculatorPackage/tree/main/tests) -> 单元测试
- [hpyculator](https://github.com/HowieHz/hpyculatorPackage/tree/main/hpyculator) -> 存放模块
- [hpycore.py](https://github.com/HowieHz/hpyculatorPackage/blob/main/hpyculator/hpycore.py) -> 核心
- [hpydecorator.py](https://github.com/HowieHz/hpyculatorPackage/blob/main/hpyculator/hpydecorator.py) -> 为了方便使用而添加的装饰器
- [hpyfunc.py](https://github.com/HowieHz/hpyculatorPackage/blob/main/hpyculator/hpyfunc.py) -> 为了方便添加的函数

### [hpyc_pyside_ui](https://github.com/HowieHz/hpyculator/tree/main/hpyc_pyside_ui)

`__main__.py` 是入口文件
Expand All @@ -47,12 +58,6 @@ pip install hpyculator
- ui -> ui
- ui_manager -> 管理ui, 程序逻辑

### [hpyculatorPackage](https://github.com/HowieHz/hpyculatorPackage)

作为包使用

- [tests](https://github.com/HowieHz/hpyculatorPackage/tree/main/tests) -> 单元测试
- [hpyculator](https://github.com/HowieHz/hpyculatorPackage/tree/main/hpyculator) -> 存放模块
- [hpycore.py](https://github.com/HowieHz/hpyculatorPackage/blob/main/hpyculator/hpycore.py) -> 核心
- [hpydecorator.py](https://github.com/HowieHz/hpyculatorPackage/blob/main/hpyculator/hpydecorator.py) -> 为了方便使用而添加的装饰器
- [hpyfunc.py](https://github.com/HowieHz/hpyculatorPackage/blob/main/hpyculator/hpyfunc.py) -> 为了方便添加的函数
### [hpyc_cli](https://github.com/HowieHz/hpyculator/tree/main/hpyc_cli)

`__main__.py` 是入口文件
6 changes: 1 addition & 5 deletions docs/source/quick_start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
用户
--------------------

1.从github的 `releases <https://github.com/HowieHz/hpyculator/releases>`__\下载最新版本.zip

2.解压,双击目录下的 点我启动.exe

3.去插件市场(建设中,先用着内置插件)下点插件就能愉快的使用了
`用户手册 <user_manual.html>`_


开发者(开发插件)
Expand Down
12 changes: 10 additions & 2 deletions docs/source/user_manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ hpyculator 用户手册。本文面向对开发不熟悉而希望使用 hpyculat

## 启动 hpyculator

[//]: # (hpyculator有两个版本,一个是使用纯控制台版本)
hpyculator目前有一个版本,是基于pyside6的图形页面版
hpyc_core目前有两个实现,一个是使用纯控制台版本,另一个是基于pyside6的图形界面版

## 使用图形界面版本

Expand All @@ -16,6 +15,15 @@ hpyculator目前有一个版本,是基于pyside6的图形页面版

(程序内置插件,可直接使用)

## 使用命令行界面版本

前往 [HowieHz/hpyculator](https://github.com/HowieHz/hpyculator/releases)
下载适合你的系统的压缩包,解压到一个文件夹内就可以使用。

[插件市场](https://github.com/HowieHz/hpyculatorPluginCatalogue)下点插件就能愉快的使用了

(程序内置插件,可直接使用)

[//]: # (## 使用纯控制台版本)

[//]: # ()
Expand Down
1 change: 1 addition & 0 deletions hpyc_cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[结构介绍](https://hpyculator.readthedocs.io/zh_CN/latest/project_structure.html#hpyc-pyside-ui)
54 changes: 54 additions & 0 deletions hpyc_cli/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from hpyc_core import Core
from pprint import pprint
import os

VERSION = "V1.0.0"
yes = ("y", "Y", "YES", "Yes", "yes")
instance_core = Core()
message_queue = instance_core.getMessageQueue()

if __name__ == "__main__":
os.system("chcp 65001")
print(
f"""\
插件存放目录: {instance_core.getPluginsDirPath()}
设置文件存放目录: {instance_core.getSettingsDirPath()}
输出目录: {instance_core.getOutputDirPath()}
获取到的插件选项名: """
)
pprint(tuple(instance_core.getPluginsOptionToId().keys()))
while True:
option = input("输入你想使用的插件的选项名, 如想退出输入exit\n:")
if option == "exit":
print(f"感谢您的使用, hpyc_cli version:{VERSION}")
break

plugin_id = instance_core.getPluginIdFromOption(option)

print(f"使用提示:\n{instance_core.getPluginMetadata(plugin_id)['help']}")

if not input("如想使用此插件请输入 y 否则输入 n\n:") in yes:
continue
rev_input = input(r"请输入待处理数据(如需换行请输入 \n ):")

if input("如想将结果保存至文件请输入 y 否则输入 n\n:") in yes:
instance_core.eventStartCalculate(
plugin_id=plugin_id, input_data=rev_input, mode="Save"
)
else:
instance_core.eventStartCalculate(
plugin_id=plugin_id, input_data=rev_input, mode="Return"
)
while True: # 消息处理
rev = message_queue.get()
if rev[0] == "OUTPUT":
print(rev[1])
elif rev[0] == "ERROR":
print(f"发生了{rev[1]}\n详细错误:{rev[2]}")
break
elif rev[0] == "MESSAGE":
if rev[1] == "CalculationProgramIsRunning":
print("正在计算, 请耐心等待")
elif rev[1] == "CalculationProgramIsFinished":
print(f"计算完毕, 花费了{rev[2]}ns")
break
29 changes: 29 additions & 0 deletions hpyc_cli/packing.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
chcp 65001

del -Force ".\out\__main__.dist\*" -Recurse
del -Force ".\out\__main__.dist\" -Recurse
del -Force ".\out\full\*" -Recurse
del -Force ".\out\full\" -Recurse
del -Force ".\out\lite\*" -Recurse
del -Force ".\out\lite\" -Recurse

nuitka --mingw64 --standalone --quiet --show-progress --show-memory --windows-icon-from-ico=..\use_for_packing\ico.ico --follow-imports --nofollow-import-to=jpype1,jpype,numpy,numba,hpyculator,hpyc_core --enable-plugin=numpy --output-dir=out __main__.py
# --windows-disable-console

copy-item -path ".\out\__main__.dist" -destination ".\out\lite\bin" -recurse
copy-item -path ".\background_img" -destination ".\out\lite\background_img" -recurse
copy-item -path "..\hpyc_pyside_ui\Plugin" -destination ".\out\lite\Plugin" -recurse
copy-item -path "..\use_for_packing\点我启动.exe" -destination ".\out\lite\点我启动.exe"

upx --best ".\out\lite\bin\__main__.exe"

# must
copy-item -path "..\use_for_packing\packing_must\*" -destination ".\out\lite\bin" -recurse
copy-item -path "..\hpyc_core\hpyc_core" -destination ".\out\lite\bin" -recurse
copy-item -path "..\..\hpyculatorPackage\hpyculator" -destination ".\out\lite\bin" -recurse

# extra
copy-item -path ".\out\lite" -destination ".\out\full" -recurse
copy-item -path "..\use_for_packing\packing_extra\*" -destination ".\out\full\bin" -recurse

# hpyculator-v1.0.0-cli-win-lite.7z
2 changes: 1 addition & 1 deletion hpyc_core/hpyc_core/_calculate/calculate_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from .. import _message_queue
from ..data_structure import MetadataDict
from ..plugin import instance_plugin_manager
from .._plugin import instance_plugin_manager


class CalculationManager:
Expand Down
14 changes: 10 additions & 4 deletions hpyc_core/hpyc_core/_data_structure/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from typing import TypedDict
from typing import TypedDict, Literal
import hpyculator as hpyc


class MetadataDict(TypedDict, total=False):
"""插件元数据数据类型"""

input_mode: int
input_mode: Literal[hpyc.STRING, hpyc.NUM, hpyc.FLOAT]
id: str
option: str
version: str
Expand All @@ -16,5 +17,10 @@ class MetadataDict(TypedDict, total=False):
author: str | list
help: str
output_end: str
return_mode: int
fullwidth_symbol: int
return_mode: Literal[
hpyc.RETURN_ONCE,
hpyc.RETURN_ITERABLE,
hpyc.NO_RETURN,
hpyc.NO_RETURN_SINGLE_FUNCTION,
]
fullwidth_symbol: Literal[hpyc.ON, hpyc.OFF]
8 changes: 4 additions & 4 deletions hpyc_pyside_ui/Plugin/heron_s_formula_hz.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ def on_calculate(data: str, do_what):
"""计算函数"""
for pattern in [",", ",", " "]:
if pattern in data:
a, b, c, *_ = map(
lambda num: int(num) if num.isdigit() else float(num),
data.split(pattern),
)
a, b, c, *_ = [
(int(num) if num.isdigit() else float(num))
for num in data.split(pattern)
]
break
else:
hpyc.output("请按格式输入!!!")
Expand Down
Loading

0 comments on commit 8261547

Please sign in to comment.