Best Python code snippet using localstack_python
idp_mdf_merge.py
Source:idp_mdf_merge.py
...336 return error_string if error_string != '' else None337def _on_closing():338 """Graceful program exit if user closes the window."""339 sys.exit("Operation cancelled.")340def get_merge_parameters(files, target, modem, lsf, meta):341 """342 Displays a UI confirming merge setup and allowing modification.343 :param files: a list of file names to merge344 :param target: the target merged file name345 :param modem: (Boolean) to include core modem definitions346 :param lsf: (Boolean) to include SkyWave LSF Core+Agent Services347 :param meta: (Boolean) to include metadata tags in merged XML output348 :return: a dictionary consisting of349 * ``files`` - (list of string) file/path names to merge350 * ``target`` - (string) output file/path name351 * ``modem`` - (Boolean) flag to include core modem definitions352 * ``lsf`` - (Boolead) flag to include SkyWave LSF core/agent definitions353 * ``meta`` - (Boolean) flag to include XML tag metadata (Service and Message)354 * ``error`` - (None) if no errors or (list of string) any processing errors355 """356 error = None357 merge_parameters = {358 'files': files,359 'target': target,360 'modem': modem,361 'lsf': lsf,362 'meta': meta,363 'error': error364 }365 root = tk.Tk()366 dialog = MergeDialog(root, merge_parameters)367 root.protocol('WM_DELETE_WINDOW', _on_closing)368 root.mainloop()369 merge_parameters = dialog.parameters370 if len(merge_parameters['files']) < 1:371 err = "ERROR: No files selected to merge."372 if merge_parameters['error'] is None:373 merge_parameters['error'] = [err]374 else:375 merge_parameters['error'].append(err)376 return merge_parameters377def parse_args(argv):378 """379 Parse the command line arguments.380 :param argv: An array containing the command line arguments381 :return: (dictionary) containing the command line arguments and their values382 * ``meta`` - (Boolean) flag to include metadata in XML tags for Service and Message383 * ``modem`` - (Boolean) flag to include core modem definitions384 * ``lsf`` - (Boolean) flag to include SkyWave LSF core/agent definitions385 * ``files`` - (list of string) input files to merge386 * ``target`` - (string) output file387 """388 global enable_smart_tags389 parser = argparse.ArgumentParser(description='Merge IDP Message Definition Files')390 parser.add_argument('-m', '--modem', required=False, dest='modem', action='store_true',391 help=str("Import IDP Core Modem definitions."))392 parser.add_argument('-l', '--lsf', required=False, dest='lsf', action='store_true',393 help=str("Import ORBCOMM/SkyWave LSF Core/Agent Service definitions."))394 parser.add_argument('-f', '--file', required=False, dest='files', action='append',395 help=str("Source XML file (*.idpmsg) to merge. Accepts muliple entries. \n"396 " NOTE: use double-quoted path names."))397 parser.add_argument('-t', '--target', required=False, dest='target',398 help=str("Destination XML file (*.idpmsg) to merge. \n"399 " NOTE: use double-quoted path name."))400 parser.add_argument('--meta', required=False, dest='meta', action='store_true',401 help=str("Add metadata tags in XML attributes. NOTE: may not be supported by IDP gateway."))402 return vars(parser.parse_args(args=argv[1:]))403def main():404 user_options = parse_args(sys.argv)405 files = user_options['files']406 merge_parameters = get_merge_parameters(files=files,407 target=user_options['target'],408 modem=user_options['modem'],409 lsf=user_options['lsf'],410 meta=user_options['meta'])411 if merge_parameters['error'] is None:412 error = merge_mdf(files=merge_parameters['files'],413 target=merge_parameters['target'],414 meta=merge_parameters['meta'])415 if error is None:416 print("Operation completed.")417 else:418 print(error)419 else:420 for e in merge_parameters['error']:...
parameter_util.py
Source:parameter_util.py
...36 default_runtime_dict = ParameterUtil.change_object_to_dict(param_obj)37 default_runtime_conf_suf = _module_setting["default_runtime_conf"]38 try:39 with open(os.path.join(default_runtime_conf_prefix, default_runtime_conf_suf), "r") as fin:40 default_runtime_dict = ParameterUtil.merge_parameters(default_runtime_dict, json.loads(fin.read()), param_obj);41 except:42 raise Exception("default runtime conf should be a json file")43 44 if not submit_dict:45 raise ValueError("submit conf does exist or format is wrong")46 runtime_role_parameters = {}47 _support_rols = _module_setting["role"].keys()48 for role in submit_dict["role"]:49 _role_setting = None50 for _rolelist in _support_rols:51 if role not in _rolelist.split("|"):52 continue53 else:54 _role_setting = _module_setting["role"].get(_rolelist)55 if not _role_setting:56 continue57 _code_path = os.path.join(_module_setting.get('module_path'), _role_setting.get('program'))58 partyid_list = submit_dict["role"][role]59 runtime_role_parameters[role] = []60 for idx in range(len(partyid_list)):61 runtime_dict = {param_class : copy.deepcopy(default_runtime_dict)}62 for key, value in submit_dict.items():63 if key not in ["algorithm_parameters", "role_parameters"]:64 runtime_dict[key] = value65 if "algorithm_parameters" in submit_dict:66 if module_alias in submit_dict["algorithm_parameters"]:67 common_parameters = submit_dict["algorithm_parameters"].get(module_alias)68 merge_dict = ParameterUtil.merge_parameters(runtime_dict[param_class], common_parameters, param_obj)69 runtime_dict[param_class] = merge_dict70 71 if "role_parameters" in submit_dict and role in submit_dict["role_parameters"]:72 role_dict = submit_dict["role_parameters"][role]73 if module_alias in role_dict:74 role_parameters = role_dict.get(module_alias)75 merge_dict = ParameterUtil.merge_parameters(runtime_dict[param_class], role_parameters, param_obj, idx)76 runtime_dict[param_class] = merge_dict77 78 runtime_dict['local'] = submit_dict.get('local', {})79 my_local = {80 "role": role, "party_id": partyid_list[idx]81 }82 runtime_dict['local'].update(my_local)83 runtime_dict['CodePath'] = _code_path84 runtime_dict['module'] = module85 runtime_role_parameters[role].append(runtime_dict)86 87 return runtime_role_parameters88 @staticmethod89 def merge_parameters(runtime_dict, role_parameters, param_obj, idx=-1):90 param_variables = param_obj.__dict__91 for key, val_list in role_parameters.items():92 if key not in param_variables:93 continue94 attr = getattr(param_obj, key)95 if type(attr).__name__ in dir(builtins) or not attr:96 if idx != -1:97 if len(val_list) <= idx:98 continue99 runtime_dict[key] = val_list[idx]100 else:101 runtime_dict[key] = val_list102 else:103 if key not in runtime_dict:104 runtime_dict[key] = {}105 runtime_dict[key] = ParameterUtil.merge_parameters(runtime_dict.get(key), val_list, attr, idx)106 return runtime_dict107 @staticmethod108 def get_args_input(submit_dict, module="args"):109 if "role_parameters" not in submit_dict:110 return {}111 roles = submit_dict["role_parameters"].keys()112 if not roles:113 return {}114 args_input = {}115 for role in roles:116 if not submit_dict["role_parameters"][role].get(module):117 continue118 args_parameters = submit_dict["role_parameters"][role].get(module)119 args_input[role] = []...
__init__.py
Source:__init__.py
...48pi3k.declare_observables()49mapk.declare_observables()50# Merge parameters that were redundantly specified in multiple component51# modules.52merge_parameters(model, 'k103', [k103_ls, k103_magic])53merge_parameters(model, 'kd103', [kd103_ls, kd103_magic])54merge_parameters(model, 'k122', [k122_gab, k122_ls, k122_priming])55merge_parameters(model, 'kd122', [kd122_gab, kd122_ls, kd122_priming])56merge_parameters(model, 'k16', [k16_scndry])57merge_parameters(model, 'kd123', [kd123_gab, kd123_ls])...
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!!