A Python package for validating chatfic-format data
Project description
Chatfic Validator
Description
The Chatfic Validator is a Python package for validating chatfic data. It checks the format and structure of chatfic data to ensure it conforms to the specified schema.
Installation
To install the Chatfic Validator, you can use pip:
pip install chatfic-validator
Usage
Here's an example of how to use the Chatfic Validator:
from chatfic_validator import ChatficValidator as validator, ChatficFormat
# Load the chatfic data from a file
with open('storybasic.json', 'r', encoding="utf-8") as file:
json_text = file.read()
# Validate the chatfic data
result = validator.validate_json_text(
json_text=json_text,
chatfic_format=ChatficFormat.BASIC_JSON,
multimedia_list=["time.jpeg"]
)
# Check if the validation was successful
if result.is_valid:
print("Chatfic data is valid!")
else:
print("Chatfic data is invalid.")
for error in result.errors:
print(error)
for warning in result.warnings:
print(warning)
ChatficFormat enums: BASIC_JSON and COMPILED_JSON. These represent the storybasic.json and story.json file contents, respectively.
The multimedia_list parameter takes a list of the multimedia files that are expected to referenced within the story data.
validate_json_text method returns a ChatficValidationResult instance with 3 attributes:
is_valid:bool
errors: List[ChatficValidationError]
warnings: List[str]
validate_json_text method loads json text and runs validate_dict method. This second method can be used directly with the same parameters (chatfic_format and multimedia_list)
More information about the chatfic-format can be found here:
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
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 chatfic_validator-0.2.4.tar.gz.
File metadata
- Download URL: chatfic_validator-0.2.4.tar.gz
- Upload date:
- Size: 23.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
582e7ff87c5d84f1e6bebccc7120a8345a9ce13c8a1a77ec6b9e5c9115e38b2c
|
|
| MD5 |
3865cf0df124f9f99a487ddc01931f75
|
|
| BLAKE2b-256 |
4edd2ce16b285e0140f0b9e180c21bedff71b134e558a9dfc0b3b06261097394
|
File details
Details for the file chatfic_validator-0.2.4-py3-none-any.whl.
File metadata
- Download URL: chatfic_validator-0.2.4-py3-none-any.whl
- Upload date:
- Size: 24.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3df8aad2acaf8a2679847eb3f9d579aa4e330a55ef2e4e2518bf987cf3a29c88
|
|
| MD5 |
752c17ff3110bc5b0d9fa5d437c0e6e7
|
|
| BLAKE2b-256 |
17e95b8dde1cd4a012058d8971cfee3b91d9ac693c507ac2fee56f9c93be798e
|