Check the syntax of a YAML file as you want to be. Checking the syntax of the YAML file is based on BaseModel of Pydantic.
Project description
Yaml Syntax
yaml-syntax to check a YAML file with your own standard for keys or fields.
like you want a YAML file with these keys:
version, service, name
for this you can make a serializer with pydantic to check it:
from pydantic import BaseModel
class MySyntax(BaseModel):
version:str
service:str
name:str
Note: You can use any option of BaseModel to build your own serializer. For example, use Field to create default values for your fields, or use typing to handle required fields, or anything else to make it more advanced.
and for example this is your yaml file:
version: 'v1.0.0'
service: 'aws'
name: 'test'
then you can check this file is correct or not:
from yaml_syntax.syntax import YamlSyntax
yaml = YamlSyntax.from_file(syntax_schema=MySyntax, yaml_file="test.yaml")
now you can use your serialized data:
serialized_data = yaml.serialized_data
print(serialized_data.version)
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 yaml_syntax-0.0.9.tar.gz.
File metadata
- Download URL: yaml_syntax-0.0.9.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee95a18b63de42f8cad0520df5f7a5faebb70c2ddfc9421890b7901891bbdc92
|
|
| MD5 |
a4d614e406d196c1c275cf11aa6e057e
|
|
| BLAKE2b-256 |
345545256d3ea838780904f5db2bf2f9851977d2399af9aa4a2fc8163fc7cf4c
|
File details
Details for the file yaml_syntax-0.0.9-py3-none-any.whl.
File metadata
- Download URL: yaml_syntax-0.0.9-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d777b981bf9ee9bd86d6d34f5ba07c66e31ad7e38450765bb483f17cefef61ec
|
|
| MD5 |
e917f5a9dbecb7a9e1d28d33610494a6
|
|
| BLAKE2b-256 |
b27ccc38a1fd431ed92b3ad4238cff3b002f6f7d08a9cdf6e4a5aa21f3e315a5
|