Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Record iter doesn't handle list of records #127

Closed
ghost opened this issue Dec 7, 2018 · 0 comments
Closed

Record iter doesn't handle list of records #127

ghost opened this issue Dec 7, 2018 · 0 comments

Comments

@ghost
Copy link

ghost commented Dec 7, 2018

When casting a record as dict, any lists within the record are not converted to dicts.
An example of this is tagged_vlans for interfaces.

The following update to the Record iter resolves the issue:

        for i in dict(self._init_cache):
            cur_attr = getattr(self, i)
            if isinstance(cur_attr, Record):
                yield i, dict(cur_attr)

            ####################
            # Correctly handle lists
            elif isinstance(cur_attr, list):
                l=[]
                for j in cur_attr:
                  if isinstance(j,Record):
                     l.append(dict(j))
                  else:
                     #Handle list of non-Records. tags are list of strings
                     l.append(j)
                yield i, l
            #####################

            else:
                yield i, cur_attr
zachmoody pushed a commit that referenced this issue Dec 7, 2018
Fixes #127 - Record iter doesn't handle list of records
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants