Skip to main content

`MetadataManager` 是一个简单的 JSON 元数据管理器,旨在方便地读取、写入和操作 JSON 文件。它提供了一系列方法来管理嵌套的 JSON 数据结构,支持添加、删除、读取和更新操作。

Project description

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

metadatamanager-0.1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

metadatamanager-0.1.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file metadatamanager-0.1.0.tar.gz.

File metadata

  • Download URL: metadatamanager-0.1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.10.8 Windows/10

File hashes

Hashes for metadatamanager-0.1.0.tar.gz
Algorithm Hash digest
SHA256 aea7ec732db45c1130d9acf52c86d416a7d30878e45efbe5620593519e6bc3e7
MD5 f5207d0e8fba1abd68ba368f13613292
BLAKE2b-256 e5927bcbcfa0f0ffa13e4aa9f680768182b14bbd0c3cb41e184b44b1d293632c

See more details on using hashes here.

File details

Details for the file metadatamanager-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: metadatamanager-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.10.8 Windows/10

File hashes

Hashes for metadatamanager-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 69b0e24a6ee5a5d34d8574173432ce433aa95d08aeec41ba030cd897c79107c2
MD5 5426c19b821aec7586a3379a1e37068f
BLAKE2b-256 e741fbbcd90c1a583a9f0da930d86a262010e6b0e63ad3f553bfe3e394c9b6b2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page