Best Python code snippet using localstack_python
pins.py
Source: pins.py
...32 elif line.startswith("enum: "):33 key, value = line.split()[1:]34 tiles[loc][name][key] = value.strip()35 return tiles36def get_base_type(tiles, row, col, name, pio):37 if (row, col) in tiles and name in tiles[(row, col)]:38 tile = tiles[(row, col)][name]39 return tile.get(f'{pio}.BASE_TYPE')40def reduce_base_types(types):41 bidi = any(t.startswith("BIDIR_") for t in types if t)42 inp = any(t.startswith("INPUT_") for t in types if t)43 out = any(t.startswith("OUTPUT_") for t in types if t)44 modes = sorted(list(set("_".join(t.split("_")[1:]) for t in types if t)))45 if bidi or (inp and out):46 return "bidi", modes47 elif inp:48 return "input", modes49 elif out:50 return "output", modes51 else:52 return None53def top_pin(tiles, row, col, pio):54 # Top pins are defined in PIOT0, PIOT1, PICT0, PICT1.55 return reduce_base_types([56 get_base_type(tiles, row, col, "PIOT0", f"PIO{pio}"),57 get_base_type(tiles, row, col+1, "PIOT1", f"PIO{pio}"),58 get_base_type(tiles, row+1, col, "PICT0", f"PIO{pio}"),59 get_base_type(tiles, row+1, col+1, "PICT1", f"PIO{pio}"),60 ])61def btm_pin(tiles, row, col, pio):62 # Bottom pins are defined in PICB0 and PICB1.63 # Sometimes EFBx_PICBy or SPICB0.64 return reduce_base_types([65 get_base_type(tiles, row, col, "PICB0", f"PIO{pio}"),66 get_base_type(tiles, row, col, "SPICB0", f"PIO{pio}"),67 get_base_type(tiles, row, col, "EFB0_PICB0", f"PIO{pio}"),68 get_base_type(tiles, row, col, "EFB2_PICB0", f"PIO{pio}"),69 get_base_type(tiles, row, col+1, "PICB1", f"PIO{pio}"),70 get_base_type(tiles, row, col+1, "EFB1_PICB1", f"PIO{pio}"),71 get_base_type(tiles, row, col+1, "EFB3_PICB1", f"PIO{pio}"),72 ])73def left_pin(tiles, row, col, pio):74 # Left pins are defined in PICL0, PICL1, PICL2.75 # Sometimes PICL2 is in MIB_CIB_LR.76 # Sometimes PICLx is shared with DQSy.77 return reduce_base_types([78 get_base_type(tiles, row, col, "PICL0", f"PIO{pio}"),79 get_base_type(tiles, row, col, "PICL0_DQS2", f"PIO{pio}"),80 get_base_type(tiles, row+1, col, "PICL1", f"PIO{pio}"),81 get_base_type(tiles, row+1, col, "PICL1_DQS0", f"PIO{pio}"),82 get_base_type(tiles, row+1, col, "PICL1_DQS3", f"PIO{pio}"),83 get_base_type(tiles, row+2, col, "PICL2", f"PIO{pio}"),84 get_base_type(tiles, row+2, col, "PICL2_DQS1", f"PIO{pio}"),85 get_base_type(tiles, row+2, col, "MIB_CIB_LR", f"PIO{pio}"),86 ])87def right_pin(tiles, row, col, pio):88 # Right pins are defined in PICR0, PICR1, PICR289 return reduce_base_types([90 get_base_type(tiles, row, col, "PICR0", f"PIO{pio}"),91 get_base_type(tiles, row, col, "PICR0_DQS2", f"PIO{pio}"),92 get_base_type(tiles, row+1, col, "PICR1", f"PIO{pio}"),93 get_base_type(tiles, row+1, col, "PICR1_DQS0", f"PIO{pio}"),94 get_base_type(tiles, row+1, col, "PICR1_DQS3", f"PIO{pio}"),95 get_base_type(tiles, row+2, col, "PICR2", f"PIO{pio}"),96 get_base_type(tiles, row+2, col, "PICR2_DQS1", f"PIO{pio}"),97 get_base_type(tiles, row+2, col, "MIB_CIB_LR", f"PIO{pio}"),98 get_base_type(tiles, row+2, col, "MIB_CIB_LR_A", f"PIO{pio}"),99 ])100def main():101 parser = argparse.ArgumentParser()102 parser.add_argument("config", help="Path to .config file to read")103 parser.add_argument("--package", default="CABGA256",104 help="Footprint to use, default CABGA256")105 parser.add_argument(106 "--dbpath",107 default="/usr/share/trellis/database/ECP5/LFE5U-25F/iodb.json",108 help="Path to database file, default is LFE5U-25F")109 args = parser.parse_args()110 iodb = load_iodb(args.dbpath, args.package)111 tiles = load_config(args.config)112 max_row = max(p['row'] for p in iodb.values())...
test_coverage.py
Source: test_coverage.py
...33 if VERSION >= (3, 0, 0):34 tests.append(typing.SupportsBytes)35 for test in tests:36 self.assertEqual(37 get_base_type(test),38 (typing_.BaseProtocol, True),39 msg=str(test),40 )41 @skipIf(not HAS_PROTOCOL, 'requires protocol from typing_extensions')42 def test_protocol(self):43 class TestProtocol(Protocol):44 pass45 self.assertEqual(get_base_type(TestProtocol), (Protocol, True))46 @skipIf(not HAS_PROTOCOL, 'requires protocol from typing_extensions')47 def test_protocol_generic(self):48 T = typing.TypeVar('T') # noqa: N80649 class TestProtocol(Protocol, typing.Generic[T]):50 pass51 self.assertEqual(get_base_type(TestProtocol), (Protocol, True))52 self.assertEqual(get_base_type(TestProtocol[int]), (Protocol, False))53 @skipIf(not HAS_PROTOCOL, 'requires protocol from typing_extensions')54 def test_generic_protocol(self):55 T = typing.TypeVar('T') # noqa: N80656 class TestProtocol(typing.Generic[T], Protocol):57 pass58 self.assertEqual(get_base_type(TestProtocol), (Protocol, True))59 self.assertEqual(get_base_type(TestProtocol[int]), (Protocol, False))60 def test_reversible(self):61 if VERSION < (3, 6):62 self.assertEqual(63 get_base_type(typing.Reversible),64 (typing_.BaseProtocol, True),65 )66 self.assertEqual(67 get_base_type(typing.Reversible[int]),68 (typing_.BaseProtocol, False),69 )70 else:71 self.assertEqual(72 get_base_type(typing.Reversible),73 (typing.Generic, True),74 )75class TypeInfoTestCase(TestCase):76 tests = [77 typing.SupportsInt,78 int,79 typing.Mapping,80 typing.Mapping[float, int],81 typing.Pattern,82 typing.Match,83 ]84 if HAS_CLASS_VAR:85 tests.append(ClassVar)86 if HAS_PROTOCOL:...
common.py
Source: common.py
...17 def __init__(self, item, default=None):18 self.item = item19 self.default = default20 def __rrshift__(self, other):21 other_type = get_base_type(other)22 return getattr(self, f"_get_{other_type}", self._get)(other)23 def _get(self, other):24 if hasattr(other, "get"):25 return other.get(self.item, self.default)26 elif hasattr(other, "__getitem__"):27 with contextlib.suppress(KeyError):28 return other[self.item]29 return self.default30 return getattr(other, self.item, self.default)31 def _get_sequence(self, other):32 with contextlib.suppress(IndexError):33 return other[self.item]34 return self.default35 def _get_mapping(self, other):36 return other.get(self.item, self.default)37def get_base_type(other):38 """39 >>> get_base_type(1)40 int41 >>> get_base_type([])42 sequence43 >>> get_base_type({})44 mapping45 """46 if isinstance(other, Mapping):47 return "mapping"48 if isinstance(other, Sequence):49 return "sequence"...
Check out the latest blogs from LambdaTest on this topic:
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 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.
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.
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.
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!!