How to use _get_definition method in localstack

Best Python code snippet using localstack_python

taxonomy.py

Source:taxonomy.py Github

copy

Full Screen

...41 self._definition = TaxonomyMap.create_recursively(_definition)42 self._code = code43 if self.is_valid:44 self._levels = [45 self._get_definition(code[:2]),46 self._get_definition(code[:4]) if len(code) >= 4 else None,47 self._get_definition(code[:6]) if len(code) >= 6 else None,48 self._get_definition(code[:8]) if len(code) == 8 else None49 ]50 else:51 self._code = None52 @property53 def definition(self):54 return self._definition55 @property56 def is_valid(self) -> bool:57 return self.code and isinstance(self.code, str) and len(self.code) >= 2 and len(self.code) <= 8 and len(58 self.code) % 2 == 0 and self._definition.get(self.code)59 @property60 def code(self):61 return self._code62 @property63 def current_level(self):64 """Gets the current level of this classification65 Returns:66 The value of the current level67 """68 return round(len(self.code)/2)69 @property70 def year(self):71 return self._year72 @property73 def benchmark(self):74 return self._benchmark75 @property76 def first_level(self):77 """Gets the definition for the level 178 Returns:79 Definition of the classification level. It has 3 properties: name, description and code.80 Keep in mind that only level 1 (ICB) and level 4 usually has a description.81 """82 return self.level(1)83 @property84 def second_level(self):85 """Gets the definition level 286 Returns:87 Definition of the classification level. It has 1 property: name88 """89 return self.level(2)90 @property91 def third_level(self):92 """Gets the definition for the level 393 Returns:94 Definition of the classification level. It has 1 property: name.95 """96 return self.level(3)97 @property98 def fourth_sector(self):99 """Gets the definition for the level 4.100 Returns:101 Definition of the classification level. It has 3 properties: name, description and code.102 """103 return self.level(4)104 @property105 def children(self):106 """Gets all the child level elements from this classification level.107 For example, for a 1st level classification, it will return all 2nd level in that folder.108 If the classification is invalid (or empty, as with a null code), it will return all 1st level classification.109 A 4th level classification will return an empty array.110 Returns:111 List containing objects with properties code (the classification code), name (the name of this112 classification), and description (where applicable)113 """114 if self.is_valid:115 keys = filter(lambda k: k.startswith(self._code) and len(k) == len(self._code) + 2, self._definition.keys())116 else:117 keys = filter(lambda k: len(k) == 2, self._definition.keys())118 return list(map(lambda k: TaxonomyMap({119 'code': k,120 'name': self._definition[k].name,121 'description': self._definition[k].description122 }), keys))123 def _get_definition(self, code):124 definition = self._definition[code]125 definition.code = code126 return definition127 def level(self, level: int):128 """Gets the definition of the given level for this classification object.129 Args:130 level: Level of classification to get.131 Valid levels are: 1, 2, 3, 4132 Returns:133 The level of the current classification. None if no valid classification is given.134 """135 if not self.is_valid or not level or not isinstance(level,int) or level < 1 or level > 4:136 return None137 return self._levels[level - 1]138 def is_same(self, another_icb: 'ICB') -> bool:139 """Determines if this ICB is the same as the given one.140 To be considered the same both ICB must either be invalid, or be valid and with the exact same code.141 This means that they represent the same values at the same level.142 Args:143 another_icb: ICB object to compare with144 """145 return another_icb and (self.is_valid == another_icb.is_valid) and (146 self.is_valid is False or self._code == another_icb.code)147 def is_within(self, another_icb: 'ICB'):148 """Determines if this ICB is a sub-component of the given ICB. For example, ICB 101010 is within ICB 10.149 Invalid ICB do not contain any children or belong to any parent, so if any of the ICB are invalid,150 this will always be false.151 Two ICB that are the same are not considered to be within one another (10 does not contain 10).152 Args:153 another_icb: ICB object to compare with154 """155 return self.is_valid and another_icb.is_valid and self._code != another_icb.code and self._code.startswith(156 another_icb.code)157 def is_immediate_within(self, another_icb: 'ICB'):158 """Determines if this ICB is a sub-component of the given ICB at the most immediate level. For example, ICB159 1010 is immediate within ICB 10, but 101010 is not.160 Invalid ICB do not contain any children or belong to any parent, so if any of the ICB are invalid,161 this will always be false.162 Two ICB that are the same are not considered to be within one another (10 does not contain 10).163 Args:164 another_icb: ICB object to compare with165 """166 return self.is_valid and another_icb.is_valid and self._code != another_icb.code and self._code.startswith(167 another_icb.code) and len(self._code) == len(another_icb._code) + 2168 def contains(self, another_icb: 'ICB'):169 """Determines if this ICB contains the given ICB. For example, ICB 10 contains ICB 101010.170 Invalid ICB do not contain any children or belong to any parent, so if any of the ICB are invalid,171 this will always be false.172 Two ICB that are the same are not considered to be within one another (10 does not contain 10).173 Args:174 another_icb: ICB object to compare with175 """176 return another_icb.is_within(self)177 def contains_immediate(self, another_icb: 'ICB'):178 """Determines if this ICB contains the given ICB at the most immediate level. For example, ICB 10 contains179 immediate ICB 1010, but not 101010.180 Invalid ICB do not contain any children or belong to any parent, so if any of the ICB are invalid, this will181 always be false.182 Two ICB that are the same are not considered to be within one another (10 does not contain 10).183 Args:184 another_icb: ICB object to compare with185 """186 return another_icb.is_immediate_within(self)187 def write_pp_file(self):188 text = ''189 for key in self._definition.keys():190 self._code=key191 qualifier =''192 if(len(key)==2):193 if (self.benchmark == 'GICS'):194 qualifier = 'GICS-SECTOR'195 elif (self.benchmark == 'ICB'):196 qualifier = 'ICB-INDUSTRY'197 elif(len(key)==4):198 if (self.benchmark == 'GICS'):199 qualifier = 'GICS-INDUSTRY_GROUP'200 elif (self.benchmark == 'ICB'):201 qualifier = 'ICB-SUPERSECTOR'202 elif (len(key) == 6):203 if (self.benchmark == 'GICS'):204 qualifier = 'GICS-INDUSTRY'205 elif (self.benchmark == 'ICB'):206 qualifier = 'ICB-SECTOR'207 elif (len(key) == 8):208 if (self.benchmark == 'GICS'):209 qualifier = 'GICS-SUB_INDUSTRY'210 elif (self.benchmark == 'ICB'):211 qualifier = 'ICB-SUBSECTOR'212 tempchild=''213 for child in self.children:214 tempchild +=child['code'] +','215 if tempchild != '':216 text += f"{key}.children = {tempchild[:-1]}\r"217 text += f"{key}.label = {self._get_definition(key)['name']}\r"218 if(len(key)!=2):219 text += f"{key}.data = ROOTCLASS-ID\={key[:-len(key)+2]};CLASS-ID\={key};{qualifier}\={self._get_definition(key)['name'].upper().replace(' ', '_').replace('&', '_').replace(',','_')}\r"220 else:221 text += f"{key}.data = CLASS-ID\={key};{qualifier}\={self._get_definition(key)['name'].upper().replace(' ','_').replace('&','_').replace(',','_')}\r"222 if 'description' in self._get_definition(key):223 text += f"{key}.description = {self._get_definition(key)['description']}\r"224 text +='\r'...

