Comments (2)
I can't see any case where this can be valid. In general, pyangbind will try to cast the input to the type that is expected, so for example, if we have the following module:
module "test" {
prefix "t";
namespace "http://rob.sh/yang/t";
container test {
leaf number {
type uint32;
}
leaf number-range {
type uint32 {
range "1..max";
}
}
}
}
Then, we can do:
>>> t.test.number = False
>>> t.test.number = 0
Since int(False) == 0
, however:
>>> t.test.number = None
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "tmp.py", line 67, in _set_number
raise ValueError("""number must be of a type compatible with base=np.uint32, is_leaf=True, yang_name="number", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True""")
ValueError: number must be of a type compatible with base=np.uint32, is_leaf=True, yang_name="number", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True
>>> int(None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: int() argument must be a string or a number, not 'NoneType'
You cannot set an int
to None
because NoneType
cannot be cast to int
. So, even without the range, I don't think that this is valid. The reason that this is relevant is because the following JSON:
{
"value": null
}
is loaded by Python's json
library to use None rather than null:
>>> import json
>>> j = json.load(open("test.json", 'r'))
>>> print j
{u'value': None}
In your specific case, this isn't ever valid though - because if None
/null
were an integer value then it would be zero - which is outside of the 1..max
range. With a normal leaf of this nature, one still get the error when one tries to set the value to 0:
>>> t.test.number_range = 0
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "tmp.py", line 93, in _set_number_range
raise ValueError("""number_range must be of a type compatible with base=RestrictedClassType(base_type=np.uint32, restriction_dict={'range': [u'1..max']}), is_leaf=True, yang_name="number-range", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True""")
ValueError: number_range must be of a type compatible with base=RestrictedClassType(base_type=np.uint32, restriction_dict={'range': [u'1..max']}), is_leaf=True, yang_name="number-range", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True
>>> t.test.number_range = 1
So, I'd say that your input JSON is not valid.
r.
from pyangbind.
OK Rob, thanks for clarifying, that all seems fine to me.
Much appreciated,
Mark
from pyangbind.
Related Issues (20)
- Add async as a reserved Python name. HOT 1
- Pyangbind PYPI release does not have pybindIETFXMLEncoder class HOT 1
- How to inspect yang model HOT 2
- pyangbind is not taking care of "when" statement in yang definitions. HOT 2
- Problem with list's key made of multiple leaf identifiers HOT 3
- Is pyangbind still maintained? HOT 3
- RuntimeError when importing an older revision of a YANG file HOT 1
- Failure on OpenConfig BFD Model HOT 3
- Fix binary type representation HOT 2
- Integration and Sample UnitTests using BGP are broken
- __add_metadata is not adding the @metadata object to JSON or XML HOT 2
- 0.8.3 - TypeError: cannot pickle 'lxml.etree.XMLSchema' object HOT 8
- Support `bits` type HOT 1
- pyangbind fails processing typedef union with default value
- pyangbind-0.8.4 installation failed HOT 2
- Can not be directly used in ncclient? HOT 2
- TypeError: unhandled keyword with children case HOT 3
- How to filter by leaf? HOT 3
- Process for moving a list element HOT 2
- When we generate python code from Yang module, missing attributes in class HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyangbind.