Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.

Change _to_dict_list function to use iteritems() #47

Conversation

luke-orden
Copy link

When using to_dict I receive the following:

Traceback (most recent call last):
  File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/home/luke/git/napalm-logs/napalm_logs/device.py", line 242, in start
    oc_obj = self._emit(**kwargs)
  File "/home/luke/git/napalm-logs/napalm_logs/device.py", line 207, in _emit
    return oc_obj.to_dict(filter=True)
  File "/home/luke/venvs/napalm-logs/local/lib/python2.7/site-packages/napalm_yang/base.py", line 181, in to_dict
    r = _to_dict(v, filter)
  File "/home/luke/venvs/napalm-logs/local/lib/python2.7/site-packages/napalm_yang/base.py", line 319, in _to_dict
    result = _to_dict_container(element, filter)
  File "/home/luke/venvs/napalm-logs/local/lib/python2.7/site-packages/napalm_yang/base.py", line 333, in _to_dict_container
    r = _to_dict(v, filter)
  File "/home/luke/venvs/napalm-logs/local/lib/python2.7/site-packages/napalm_yang/base.py", line 319, in _to_dict
    result = _to_dict_container(element, filter)
  File "/home/luke/venvs/napalm-logs/local/lib/python2.7/site-packages/napalm_yang/base.py", line 333, in _to_dict_container
    r = _to_dict(v, filter)
  File "/home/luke/venvs/napalm-logs/local/lib/python2.7/site-packages/napalm_yang/base.py", line 321, in _to_dict
    result = _to_dict_list(element, filter)
  File "/home/luke/venvs/napalm-logs/local/lib/python2.7/site-packages/napalm_yang/base.py", line 342, in _to_dict_list
    for k, v in element.items():
AttributeError: 'YANGBaseClass' object has no attribute 'items'

When using `to_dict` I receive the following:

```
AttributeError: 'YANGBaseClass' object has no attribute 'items'
```
@dbarrosop
Copy link
Member

How did you install the requirements? You have to use the patched version in the requirements.txt file which has that method (pip version doesn't yet have them). Alternatively, you can install from upstream#master if you prefer which also has the necessary patches.

Doing pip install -U -r requirements.txt should suffice.

@dbarrosop dbarrosop closed this Apr 18, 2017
@dbarrosop
Copy link
Member

Just for reference; iteritems and items provide the same functionality. However, iteritems works only with python2.7 while items works with python3 as well.

@dbarrosop
Copy link
Member

Some more details:
pip install -U napalm-yang should also work if you installed from pip or if you want to target only pyangbind pip install -e git://github.com/napalm-automation/pyangbind.git@napalm_custom#egg=pyangbind

And even though I closed the ticket feel free to comment/reopen :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants