Best Python code snippet using pandera_python
contract.py
Source: contract.py
...24 def get_section(self, section):25 code = self.get_code()26 return next(s for s in code if s['prim'] == section)27 @lru_cache(maxsize=None)28 def _get_schema(self, section):29 return build_schema(self.get_section(section))30 def _get_big_map_schema(self):31 schema = self._get_schema('storage')32 root = next(k for k, v in schema.type_map.items() if v['prim'] == 'big_map')33 key_path, val_path = root + '0', root + '1'34 return schema, key_path, val_path35 @classmethod36 def from_code(cls, code):37 return Contract(code=code)38 @classmethod39 def from_string(cls, text):40 code = micheline_parser.parse(text)41 return cls.from_code(code)42 @classmethod43 def from_file(cls, path):44 with open(path) as f:45 return cls.from_string(f.read())46 def decode_storage(self, data=None, annotations=True, literals=True):47 if data is None:48 data = self.get('script')['storage']49 return decode_data(50 data=data,51 schema=self._get_schema('storage'),52 annotations=annotations,53 literals=literals54 )55 def encode_storage(self, data):56 return encode_data(57 data=data,58 schema=self._get_schema('storage')59 )60 def decode_parameters(self, data, annotations=True, literals=True):61 return decode_data(62 data=data,63 schema=self._get_schema('parameter'),64 annotations=annotations,65 literals=literals66 )67 def encode_parameters(self, data):68 return encode_data(69 data=data,70 schema=self._get_schema('parameter')71 )72 def storage_schema(self):73 return decode_schema(self._get_schema('storage'))74 def parameter_schema(self):75 return decode_schema(self._get_schema('parameter'))76 def big_map_get(self, key):77 schema, key_path, val_path = self._get_big_map_schema()78 query = dict(79 key=encode_data(key, schema, root=key_path),80 type=schema.type_map[key_path]81 )82 value = self._node.post(f'{self._path}/big_map_get', json=query)83 return decode_data(value, schema, root=val_path)84 def big_map_diff_decode(self, data):85 schema, key_path, val_path = self._get_big_map_schema()86 return {87 decode_data(item['key'], schema, root=key_path):88 decode_data(item['value'], schema, root=val_path)89 for item in data...
schemas.py
Source: schemas.py
1import os2import json3import aavm4_SCHEMAS_DIR = os.path.join(os.path.dirname(aavm.__file__), 'schemas')5def _get_schema(schema_fpath: str) -> dict:6 if not os.path.isfile(schema_fpath):7 raise FileNotFoundError(schema_fpath)8 with open(schema_fpath, 'r') as fin:9 return json.load(fin)10def get_machine_schema(schema: str) -> dict:11 schema_fpath = os.path.join(_SCHEMAS_DIR, "machine.json", f"{schema}.json")12 return _get_schema(schema_fpath)13def get_runtime_schema(schema: str) -> dict:14 schema_fpath = os.path.join(_SCHEMAS_DIR, "runtime.json", f"{schema}.json")15 return _get_schema(schema_fpath)16def get_index_schema(schema: str) -> dict:17 schema_fpath = os.path.join(_SCHEMAS_DIR, "index", f"{schema}.json")18 return _get_schema(schema_fpath)19__all__ = [20 "get_machine_schema",21 "get_runtime_schema",22 "get_index_schema"...
Check out the latest blogs from LambdaTest on this topic:
One of the most important skills for leaders to have is the ability to prioritize. To understand how we can organize all of the tasks that must be completed in order to complete a project, we must first understand the business we are in, particularly the project goals. There might be several project drivers that stimulate project execution and motivate a company to allocate the appropriate funding.
Hola Testers! Hope you all had a great Thanksgiving weekend! To make this time more memorable, we at LambdaTest have something to offer you as a token of appreciation.
API (Application Programming Interface) is a set of definitions and protocols for building and integrating applications. It’s occasionally referred to as a contract between an information provider and an information user establishing the content required from the consumer and the content needed by the producer.
In today’s data-driven world, the ability to access and analyze large amounts of data can give researchers, businesses & organizations a competitive edge. One of the most important & free sources of this data is the Internet, which can be accessed and mined through web scraping.
Development practices are constantly changing and as testers, we need to embrace change. One of the changes that we can experience is the move from monthly or quarterly releases to continuous delivery or continuous deployment. This move to continuous delivery or deployment offers testers the chance to learn new skills.
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!!