8000 Add FortiConfig.to_dict() for genie parser to compare. · Issue #43 · spotify/pyfg · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Mar 28, 2022. It is now read-only.
This repository was archived by the owner on Mar 28, 2022. It is now read-only.
Add FortiConfig.to_dict() for genie parser to compare. #43
Open
@horizon365

Description

@horizon365

#5adb234

` def to_dict(self, root=None, tree_dict=None):
"""
This method convert FortiConfig to dict.

    Args:
        - **root** (class:`~pyFG.forticonfig.FortiConfig` object):
                * If ``None`` use self as tree root.
        - **tree_dict** (dict): This value is for output.
                * If ``None`` use a blank dict.
    """
    if root is None:
        root = self
    if tree_dict is None:
        tree_dict = {}
    if not hasattr(root, 'get_block_names') or not root.get_block_names():
        return
    for child in root.get_block_names():
        if not tree_dict.get(child):
            if root[child].get_parameter_names():
                tree_dict[child] = {k: root[child].get_param(k).replace('"', '')
                                    for k in root[child].get_parameter_names()}
            else:
                tree_dict[child] = {}
        self.to_dict(root[child], tree_dict[child])
    return tree_dict

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0