Skip to content

Commit

Permalink
feat(yaml): switch from YAML 1.1 to YAML 1.2
Browse files Browse the repository at this point in the history
Migrate from PyYAML to ruamel.yaml.

Drop support for `--sort-keys` for YAML output.

Replace the keyword argument `ordered` with `sort_keys`.
Create a dataclass for `yaml_options` arguments.
  • Loading branch information
dbohdan committed Feb 13, 2024
1 parent 05333e6 commit 1f48011
Show file tree
Hide file tree
Showing 17 changed files with 282 additions and 260 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ Binary fields can be converted between CBOR, MessagePack, and YAML.
The Local Date type can only be converted to JSON (as a string) and YAML.
The Local Time type cannot be converted to any other format.
Offset Date-Time and its equivalents can be converted between CBOR, MessagePack, TOML, and YAML.
Keys of any date-time type are converted to string TOML keys.
- Date and time types are converted to JSON strings.
- The date and time types have no JSON counterpart.
They are converted to JSON strings with the `--stringify` option.
They cannot be safely roundtripped through JSON.
- A YAML timestamp with only a date becomes a YAML timestamp or a TOML Local Date-Time for the midnight of that date.
This means you cannot roundtrip every YAML document through Remarshal.

## Installation

Expand Down
4 changes: 2 additions & 2 deletions example.cbor
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
eowner�cdob�x1979-05-27T07:32:00+00:00cbiox1GitHub Cofounder & CEO
Likes tater tots and beer.dnamerTom Preston-WernerlorganizationfGitHubetitlelTOML Examplegclients�ddata��egammaedelta�ehosts�ealphaeomegagservers�dbeta�bdcfeqdc10biph10.0.0.2gcountryf中国ealpha�bdcfeqdc10biph10.0.0.1hdatabase�eports�AABfserverk192.168.1.1genabled�nconnection_max�hproducts��csku,ydnamefHammer�csku�ydnamedNailecolordgray
etitlelTOML Exampleeowner�dnamerTom Preston-WernerlorganizationfGitHubcbiox1GitHub Cofounder & CEO
Likes tater tots and beer.cdob�t1979-05-27T07:32:00Zhdatabase�fserverk192.168.1.1eports�AABnconnection_max�genabled�gservers�ealpha�biph10.0.0.1bdcfeqdc10dbeta�biph10.0.0.2bdcfeqdc10gcountryf中国gclients�ddata��egammaedelta�ehosts�ealphaeomegahproducts��dnamefHammercsku,y�dnamedNailcsku�yecolordgray
62 changes: 31 additions & 31 deletions example.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
{
"title": "TOML Example",
"owner": {
"name": "Tom Preston-Werner",
"organization": "GitHub",
"bio": "GitHub Cofounder & CEO\nLikes tater tots and beer.",
"dob": "1979-05-27T07:32:00+00:00"
},
"database": {
"server": "192.168.1.1",
"ports": [
8001,
8001,
8002
],
"connection_max": 5000,
"enabled": true
},
"servers": {
"alpha": {
"ip": "10.0.0.1",
"dc": "eqdc10"
},
"beta": {
"ip": "10.0.0.2",
"dc": "eqdc10",
"country": "中国"
}
},
"clients": {
"data": [
[
Expand All @@ -15,43 +43,15 @@
"omega"
]
},
"database": {
"connection_max": 5000,
"enabled": true,
"ports": [
8001,
8001,
8002
],
"server": "192.168.1.1"
},
"owner": {
"bio": "GitHub Cofounder & CEO\nLikes tater tots and beer.",
"dob": "1979-05-27T07:32:00+00:00",
"name": "Tom Preston-Werner",
"organization": "GitHub"
},
"products": [
{
"name": "Hammer",
"sku": 738594937
},
{
"color": "gray",
"name": "Nail",
"sku": 284758393
"sku": 284758393,
"color": "gray"
}
],
"servers": {
"alpha": {
"dc": "eqdc10",
"ip": "10.0.0.1"
},
"beta": {
"country": "中国",
"dc": "eqdc10",
"ip": "10.0.0.2"
}
},
"title": "TOML Example"
]
}
4 changes: 2 additions & 2 deletions example.msgpack
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
��clients��data���gamma�delta��hosts��alpha�omega�database��connection_max���enabledåports��A�A�B�server�192.168.1.1�owner��bio�1GitHub Cofounder & CEO
Likes tater tots and beer.�dob���Wp�name�Tom Preston-Werner�organization�GitHub�products���name�Hammer�sku�,y��color�gray�name�Nail�sku��y�servers��alpha��dc�eqdc10�ip�10.0.0.1�beta��country�中国�dc�eqdc10�ip�10.0.0.2�title�TOML Example
��title�TOML Example�owner��name�Tom Preston-Werner�organization�GitHub�bio�1GitHub Cofounder & CEO
Likes tater tots and beer.�dob���Wp�database��server�192.168.1.1�ports��A�A�B�connection_max���enabledçservers��alpha��ip�10.0.0.1�dc�eqdc10�beta��ip�10.0.0.2�dc�eqdc10�country�中国�clients��data���gamma�delta��hosts��alpha�omega�products���name�Hammer�sku�,y��name�Nail�sku��y�color�gray
50 changes: 24 additions & 26 deletions example.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
title: TOML Example
owner:
name: Tom Preston-Werner
organization: GitHub
bio: "GitHub Cofounder & CEO\nLikes tater tots and beer."
dob: 1979-05-27 07:32:00+00:00
database:
server: 192.168.1.1
ports:
- 8001
- 8001
- 8002
connection_max: 5000
enabled: true
servers:
alpha:
ip: 10.0.0.1
dc: eqdc10
beta:
ip: 10.0.0.2
dc: eqdc10
country: 中国
clients:
data:
- - gamma
Expand All @@ -7,33 +29,9 @@ clients:
hosts:
- alpha
- omega
database:
connection_max: 5000
enabled: true
ports:
- 8001
- 8001
- 8002
server: 192.168.1.1
owner:
bio: 'GitHub Cofounder & CEO
Likes tater tots and beer.'
dob: 1979-05-27 07:32:00+00:00
name: Tom Preston-Werner
organization: GitHub
products:
- name: Hammer
sku: 738594937
- color: gray
name: Nail
- name: Nail
sku: 284758393
servers:
alpha:
dc: eqdc10
ip: 10.0.0.1
beta:
country: 中国
dc: eqdc10
ip: 10.0.0.2
title: TOML Example
color: gray
Loading

0 comments on commit 1f48011

Please sign in to comment.