<!-- markdownlint-disable MD041 -->
<p align="center">
<a href="https://nonebot.dev/"><img src="https://nonebot.dev/logo.png" width="200" height="200" alt="nonebot"></a>
</p>
<div align="center">
# NoneBot Plugin LocalStore
<!-- prettier-ignore-start -->
<!-- markdownlint-disable-next-line MD036 -->
_✨ NoneBot 本地数据存储插件 ✨_
<!-- prettier-ignore-end -->
</div>
<p align="center">
<a href="https://raw.githubusercontent.com/nonebot/plugin-localstore/master/LICENSE">
<img src="https://img.shields.io/github/license/nonebot/plugin-localstore.svg" alt="license">
</a>
<a href="https://pypi.python.org/pypi/nonebot-plugin-localstore">
<img src="https://img.shields.io/pypi/v/nonebot-plugin-localstore.svg" alt="pypi">
</a>
<img src="https://img.shields.io/badge/python-3.8+-blue.svg" alt="python">
</p>
## 使用方式
加载插件后使用 `require` 声明插件依赖,直接使用 `localstore` 插件提供的函数即可。
```python
from pathlib import Path
from nonebot import require
require("nonebot_plugin_localstore")
import nonebot_plugin_localstore as store
plugin_cache_dir: Path = store.get_plugin_cache_dir()
plugin_cache_file: Path = store.get_plugin_cache_file("filename")
plugin_config_dir: Path = store.get_plugin_config_dir()
plugin_config_file: Path = store.get_plugin_config_file("filename")
plugin_data_dir: Path = store.get_plugin_data_dir()
plugin_data_file: Path = store.get_plugin_data_file("filename")
```
## 存储路径
在项目安装插件后,可以使用 `nb-cli` 查看具体的存储路径:
```bash
nb localstore
```
参考路径如下:
### cache path
- macOS: `~/Library/Caches/<AppName>`
- Unix: `~/.cache/<AppName>` (XDG default)
- Windows: `C:\Users\<username>\AppData\Local\<AppName>\Cache`
### data path
- macOS: `~/Library/Application Support/<AppName>`
- Unix: `~/.local/share/<AppName>` or in $XDG_DATA_HOME, if defined
- Win XP (not roaming): `C:\Documents and Settings\<username>\Application Data\<AppName>`
- Win 7 (not roaming): `C:\Users\<username>\AppData\Local\<AppName>`
### config path
- macOS: same as user_data_dir
- Unix: `~/.config/<AppName>`
- Win XP (roaming): `C:\Documents and Settings\<username>\Local Settings\Application Data\<AppName>`
- Win 7 (roaming): `C:\Users\<username>\AppData\Roaming\<AppName>`
## 配置项
插件支持配置全局存储路径,也支持为插件单独配置存储路径。
```dotenv
LOCALSTORE_CACHE_DIR=/tmp/cache
LOCALSTORE_DATA_DIR=/tmp/data
LOCALSTORE_CONFIG_DIR=/tmp/config
LOCALSTORE_PLUGIN_CACHE_DIR='
{
"plugin1": "/tmp/plugin1/cache",
"plugin2:sub_plugin": "/tmp/plugin2/sub_plugin/cache"
}
'
LOCALSTORE_PLUGIN_DATA_DIR='
{
"plugin1": "/tmp/plugin1/data",
"plugin2:sub_plugin": "/tmp/plugin2/sub_plugin/data"
}
'
LOCALSTORE_PLUGIN_CONFIG_DIR='
{
"plugin1": "/tmp/plugin1/config",
"plugin2:sub_plugin": "/tmp/plugin2/sub_plugin/config"
}
'
```
Raw data
{
"_id": null,
"home_page": "https://github.com/nonebot/plugin-localstore",
"name": "nonebot-plugin-localstore",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "nonebot2, qq, plugin",
"author": "yanyongyu",
"author_email": "yyy@nonebot.dev",
"download_url": "https://files.pythonhosted.org/packages/5e/aa/a038f16a1770e0f3a12efa4e99ffee236a7742bbbba0f7ed7c369a0e073e/nonebot_plugin_localstore-0.7.3.tar.gz",
"platform": null,
"description": "<!-- markdownlint-disable MD041 -->\n<p align=\"center\">\n <a href=\"https://nonebot.dev/\"><img src=\"https://nonebot.dev/logo.png\" width=\"200\" height=\"200\" alt=\"nonebot\"></a>\n</p>\n\n<div align=\"center\">\n\n# NoneBot Plugin LocalStore\n\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable-next-line MD036 -->\n_\u2728 NoneBot \u672c\u5730\u6570\u636e\u5b58\u50a8\u63d2\u4ef6 \u2728_\n<!-- prettier-ignore-end -->\n\n</div>\n\n<p align=\"center\">\n <a href=\"https://raw.githubusercontent.com/nonebot/plugin-localstore/master/LICENSE\">\n <img src=\"https://img.shields.io/github/license/nonebot/plugin-localstore.svg\" alt=\"license\">\n </a>\n <a href=\"https://pypi.python.org/pypi/nonebot-plugin-localstore\">\n <img src=\"https://img.shields.io/pypi/v/nonebot-plugin-localstore.svg\" alt=\"pypi\">\n </a>\n <img src=\"https://img.shields.io/badge/python-3.8+-blue.svg\" alt=\"python\">\n</p>\n\n## \u4f7f\u7528\u65b9\u5f0f\n\n\u52a0\u8f7d\u63d2\u4ef6\u540e\u4f7f\u7528 `require` \u58f0\u660e\u63d2\u4ef6\u4f9d\u8d56\uff0c\u76f4\u63a5\u4f7f\u7528 `localstore` \u63d2\u4ef6\u63d0\u4f9b\u7684\u51fd\u6570\u5373\u53ef\u3002\n\n```python\nfrom pathlib import Path\nfrom nonebot import require\n\nrequire(\"nonebot_plugin_localstore\")\n\nimport nonebot_plugin_localstore as store\n\nplugin_cache_dir: Path = store.get_plugin_cache_dir()\nplugin_cache_file: Path = store.get_plugin_cache_file(\"filename\")\nplugin_config_dir: Path = store.get_plugin_config_dir()\nplugin_config_file: Path = store.get_plugin_config_file(\"filename\")\nplugin_data_dir: Path = store.get_plugin_data_dir()\nplugin_data_file: Path = store.get_plugin_data_file(\"filename\")\n```\n\n## \u5b58\u50a8\u8def\u5f84\n\n\u5728\u9879\u76ee\u5b89\u88c5\u63d2\u4ef6\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528 `nb-cli` \u67e5\u770b\u5177\u4f53\u7684\u5b58\u50a8\u8def\u5f84\uff1a\n\n```bash\nnb localstore\n```\n\n\u53c2\u8003\u8def\u5f84\u5982\u4e0b\uff1a\n\n### cache path\n\n- macOS: `~/Library/Caches/<AppName>`\n- Unix: `~/.cache/<AppName>` (XDG default)\n- Windows: `C:\\Users\\<username>\\AppData\\Local\\<AppName>\\Cache`\n\n### data path\n\n- macOS: `~/Library/Application Support/<AppName>`\n- Unix: `~/.local/share/<AppName>` or in $XDG_DATA_HOME, if defined\n- Win XP (not roaming): `C:\\Documents and Settings\\<username>\\Application Data\\<AppName>`\n- Win 7 (not roaming): `C:\\Users\\<username>\\AppData\\Local\\<AppName>`\n\n### config path\n\n- macOS: same as user_data_dir\n- Unix: `~/.config/<AppName>`\n- Win XP (roaming): `C:\\Documents and Settings\\<username>\\Local Settings\\Application Data\\<AppName>`\n- Win 7 (roaming): `C:\\Users\\<username>\\AppData\\Roaming\\<AppName>`\n\n## \u914d\u7f6e\u9879\n\n\u63d2\u4ef6\u652f\u6301\u914d\u7f6e\u5168\u5c40\u5b58\u50a8\u8def\u5f84\uff0c\u4e5f\u652f\u6301\u4e3a\u63d2\u4ef6\u5355\u72ec\u914d\u7f6e\u5b58\u50a8\u8def\u5f84\u3002\n\n```dotenv\nLOCALSTORE_CACHE_DIR=/tmp/cache\nLOCALSTORE_DATA_DIR=/tmp/data\nLOCALSTORE_CONFIG_DIR=/tmp/config\n\nLOCALSTORE_PLUGIN_CACHE_DIR='\n{\n \"plugin1\": \"/tmp/plugin1/cache\",\n \"plugin2:sub_plugin\": \"/tmp/plugin2/sub_plugin/cache\"\n}\n'\nLOCALSTORE_PLUGIN_DATA_DIR='\n{\n \"plugin1\": \"/tmp/plugin1/data\",\n \"plugin2:sub_plugin\": \"/tmp/plugin2/sub_plugin/data\"\n}\n'\nLOCALSTORE_PLUGIN_CONFIG_DIR='\n{\n \"plugin1\": \"/tmp/plugin1/config\",\n \"plugin2:sub_plugin\": \"/tmp/plugin2/sub_plugin/config\"\n}\n'\n```\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Local Storage Support for NoneBot2",
"version": "0.7.3",
"project_urls": {
"Documentation": "https://github.com/nonebot/plugin-localstore#readme",
"Homepage": "https://github.com/nonebot/plugin-localstore",
"Repository": "https://github.com/nonebot/plugin-localstore"
},
"split_keywords": [
"nonebot2",
" qq",
" plugin"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d6ab5589d873bbc47bfb70c5fca95de7538568ddfd4e9a1f0a40c16d3b80077d",
"md5": "3a5c6dae4c91257c62f3a8f2fd7ec369",
"sha256": "1bc239b4b5320df0dc08eada7c4f8ba4cb92d4dc3134bf4646ab5e297bd7e575"
},
"downloads": -1,
"filename": "nonebot_plugin_localstore-0.7.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3a5c6dae4c91257c62f3a8f2fd7ec369",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 6894,
"upload_time": "2024-12-21T11:34:37",
"upload_time_iso_8601": "2024-12-21T11:34:37.897886Z",
"url": "https://files.pythonhosted.org/packages/d6/ab/5589d873bbc47bfb70c5fca95de7538568ddfd4e9a1f0a40c16d3b80077d/nonebot_plugin_localstore-0.7.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5eaaa038f16a1770e0f3a12efa4e99ffee236a7742bbbba0f7ed7c369a0e073e",
"md5": "376114b4df4f098a8e8abf8323be9dca",
"sha256": "1aff10e2dacfc5bc9ce239fd34849f8d7172a118135dbc5aeba1c97605d9959d"
},
"downloads": -1,
"filename": "nonebot_plugin_localstore-0.7.3.tar.gz",
"has_sig": false,
"md5_digest": "376114b4df4f098a8e8abf8323be9dca",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 5681,
"upload_time": "2024-12-21T11:34:39",
"upload_time_iso_8601": "2024-12-21T11:34:39.964716Z",
"url": "https://files.pythonhosted.org/packages/5e/aa/a038f16a1770e0f3a12efa4e99ffee236a7742bbbba0f7ed7c369a0e073e/nonebot_plugin_localstore-0.7.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-21 11:34:39",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "nonebot",
"github_project": "plugin-localstore",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "nonebot-plugin-localstore"
}