-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue-509: Added testcase to verify bgp timers
- Loading branch information
1 parent
f68244e
commit c6767ef
Showing
4 changed files
with
234 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright (c) 2024 Arista Networks, Inc. | ||
# Use of this source code is governed by the Apache License 2.0 | ||
# that can be found in the LICENSE file. | ||
""" | ||
Toolkit for ANTA. | ||
""" | ||
from __future__ import annotations | ||
|
||
from collections import defaultdict | ||
from typing import Any, Dict, List | ||
|
||
|
||
def create_index(list_of_dicts: List[Dict[str, Any]], key: str) -> Dict[str, List[Dict[str, Any]]]: | ||
""" | ||
Creates an index for a list of dictionaries based on a specified key. | ||
Parameters: | ||
list_of_dicts (List[Dict[str, Any]]): A list of dictionaries. | ||
key (str): The key to be indexed. | ||
Returns: | ||
Dict[str, List[Dict[str, Any]]]: A dictionary where each key is a unique value from the list_of_dicts[key] | ||
and each value is a list of dictionaries that have that value for the key. | ||
""" | ||
|
||
# Initialize a default dictionary | ||
index = defaultdict(list) | ||
|
||
# Iterate over each dictionary in the list | ||
for dict_item in list_of_dicts: | ||
# Check if the key exists in the dictionary | ||
if key in dict_item: | ||
# Add the dictionary to the list of its key's value | ||
index[dict_item[key]].append(dict_item) | ||
|
||
return index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters