hpenetworking / pyszn Goto Github PK
View Code? Open in Web Editor NEWA Python package for the SZN standard of topologies representation
License: Apache License 2.0
A Python package for the SZN standard of topologies representation
License: Apache License 2.0
Latest working version of PyParsing for PySZN was version 2.2.2. Then, the next release, 2.3.0, released 9 days ago, breaks the parsing of SZN.
The issue is located at line 188 of the file parser.py
:
parsed = statement.parseString(line)
With PyParsing 2.2.2 the output is the following:
ipdb> parsed
(
['hs1', ':', '1', '--', 'sw1', ':', '1'],
{
'endpoint_a': [
((['hs1', ':', '1'], {'node': [('hs1', 0)], 'port': [('1', 2)]}), 0),
],
'endpoint_b': [
((['sw1', ':', '1'], {'node': [('sw1', 0)], 'port': [('1', 2)]}), 4),
],
'link': [
(
(
['hs1', ':', '1', '--', 'sw1', ':', '1'],
{
'endpoint_a': [
(
(
['hs1', ':', '1'],
{'node': [('hs1', 0)], 'port': [('1', 2)]},
),
0,
),
],
'endpoint_b': [
(
(
['sw1', ':', '1'],
{'node': [('sw1', 0)], 'port': [('1', 2)]},
),
4,
),
],
'node': [('hs1', 0), ('sw1', 4)],
'port': [('1', 2), ('1', 6)],
},
),
0,
),
],
'node': [('hs1', 0), ('sw1', 4)],
'port': [('1', 2), ('1', 6)],
},
)
With PyParsing 2.3.0, the following is returned:
ipdb> parsed
(
['hs1', ':', '1', '--', 'sw1', ':', '1'],
{
'endpoint_a': [(['hs1', ':', '1'], {})],
'endpoint_b': [(['sw1', ':', '1'], {})],
'link': [(['hs1', ':', '1', '--', 'sw1', ':', '1'], {})],
'node': ['hs1', 'sw1'],
'port': ['1', '1'],
},
)
This makes that the later calls parsed.link.endpoint_a.node
fail because the element doesn't exists. Because of the broad way the try/catch is set, this result in an really unrelated ParseException
, but it is really not.
The solution is to review why the parser is returning such different and wrong data, as the semantics of the grammar isn't respected in the newer version.
I checked the release notes, but nothing really enlightening is said:
https://github.com/pyparsing/pyparsing/releases/tag/pyparsing_2.3.0
What is not a solution is to pin the pyparsing package in a public library, that will impose on the version users of this library may have and break their system. If you need a specific version in your environment pin it there, either before or after the pyszn requirement itself.
I started some work on the refresh
branch, and still investigating the issue in depth.
Regards
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.