Re: Quoting strings of digits

Andrey Somov <[email protected]> Mon, 20 Nov 2017 23:03:05 +0100
Newsgroups gmane.text.yaml.general
Message-ID <CALbkv0emKQzYsY070udqwOafdQiQOeWF9geg_2O22Q-qPrSQZA@mail.gmail.com>
ассоrding to the provided link:

PyYAML is a *complete* YAML 1.1 <http://yaml.org/spec/1.1/> parser.

It looks like version 3.12 does not support YAM 1.2 yet.

Andrey


On Mon, Nov 20, 2017 at 10:58 PM, Thomas Conway <[email protected]> wrote:

> The PyYAML version is 3.12
>
> $ pip2 show pyyaml
>> Name: PyYAML
>> Version: 3.12
>> Summary: YAML parser and emitter for Python
>> Home-page: http://pyyaml.org/wiki/PyYAML
>> Author: Kirill Simonov
>> Author-email: xi-RCSp1WnSyaseIZ0/[email protected]
>> License: MIT
>> Location: /Users/conwaythomas/Library/Python/2.7/lib/python/site-packages
>> Requires:
>
>
> On 21 November 2017 at 08:51, Andrey Somov <[email protected]> wrote:
>
>> I quote the spec for YAML 1.2 (core schema) :
>>  [-+]? [0-9]+      tag:yaml.org,2002:int (Base 10)
>>
>> SnakeYAML implements YAML 1.1
>>
>> What is the PyYAML version ?
>>
>> Cheers,
>> Andrey
>>
>> On Mon, Nov 20, 2017 at 8:15 PM, Laurent Lyaudet <
>> [email protected]> wrote:
>>
>>> Hi Thomas,
>>>
>>> In my humble opinion, I think the problem is on the Java side.
>>> If I quote the spec for YAML 1.2 :
>>> "Decimal integer notation, with a leading “-” character for negative
>>> values, matching the regular expression 0 | -? [1-9] [0-9]*"
>>> As you can see, there is no leading zero tolerated for integers except
>>> for the value 0.
>>> Hence 08063075 is a valid string element, pyyaml can strip the quotes
>>> and snakeyaml should understand that.
>>>
>>> Best regards,
>>>    Laurent Lyaudet
>>>
>>> 2017-11-20 2:10 GMT+01:00 Thomas Conway <[email protected]>:
>>> > Hi Yamlies,
>>> >
>>> > I have a bit of a problem where some of our tools use Java, and some
>>> Python
>>> > (2). The output of the python is consumed by the Java, and
>>> inconsistencies
>>> > are leading to some problems. My question is which if any behaviours
>>> are
>>> > incorrect with respect to the specification?
>>> >
>>> > I've cut down the problem to the following.
>>> >
>>> > Consider the following python code (using pyyaml):
>>> >
>>> > import sys
>>> > import yaml
>>> > w = {'userName': 'scientist ', 'userEmail': '[email protected]',
>>> > 'sampleName': '08063075', 'fastqDir':
>>> > '/foo/bar/baz/171108_M00139_0253_000000000-BHFD5/ProjectFold
>>> ers/Project_Qux-Wombat-/Sample_08063075',
>>> > 'analysis': 'Somatic_Run375_MY_DY_08112017', 'laneNo': 1, 'panel':
>>> > 'Somatic_Panel_Manifest_v4_23_10_2015'}
>>> > yaml.dump(w, sys.stdout, default_flow_style=False)
>>> >
>>> > which produces the output:
>>> >
>>> > analysis: Somatic_Run375_MY_DY_08112017
>>> > fastqDir:
>>> > /foo/bar/baz/171108_M00139_0253_000000000-BHFD5/ProjectFolde
>>> rs/Project_Qux-Wombat-/Sample_08063075
>>> > laneNo: 1
>>> > panel: Somatic_Panel_Manifest_v4_23_10_2015
>>> > sampleName: 08063075
>>> > userEmail: [email protected]
>>> > userName: 'scientist '
>>> >
>>> > Note in particular that the string value for the key 'sampleName' is a
>>> > sequence of digits with a leading zero, and is not quoted.
>>> >
>>> > When we read it in to our java system (using snakeyaml), the unquoted
>>> > sequence of digits is turned into an integer, which means that
>>> subsequent
>>> > steps drop the leading zero.
>>> >
>>> > I've tried reading the specification, but I can't see that it defines
>>> the
>>> > conversion.
>>> >
>>> > Is the serialisation valid?
>>> >
>>> > Is the conversion of the string of digits to an integer valid?
>>> >
>>> > Thanks for any precision you can add to my understanding,
>>> >
>>> > Tom.
>>> > --
>>> > Dr Thomas Conway
>>> > [email protected]
>>> > My friends, love is better than anger. Hope is better than fear.
>>> Optimism is
>>> > better than despair. So let us be loving, hopeful and optimistic. And
>>> we'll
>>> > change the world. - Jack Layton
>>> >
>>> > ------------------------------------------------------------
>>> ------------------
>>> > Check out the vibrant tech community on one of the world's most
>>> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>>> > _______________________________________________
>>> > Yaml-core mailing list
>>> > [email protected]
>>> > https://lists.sourceforge.net/lists/listinfo/yaml-core
>>> >
>>>
>>> ------------------------------------------------------------
>>> ------------------
>>> Check out the vibrant tech community on one of the world's most
>>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>>> _______________________________________________
>>> Yaml-core mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/yaml-core
>>>
>>
>>
>> ------------------------------------------------------------
>> ------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>> _______________________________________________
>> Yaml-core mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/yaml-core
>>
>>
>
>
> --
> Thomas Conway
> [email protected]
> My friends, love is better than anger. Hope is better than fear. Optimism
> is better than despair. So let us be loving, hopeful and optimistic. And
> we'll change the world. - Jack Layton
>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

_______________________________________________
Yaml-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/yaml-core