Best Python code snippet using localstack_python
kms_listener.py
Source:kms_listener.py  
...73def filter_if_present(grant, data, filter_key):74    return filter_key not in data or grant[filter_key] == data[filter_key]75def filter_grantee_principal(grant, data):76    return filter_if_present(grant, data, GRANTEE_PRINCIPAL)77def filter_grant_id(grant, data):78    return filter_if_present(grant, data, GRANT_ID)79def handle_list_grants(data):80    if KEY_ID not in data:81        raise ValidationException("KeyId must be specified")82    verify_key_exists(data[KEY_ID])83    grants = KMSBackend.get().grants84    limit = data.get("Limit", 50)85    if "Marker" in data:86        markers = KMSBackend.get().markers87        filtered = markers.get(data["Marker"], [])88    else:89        filtered = [90            grant91            for grant in grants.values()92            if grant[KEY_ID] == data[KEY_ID]93            and filter_grant_id(grant, data)94            and filter_grantee_principal(grant, data)95        ]96    if len(filtered) <= limit:97        return {"Grants": filtered, "Truncated": False}98    markers = KMSBackend.get().markers99    in_limit = filtered[:limit]100    out_limit = filtered[limit:]101    marker_id = long_uid()102    markers[marker_id] = out_limit103    return {"Grants": in_limit, "Truncated": True, "NextMarker": marker_id}104def handle_retire_grant(data):105    grants = KMSBackend.get().grants106    if GRANT_ID in data and KEY_ID in data and grants[data[GRANT_ID]][KEY_ID] == data[KEY_ID]:107        del grants[data[GRANT_ID]]...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!!