Full Screen

Full Screen

factory.py

Source:factory.py Github

copy

Full Screen

...31 return result32def _get_type_definitions(modules):33 """Returns set of type definitions instantiated from a set of modules.34 """35 def _get_definition(func):36 """Returns a type definition."""37 result = func()38 result['name'] = func.__name__39 result['doc'] = func.__doc__.strip()40 return result41 return [_get_definition(i) for i in _get_functions(modules)]42def _get_package_definitions(schema):43 """Returns set of package definitions.44 """45 def _get_definition(func):46 """Returns a package definition.47 """48 defn = {49 'name': func.__name__,50 'doc': func.__doc__.strip(),51 'types': func()52 }53 return defn54 return [_get_definition(f) for f in _get_functions(schema)]55def _get_class_properties(class_):56 """Returns class property definitions.57 """58 result = []59 doc_strings = class_.get('doc_strings', dict())60 for prop in class_.get('properties', []):61 if len(prop) == 4:62 name, type_name, cardinality, doc_string = prop63 elif len(prop) == 3:64 name, type_name, cardinality = prop65 doc_string = doc_strings.get(name, None)66 result.append(Property(name, type_name, cardinality, doc_string))67 if class_.get('is_document', False):68 result.append(Property('meta', 'shared.doc_meta_info', '1.1', "Injected document metadata."))...

Full Screen

Full Screen

dictionary.py

Source:dictionary.py Github

copy

Full Screen

1import aiohttp2url = 'https://api.dictionaryapi.dev/api/v2/entries/en/'3async def _get_definition(word):4 async with aiohttp.ClientSession() as session:5 async with session.get(f'{url}{word}') as r:6 if r.status == 200:7 js = await r.json()8 return js9 else:10 return None11async def lookup(word):12 isWord = True13 definition = ''14 data = await _get_definition(word)15 if data is not None:16 meanings = data[0]["meanings"]17 for m in meanings:18 definition += f'{m["partOfSpeech"]}\n\t'19 first_def = m["definitions"][0]20 definition += f'{first_def["definition"]}\n'21 else:22 isWord = False23 definition = f"Sorry, we couldn't find any definitions for {word}"24 return {25 "isWord": isWord,26 "definition": definition27 }28async def pronounce(word):29 data = await _get_definition(word)30 print(data)31 32 if data is None or len(data) == 0:33 return None34 phonetics = []35 for word in data:36 sounds = word.get('phonetics')37 if sounds is not None:38 phonetics += sounds39 if len(phonetics) == 0:40 return None41 urls = [p['audio'] for p in phonetics if 'audio' in p and p['audio'] != '']42 print(f'URLs are {urls}')43 if len(urls) == 0:...

Full Screen

Full Screen

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