NoneBot2 编程命名风格快速转换插件 (snake_case / camelCase / PascalCase / kebab-case / UPPER_SNAKE_CASE / Train-Case)
Project description
📖 介绍
写代码时经常被 userName / user_name / USER_NAME 之间的转换打断思路?这个插件让你在群聊里一句话搞定。
支持在以下 6 种命名风格之间互转,自带智能分词,能正确处理形如 XMLParserHTTP_url2name 的混合大小写与缩写组合:
snake_casecamelCasePascalCasekebab-caseUPPER_SNAKE_CASETrain-Case
💿 安装
使用 nb-cli 安装
nb plugin install nonebot-plugin-namepy
使用包管理器安装
pip install nonebot-plugin-namepy
或
poetry add nonebot-plugin-namepy
打开 NoneBot 项目根目录下的 pyproject.toml 文件, 在 [tool.nonebot] 部分追加写入:
plugins = ["nonebot_plugin_namepy"]
🎉 使用
| 指令 | 说明 | 示例 |
|---|---|---|
/命名 <标识符> |
一次性展示全部 6 种风格 | /命名 user_name |
/驼峰 <标识符> |
转 camelCase |
/驼峰 user_name → userName |
/大驼峰 <标识符> |
转 PascalCase |
/大驼峰 user_name → UserName |
/下划线 <标识符> |
转 snake_case |
/下划线 userName → user_name |
/常量 <标识符> |
转 UPPER_SNAKE_CASE |
/常量 userName → USER_NAME |
/中划线 <标识符> |
转 kebab-case |
/中划线 userName → user-name |
/标题 <标识符> |
转 Train-Case |
/标题 user_name → User-Name |
支持的别名:大驼峰 ↔ 帕斯卡,下划线 ↔ 蛇形,常量 ↔ 大写下划线 ↔ 大下划线,中划线 ↔ 连字符,标题 ↔ 火车。
🔍 智能分词
输入 /命名 XMLParserHTTP_url2name 会得到:
原始词元:['xml', 'parser', 'http', 'url', '2', 'name']
snake_case : xml_parser_http_url_2_name
camelCase : xmlParserHttpUrl2Name
PascalCase : XmlParserHttpUrl2Name
kebab-case : xml-parser-http-url-2-name
UPPER_SNAKE_CASE: XML_PARSER_HTTP_URL_2_NAME
Train-Case : Xml-Parser-Http-Url-2-Name
可正确处理:
- 多重大写缩略词后接小写:
HTTPServer→["http", "server"] - 字母数字交替:
v2Tag42→["v", "2", "tag", "42"] - 已存在的分隔符:
user-id_FOO→["user", "id", "foo"]
📄 许可
本项目采用 MIT License。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nonebot_plugin_namepy-0.1.0.tar.gz.
File metadata
- Download URL: nonebot_plugin_namepy-0.1.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7c39e89d95c06af79b44ba613447417b6c4101bf8294a0c76a01673f7ebda53
|
|
| MD5 |
eb800ac26bb1beafa8a7fe97a37f3982
|
|
| BLAKE2b-256 |
944401fffac4a7c0923e1410ec5178f97920529822fd88487b1c848b712f133b
|
File details
Details for the file nonebot_plugin_namepy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nonebot_plugin_namepy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
469676048eedec7ee047e50f98e21e82f7f4fbf9acdf777a1b436a424c88ca55
|
|
| MD5 |
8a5f217a5956c31323013de9bff263e8
|
|
| BLAKE2b-256 |
4f83da32663b0945ee50a7c0997a74167d3091a8d05134b503dc9ea724e3a075
|