我正在尝试整合JNC和Pyang。正如jnc步骤描述的那样,我复制了PYANG_HOME/pyang/plugins
下的 jnc.py 。我尝试使用命令
simple.yang
下为$JNC_HOME/examples/yang
生成java类
pyang -f jnc --jnc-output src/gen/simple yang/simple.yang
面临以下错误,
Traceback (most recent call last):
File "D:/tools/pyang-master/bin/pyang", line 434, in <module>
run()
File "D:/tools/pyang-master/bin/pyang", line 408, in run
emit_obj.emit(ctx, modules, fd)
File "C:\Users\Siva\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pyang-1.7-py3.5.egg\pyang/plugins\jnc.py", line 208, in emit
if module_stmt in (imported + included):
TypeError: unsupported operand type(s) for +: 'map' and 'map'
任何人都遇到过这种问题。请让我知道如何解决这个问题。
答案 0 :(得分:0)
问题在于地图实施:
Python-3中的 map
返回一个迭代器,而Python 2中的map
返回一个列表:
Python 2:
>>> type(map(abs, [43, -12, 13, -14]))
<type 'list'>
Python 3:
>>> type(map(abs, [99, -52, 32, -34, 13]))
<class 'map'>
您可以编辑文件jnc.py并更改代码,如下所示:
for (module_stmt, rev) in self.ctx.modules:
if module_stmt in (imported + included):
module_set.add(self.ctx.modules[(module_stmt, rev)])
for (module_stmt, rev) in self.ctx.modules:
if module_stmt in (included):
module_set.add(self.ctx.modules[(module_stmt, rev)])
if module_stmt in (imported):
module_set.add(self.ctx.modules[(module_stmt, rev)])