Skip to content

Conversation

@glennmatthews
Copy link
Collaborator

See #34. I think it's an improvement but would appreciate input!

Diff dict before:

{'location': {'DC1': {'device': {'DC1-LEAF1': {'interface': {'Ethernet1/3': {'_dst': {'mode': 'NONE', 'switchport_mode': 'NONE'},
                                                                             '_src': {'mode': 'TRUNK', 'switchport_mode': 'TRUNK'}},
                                                             'Ethernet1/4': {'_dst': {'mode': 'NONE', 'switchport_mode': 'NONE'},
                                                                             '_src': {'mode': 'TRUNK', 'switchport_mode': 'TRUNK'}},
                                                             'Ethernet1/49': {'_dst': {'mode': 'NONE', 'switchport_mode': 'NONE'},
                                                                              '_src': {'mode': 'TRUNK', 'switchport_mode': 'TRUNK'}},

Diff element dict before:

{
  "dst": {
    "mode": "NONE",
    "switchport_mode": "NONE"
  },
  "src": {
    "mode": "TRUNK",
    "switchport_mode": "TRUNK"
  }
}

Diff dict after:

{'location': {'DC1': {'device': {'DC1-LEAF1': {'interface': {'Ethernet1/3': {'<': {'mode': 'NONE', 'switchport_mode': 'NONE'},
                                                                             '>': {'mode': 'TRUNK', 'switchport_mode': 'TRUNK'}},
                                                             'Ethernet1/4': {'<': {'mode': 'NONE', 'switchport_mode': 'NONE'},
                                                                             '>': {'mode': 'TRUNK', 'switchport_mode': 'TRUNK'}},
                                                             'Ethernet1/49': {'<': {'mode': 'NONE', 'switchport_mode': 'NONE'},
                                                                              '>': {'mode': 'TRUNK', 'switchport_mode': 'TRUNK'}}}}}}}}

Diff element dict after:

{
  "<": {
    "mode": "NONE",
    "switchport_mode": "NONE"
  },
  ">": {
    "mode": "TRUNK",
    "switchport_mode": "TRUNK"
  }
}

dgarros
dgarros previously approved these changes Nov 11, 2020
Copy link
Contributor

@dgarros dgarros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@glennmatthews
Copy link
Collaborator Author

One aesthetic downside is that while < sorts before >, - sorts after +:

>>> sorted(["<", ">", "-", "+"])
['+', '-', '<', '>']

This is mostly noticeable when using pprint as it sorts dict keys by default:

{'site': {'atl': {'device': {'atl-spine1': {'interface': {'eth0': {'-': {'description': 'Interface 0'}},
                                                          'eth1': {'-': {'description': 'Interface 1'}}}},
                             'atl-spine2': {'interface': {'eth0': {'-': {'description': 'Interface 0'}},
                                                          'eth1': {'-': {'description': 'Interface 1'}}}}}},
          'nyc': {'device': {'nyc-spine1': {'interface': {'eth0': {'+': {'description': 'Interface 0'},
                                                                   '-': {'description': 'Interface 0/0'}}}}}},
          'sfo': {'device': {'sfo-spine2': {'interface': {'eth2': {'+': {'description': 'Interface 2'}}}}}}}}

@dgarros dgarros self-requested a review November 13, 2020 16:00
dgarros
dgarros previously approved these changes Nov 13, 2020
Copy link
Contributor

@dgarros dgarros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@glennmatthews glennmatthews changed the title Change dst/src dict keys to </> keys Change dst/src dict keys to -/+ keys Nov 13, 2020
@glennmatthews glennmatthews merged commit cf15ab7 into master Nov 13, 2020
@glennmatthews glennmatthews deleted the gfm-issue-34 branch November 13, 2020 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants