How to use lookup_function method in localstack

Best Python code snippet using localstack_python

descriptors.py

Source: descriptors.py Github

copy

Full Screen

1# Copyright 2020, Chris PeBenito <pebenito@ieee.org>2#3# SPDX-License-Identifier: LGPL-2.1-only4#5import re6from typing import Callable, Union7from ..exception import InvalidCheckValue8from ..descriptors import CriteriaDescriptor, CriteriaPermissionSetDescriptor9class ConfigDescriptor(CriteriaDescriptor):10 """11 Single item configuration option descriptor.12 Parameter:13 lookup_function The name of the SELinuxPolicy lookup function,14 e.g. lookup_type or lookup_boolean.15 Read-only instance attribute use (obj parameter):16 checkname The name of the check.17 policy The instance of SELinuxPolicy18 """19 def __init__(self, lookup_function: Union[Callable, str]) -> None:20 super().__init__(lookup_function=lookup_function)21 def __set__(self, obj, value):22 if not value:23 self.instances[obj] = None24 else:25 try:26 super().__set__(obj, value.strip())27 except ValueError as ex:28 raise InvalidCheckValue("{}: Invalid {} setting: {}".format(29 obj.checkname, self.name, ex)) from ex30class ConfigSetDescriptor(CriteriaDescriptor):31 """32 Descriptor for a configuration option set.33 Parameter:34 lookup_function The name of the SELinuxPolicy lookup function,35 e.g. lookup_type or lookup_boolean.36 Keyword Parameters:37 strict (Bool) If True, all objects must exist in the policy38 when setting the value. If False, any objects that39 fail the policy lookup will be dropped instead of raising40 an exception. The default is True.41 expand (Bool) If True, each object will be expanded. Default42 is False.43 Read-only instance attribute use (obj parameter):44 checkname The name of the check.45 log A logger instance.46 policy The instance of SELinuxPolicy47 """48 def __init__(self, lookup_function: Union[Callable, str], strict: bool = True,49 expand: bool = False) -> None:50 super().__init__(lookup_function=lookup_function, default_value=frozenset())51 self.strict = strict52 self.expand = expand53 def __set__(self, obj, value):54 if not value:55 self.instances[obj] = frozenset()56 else:57 log = obj.log58 if callable(self.lookup_function):59 lookup = self.lookup_function60 else:61 lookup = getattr(obj.policy, self.lookup_function)62 ret = set()63 for item in (i for i in re.split(r"\s", value) if i):64 try:65 o = lookup(item)66 if self.expand:67 ret.update(o.expand())68 else:69 ret.add(o)70 except ValueError as e:71 if self.strict:72 log.error("Invalid {} item: {}".format(self.name, e))73 log.debug("Traceback:", exc_info=e)74 raise InvalidCheckValue("{}: Invalid {} item: {}".format(75 obj.checkname, self.name, e)) from e76 log.info("{}: Invalid {} item: {}".format(77 obj.checkname, self.name, e))78 self.instances[obj] = frozenset(ret)79class ConfigPermissionSetDescriptor(CriteriaPermissionSetDescriptor):80 """81 Descriptor for a configuration permissions set.82 Read-only instance attribute use (obj parameter):83 checkname The name of the check.84 policy The instance of SELinuxPolicy85 tclass If it exists, it will be used to validate the86 permissions. See validate_perms_any()87 """88 def __init__(self) -> None:89 super().__init__(default_value=frozenset())90 def __set__(self, obj, value):91 if not value:92 self.instances[obj] = frozenset()93 else:94 try:95 super().__set__(obj, (v for v in value.split(" ") if v))96 except ValueError as ex:97 raise InvalidCheckValue("{}: Invalid {} setting: {}".format(...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

13 Best Java Testing Frameworks For 2023

The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.

QA Innovation &#8211; Using the senseshaping concept to discover customer needs

QA Innovation - Using the senseshaping concept to discover customer needsQA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.

Best 23 Web Design Trends To Follow In 2023

Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.

Acquiring Employee Support for Change Management Implementation

Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful