SiteD plugin testing tool for Python version, for SiteD developers testing their own plugins on computer/desktop platform.
[ 中文说明]
schema0/1/2
buildUrl
, parseUrl(CALL::)
, parse(get/post/@null)
, require(include online js library)
header(cookie/referer)
, ua
configurationshots
, updates
, tags
, tag(subtag)
, search
, book[12345678](sections)
, section[123]
nodes"""
* Outputs nodes' data to console on Python.
* @param sitedPath: A string of .sited or .sited.xml file's path, advises to absolute path.
* @param key: A keyword string that is used for searching on search node.
* @param callback: Outputs the entrance test functions of home/search/book node etc.
* @param nodeName@doTest@home_test: The string "hots", "updates" or "tags", which starts test function of hots/updates/tags node.
* @param bookUrl@book_test: Url argument of book node function, for test of book node alone.
"""
sited_test(
sitedPath: str,
key: str,
callback: (
home_test: (
cback: (
doTest: (nodeName: "hots" | "updates" | "tags", cb: () -> None
) -> None
) -> None
) -> None,
search_test: (cb: () -> None) -> None,
book_test: (bookUrl: str, from_where: "from_externalValue", cb: () -> None) -> None,
tag_test: (tagUrl: str, from_where: str, cb: () -> None) -> None,
section_test: (sectionUrl: str, from_where: str, cb: () -> None) -> None,
subtag_test: (subtagUrl: str, from_where: str, cb: () -> None) -> None
) -> None
): None
1. After pip installs the project as
python -m pip install sited_test_py
A. Uses Python to run a py script like demo.py which imports the API within the sited_test_py directory.
# demo.py, has written file path of .sited or .sited.xml
import asyncio
import os
import sys
if __package__ == "" or __package__ == None:
os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")
sys.path.insert(0, path)
from sited_test_py import sited_test, LogWriter
sitedPath = os.path.join(
os.path.dirname(os.path.realpath(__file__)), "demo.sited.xml"
)
key = "我们"
async def callback(home_test, search_test, book_test, *args):
async def cb(*args):pass
async def cback(doTest):
if doTest:
await doTest("hots", cb)
await doTest("updates", cb)
await doTest("tags", cb)
await home_test(cback)
await search_test(cb)
# bookUrl = "http://... url argument of book node function such as the link in favorites"
# await book_test(bookUrl, "from_externalValue", cb)
asyncio.run(sited_test(sitedPath, key, callback))
LogWriter.tryClose()
cd /path/to/site-packages/sited_test_py
python demo.py
or B.
need not to cd, input single
sited_test_py
on CLI will get:
Tests own SiteD plugin on Python
sitedPath: File path of .sited or .sited.xml.
key(optional): A keyword string that is used for searching on search node, if not be inputted, built-in keyword of bin.py would be used.
Usage: sited_test_py <sitedPath> [key]
Usage: sited_test_py [options]
Options:
--version Show version number
--help Show help
--demo Tests a demo sited plugin
Examples:
sited_test_py /path/to/sited.sited.xml #Outputs nodes' data to console on Python.
or C. By the way, using Code Runner extension or built-in debugger to call Python is quick, when you are editing sited plugin file on VS Code.
a. You can start Code Runner when editor focuses sited plugin file, after configuring Code Runner to execute .sited and .sited.xml as python command below, test the plugin directly, need not to write the plugin path, it will be identified by $fullFileName.
"code-runner.executorMapByGlob": {
"*.{sited,sited.xml}": "python /path/to/site-packages/sited_test_py/bin.py $fullFileName key"
}
// replace /path/to/node_modules/sited_test_py/bin.py with actual bin.py's path. If (key) be deleted, that built-in keyword of bin.py would be used.
or b. You can start debugging (sited_test_py) when editor focuses sited plugin file, after adding a debug configure to execute as python command below, test the plugin directly, need not to write the plugin path, it will be identified by ${file}.
"launch": {
"version": "0.2.0",
"configurations": [
{
"name": "sited_test_py",
"type": "python",
"request": "launch",
// "cwd": "${fileDirname}",
"program": "/path/to/site-packages/sited_test_py/bin.py",
"args": ["${file}", "searchword"],
// "stopOnEntry": true,
"console": "internalConsole" // internalConsole integratedTerminal
}
]
}
replace /path/to/site-packages/sited_test_py/bin.py with actual bin.py's path. If "searchword"
was deleted, that built-in keyword of bin.py would be used.
SiteD plugin center: Official SiteD plugin center.
ddcat_plugin_develop: Knowledge about sited plugin development.
DDCat SiteD: Syntax extension for VS Code, enabled .sited and .sided.xml files in sited language, support syntax highlight.
generators-sited-plugin: Yeoman generator for sited plugin.
sited_test SiteD plugin testing tool for Node JavaScript version.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。