-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from HowieHz/dev
1.7.0
- Loading branch information
Showing
124 changed files
with
1,557 additions
and
1,104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
|
||
## 装依赖 | ||
|
||
毋庸置疑python3是必须的 | ||
毋庸置疑python3.10是必须的 | ||
|
||
确保你cmd的工作目录为docs | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
创建核心实例 | ||
============================================= | ||
首先确保你安装了 ``hpyc_core`` 模块 | ||
|
||
.. code-block:: bash | ||
pip install hpyc_core | ||
接下来创建核心实例 | ||
|
||
.. code-block:: python | ||
from hpyc_core import Core | ||
instance_core = Core(output_dir_path: Optional[str] = None, # 输出目录 | ||
settings_dir_path: Optional[str] = None, # 设置文件所在目录 | ||
plugins_dir_path: Optional[str] = None, # 插件存放目录 | ||
settings_file_name: str = "hpyculator_setting", # 设置文件名 | ||
settings_file_format: str = "json",) # 设置文件格式 | ||
.. list-table:: 选取顺序: 输入 > 设置文件 > 默认值! | ||
:widths: 20 20 45 20 | ||
:header-rows: 1 | ||
|
||
* - 参数 | ||
- 设置文件中对应键 | ||
- 默认值 | ||
- 数据要求 | ||
* - output_dir_path | ||
- "output_dir_path" | ||
- str(os.path.join(os.getcwd(), "Output")) | ||
- 字符串类型 | ||
* - settings_dir_path | ||
- 无 | ||
- str(os.path.join(os.getcwd(), "Settings")) | ||
- 字符串类型 | ||
* - plugins_dir_path | ||
- "plugins_dir_path" | ||
- str(os.path.join(os.getcwd(), "Plugin")) | ||
- 字符串类型 | ||
* - settings_file_name | ||
- 无 | ||
- "hpyculator_setting" | ||
- 字符串类型 | ||
* - settings_file_format | ||
- 无 | ||
- "json" | ||
- "json" | "yaml" | "toml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
数据结构 | ||
================== | ||
可通过 ``from hpyc_core.data_structure import 结构名`` 来获取对应结构 | ||
|
||
|
||
MetadataDict | ||
--------------- | ||
插件元数据规定 | ||
|
||
通过 ``getPluginMetadata`` 获取到的数据类型 | ||
|
||
.. code-block:: python | ||
class MetadataDict(TypedDict, total=False): | ||
"""插件元数据数据类型""" | ||
input_mode: int | ||
id: str | ||
option: str | ||
version: str | ||
tag: list | str | ||
save_name: str | ||
quantifier: str | ||
output_start: str | ||
output_name: str | ||
author: str | list | ||
help: str | ||
output_end: str | ||
return_mode: int | ||
fullwidth_symbol: int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
事件 | ||
============================================= | ||
以下均为 ``hpyc_core.Core`` 的方法 | ||
|
||
eventStartCalculate | ||
----------------------- | ||
开始计算 (启动计算线程) | ||
|
||
.. code-block:: python | ||
eventStartCalculate(self, plugin_id: str, input_data: Any, mode="Return") -> None: | ||
参数说明 | ||
- plugin_id: 插件id, 类型 ``str`` | ||
- input_data: 未处理的原始输入数据, 类型 ``typing.Any`` | ||
- mode: 计算模式, 类型 ``str`` | ||
|
||
可能引发的异常 | ||
- ValueError: 当输入了不存在的mode | ||
|
||
mode参数别名 | ||
- 运算结果仅返回到消息队列 | ||
"ReturnAfterComputing", | ||
"ComputingAndReturn", | ||
"RAC", | ||
"Return", | ||
"ReturnAfterCalculating", | ||
|
||
- 运算结果仅保存到文件中 | ||
"SaveAfterComputing", | ||
"ComputingAndSave", | ||
"SAC", | ||
"Save", | ||
"SaveAfterCalculating", | ||
|
||
- 运算结果从缓冲区中返回到消息队列 | ||
"ReturnAfterComputingFromBuffer", | ||
"ComputingAndReturnFromBuffer", | ||
"RACFB", | ||
"ReturnFromBuffer", | ||
"ReturnAfterCalculatingFromBuffer", | ||
|
||
- 运算结果从缓冲区中返回到消息队列,但是有返回上限 | ||
"ReturnAfterComputingFromLimitedBuffer", | ||
"ComputingAndReturnFromLimitedBuffer", | ||
"RACFLB", | ||
"ReturnFromLimitedBuffer", | ||
"ReturnAfterCalculatingFromLimitedBuffer", | ||
|
||
eventReloadPlugins | ||
----------------------- | ||
重新加载插件 | ||
|
||
.. code-block:: python | ||
def eventReloadPlugins(self) -> None: | ||
eventExit | ||
----------------------- | ||
退出流程,进行一些收尾工作防止进程残留 | ||
|
||
默认使用atexit模块注册到退出事件 | ||
|
||
所以一般来说不需要手动触发 | ||
|
||
.. code-block:: python | ||
def eventExit() -> None: | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
获取 | ||
============================================= | ||
以下均为 ``hpyc_core.Core`` 的方法 | ||
|
||
getMessageQueue | ||
----------------------- | ||
获取消息输出队列 | ||
|
||
.. code-block:: python | ||
def getMessageQueue() -> Queue: | ||
getSettingsFileInstance | ||
----------------------- | ||
获取设置文件实例 | ||
|
||
.. code-block:: python | ||
def getSettingsFileInstance() -> SettingsFileObject: | ||
getPluginsDirPath | ||
----------------------- | ||
获取插件存放路径 | ||
|
||
.. code-block:: python | ||
def getMessageQueue() -> str: | ||
getOutputDirPath | ||
----------------------- | ||
获取输出路径 | ||
|
||
.. code-block:: python | ||
def getOutputDirPath(self) -> str: | ||
getSettingsDirPath | ||
----------------------- | ||
获取设置文件存放路径 | ||
|
||
.. code-block:: python | ||
def getSettingsDirPath(self) -> str: | ||
getPluginsTagOption | ||
----------------------- | ||
获取所有插件的tag,tag对应插件选项名 | ||
|
||
(((plugin1_tag1, plugin1_tag2, ...), plugin1_option), ((plugin2_tag1,), plugin2_option)), ...) | ||
|
||
.. code-block:: python | ||
def getPluginsTagOption() -> tuple[tuple[tuple[str, ...], str], ...]: | ||
getPluginsOptionToId | ||
----------------------- | ||
获取插件选项名和id的映射表 | ||
|
||
.. code-block:: python | ||
def getPluginsOptionToId() -> dict[str, str]: | ||
getPluginIdFromOption | ||
----------------------- | ||
通过选项名获得对应插件ID | ||
|
||
.. code-block:: python | ||
getPluginIdFromOption(option: str) -> str: | ||
getPluginInstance | ||
----------------------- | ||
获取对应插件实例 | ||
|
||
.. code-block:: python | ||
def getPluginInstance(plugin_id: str) -> ModuleType: | ||
getPluginMetadata | ||
----------------------- | ||
拖过插件ID获取对应插件元数据 | ||
|
||
.. code-block:: python | ||
def getPluginMetadata(plugin_id: str) -> MetadataDict: | ||
Oops, something went wrong.