strictyaml
strictyaml copied to clipboard
Acessing Values of Mapping via .data .value or .scalar
I just started using strictyaml and was surprised that when lets say parsing
import strictyaml
from datetime import timedelta
config = strictyaml.load('stop_time: 2021-01-22T23:50:00', strictyaml.Map({'stop_time', strictyaml.Datetime()}))
newtime = config['stop_time'] + timedelta(seconds=300)
you get an error
TypeError: unsupported operand type(s) for +: 'YAML' and 'datetime.timedelta'
Now, the documentation isn't very concise how to access the actual value. .data is mentioned, but what about .value and .scalar. I looked at the code and can see the differences, but I'd like to hear an official "recommended procedure" for doing this (and I assume it's just going to be "use .data").
yep, use .data
.value should be unused, really.
the YAML object itself is meant for editing and saving YAML (with comments preserved).
thanks for pointing this out though, looking at it from your perspective it's not super clear.
On Thu, 20 Feb 2020, 08:58 orangelynx, [email protected] wrote:
I just started using strictyaml and was surprised that when lets say parsing
import strictyamlfrom datetime import timedelta
config = strictyaml.load('stop_time: 2021-01-22T23:50:00', strictyaml.Map({'stop_time', strictyaml.Datetime()}))
newtime = config['stop_time'] + timedelta(seconds=300)
you get an error
TypeError: unsupported operand type(s) for +: 'YAML' and 'datetime.timedelta'
Now, the documentation isn't very concise how to access the actual value. .data is mentioned, but what about .value and .scalar. I looked at the code and can see the differences, but I'd like to hear an official "recommended procedure" for doing this (and I assume it's just going to be "use .data").
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/crdoconnor/strictyaml/issues/88?email_source=notifications&email_token=ABOJKNMJI55LWZBK2KFA4JDRDZA27A5CNFSM4KYKEWJ2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IO5HOEQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOJKNOTB6ZPMO6FNI3FUTLRDZA27ANCNFSM4KYKEWJQ .
actually I'd like to leave this one open as a reminder to fix the read me.
On Thu, 20 Feb 2020, 10:03 orangelynx, [email protected] wrote:
Closed #88 https://github.com/crdoconnor/strictyaml/issues/88.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/crdoconnor/strictyaml/issues/88?email_source=notifications&email_token=ABOJKNNC3V7QKYC7DYVLYFTRDZIPLA5CNFSM4KYKEWJ2YY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOWYM6QLA#event-3055151148, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOJKNMYMEZOH7L7VJGNAXTRDZIPLANCNFSM4KYKEWJQ .
Cheers
On Thu, 20 Feb 2020, 11:23 orangelynx, [email protected] wrote:
Reopened #88 https://github.com/crdoconnor/strictyaml/issues/88.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/crdoconnor/strictyaml/issues/88?email_source=notifications&email_token=ABOJKNOLW546D5ECBGJ4JETRDZR45A5CNFSM4KYKEWJ2YY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOWYPPUQA#event-3055483456, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABOJKNNQCQ2WN4A7PDVUPSTRDZR45ANCNFSM4KYKEWJQ .