marvin-zhao / pyang

Automatically exported from code.google.com/p/pyang
0 stars 0 forks source link

DSDL plugin zero length default values #62

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
For the following YANG snippet:

...
prefix mgd;
...
leaf str-leaf {
    type string;
    default "";
}

I would expect the following hybrid schema element:

<element name="mgd:str-leaf" nma:default="">
    <data type="string"/>
</element>

instead of what currently gets generated:

<element name="mgd:str-leaf">
    <data type="string"/>
</element>

If this is a bug, then I suggest you take a look at function
dsdl.leaf_stmt(self, stmt, p_elem, pset)
where a check for a default statement is made. As far as I know python treats 
empty strings as False when used in boolean expressions. You should check if 
the value is not None instead of just casting to boolean.

Original issue reported on code.google.com by jernej.t...@gmail.com on 19 Jan 2012 at 1:23

GoogleCodeExporter commented 9 years ago

Original comment by mbj4...@gmail.com on 23 Jan 2012 at 2:57

GoogleCodeExporter commented 9 years ago
Fixed, good catch.

Original comment by lada.lho...@gmail.com on 26 Jan 2012 at 12:34