MetadataManager 使用说明
简介
MetadataManager 是一个简单的 JSON 元数据管理器,旨在方便地读取、写入和操作 JSON 文件。它提供了一系列方法来管理嵌套的 JSON 数据结构,支持添加、删除、读取和更新操作。
特性
- 读取和解析 JSON 文件
- 保存和更新 JSON 文件
- 支持嵌套键的访问
- 支持从列表中添加和删除元素
- 可选的唯一性检查以防止重复项
安装
确保您已安装 Python 3.x。将 metadata_manager.py 文件下载到您的项目目录中。
# 克隆或下载代码
git clone https://github.com/amumu2022/MetadataManager.git
cd https://github.com/amumu2022/MetadataManager.git
使用方法
初始化
首先,您需要创建一个 MetadataManager 实例。您可以指定缓存目录的名称,默认为 cache_path。
from metadata_manager import MetadataManager
manager = MetadataManager(cache_dir='your_cache_directory')
读取数据
使用 read 方法读取 JSON 文件中的数据。您可以提供多个键以访问嵌套数据。
data = manager.read('your_file_name', 'key1', 'key2')
如果未提供键,则返回整个字典。
添加或更新数据
使用 add 方法添加或更新指定嵌套键的值。
manager.add('your_file_name', 'key1', 'key2', value='your_value')
删除数据
使用 delete 方法删除指定嵌套键的值。
success = manager.delete('your_file_name', 'key1', 'key2')
向列表中添加元素
使用 add_to_list 方法向指定键的列表中添加元素。可以选择设置 unique 参数以防止添加重复项。
manager.add_to_list('your_file_name', 'your_list_key', value='new_value', unique=True)
Metadata
Release files for metadatamanager 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| metadatamanager-0.1.0.tar.gz | 4.3 kB | Without provenance | Details for metadatamanager-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| metadatamanager-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for metadatamanager-0.1.0-py3-none-any.whl |
Total release size: 9.6 kB
Release files / metadatamanager-0.1.0.tar.gz
| Download URL | metadatamanager-0.1.0.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aea7ec732db45c1130d9acf52c86d416a7d30878e45efbe5620593519e6bc3e7
|
|
BLAKE2b-256 checksum How to use checksums |
e5927bcbcfa0f0ffa13e4aa9f680768182b14bbd0c3cb41e184b44b1d293632c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.1 CPython/3.10.8 Windows/10
|
Release files / metadatamanager-0.1.0-py3-none-any.whl
| Download URL | metadatamanager-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
69b0e24a6ee5a5d34d8574173432ce433aa95d08aeec41ba030cd897c79107c2
|
|
BLAKE2b-256 checksum How to use checksums |
e741fbbcd90c1a583a9f0da930d86a262010e6b0e63ad3f553bfe3e394c9b6b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.1 CPython/3.10.8 Windows/10
|
Security for metadatamanager 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.