Best Python code snippet using tavern
example_user_data_parser.py
Source:example_user_data_parser.py
1#!/usr/bin/python2import argparse3import os4import yaml5import re6import shutil7from nuage_metroae_config.template import TemplateStore8from nuage_metroae_config.user_data_parser import UserDataParser9from metroae_config import MetroConfig10class TypeToObjectName():11 def __init__(self, type_name, type_dict):12 self.type_name = type_name13 self.type_dict = type_dict14class CombinationKey():15 def __init__(self, key_name):16 self.key = key_name17 def get_keys(self, combinationKey):18 return combinationKey.split(" ")19class Expression():20 def __init__(self, key_name):21 self.key_name = key_name22 def get_keys(self, expression):23 keys = []24 split_keys = expression.split('"')25 for i in range(1, len(split_keys), 2):26 keys.append((self.key_name, split_keys[i]))27 return keys28class NoAliasDumper(yaml.SafeDumper):29 def ignore_aliases(self, data):30 return True31GATEWAY_NAME_DICT = dict(NSGATEWAY="nsg_name", GATEWAY="gateway_name")32GATEWAY_NAME_TYPE = TypeToObjectName("gateway_type", GATEWAY_NAME_DICT)33INTERFACE_TYPE = TypeToObjectName("interface_type",34 {"WIRED": "nsg_access_port_name",35 "WIRELESS": "nsg_wifi_port_name"})36ACCESS_PORT_NAME_TYPE = TypeToObjectName("gateway_type",37 {"NSGATEWAY": INTERFACE_TYPE,38 "GATEWAY": "port_name"})39COMMON_LOCATION_TYPE = {"SUBNET": "subnet_name",40 "ZONE": "zone_name",41 "POLICYGROUP": "policy_group_name",42 "PGEXPRESSION": "policy_group_expression_name",43 "NETWORK_MACRO": "network_macro_name",44 "NETWORK_MACRO_GROUP": "network_macro_group_name"}45SERVICE_CHAINING_POLICY_KEY = TypeToObjectName("action", {"REDIRECT": "redirection_target_name",46 "FORWARD": "ingress_forwarding_policy_name"})47NETWORK_TYPE = TypeToObjectName("network_type", COMMON_LOCATION_TYPE)48LOCATION_TYPE = TypeToObjectName("location_type", COMMON_LOCATION_TYPE)49INGRESS_SOURCE_LOCATION_TYPE = TypeToObjectName("source_location_type", COMMON_LOCATION_TYPE)50INGRESS_DEST_LOCATION_TYPE = TypeToObjectName("destination_location_type", COMMON_LOCATION_TYPE)51EGRESS_SOURCE_LOCATION_TYPE = TypeToObjectName("source_location_type",52 COMMON_LOCATION_TYPE)53EGRESS_DEST_LOCATION_TYPE = TypeToObjectName("destination_location_type",54 COMMON_LOCATION_TYPE)55SERVICE_GROUP_TYPE = TypeToObjectName("l4_service_or_group_type", {"L4_SERVICE": "l4_service_name",56 "L4_SERVICE_GROUP": "l4_service_group_name"})57RANGE_KEYS = {"vlan_value": ["access_vlan_values", "vlan_values"],58 "access_vlan_value": ["access_vlan_values", "vlan_values"]}59EXECLUDE_DEPENDENCIES = {"application": ["l7_application_signature_name"]}60PRE_DEFINED_OBJECTS = {("enterprise_profile_name", "Default Profile"),61 ("enterprise_name", "Shared Infrastructure"),62 ("import_routing_policy_name", "RejectAll"),63 ('export_routing_policy_name', 'DefaultOnly'),64 ('saas_application_name', 'WebEx'),65 ('network_name', 'ANY'),66 ('group_name', 'Administrators')}67LIST_DEPENDENCY_KEYS = {"monitor scope": {"destination_nsgs": "nsg_name",68 "source_nsgs": "nsg_name",69 "all_nsgs_filter_list": "nsg_name"},70 "application performance management binding": {"domain_names": "domain_name",71 "l2_domain_names": "l2_domain_name"},72 "network performance binding": {"domain_names": "domain_name",73 "l2_domain_names": "l2_domain_name"},74 "nsg access port": {"egress_qos_policy_names": "egress_qos_policy_name"}}75POLICY_GROUP_EXPRESSION = Expression('policy_group_name')76BR_DOMAIN_LINK_COMBINATION_KEY = CombinationKey("source_domain_name,domain_name")77REPLACEMENT_KEYS = \78 {"ingress qos policy": {"wrr_queue_2_rate_limiter_name": "rate_limiter_name",79 "wrr_queue_3_rate_limiter_name": "rate_limiter_name",80 "wrr_queue_4_rate_limiter_name": "rate_limiter_name",81 "priority_queue_1_rate_limiter_name": "rate_limiter_name",82 "parent_rate_limiter_name": "rate_limiter_name",83 "priority_queue_1_rate_limiter_name": "rate_limiter_name",84 "management_queue_rate_limiter_name": "rate_limiter_name",85 "network_control_queue_rate_limiter_name": "rate_limiter_name"},86 "egress qos policy": {"wrr_queue_2_rate_limiter_name": "rate_limiter_name",87 "wrr_queue_3_rate_limiter_name": "rate_limiter_name",88 "wrr_queue_4_rate_limiter_name": "rate_limiter_name",89 "priority_queue_1_rate_limiter_name": "rate_limiter_name",90 "parent_rate_limiter_name": "rate_limiter_name",91 "priority_queue_1_rate_limiter_name": "rate_limiter_name",92 "management_queue_rate_limiter_name": "rate_limiter_name",93 "network_control_queue_rate_limiter_name": "rate_limiter_name"},94 "bridge port": {"gateway_name": GATEWAY_NAME_TYPE,95 "access_port_name": ACCESS_PORT_NAME_TYPE,96 "vlan": "access_vlan_numbers"},97 "floating ip": {"shared_domain_name": "domain_name",98 "shared_zone_name": "zone_name",99 "shared_subnet_name": "subnet_name"},100 "dc gateway": {"gateway_enterprise_name": "enterprise_name"},101 "dc gateway vlan": {"vlan_enterprise_name": "enterprise_name"},102 "dc gateway port": {"port_enterprise_name": "enterprise_name"},103 "bidirectional security policy entry": {"network_name": NETWORK_TYPE,104 "location_name": LOCATION_TYPE,105 "location_zone_name": "zone_name",106 "network_zone_name": "zone_name"},107 "egress security policy entry": {"source_location_zone_name": "zone_name",108 "source_location_name": EGRESS_SOURCE_LOCATION_TYPE,109 "destination_location_name": EGRESS_DEST_LOCATION_TYPE,110 "l4_service_or_group_name": SERVICE_GROUP_TYPE,111 "destination_location_zone_name": "zone_name"},112 "ingress forwarding policy entry": {"source_location_zone_name": "zone_name",113 "destination_location_zone_name": "zone_name",114 "source_location_name": INGRESS_SOURCE_LOCATION_TYPE,115 "destination_location_name": INGRESS_DEST_LOCATION_TYPE,116 "l4_service_or_group_name": SERVICE_GROUP_TYPE,117 "source_network_macro_group_name": "network_macro_group_name"},118 "ingress security policy entry": {"source_location_zone_name": "zone_name",119 "destination_location_zone_name": "zone_name",120 "source_location_name": INGRESS_SOURCE_LOCATION_TYPE,121 "destination_location_name": INGRESS_DEST_LOCATION_TYPE,122 "l4_service_or_group_name": SERVICE_GROUP_TYPE},123 "service chaining policy": {"location_name": LOCATION_TYPE,124 "network_name": NETWORK_TYPE,125 "location_zone_name": "zone_name",126 "port_name": [('nsg_name', 'nsg_access_port_name'),127 ('gateway_name', 'port_name')]},128 "bgp neighbour": {"import_routing_policy_name": "routing_policy_name"},129 "virtual ip": {"port_name": [('nsg_name', 'nsg_access_port_name'),130 ('gateway_name', 'port_name')]},131 "redirection target binding": {"port_name": [('nsg_name', 'nsg_access_port_name'),132 ('gateway_name', 'port_name')]},133 "policy group binding": {"port_name": [('nsg_name', 'nsg_access_port_name'),134 ('gateway_name', 'port_name')]},135 "enterprise permission": {"port_name": [('nsg_name', 'nsg_access_port_name'),136 ('gateway_name', 'port_name')]},137 "policy group expression": {"expression": POLICY_GROUP_EXPRESSION},138 "br domain link": {"expression": BR_DOMAIN_LINK_COMBINATION_KEY,139 "source_domain_name": "domain_name",140 "source_enterprise_name": "enterprise_name"},141 "br demarcation service": {"source_domain_name": "domain_name",142 "source_enterprise_name": "enterprise_name"}}143REPLACEMENT_KEY_TEMPLATES = {"DC Gateway Vlan": "access_vlan_values",144 "Enterprise Permission": 0,145 "Static Route": ["ipv4_network", "ipv6_network"],146 "Virtual IP": ["virtual_ipv4_address",147 "virtual_ipv6_address"],148 "Network Performance Binding": "priority",149 "Application Performance Management Binding": "priority",150 "DHCP Option": "type",151 "DHCPv6 Option": "type",152 "DHCP Pool": "minAddress",153 "Floating IP": "last",154 "Destination Url": "destination_url",155 "Application Binding": 0,156 "Service Chaining Policy": SERVICE_CHAINING_POLICY_KEY,157 "Network Macro Group Binding": 0,158 "L4 Service Group Binding": 0,159 "Redirection Target Binding": 0,160 "NSGateway Activate": 0,161 "NSG ZFBInfo Download": 0,162 "BR Connection": "ipv4_network",163 "BR Demarcation Service": ["vlan_value", "nsg_name"],164 "BR Domain Link": BR_DOMAIN_LINK_COMBINATION_KEY}165EXTRA_KEYS = {'nsg access port': ['vlan_values']}166def main():167 parser = argparse.ArgumentParser(prog="User Data parser")168 parser.add_argument('-dp', '--data_path', dest='data_path',169 action='store', required=True,170 default=None,171 help='Path containing user data.')172 parser.add_argument('-tp', '--template_path', dest='template_path',173 action='append', required=True,174 default=None,175 help='Path containing template information.')176 parser.add_argument('-g', '--group', dest='group', action='store',177 required=True, default=None,178 help='Group name')179 parser.add_argument('-d', '--destination_file', dest='output_file',180 action='store', required=False,181 default=None,182 help='Path to the destination file')183 parser.add_argument('-v', '--version', dest='version',184 action='store', required=False,185 default=None,186 help='Version of VSD')187 parser.add_argument('-e', '--example', dest='example',188 action='store_true', required=False,189 default=None,190 help='Dumps minimum templates required for a group')191 parser.add_argument('-ex', '--excel', dest='excel',192 action='store', required=False,193 default=None,194 help='Dumps a yaml file for each template type to be consumed by excel generator')195 args = parser.parse_args()196 parse(args)197def filter_data_file(sorted_file_names, version):198 filtered_file_list = []199 for i in range(0, len(sorted_file_names)):200 if version:201 if re.match('.*v[0-9].*', sorted_file_names[i]):202 if version == sorted_file_names[i].split('_')[-1][1:]:203 if sorted_file_names[i].startswith(sorted_file_names[i - 1][:-4]):204 filtered_file_list.pop()205 filtered_file_list.append(sorted_file_names[i])206 elif sorted_file_names[i + 1].startswith(sorted_file_names[i][:-4]):207 filtered_file_list.append(sorted_file_names[i])208 else:209 if not re.match('.*v[0-9].*', sorted_file_names[i]):210 filtered_file_list.append(sorted_file_names[i])211 else:212 if not sorted_file_names[i].startswith(sorted_file_names[i - 1][:-4]):213 filtered_file_list.append(sorted_file_names[i])214 return filtered_file_list215def load_data(args, jinja2_template_data):216 group_user_data = {}217 remaining_user_data = {}218 extra_keys_dict = {}219 groups_dict = {}220 if not os.path.exists(args.data_path) and os.path.isdir(args.data_path):221 print("Please provide a valid path for data files")222 # first load files that path the group pattern223 for file_name in filter_data_file(sorted(os.listdir(args.data_path)), args.version):224 udp = UserDataParser()225 udp.read_data(os.path.join(args.data_path, file_name))226 udp.get_template_name_data_pairs()227 for user_data in udp.data:228 template_name = user_data[0].lower()229 template_object_name = get_object_name(user_data[1], jinja2_template_data[template_name])230 if re.match(args.group + ".*", file_name):231 object_name_to_data = group_user_data.get(template_name, {})232 object_name_to_data[template_object_name] = user_data233 group_user_data[template_name] = object_name_to_data234 elif args.group in ["vnsaar", "vnswifi", "network"] and template_name == "nsg network port":235 object_name_to_data = group_user_data.get(template_name, {})236 object_name_to_data[template_object_name] = user_data237 group_user_data[template_name] = object_name_to_data238 elif args.group in ["security", "advrouting"] and template_name in ["bridge port",239 "application binding",240 "monitor scope",241 "application performance management binding",242 "enterprise permission"]:243 object_name_to_data = group_user_data.get(template_name, {})244 object_name_to_data[template_object_name] = user_data245 group_user_data[template_name] = object_name_to_data246 elif args.group == "vnsnsg" and template_name in ["bridge port",247 "application binding",248 "monitor scope",249 "application performance management binding",250 "enterprise permission"]:251 object_name_to_data = group_user_data.get(template_name, {})252 object_name_to_data[template_object_name] = user_data253 group_user_data[template_name] = object_name_to_data254 else:255 if template_name in remaining_user_data:256 object_name_to_data = remaining_user_data[template_name]257 else:258 object_name_to_data = {}259 object_name_to_data[template_object_name] = user_data260 remaining_user_data[template_name] = object_name_to_data261 if template_name in EXTRA_KEYS:262 for k in EXTRA_KEYS[template_name]:263 template_dict = extra_keys_dict.get(template_name, {})264 if k in user_data[1]:265 template_dict[(k, tuple(user_data[1][k]))] = user_data266 extra_keys_dict[template_name] = template_dict267 groups_dict.update(udp.groups)268 return group_user_data, remaining_user_data, extra_keys_dict, groups_dict269def parse(args):270 template_store = TemplateStore(None)271 template_store.read_templates(args.template_path[0])272 group_user_data, remaining_user_data, extra_keys_dict, groups_dict = load_data(args, template_store.templates)273 dependencies_not_found = resolve_dependencies(group_user_data,274 remaining_user_data,275 extra_keys_dict,276 template_store.templates)277 while len(dependencies_not_found) > 0:278 dependencies_not_found = resolve_dependencies(group_user_data,279 remaining_user_data,280 extra_keys_dict,281 template_store.templates)282 file_data = []283 for key, value in group_user_data.items():284 for key, user_data in value.items():285 temp_dict = {}286 temp_dict["template"] = user_data[0]287 if not args.example:288 temp_dict["values"] = user_data[1]289 else:290 template = template_store.templates[user_data[0]]291 for variable in template.variables:292 temp_dict["values"]293 file_data.append(temp_dict)294 for key, value in groups_dict.items():295 group_dict = {}296 group_dict["group"] = key297 group_dict["values"] = value298 file_data.append(group_dict)299 if args.output_file:300 with open(args.output_file, 'w') as f:301 yaml.dump(file_data, f, Dumper=NoAliasDumper)302 f.write('\n')303 else:304 for key, value in group_user_data.items():305 print(yaml.dump(value, Dumper=NoAliasDumper))306 if args.excel:307 template_values_dict = dict()308 for val in file_data:309 if "template" in val:310 template_name = val["template"]311 template_values = template_values_dict.get(template_name, [])312 template_values.append(val["values"])313 template_values_dict[template_name] = template_values314 temp_template_files = "/tmp/excel_data/"315 os.mkdir(temp_template_files)316 for key, value in template_values_dict.items():317 with open(os.path.join(temp_template_files, key + ".yml"), 'w') as f:318 yaml.dump(value, f, Dumper=NoAliasDumper)319 args.software_version = None320 metroConfig = MetroConfig(args, None)321 metroConfig.setup_template_store()322 metroConfig.write_excel_input_form(template_values_dict.keys(), args.excel, temp_template_files)323 shutil.rmtree(temp_template_files)324def calculate_template_dependencies(template_dict, group_user_data):325 template_dependencies = {}326 for key in group_user_data:327 required_references = []328 execlude = []329 if key in EXECLUDE_DEPENDENCIES:330 execlude = EXECLUDE_DEPENDENCIES[key]331 template_variables = template_dict[key][0].variables332 for variable in template_variables:333 variable_type = variable["type"]334 if variable_type == "list":335 variable_type = variable["item-type"]336 if variable_type == "reference" and variable["name"] not in execlude:337 required_references.append(variable["name"])338 template_dependencies[key] = required_references339 return template_dependencies340def find_dependency(tuple_key, user_data):341 if tuple_key in PRE_DEFINED_OBJECTS:342 return True, None, None, tuple_key343 else:344 for template_name, value in user_data.items():345 if tuple_key[0] in RANGE_KEYS:346 for value_keys, data in value:347 matched = False348 for range_key in RANGE_KEYS[tuple_key[0]]:349 if range_key == value_keys:350 matched = True351 break352 if not matched:353 continue354 object_name = data355 if type(object_name) == int:356 if int(tuple_key[1]) == object_name:357 return (True,358 value[(tuple_key[0], data)],359 template_name,360 (value_keys, data))361 else:362 if type(object_name) == str:363 object_name = object_name.split(',')364 for name in object_name:365 if type(name) == str and '-' in name:366 range_keys = [int(x) for x in name.split('-')]367 if range_keys[0] <= tuple_key[1] \368 <= range_keys[1]:369 return (True,370 value[(value_keys, data)],371 template_name,372 (value_keys, data))373 elif int(tuple_key[1]) == int(name):374 return (True,375 value[(value_keys, data)],376 template_name,377 (value_keys, data))378 if tuple_key in value:379 return True, value[tuple_key], template_name, tuple_key380 return False, None, None, None381def resolve_list_dependencies(template_name,382 dependency,383 group_user_data,384 extra_keys_dict,385 curr_object_data):386 dependencies_not_found = []387 dependency_key = LIST_DEPENDENCY_KEYS[template_name][dependency]388 for value in curr_object_data[dependency]:389 if value == "":390 continue391 tuple_key = (dependency_key, value)392 found, data, temp_template_name, temp_key = find_dependency(tuple_key,393 group_user_data)394 if not found:395 found, data, temp_template_name, temp_key = find_dependency(tuple_key,396 extra_keys_dict)397 if not found and tuple_key not in dependencies_not_found:398 dependencies_not_found.append(tuple_key)399 return dependencies_not_found400def get_replacement_keys(template_name, dependency, curr_object_data):401 tuple_keys = []402 if template_name in REPLACEMENT_KEYS and \403 dependency in REPLACEMENT_KEYS[template_name]:404 tuple_key = (REPLACEMENT_KEYS[template_name][dependency], curr_object_data[dependency])405 if isinstance(REPLACEMENT_KEYS[template_name][dependency], TypeToObjectName):406 object_name = REPLACEMENT_KEYS[template_name][dependency]407 key_type = object_name.type_name408 if curr_object_data[key_type].upper() in object_name.type_dict:409 key = object_name.type_dict[curr_object_data[key_type].upper()]410 if isinstance(key, TypeToObjectName):411 key_type = key.type_name412 key = key.type_dict[curr_object_data[key_type].upper()]413 tuple_key = (key, curr_object_data[dependency])414 else:415 tuple_key = (key, curr_object_data[dependency])416 else:417 tuple_key = (dependency, curr_object_data[key_type].upper())418 elif type(REPLACEMENT_KEYS[template_name][dependency]) == list:419 tmp_list = REPLACEMENT_KEYS[template_name][dependency]420 for tuple in tmp_list:421 if tuple[0] in curr_object_data:422 tuple_key = (tuple[1], curr_object_data[dependency])423 break424 elif isinstance(REPLACEMENT_KEYS[template_name][dependency], Expression):425 exp = REPLACEMENT_KEYS[template_name][dependency]426 return exp.get_keys(curr_object_data[dependency])427 tuple_keys.append(tuple_key)428 return tuple_keys429def resolve_single_dependencies(template_name,430 dependency,431 group_user_data,432 extra_keys_dict,433 curr_object_data):434 tuple_keys = [(dependency, curr_object_data[dependency])]435 dependencies_not_found = []436 replacement_tuple_keys = get_replacement_keys(template_name,437 dependency,438 curr_object_data)439 tuple_keys = replacement_tuple_keys if len(replacement_tuple_keys) > 0 else tuple_keys440 for key in tuple_keys:441 found, data, temp_template_name, temp_key = find_dependency(key,442 group_user_data)443 if not found:444 found, data, temp_template_name, temp_key = find_dependency(key,445 extra_keys_dict)446 if not found:447 dependencies_not_found.append(key)448 return dependencies_not_found449def resolve_dependencies(group_user_data,450 remaining_user_data,451 extra_keys_dict,452 template_dict):453 template_dependencies = calculate_template_dependencies(template_dict,454 group_user_data)455 dependencies_not_found = []456 for template_name, value in group_user_data.items():457 for object_key, object_data in value.items():458 for dependency in template_dependencies[template_name]:459 if dependency in object_data[1]:460 if template_name in LIST_DEPENDENCY_KEYS and\461 dependency in LIST_DEPENDENCY_KEYS[template_name]:462 dependencies_not_found.extend(resolve_list_dependencies(template_name,463 dependency,464 group_user_data,465 extra_keys_dict,466 object_data[1]))467 else:468 dependencies_not_found.extend(resolve_single_dependencies(template_name,469 dependency,470 group_user_data,471 extra_keys_dict,472 object_data[1]))473 for val in dependencies_not_found:474 found, data, template_name, key = find_dependency(val,475 remaining_user_data)476 if not found:477 found, data, template_name, key = find_dependency(val,478 extra_keys_dict)479 if found:480 template_user_data = group_user_data.get(template_name, {})481 template_user_data[key] = data482 group_user_data[template_name] = template_user_data483 print(dependencies_not_found)484 return dependencies_not_found485def get_object_name(yaml_data, jinja2_template_data):486 if jinja2_template_data[0].get_name() in REPLACEMENT_KEY_TEMPLATES:487 key = REPLACEMENT_KEY_TEMPLATES[jinja2_template_data[0].get_name()]488 if type(key) == list:489 for k in key:490 if k in yaml_data:491 key = k492 break493 elif isinstance(key, TypeToObjectName):494 for variable in jinja2_template_data[0].variables:495 if re.match(".*name", variable["name"]) is not None and \496 variable["type"] != "reference":497 return (key.type_dict[yaml_data[key.type_name]], yaml_data[variable["name"]])498 elif type(key) == int:499 key += 1500 REPLACEMENT_KEY_TEMPLATES[jinja2_template_data[0].get_name()] = key501 return (jinja2_template_data[0].get_name(),502 jinja2_template_data[0].get_name() + str(key))503 elif isinstance(key, CombinationKey):504 key_list = key.key.split(',')505 comb_key = ""506 for k in key_list:507 if k in yaml_data:508 comb_key = comb_key + yaml_data[k] + " "509 comb_key.strip()510 return (key, comb_key)511 if key in yaml_data:512 return (key, yaml_data[key])513 else:514 return (key, key)515 for variable in jinja2_template_data[0].variables:516 if re.match(".*name", variable["name"]) is not None and variable["type"] != "reference":517 return (variable["name"], yaml_data[variable["name"]])518if __name__ == "__main__":...
test_helpers.py
Source:test_helpers.py
...282 self._wrap_test_block("kdsfofs")283 def nonexistent_dict(self):284 with pytest.raises(exceptions.BadSchemaError):285 self._wrap_test_block({"file_path": "gogfgl"})286 def extra_keys_dict(self):287 with pytest.raises(exceptions.BadSchemaError):288 self._wrap_test_block({"file_path": "gogfgl", "blop": 123})289class TestStrictUtils:290 @pytest.mark.parametrize("section", ["json", "headers", "redirect_query_params"])291 @pytest.mark.parametrize("setting", ["on", "off"])292 def test_parse_option(self, section, setting):293 option = "{}:{}".format(section, setting)294 match = validate_and_parse_option(option)295 assert match.section == section296 if setting == "on":297 assert match.is_on()298 else:299 assert not match.is_on()300 @pytest.mark.parametrize("section", ["json", "headers", "redirect_query_params"])...
base_object.py
Source:base_object.py
1import logging2import typing3from ..client import DiscordClientAsync4extra_keys_dict: typing.Dict[str, typing.Set[typing.FrozenSet[str]]] = {}5class DiscordObject:6 """7 Basic class for all other discord objects8 """9 def __init__(self, client_bind: DiscordClientAsync = None, snowflake: str = None):10 self.client_bind = client_bind11 self.snowflake = snowflake12 def __eq__(self, other: 'DiscordObject') -> bool:13 return self.snowflake == other.snowflake14 @classmethod15 def kwargs_handler(cls, **kwargs):16 if not kwargs:17 return18 extra_keys = frozenset(kwargs.keys())19 try:20 post_warning = extra_keys not in extra_keys_dict[cls.__name__]21 except KeyError:22 extra_keys_dict[cls.__name__] = set()23 post_warning = True24 if post_warning:25 extra_keys_dict[cls.__name__].add(extra_keys)26 logging.warning(27 (f"DiscordObject Initialization warning. Object {cls.__name__}"28 f" was attempted to initialize with the keys: "...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!