Best Python code snippet using yandex-tank
test_Observation.py
Source:test_Observation.py
...11 observation = Observation()12 return observation13def test_create_blank_observation(create_observation):14 observation = create_observation15 assert len(observation.get_dict()) == 116 assert type(observation.get_dict()) == dict17 assert observation.get_dict()['success'] == TrinaryEnum.UNKNOWN18 assert type(observation.get_dict()['success']) == TrinaryEnum19@pytest.fixture()20def set_success_true(create_observation):21 observation = create_observation22 observation.set_success(True)23 return observation24def test_set_success_true(set_success_true):25 observation = set_success_true26 assert observation.get_dict()['success'] == TrinaryEnum.TRUE27 assert type(observation.get_dict()['success']) == TrinaryEnum28 return observation29@pytest.fixture()30def set_success_false(create_observation):31 observation = create_observation32 observation.set_success(False)33 return observation34def test_set_success_false(set_success_false):35 observation = set_success_false36 assert observation.get_dict()['success'] == TrinaryEnum.FALSE37 assert type(observation.get_dict()['success']) == TrinaryEnum38def test_add_no_process(create_observation):39 observation = create_observation40 observation.add_process()41 assert len(observation.get_dict()) == 142 assert type(observation.get_dict()) == dict43@pytest.mark.parametrize('pids', [[1], [2845], [1, 2, 3], [1, 1, 1], [1, 2, 1, 5, 3, 6, 8, 4, 1], list(range(1000))])44def test_add_pids_process_single_host(create_observation, pids):45 observation = create_observation46 for p in pids:47 observation.add_process(hostid="test", pid=p)48 assert len(observation.get_dict()) == 249 assert type(observation.get_dict()) == dict50 new_host = observation.get_dict()["test"]51 u_pids = np.unique(np.array(pids))52 assert len(new_host["Processes"]) == len(u_pids)53 for pid in u_pids:54 success = False55 for proc in new_host["Processes"]:56 if proc["PID"] == pid:57 success = True58 assert success, f"PID {pid} not added to process observation"59@pytest.mark.parametrize('pids', [[1], [2845], [1, 2, 3], [1, 1, 1], [1, 2, 1, 5, 3, 6, 8, 4, 1], list(range(1000))])60def test_add_pids_process_many_hosts(create_observation, pids):61 observation = create_observation62 for p in pids:63 observation.add_process(pid=p)64 assert len(observation.get_dict()) == len(pids) + 165 assert type(observation.get_dict()) == dict66 for pid in pids:67 success = False68 for key, host in list(observation.get_dict().items()):69 if key != 'success':70 if host["Processes"][0]["PID"] == pid:71 success = True72 break73 assert success, f"PID {pid} not added to process observation"74 for key, host in observation.get_dict().items():75 if key != 'success':76 assert len(host["Processes"]) == 177@pytest.fixture()78def add_info_process_1(create_observation):79 observation = create_observation80 observation.add_process(hostid="test", pid=1)81 return observation82def test_add_info_process_1(add_info_process_1):83 observation = add_info_process_184 assert len(observation.get_dict()["test"]["Processes"]) == 185 assert observation.get_dict()["test"]["Processes"][0]["PID"] == 186@pytest.fixture()87def add_info_process_2(add_info_process_1):88 observation = add_info_process_189 observation.add_process(hostid="test", pid=1, parent_pid=2)90 return observation91def test_add_info_process_2(add_info_process_2):92 observation = add_info_process_293 assert len(observation.get_dict()["test"]["Processes"]) == 194 assert observation.get_dict()["test"]["Processes"][0]["PID"] == 195 assert observation.get_dict()["test"]["Processes"][0]["PPID"] == 296@pytest.fixture()97def add_info_process_3(add_info_process_2):98 observation = add_info_process_299 observation.add_process(hostid="test", pid=1, process_name="hello")100 return observation101def test_add_info_process_3(add_info_process_3):102 observation = add_info_process_3103 assert len(observation.get_dict()["test"]["Processes"]) == 1104 assert observation.get_dict()["test"]["Processes"][0]["PID"] == 1105 assert observation.get_dict()["test"]["Processes"][0]["PPID"] == 2106 assert observation.get_dict()["test"]["Processes"][0]["Process Name"] == "hello"107 assert observation.get_dict()["test"]["Processes"][0]["Known Process"] == ProcessName.UNKNOWN108@pytest.fixture()109def add_info_process_4(add_info_process_3):110 observation = add_info_process_3111 observation.add_process(hostid="test", pid=1, process_type="SSH")112 return observation113def test_add_info_process_4(add_info_process_4):114 observation = add_info_process_4115 assert len(observation.get_dict()["test"]["Processes"]) == 1116 assert observation.get_dict()["test"]["Processes"][0]["PID"] == 1117 assert observation.get_dict()["test"]["Processes"][0]["PPID"] == 2118 assert observation.get_dict()["test"]["Processes"][0]["Process Name"] == "hello"119 assert observation.get_dict()["test"]["Processes"][0]["Known Process"] == ProcessName.UNKNOWN120 assert observation.get_dict()["test"]["Processes"][0]["Process Type"] == ProcessType.SSH121@pytest.fixture()122def add_info_process_5(add_info_process_4):123 observation = add_info_process_4124 observation.add_process(hostid="test", pid=1, process_version="OpenSSH 1.3")125 return observation126def test_add_info_process_5(add_info_process_5):127 observation = add_info_process_5128 assert len(observation.get_dict()["test"]["Processes"]) == 1129 assert observation.get_dict()["test"]["Processes"][0]["PID"] == 1130 assert observation.get_dict()["test"]["Processes"][0]["PPID"] == 2131 assert observation.get_dict()["test"]["Processes"][0]["Process Name"] == "hello"132 assert observation.get_dict()["test"]["Processes"][0]["Known Process"] == ProcessName.UNKNOWN133 assert observation.get_dict()["test"]["Processes"][0]["Process Type"] == ProcessType.SSH134 assert observation.get_dict()["test"]["Processes"][0]["Process Version"] == ProcessVersion.OPENSSH_1_3135@pytest.fixture()136def add_network_process_info_1(create_observation):137 observation = create_observation138 # add single listening UDP port139 observation.add_process(hostid="test", pid=1, local_address="0.0.0.0", local_port=80, app_protocol="HTTP")140 return observation141def test_add_network_process_info_1(add_network_process_info_1):142 observation = add_network_process_info_1143 assert len(observation.get_dict()["test"]["Processes"]) == 1144 assert observation.get_dict()["test"]["Processes"][0]["PID"] == 1145 assert len(observation.get_dict()["test"]["Processes"][0]["Connections"]) == 1146 assert observation.get_dict()["test"]["Processes"][0]["Connections"][0]["local_address"] == IPv4Address("0.0.0.0")147 assert "remote_address" not in observation.get_dict()["test"]["Processes"][0]["Connections"][0]148 assert "remote_port" not in observation.get_dict()["test"]["Processes"][0]["Connections"][0]149 assert observation.get_dict()["test"]["Processes"][0]["Connections"][0]["local_port"] == 80150 assert observation.get_dict()["test"]["Processes"][0]["Connections"][0]["Application Protocol"] == AppProtocol.HTTP151@pytest.fixture()152def add_network_process_info_2(add_network_process_info_1):153 observation = add_network_process_info_1154 # add a remote HTTP connection155 observation.add_process(hostid="test", pid=1, remote_port=80, remote_address="10.0.0.1", app_protocol="TCP")156 return observation157def test_add_network_process_info_2(add_network_process_info_2):158 observation = add_network_process_info_2159 assert len(observation.get_dict()["test"]["Processes"]) == 1160 assert observation.get_dict()["test"]["Processes"][0]["PID"] == 1161 assert len(observation.get_dict()["test"]["Processes"][0]["Connections"]) == 2162 assert observation.get_dict()["test"]["Processes"][0]["Connections"][0]["local_address"] == IPv4Address("0.0.0.0")163 assert "remote_address" not in observation.get_dict()["test"]["Processes"][0]["Connections"][0]164 assert "remote_port" not in observation.get_dict()["test"]["Processes"][0]["Connections"][0]165 assert observation.get_dict()["test"]["Processes"][0]["Connections"][0]["local_port"] == 80166 assert observation.get_dict()["test"]["Processes"][0]["Connections"][0]["Application Protocol"] == AppProtocol.HTTP167 assert observation.get_dict()["test"]["Processes"][0]["Connections"][1]["remote_address"] == IPv4Address("10.0.0.1")168 assert "local_address" not in observation.get_dict()["test"]["Processes"][0]["Connections"][1]169 assert "local_port" not in observation.get_dict()["test"]["Processes"][0]["Connections"][1]170 assert observation.get_dict()["test"]["Processes"][0]["Connections"][1]["remote_port"] == 80171 assert observation.get_dict()["test"]["Processes"][0]["Connections"][1]["Application Protocol"] == AppProtocol.TCP172@pytest.fixture()173def add_network_process_info_3(add_network_process_info_2):174 observation = add_network_process_info_2175 # add local ephemeral port connection176 observation.add_process(hostid="test", pid=1, local_port=52435, local_address="10.0.0.2", app_protocol="TCP")177 return observation178def test_add_network_process_info_3(add_network_process_info_3):179 observation = add_network_process_info_3180 assert len(observation.get_dict()["test"]["Processes"]) == 1181 assert observation.get_dict()["test"]["Processes"][0]["PID"] == 1182 assert len(observation.get_dict()["test"]["Processes"][0]["Connections"]) == 3183 assert observation.get_dict()["test"]["Processes"][0]["Connections"][0]["local_address"] == IPv4Address("0.0.0.0")184 assert "remote_address" not in observation.get_dict()["test"]["Processes"][0]["Connections"][0]185 assert "remote_port" not in observation.get_dict()["test"]["Processes"][0]["Connections"][0]186 assert observation.get_dict()["test"]["Processes"][0]["Connections"][0]["local_port"] == 80187 assert observation.get_dict()["test"]["Processes"][0]["Connections"][0]["Application Protocol"] == AppProtocol.HTTP188 assert observation.get_dict()["test"]["Processes"][0]["Connections"][1]["remote_address"] == IPv4Address("10.0.0.1")189 assert "local_address" not in observation.get_dict()["test"]["Processes"][0]["Connections"][1]190 assert "local_port" not in observation.get_dict()["test"]["Processes"][0]["Connections"][1]191 assert observation.get_dict()["test"]["Processes"][0]["Connections"][1]["remote_port"] == 80192 assert observation.get_dict()["test"]["Processes"][0]["Connections"][1]["Application Protocol"] == AppProtocol.TCP193 assert observation.get_dict()["test"]["Processes"][0]["Connections"][2]["local_address"] == IPv4Address("10.0.0.2")194 assert "remote_address" not in observation.get_dict()["test"]["Processes"][0]["Connections"][2]195 assert "remote_port" not in observation.get_dict()["test"]["Processes"][0]["Connections"][2]196 assert observation.get_dict()["test"]["Processes"][0]["Connections"][2]["local_port"] == 52435197 assert observation.get_dict()["test"]["Processes"][0]["Connections"][2]["Application Protocol"] == AppProtocol.TCP198def test_add_negative_pid_process(create_observation):199 observation = create_observation200 success = True201 try:202 observation.add_process(hostid="test", pid=-1)203 except ValueError:204 success = False205 if success:206 pytest.fail("Negative pid successfully added")207@pytest.fixture()208def add_all_process_info(create_observation):209 observation = create_observation210 observation.add_process(hostid="test", pid=123, parent_pid=23, process_name="svchost", program_name="svchost",211 username="NT Authority/System", path="C:/Windows/System32/", local_port=32421,212 remote_port=443, local_address="10.0.0.1", remote_address="10.0.0.2", app_protocol="TCP",213 status="Open", process_type="?????", process_version="10.0.17763.1",214 vulnerability="ms10-040")215 return observation216def test_all_process_info(add_all_process_info):217 observation = add_all_process_info218 assert len(observation.get_dict()["test"]["Processes"]) == 1219 assert observation.get_dict()["test"]["Processes"][0]["PID"] == 123220 assert observation.get_dict()["test"]["Processes"][0]["PPID"] == 23221 assert observation.get_dict()["test"]["Processes"][0]["Process Name"] == "svchost"222 assert observation.get_dict()["test"]["Processes"][0]["Known Process"] == ProcessName.SVCHOST223 assert observation.get_dict()["test"]["Processes"][0]["Program Name"] == FileType.SVCHOST224 assert observation.get_dict()["test"]["Processes"][0]["Username"] == "NT Authority/System"225 assert observation.get_dict()["test"]["Processes"][0]["Path"] == "C:/Windows/System32/"226 assert observation.get_dict()["test"]["Processes"][0]["Known Path"] == Path.WINDOWS_SYSTEM227 assert len(observation.get_dict()["test"]["Processes"][0]["Connections"]) == 1228 assert observation.get_dict()["test"]["Processes"][0]["Connections"][0]["local_address"] == IPv4Address("10.0.0.1")229 assert observation.get_dict()["test"]["Processes"][0]["Connections"][0]["remote_address"] == IPv4Address("10.0.0.2")230 assert observation.get_dict()["test"]["Processes"][0]["Connections"][0]["local_port"] == 32421231 assert observation.get_dict()["test"]["Processes"][0]["Connections"][0]["remote_port"] == 443232 assert observation.get_dict()["test"]["Processes"][0]["Connections"][0]["Application Protocol"] == AppProtocol.TCP233 assert observation.get_dict()["test"]["Processes"][0]["Connections"][0]["Status"] == ProcessState.OPEN234 assert observation.get_dict()["test"]["Processes"][0]["Process Type"] == ProcessType.UNKNOWN235 assert observation.get_dict()["test"]["Processes"][0]["Process Version"] == ProcessVersion.SVC10_0_17763_1236 assert observation.get_dict()["test"]["Processes"][0]["Vulnerability"][0] == Vulnerability.UNKNOWN237@pytest.fixture()238def add_system_info(create_observation):239 observation = create_observation240 observation.add_system_info(hostid="test", hostname="TestHost", os_type="Windows", os_distribution="Windows 8",241 os_version="6.2.9200.16384", architecture="x86")242 return observation243def test_add_system_info(add_system_info):244 observation = add_system_info245 assert len(observation.get_dict()) == 2246 system_info = observation.get_dict()["test"]["System info"]247 assert system_info["Hostname"] == "TestHost"248 assert system_info["OSType"] == OperatingSystemType.WINDOWS249 assert system_info["OSDistribution"] == OperatingSystemDistribution.WINDOWS_8250 assert system_info["OSVersion"] == OperatingSystemVersion.W6_2_9200_16384251 assert system_info["Architecture"] == Architecture.x86252@pytest.fixture()253def add_interface_info(create_observation):254 observation = create_observation255 observation.add_interface_info(hostid="test", interface_name="test_interface", ip_address="10.11.12.13",256 subnet="10.11.12.0/24")257 return observation258def test_add_interface_info(add_interface_info):259 observation = add_interface_info260 assert len(observation.get_dict()) == 2261 assert len(observation.get_dict()["test"]["Interface"]) == 1262 interface = observation.get_dict()["test"]["Interface"][0]263 assert interface["Interface Name"] == "test_interface"264 assert interface["IP Address"] == IPv4Address("10.11.12.13")265 assert interface["Subnet"] == IPv4Network("10.11.12.0/24")266@pytest.fixture()267def add_file_info(create_observation):268 observation = create_observation269 observation.add_file_info(hostid="test", path="/tmp/", name="dodgy", vendor="stranger", version="0.1",270 file_type="nmap", user="root", user_permissions=7, group="1000", group_permissions=7,271 default_permissions=7)272 return observation273def test_add_file_info(add_file_info):274 observation = add_file_info275 assert len(observation.get_dict()) == 2276 assert len(observation.get_dict()["test"]["Files"]) == 1277 file = observation.get_dict()["test"]["Files"][0]278 assert file["File Name"] == "dodgy"279 assert file["Known File"] == FileType.UNKNOWN280 assert file["Path"] == "/tmp/"281 assert file["Known Path"] == Path.TEMP282 assert file["Vendor"] == Vendor.UNKNOWN283 assert file["Version"] == "0.1"284 assert file["Type"] == FileType.NMAP285 assert file["Username"] == "root"286 assert file["User Permissions"] == 7287 assert file["Group Name"] == "1000"288 assert file["Group Permissions"] == 7289 assert file["Default Permissions"] == 7290 # TODO needs to be completed once the enums are complete291@pytest.fixture()292def add_user_info(create_observation):293 observation = create_observation294 observation.add_user_info(hostid="test", group_name="Users", username="Basic_user",295 password="password", password_hash="5f4dcc3b5aa765d61d8327deb882cf99", password_hash_type="MD5")296 return observation297def test_add_user_info(add_user_info):298 observation = add_user_info299 assert len(observation.get_dict()) == 2300 assert len(observation.get_dict()["test"]["User Info"]) == 1301 user = observation.get_dict()["test"]["User Info"][0]302 assert user["Username"] == "Basic_user"303 assert len(user["Groups"]) == 1304 assert user["Groups"][0]["Group Name"] == "Users"305 assert user["Groups"][0]["Builtin Group"] == BuiltInGroups.USERS306 assert user["Password"] == "password"307 assert user["Password Hash"] == "5f4dcc3b5aa765d61d8327deb882cf99"308 assert user["Password Hash Type"] == PasswordHashType.MD5309@pytest.fixture()310def add_user_info2(add_user_info):311 observation = add_user_info312 observation.add_user_info(hostid="test", group_name="Users", username="Basic_user", uid=1001, gid=1001,313 password="password", password_hash="5f4dcc3b5aa765d61d8327deb882cf99", password_hash_type="MD5")314 return observation315def test_add_user_info_2(add_user_info2):316 observation = add_user_info2317 assert len(observation.get_dict()) == 2318 assert len(observation.get_dict()["test"]["User Info"]) == 1319 user = observation.get_dict()["test"]["User Info"][0]320 assert user["Username"] == "Basic_user"321 assert user["UID"] == 1001322 assert len(user["Groups"]) == 1323 assert len(user["Groups"][0]) == 3324 assert user["Groups"][0]["Group Name"] == "Users"325 assert user["Groups"][0]["Builtin Group"] == BuiltInGroups.USERS326 assert user["Groups"][0]["GID"] == 1001327 assert user["Password"] == "password"328 assert user["Password Hash"] == "5f4dcc3b5aa765d61d8327deb882cf99"329 assert user["Password Hash Type"] == PasswordHashType.MD5330@pytest.fixture()331def add_user_info3(create_observation):332 observation = create_observation333 observation.add_user_info(hostid="test", username="Basic_user", uid=1001, gid=1001)334 observation.add_user_info(hostid="test", username="Basic_user", group_name="Basic_Group", gid=1001)335 return observation336def test_add_user_info_3(add_user_info3):337 observation = add_user_info3338 assert len(observation.get_dict()) == 2339 assert len(observation.get_dict()["test"]["User Info"]) == 1340 user = observation.get_dict()["test"]["User Info"][0]341 assert user["Username"] == "Basic_user"342 assert user["UID"] == 1001343 assert len(user["Groups"]) == 1344 assert len(user["Groups"][0]) == 2345 assert user["Groups"][0]["Group Name"] == "Basic_Group"346 assert user["Groups"][0]["GID"] == 1001347@pytest.fixture()348def add_user_info4(create_observation):349 observation = create_observation350 observation.add_user_info(hostid="test", username="Basic_user", uid=1001, gid=1001)351 observation.add_user_info(hostid="test", group_name="Basic_Group", gid=1001)352 return observation353def test_add_user_info_4(add_user_info4):354 observation = add_user_info4355 assert len(observation.get_dict()) == 2356 assert len(observation.get_dict()["test"]["User Info"]) == 1357 user = observation.get_dict()["test"]["User Info"][0]358 assert user["Username"] == "Basic_user"359 assert user["UID"] == 1001360 assert len(user["Groups"]) == 1361 assert len(user["Groups"][0]) == 2362 assert user["Groups"][0]["Group Name"] == "Basic_Group"363 assert user["Groups"][0]["GID"] == 1001364@pytest.fixture()365def add_user_info5(create_observation):366 observation = create_observation367 observation.add_user_info(hostid="test", group_name="Basic_Group", gid=1001)368 observation.add_user_info(hostid="test", username="Basic_user", uid=1001, gid=1001)369 return observation370# this is a known issue with the current implementation of the observation. The order of adding a group should not affect the solution371# def test_add_user_info_5(add_user_info5):372# observation = add_user_info5373# assert len(observation.get_dict()) == 2374# assert len(observation.get_dict()["test"]["User Info"]) == 1375# user = observation.get_dict()["test"]["User Info"][0]376# assert user["Username"] == "Basic_user"377# assert user["UID"] == 1001378# assert len(user["Groups"]) == 1379# assert len(user["Groups"][0]) == 2380# assert user["Groups"][0]["Group Name"] == "Basic_Group"381# assert user["Groups"][0]["GID"] == 1001382@pytest.fixture()383def add_session_info(create_observation):384 observation = create_observation385 observation.add_session_info(hostid="test", username="test", session_id=0, timeout=0, pid=432, session_type="ssh", agent="Red")386 return observation387def test_add_session_info(add_session_info):388 observation = add_session_info389 assert len(observation.get_dict()) == 2390 assert len(observation.get_dict()["test"]["Sessions"]) == 1391 session = observation.get_dict()["test"]["Sessions"][0]392 assert session["ID"] == 0393 assert session["Username"] == "test"394 assert session["Timeout"] == 0395 assert session["PID"] == 432396 assert session["Type"] == SessionType.SSH397 assert len(observation.get_dict()["test"]["Processes"]) == 1398 process = observation.get_dict()["test"]["Processes"][0]399 assert process["Username"] == "test"400 assert process["PID"] == 432401def test_repeat_adding_interface_info(create_observation):402 observation = create_observation403 observation.add_interface_info(hostid="test", ip_address="127.0.0.1")404 observation.add_interface_info(hostid="test", ip_address="127.0.0.1")...
markups.py
Source:markups.py
...29 if count == 2:30 markup.row(c[0], c[1])31 c.clear()32 count = 033 markup.row(get_dict('main_menu', d), get_dict('back', d))34 return markup35async def get_markups(table_name, message: types.Message):36 try:37 user_id = message.from_user.id38 d = get_lang(user_id)39 update_log(user_id, get_log(user_id) + message.text)40 j = 041 for i in get_buttons(d, table_name):42 if message.text == i[1]:43 if i[4]:44 await bot.send_message(user_id, i[2],45 reply_markup=inline_keyboards(d, table_name, i[0]))46 else:47 await bot.send_message(user_id, i[2], reply_markup=reply_markup(d, i[3]))48 set_user_state(user_id, get_state(d, i[0], table_name))49 else:50 j = j + 151 if j == len(get_buttons(d, table_name)):52 await bot.send_message(user_id, get_dict('section', d))53 except Exception as e:54 logger_app.error("\nMethod: " + table_name + '\n' + str(e))55def inline_keyboards(lang, table, name):56 keyboard = types.InlineKeyboardMarkup()57 for i in get_inline_markup(table, lang, name):58 for j in range(len(i[0].split(", "))):59 keyboard.add(types.InlineKeyboardButton(text=i[1].split(", ")[j], url=i[0].split(", ")[j]))60 return keyboard61def reply_markup(lang, state_id):62 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)63 count = 064 c = []65 tup = []66 List = get_reply_markup(lang, state_id)67 for i in List:68 tup.append(i[0])69 if len(tup) % 2 != 0:70 for i in tup:71 if i != tup[-1]:72 c.append(i)73 count = count + 174 if count == 2:75 markup.row(c[0], c[1])76 c.clear()77 count = 078 else:79 c.append(i)80 markup.row(c[0])81 else:82 for i in tup:83 c.append(i)84 count = count + 185 if count == 2:86 markup.row(c[0], c[1])87 c.clear()88 count = 089 return markup90def buttons(lang, table_name):91 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)92 count = 093 c = []94 tup = []95 List = get_buttons(lang, table_name)96 for i in List:97 tup.append(i[1])98 if len(tup) % 2 != 0:99 for i in tup:100 if i != tup[-1]:101 c.append(i)102 count = count + 1103 if count == 2:104 markup.row(c[0], c[1])105 c.clear()106 count = 0107 else:108 c.append(i)109 markup.row(c[0])110 else:111 for i in tup:112 c.append(i)113 count = count + 1114 if count == 2:115 markup.row(c[0], c[1])116 c.clear()117 count = 0118 return markup119def auth(d):120 markup = types.ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True)121 contact = types.KeyboardButton(text=get_dict('send', d), request_contact=True)122 markup.add(contact)123 return markup124def cancel(d):125 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)126 markup.row(get_dict('cancel', d))127 return markup128def repayment_of_loans_bank_type(d):129 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)130 markup.row(get_dict('repayment_of_loans_bank_type_hamkorbank', d),131 get_dict('repayment_of_loans_bank_type_other', d))132 markup.row(get_dict('back', d))133 return markup134def payment_mobile_operators(user_id, d):135 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)136 markup.row(get_phone_number(user_id))137 markup.row(get_dict('cancel', d))138 return markup139def minibank(code, d):140 List = get_minibanks(code, d)141 m = markup_maker(List, d)142 return m143def atm(code, d):144 List = get_atms(code, d)145 m = markup_maker(List, d)146 return m147def districts(code, d):148 List = get_districts(code, d)149 m = markup_maker(List, d)150 return m151def regions(d):152 List = get_regions(d)153 m = markup_maker(List, d)154 return m155def cost(d):156 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)157 markup.row("100", "200")158 markup.row("300", "500")159 markup.row(get_dict('other_amount', d))160 markup.row(get_dict('main_menu', d), get_dict('back', d))161 return markup162def calculator(d):163 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)164 markup.row(get_dict('purchase_currency', d), get_dict('sale_currency', d))165 markup.row(get_dict('main_menu', d), get_dict('back', d))166 return markup167def branches(d):168 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)169 markup.row(get_dict('branches', d), get_dict('mini_bank', d))170 markup.row(get_dict('atm', d))171 markup.row(get_dict('main_menu', d), get_dict('back', d))172 return markup173def exchange_rates(d):174 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)175 markup.row(get_dict('calculator', d))176 markup.row(get_dict('main_menu', d), get_dict('back', d))177 return markup178def change_lang_cyrillic(d):179 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)180 markup.row(get_dict('lang_rus', d), get_dict('lang_latin', d))181 markup.row(get_dict('main_menu', d), get_dict('back', d))182 return markup183def change_lang_latin(d):184 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)185 markup.row(get_dict('lang_rus', d), get_dict('lang_cyrillic', d))186 markup.row(get_dict('main_menu', d), get_dict('back', d))187 return markup188def change_lang_rus(d):189 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)190 markup.row(get_dict('lang_latin', d), get_dict('lang_cyrillic', d))191 markup.row(get_dict('main_menu', d), get_dict('back', d))192 return markup193def poll(d):194 keyboard = types.InlineKeyboardMarkup()195 url_btn1 = types.InlineKeyboardButton(text=get_dict('go_to_poll', d), url=(get_poll_url('poll_url', d))[0])196 keyboard.add(url_btn1)197 return keyboard198def loan_legal_entity_3_apply(d):199 keyboard = types.InlineKeyboardMarkup()200 url_btn1 = types.InlineKeyboardButton(text=get_dict('apply', d),201 url='http://hamkorbank.uz/application-legal-entities/')202 keyboard.add(url_btn1)203 return keyboard204def legal_entity_internet_banking(d):205 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)206 markup.row(get_dict('internet_banking', d), get_dict('mobile_banking', d))207 markup.row(get_dict('main_menu', d), get_dict('back', d))208 return markup209def other_services(d):210 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)211 markup.row(get_dict('other_services_1', d), get_dict('other_services_2', d))212 markup.row(get_dict('other_services_3', d), get_dict('other_services_4', d))213 markup.row(get_dict('main_menu', d), get_dict('back', d))214 return markup215def credit_legal(d):216 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)217 markup.row(get_dict('loan_legal_entity_1', d), get_dict('loan_legal_entity_2', d))218 markup.row(get_dict('loan_legal_entity_3', d))219 markup.row(get_dict('main_menu', d), get_dict('back', d))220 return markup221def my_bills(d):222 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)223 markup.row(get_dict('balance_state', d))224 markup.row(get_dict('cardindex_1', d), get_dict('cardindex_2', d))225 markup.row(get_dict('main_menu', d), get_dict('back', d))226 return markup227def zolotaya_korona(d):228 keyboard = types.InlineKeyboardMarkup()229 url_btn1 = types.InlineKeyboardButton(text=get_dict('download_hamkor_mobile_android', d),230 url=get_dict('url_hamkor_mobile_android', d))231 url_btn2 = types.InlineKeyboardButton(text=get_dict('download_hamkor_mobile_ios', d),232 url=get_dict('url_hamkor_mobile_ios', d))233 keyboard.add(url_btn1, url_btn2)234 return keyboard235def deposit_online_fc(d):236 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)237 markup.row(get_dict('contribution_online_7', d), get_dict('contribution_online_8', d))238 markup.row(get_dict('contribution_online_9', d))239 markup.row(get_dict('main_menu', d), get_dict('back', d))240 return markup241def deposit_fc(d):242 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)243 markup.row(get_dict('contribution_foreign_currency_1', d), get_dict('contribution_foreign_currency_2', d))244 markup.row(get_dict('contribution_foreign_currency_3', d), get_dict('contribution_foreign_currency_4', d))245 markup.row(get_dict('main_menu', d), get_dict('back', d))246 return markup247def contribution_national_currency_online(d):248 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)249 markup.row(get_dict('contribution_online_1', d), get_dict('contribution_online_2', d))250 markup.row(get_dict('contribution_online_3', d), get_dict('contribution_online_4', d))251 markup.row(get_dict('contribution_online_5', d), get_dict('contribution_online_6', d))252 markup.row(get_dict('main_menu', d), get_dict('back', d))253 return markup254def contribution_national_currency_branches(d):255 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)256 markup.row(get_dict('contribution_national_currency_1', d), get_dict('contribution_national_currency_2', d))257 markup.row(get_dict('contribution_national_currency_3', d), get_dict('contribution_national_currency_4', d))258 markup.row(get_dict('contribution_national_currency_5', d), get_dict('contribution_national_currency_6', d))259 markup.row(get_dict('main_menu', d), get_dict('back', d))260 return markup261def contribution_online_branch(d):262 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)263 markup.row(get_dict('online', d), get_dict('in_branches', d))264 markup.row(get_dict('main_menu', d), get_dict('back', d))265 return markup266def visa_virtual(d):267 keyboard = types.InlineKeyboardMarkup()268 url_btn1 = types.InlineKeyboardButton(text=get_dict('download_hamkor_mobile_android', d),269 url=get_dict('url_hamkor_mobile_android', d))270 url_btn2 = types.InlineKeyboardButton(text=get_dict('download_hamkor_mobile_ios', d),271 url=get_dict('url_hamkor_mobile_ios', d))272 keyboard.add(url_btn1, url_btn2)273 return keyboard274def union_pay(d):275 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)276 markup.row(get_dict('union_pay_classic', d), get_dict('union_pay_exchange', d))277 markup.row(get_dict('main_menu', d), get_dict('back', d))278 return markup279def visa(d):280 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)281 markup.row(get_dict('visa_gold', d), get_dict('visa_paywave_classic', d))282 markup.row(get_dict('visa_virtual', d), get_dict('visa_paywave_exchange', d))283 markup.row(get_dict('main_menu', d), get_dict('back', d))284 return markup285def checkout(d):286 keyboard = types.InlineKeyboardMarkup()287 url_btn = types.InlineKeyboardButton(text=get_dict('checkout', d), url=get_dict('url_card_online_application', d))288 keyboard.add(url_btn)289 return keyboard290def cards_menu(d):291 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)292 markup.row(get_dict('balance', d), get_dict('statement', d))293 markup.row(get_dict('block', d), get_dict('add_new_card', d))294 markup.row(get_dict('main_menu', d), get_dict('back', d))295 return markup296def apply_loan(d):297 keyboard = types.InlineKeyboardMarkup()298 url_btn = types.InlineKeyboardButton(text=get_dict('apply', d), url=get_dict('url_credit_registration', d))299 keyboard.add(url_btn)300 return keyboard301def mobile_application(d):302 keyboard = types.InlineKeyboardMarkup()303 url_btn1 = types.InlineKeyboardButton(text=get_dict('download_hamkor_mobile_android', d),304 url=get_dict('url_hamkor_mobile_android', d))305 url_btn2 = types.InlineKeyboardButton(text=get_dict('download_hamkor_mobile_ios', d),306 url=get_dict('url_hamkor_mobile_ios', d))307 keyboard.add(url_btn1, url_btn2)308 return keyboard309def money_transfers(d):310 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)311 markup.row(get_dict('soniya', d), get_dict('swift', d))312 markup.row(get_dict('corona', d), get_dict('unistream', d))313 markup.row(get_dict('contact', d), get_dict('moneygram', d))314 markup.row(get_dict('western_union', d))315 markup.row(get_dict('main_menu', d), get_dict('back', d))316 return markup317def loans_individual(d):318 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)319 markup.row(get_dict('consumer_loan', d), get_dict('car_loan', d))320 markup.row(get_dict('mortgage', d), get_dict('micro_loan', d))321 markup.row(get_dict('main_menu', d), get_dict('back', d))322 return markup323def deposits_individual(d):324 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)325 markup.row(get_dict('national_currency', d), get_dict('contribution_us_dollar', d))326 markup.row(get_dict('main_menu', d), get_dict('back', d))327 return markup328def cards(d):329 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)330 markup.row(get_dict('uzcard', d), get_dict('humo', d))331 markup.row(get_dict('visa', d), get_dict('union_pay', d))332 markup.row(get_dict('main_menu', d), get_dict('back', d))333 return markup334def main_menu(d):335 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)336 markup.row(get_dict('payments', d), get_dict('individual', d))337 markup.row(get_dict('legal_entity', d), get_dict('contact_bank', d))338 markup.row(get_dict('news', d), get_dict('settings', d))339 markup.row(get_dict('general', d))340 return markup341def individual(d):342 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)343 markup.row(get_dict('mobile_application', d), get_dict('loans', d))344 markup.row(get_dict('cards', d), get_dict('contributions', d))345 markup.row(get_dict('money_transfers', d), get_dict('tariffs', d))346 markup.row(get_dict('back', d))347 return markup348def legal_entity(d):349 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)350 markup.row(get_dict('my_bills', d), get_dict('loans', d))351 markup.row(get_dict('hamkor_pay_for_business', d), get_dict('deposit', d))352 markup.row(get_dict('internet_banking', d), get_dict('other_services', d))353 markup.row(get_dict('tariffs', d), get_dict('back', d))354 return markup355def payments(d):356 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)357 markup.row(get_dict('my_cards', d), get_dict('card_to_card_transfers', d))358 markup.row(get_dict('mobile_operators', d), get_dict('repayment_of_loans', d))359 markup.row(get_dict('back', d))360 return markup361def general(d):362 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)363 markup.row(get_dict('exchange_rates', d), get_dict('branch_offices', d))364 markup.row(get_dict('back', d))365 return markup366def settings(d):367 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)368 markup.row(get_dict('change_lang', d))369 markup.row(get_dict('back', d))370 return markup371def feedback(d):372 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)373 markup.row(get_dict('contact_centre', d), get_dict('online_consultant', d))374 markup.row(get_dict('social_network', d), get_dict('poll', d))375 markup.row(get_dict('back', d))376 return markup377def create_card_agreement(d):378 markup = types.ReplyKeyboardMarkup(resize_keyboard=True)379 markup.row(get_dict('create_card_next', d))380 markup.row(get_dict('cancel', d))...
douban_human_info.py
Source:douban_human_info.py
1#-*- coding:utf-8 -*- 2import pymongo3client = pymongo.MongoClient('112.74.106.159', 27017)4db = client.MovieData5get_info = db.IpData.find({'source': 'douban'}).skip(0).limit(100)6import urllib27from scrapy.selector import Selector8from config_constant import *9import bson10import time11#解æ页é¢12# def html_parse(get_info):13# for i in get_info:14# # response = urllib2.urlopen(i['url'])15# # data = response.read()16# # sel = Selector(text=data)17# # print u'请æ±å°ç人ç©URL:%s' % response.url18# print u'人ç©:%s' % i['name']19# print u'读åç人ç©URL:%s' % i['url']20# print '--------' * 521# html_parse(get_info)22# db.IpData.update({'url': 'https://movie.douban.com/search/%E9%9D%B3%E4%B8%9C'}, {'$set': {'url': 'https://movie.douban.com/celebrity/1314123/'}})23#mongodbä¸çæç´¢ç»æ转人ç©URL24def search_to_douban_id(human_dict):25 if 'search/' in human_dict['url']:26 print u'æ§çURL:%s' % human_dict['url']27 response = urllib2.urlopen(human_dict['url'])28 data = response.read()29 sel = Selector(text=data)30 new_url = sel.xpath('//*[@class="content"]/h3/a/@href').extract()31 if new_url:32 new_url = new_url[0].strip()33 print u'æ°çURL:%s' % new_url34 # db.IpData.update({'url': human_dict['url']}, {'$set': {'url': new_url}})35 print u'-----' * 536# map_list = [i for i in get_info]37# map(search_to_douban_id, map_list)38#代ç39def proxy_request(url):40 request = urllib2.Request(url)41 proxy = urllib2.ProxyHandler(42 {43 'http': 'http://127.0.0.1:8123',44 'https': 'https://127.0.0.1:8123',45 }46 )47 opener = urllib2.build_opener(proxy)48 urllib2.install_opener(opener)49 return opener.open(request).read()50def human_info(info_dict):51 data = proxy_request(info_dict['url'])52 sel = Selector(text=data)53 print u'URL:%s' % info_dict['url']54 get_dict = human_info_format()55 get_dict['human_url'] = info_dict['url']56 get_dict['Releate_ID'] = info_dict['url'].split('/')[-2].strip()57 #ç
§ç58 get_dict['img_url'] = sel.xpath('//*[@id="headline"]//*[@class="pic"]/a/img/@src').extract()[0].strip()59 print u'ç
§çURL:%s' % get_dict['img_url']60 get_dict['img_data'] = bson.Binary(urllib2.urlopen(get_dict['img_url']).read())61 #ä¸æååè±æå62 name = sel.xpath('//*[@id="content"]/h1/text()').extract()[0].strip()63 print u'åå:%s' % name64 name_list = name.split(' ')65 get_dict['cn_name'] = name_list[0]66 print u'ä¸æå:%s' % get_dict['cn_name']67 name_list.pop(0)68 get_dict['en_name'] = ' '.join(name_list)69 print u'è±æå:%s' % get_dict['en_name']70 #å
¶ä½ä¿¡æ¯71 for i in sel.xpath('//*[@id="headline"]//*[@class="info"]/ul/li'):72 for j in douban_human_dict:73 if i.xpath('./span/text()').extract()[0].strip() == douban_human_dict[j]:74 source_info = i.xpath('./text()').extract()75 if source_info:76 source_info = i.xpath('./text()').extract()[1].strip().split(':')[1].strip()77 get_dict[j] = source_info78 print u'{0}\t\t{1}'.format(j, get_dict[j])79 if i.xpath('./span/text()').extract()[0].strip() == u'imdbç¼å·':80 get_dict['IMDB_ID'] = dict()81 get_dict['IMDB_ID']['name'] = i.xpath('./a/text()').extract()[0].strip()82 get_dict['IMDB_ID']['url'] = i.xpath('./a/@href').extract()[0].strip()83 print u'imdbç¼å·:{0}é¾æ¥:{1}'.format(get_dict['IMDB_ID']['name'], get_dict['IMDB_ID']['url'])84 #ç®ä»85 all_introduce = sel.xpath('//*[@class="all hidden"]/text() | //*[@id="intro"]//*[@class="bd"]/text()').extract()86 if all_introduce:87 get_dict['introduce'] = all_introduce 88 for kk in all_introduce:89 print kk90 #å
¨é¨ä½å91 # history_works_record(info_dict['movie_id'])92 #è·å¥æ
åµ93 history_awards_info(info_dict['movie_id'])94 # db.PeopleData.update({'url': get_dict['human_url']}, {'$set': get_dict}, True)95#åå²ä½åæ»æ°96def history_works_record(movie_id):97 history_works_list = list()98 new_url = 'https://movie.douban.com/celebrity/{0}/movies?start=0&format=pic&sortby=time&'.format(movie_id)99 data = proxy_request(new_url)100 sel = Selector(text=data)101 history_works_list.extend(history_info(sel))102 all_count = int(sel.xpath('//*[@class="count"]/text()').extract()[0].strip().split(u'å
±')[1].split(u'æ¡')[0].strip())103 print u'ä¸å
±çæ¡æ°:%s' % all_count104 for i in range(1, all_count/10 + 1):105 new_url = 'https://movie.douban.com/celebrity/{0}/movies?start={1}&format=pic&sortby=time&'.format(movie_id, i*10)106 data = proxy_request(new_url)107 sel = Selector(text=data)108 history_works_list.extend(history_info(sel))109 print len(history_works_list)110#ä½å页é¢è§£æ 缺IMDBç¼å·111def history_info(sel):112 works_list = list()113 for i in sel.xpath('//*[@ class="grid_view"]/ul/li'):114 works_dict = dict()115 works_dict['name'] = i.xpath('./dl/dd/h6/a/text()').extract()[0].strip()116 print u'ä½åå称:%s' % works_dict['name']117 works_dict['works_url'] = i.xpath('./dl/dd/h6/a/@href').extract()[0].strip()118 print u'ä½åé¾æ¥:%s' % works_dict['works_url']119 if len(i.xpath('./dl/dd/h6/span')) == 3:120 121 works_dict['date'] = i.xpath('./dl/dd/h6/span[1]/text()').extract()[0].strip()122 print u'ä½åæ¶é´:%s' % works_dict['date']123 works_dict['status'] = i.xpath('./dl/dd/h6/span[2]/text()').extract()[0].strip()124 print u'ç¶æ:%s' % works_dict['status']125 works_dict['position'] = i.xpath('./dl/dd/h6/span[3]/text()').extract()[0].strip()126 print u'èè½:%s' % works_dict['position']127 else:128 works_dict['date'] = i.xpath('./dl/dd/h6/span[1]/text()').extract()[0].strip()129 print u'ä½åæ¶é´:%s' % works_dict['date']130 works_dict['status'] = u'å·²ä¸æ '131 works_dict['position'] = i.xpath('./dl/dd/h6/span[2]/text()').extract()[0].strip()132 print u'èè½:%s' % works_dict['position']133 works_list.append(works_dict)134 print '-------' * 5135 return works_list136#è·å¥è®°å½ 缺IMDBç¼å·137def history_awards_info(movie_id):138 url = 'https://movie.douban.com/celebrity/{0}/awards/'.format(movie_id)139 data = proxy_request(url)140 sel = Selector(text=data)141 all_awards_list = list()142 for i in sel.xpath('//*[@id="content"]//*[@class="article"]/div'):143 awards_dict = dict()144 awards_dict['date'] = str()145 awards_dict['award_introduce'] = list()146 awards_dict['date'] = i.xpath('./div/h2/text()').extract()[0].strip()147 print u'年份:%s' % awards_dict['date']148 for j in i.xpath('.//*[@class="award"]'):149 single_record = dict()150 single_record['award_body'] = str()151 single_record['award_name'] = str()152 single_record['film_info'] = dict()153 single_record['award_body'] = j.xpath('./li[1]/a/text()').extract()[0].strip()154 print u'ç±»å:%s' % single_record['award_body']155 single_record['award_name'] = j.xpath('./li[2]/text()').extract()[0].strip()156 print u'å¥é¡¹:%s' % single_record['award_name']157 single_record['film_info']['name'] = j.xpath('./li[3]/a/text()').extract()[0].strip()158 print u'è·å¥ä½å:%s' % single_record['film_info']['name']159 single_record['film_info']['url'] = j.xpath('./li[3]/a/@href').extract()[0].strip()160 print u'è·å¥ä½åé¾æ¥:%s' % single_record['film_info']['url']161 print '----------------' * 5162human_info({'name': u'å¨æé©°', 'url': 'https://movie.douban.com/celebrity/1048026/', 'movie_id': '1048026'})163# for i in get_info:164# time.sleep(1.5)165# if 'celebrity' in i['url']:166# human_info(i)...
malay-eng-dict-obtainer.py
Source:malay-eng-dict-obtainer.py
...40 if t != '':41 tns.append(t) 42 return tns43#Combining words and translations into a dict44def get_dict(letter: str, wrds_to_remove: list[str], 45 tns_to_remove: list[str]) -> dict():46 #Getting page content and making BeautifulSoup object47 URL = f"http://dictionary.bhanot.net/{letter}.html"48 page = requests.get(URL)49 soup = BeautifulSoup(page.content, "html.parser")50 51 words = get_words(soup)52 tns = get_tns(soup)53 54 words_dict = {}55 if wrds_to_remove != []: #remove words with no translations56 for wrd in wrds_to_remove:57 words.remove(wrd)58 if tns_to_remove != []: #remove translations with no words59 for tn in tns_to_remove:60 tns.remove(tn)61 for indx in range(0, len(words)):62 words_dict[words[indx]] = tns[indx]63 return words_dict64#Cleaning up dicts for each letter and combining into 1 main dict65def get_main_dict() -> dict:66 a_dict = (get_dict('a', [], ['mengajukan: to propose; to put forward for discussion']))67 b_dict = (get_dict('b', [], []))68 c_dict = (get_dict('c', [], ['bercawat: to wear a loincloth',69 'mencebur: to plunge',70 'menceburi: to get involved in; to plunge into',71 'menceburkan: to plunge into; to get involved in']))72 d_dict = (get_dict('d', [], []))73 e_dict = (get_dict('e', [], []))74 f_dict = (get_dict('f', [], []))75 g_dict = (get_dict('g', [], ['bergelumang: dirty']))76 h_dict = (get_dict('h', [], []))77 i_dict = (get_dict('i', [], []))78 j_dict = (get_dict('j', ['juruukur'], []))79 k_dict = (get_dict('k', ['glossy;'], ["kacang bendi: lady's fingers", 80 'kekasaran: coarseness; rudeness; roughness',81 'menguap: to yawn',82 'terkuap-kuap: yawning repeatedly']))83 l_dict = (get_dict('l', [], []))84 m_dict = (get_dict('m', [], []))85 n_dict = (get_dict('n', [], []))86 o_dict = (get_dict('o', [], []))87 p_dict = (get_dict('p', [], []))88 q_dict = (get_dict('q', [], []))89 r_dict = (get_dict('r', [], []))90 s_dict = (get_dict('s', [], []))91 t_dict = (get_dict('t', [], []))92 u_dict = (get_dict('u', [], ['(2) comment']))93 v_dict = (get_dict('v', [], []))94 w_dict = (get_dict('w', ['sewajarnya', 'berwaspada'], []))95 w_dict = {'walau' if k == '\nwalau' else k:v for k,v in w_dict.items()} #replacing bad word96 x_dict = (get_dict('x', [], []))97 y_dict = (get_dict('y', [], []))98 z_dict = (get_dict('z', [], []))99 100 main_dict = {}101 list_of_letterdicts = [a_dict, b_dict, c_dict, d_dict, e_dict, f_dict, g_dict,102 h_dict, i_dict, j_dict, k_dict, l_dict, m_dict, n_dict,103 o_dict, p_dict, q_dict, r_dict, s_dict, t_dict, u_dict,104 v_dict, w_dict, x_dict, y_dict, z_dict]105 106 for d in list_of_letterdicts:107 main_dict.update(d)108 109 return main_dict110#Serializing main dict to json and writing to file111def get_json(main_dict) -> None:112 json_dict = json.dumps(main_dict, indent=4)...
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!!