0

I'm trying to integrate JNC and Pyang. As the jnc steps describes I have copied jnc.py under PYANG_HOME/pyang/plugins. I try to generate the java classes for simple.yang under $JNC_HOME/examples/yang using the command

pyang -f jnc --jnc-output src/gen/simple yang/simple.yang

facing the following error,

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'

Anyone faced this kind of issue. please let me know how to fix this.

Arnab Nandy
  • 6,472
  • 5
  • 44
  • 50
Siva
  • 1,229
  • 2
  • 9
  • 7

1 Answers1

0

Problem is with map implementation:

map in Python-3 returns an iterator, while map in Python 2 returns a list:

Python 2:

>>> type(map(abs, [43, -12, 13, -14]))
<type 'list'>

Python 3:

>>> type(map(abs, [99, -52, 32, -34, 13]))
<class 'map'> 

You can edit file jnc.py and change code as below:

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)])
Servesh Singh
  • 113
  • 1
  • 9