How to use get_details method in tempest

Best Python code snippet using tempest_python

expert_system.py

Source:expert_system.py Github

copy

Full Screen

...6 global advise_map7 with open(os.path.dirname(os.path.abspath(__file__)) + "/recomendacion/advises.json",'r') as f:8 advise_map = json.load(f)9 10def get_details(indicator, label):11 return advise_map[indicator][label]12def get_details_extra(indicator, range ,label):13 return advise_map[indicator][range][label]14class Expert(KnowledgeEngine):15 def set_facts(self, params: dict):16 """17 Maps incoming facts into the system data structures18 Remark: It calls "reset" method at the beginning to delete old Facts.19 """20 self.reset()21 self.declare(Fact(cr=params["current_ratio"]))22 self.declare(Fact(rg=params["revenue_growth_year_over_year"]))23 self.declare(Fact(da=params["total_debt_to_total_assets"]))24 self.declare(Fact(fd=params["free_cash_flow_to_total_debt"]))25 self.declare(Fact(om=params["operating_margin"]))26 self.declare(Fact(ra=params["return_on_assets"]))27 self.declare(Fact(ap=params["accounts_payable_turnover"]))28 self.declare(Fact(se=params["sales_per_employee"]))29 self.declare(Fact(at=params["asset_turnover"]))30 @DefFacts()31 def _initial_action(self):32 self.answer = dict()33 print("")34 print("Welcome! this service will give you some advices to improve your free cash flow.")35 print("Please complete the following info:")36 print("")37 yield Fact(action='find_state')38 # para cada iteración se le asignará una etiqueta a la característica para evaluarla39 # para la liquidez40 41 @Rule(Fact(action='find_state'),Fact(cr=P(lambda cr: cr < 80.0)))42 def liquidez_1(self):43 self.declare(Fact(liquidez=get_details('liquidez', 'problematico')))44 self.answer['liquidez']=get_details('liquidez', 'problematico')45 @Rule(Fact(action='find_state'),Fact(cr=P(lambda cr: cr > 80.0) & P(lambda cr: cr < 100.0)))46 def liquidez_2(self):47 self.declare(Fact(liquidez=get_details('liquidez', 'mejorable')))48 self.answer['liquidez']=get_details('liquidez', 'mejorable')49 50 @Rule(Fact(action='find_state'),Fact(cr=P(lambda cr: cr > 100.0) & P(lambda cr: cr < 150.0)))51 def liquidez_3(self):52 self.declare(Fact(liquidez=get_details('liquidez', 'moderado')))53 self.answer['liquidez']=get_details('liquidez', 'moderado') 54 55 @Rule(Fact(action='find_state'),Fact(cr=P(lambda cr: cr > 150.0) & P(lambda cr: cr < 200.0)))56 def liquidez_4(self):57 self.declare(Fact(liquidez=get_details('liquidez', 'sobresaliente')))58 self.answer['liquidez']=get_details('liquidez', 'sobresaliente') 59 60 @Rule(Fact(action='find_state'),Fact(cr=P(lambda cr: cr > 200.0)))61 def liquidez_5(self):62 self.declare(Fact(liquidez=get_details('liquidez', 'excelente')))63 self.answer['liquidez']=get_details('liquidez', 'excelente') 64 65 @Rule(Fact(action='find_state'),Fact(liquidez=MATCH.liquidez),salience = -998)66 def situation1(self, liquidez):67 print("LIQUIDEZ: OK")68 69 # para el crecimiento70 71 @Rule(Fact(action='find_state'),Fact(rg=P(lambda rg: rg<(-20.0))))72 def crecimiento_1(self):73 self.declare(Fact(crecimiento=get_details('crecimiento', 'problematico')))74 self.answer['crecimiento']=get_details('crecimiento', 'problematico')75 @Rule(Fact(action='find_state'), Fact(rg=P(lambda rg: rg > -20.0) & P(lambda rg: rg < -5.0)))76 def crecimiento_2(self):77 self.declare(Fact(crecimiento=get_details('crecimiento', 'mejorable')))78 self.answer['crecimiento']=get_details('crecimiento', 'mejorable')79 80 @Rule(Fact(action='find_state'), Fact(rg=P(lambda rg: rg > -5.0) & P(lambda rg: rg < 5.0)))81 def crecimiento_3(self):82 self.declare(Fact(crecimiento=get_details('crecimiento', 'moderado')))83 self.answer['crecimiento']=get_details('crecimiento', 'moderado')84 85 @Rule(Fact(action='find_state'),Fact(rg=P(lambda rg: rg > 5.0) & P(lambda rg: rg < 20.0)))86 def crecimiento_4(self):87 self.declare(Fact(crecimiento=get_details('crecimiento', 'sobresaliente')))88 self.answer['crecimiento']=get_details('crecimiento', 'sobresaliente')89 90 @Rule(Fact(action='find_state'),Fact(rg=P(lambda rg: rg > 20.0)))91 def crecimiento_5(self):92 self.declare(Fact(crecimiento=get_details('crecimiento', 'excelente'))) 93 self.answer['crecimiento']=get_details('crecimiento', 'excelente')94 95 @Rule(Fact(action='find_state'),Fact(crecimiento=MATCH.crecimiento),salience = -998)96 def situation2(self, crecimiento):97 print("CRECIMIENTO: OK")98 99 # para el apalancamiento100 101 @Rule(Fact(action='find_state'),Fact(da=P(lambda da: da > 0.8) & P(lambda da: da < 1.0)))102 def apalancamiento_1(self):103 self.declare(Fact(apalancamiento=get_details_extra('apalancamiento', '1', 'problematico')))104 self.answer['apalancamiento']=get_details_extra('apalancamiento', '1', 'problematico')105 106 @Rule(Fact(action='find_state'),Fact(da=P(lambda da: da > 0.7) & P(lambda da: da < 0.8)))107 def apalancamiento_2(self):108 self.declare(Fact(apalancamiento=get_details_extra('apalancamiento', '1', 'mejorable')))109 self.answer['apalancamiento']=get_details('apalancamiento', '1', 'mejorable')110 111 @Rule(Fact(action='find_state'),Fact(da=P(lambda da: da > 0.5) & P(lambda da: da < 0.7)))112 def apalancamiento_3(self):113 self.declare(Fact(apalancamiento=get_details_extra('apalancamiento', '1', 'moderado')))114 self.answer['apalancamiento']=get_details('apalancamiento', '1', 'moderado')115 116 @Rule(Fact(action='find_state'),Fact(da=P(lambda da: da > 0.4) & P(lambda da: da < 0.5)))117 def apalancamiento_4(self):118 self.declare(Fact(apalancamiento=get_details_extra('apalancamiento', '1', 'sobresaliente')))119 self.answer['apalancamiento']=get_details('apalancamiento', '1', 'sobresaliente')120 121 @Rule(Fact(action='find_state'),Fact(da=P(lambda da: da > 0.3) & P(lambda da: da < 0.4)))122 def apalancamiento_5(self):123 self.declare(Fact(apalancamiento=get_details_extra('apalancamiento', '1', 'excelente')))124 self.answer['apalancamiento']=get_details('apalancamiento', '1', 'excelente')125 126 #-------------------------------------------------------------------------------------------------127 128 @Rule(Fact(action='find_state'),Fact(da=P(lambda da: da >= 0.0) & P(lambda da: da < 0.05)))129 def apalancamiento_6(self):130 self.declare(Fact(apalancamiento=get_details_extra('apalancamiento', '2', 'problematico')))131 self.answer['apalancamiento']=get_details_extra('apalancamiento', '2', 'problematico')132 133 @Rule(Fact(action='find_state'),Fact(da=P(lambda da: da > 0.05) & P(lambda da: da < 0.1)))134 def apalancamiento_7(self):135 self.declare(Fact(apalancamiento=get_details_extra('apalancamiento', '2', 'mejorable')))136 self.answer['apalancamiento']=get_details_extra('apalancamiento', '2', 'mejorable')137 138 @Rule(Fact(action='find_state'),Fact(da=P(lambda da: da > 0.1) & P(lambda da: da < 0.15)))139 def apalancamiento_8(self):140 self.declare(Fact(apalancamiento=get_details_extra('apalancamiento', '2', 'moderado')))141 self.answer['apalancamiento']=get_details_extra('apalancamiento', '2', 'moderado')142 143 @Rule(Fact(action='find_state'),Fact(da=P(lambda da: da > 0.15) & P(lambda da: da < 0.3)))144 def apalancamiento_9(self):145 self.declare(Fact(apalancamiento=get_details_extra('apalancamiento', '2', 'sobresaliente')))146 self.answer['apalancamiento']=get_details_extra('apalancamiento', '2', 'sobresaliente')147 148 @Rule(Fact(action='find_state'),Fact(apalancamiento=MATCH.apalancamiento),salience = -998)149 def situation3(self, apalancamiento):150 print("APALANCAMIENTO: OK")151 # para el solvencia152 153 @Rule(Fact(action='find_state'),Fact(fd=P(lambda fd: fd > 3.0)))154 def solvencia_1(self):155 self.declare(Fact(solvencia=get_details_extra('solvencia', '1', 'problematico')))156 self.answer['solvencia']=get_details_extra('solvencia', '1', 'problematico')157 158 @Rule(Fact(action='find_state'),Fact(fd=P(lambda fd: fd > 1.7) & P(lambda fd: fd < 3.0)))159 def solvencia_2(self):160 self.declare(Fact(solvencia=get_details_extra('solvencia', '1', 'mejorable')))161 self.answer['solvencia']=get_details_extra('solvencia', '1', 'mejorable')162 163 @Rule(Fact(action='find_state'),Fact(fd=P(lambda fd: fd > 1.4) & P(lambda fd: fd < 1.7)))164 def solvencia_3(self):165 self.declare(Fact(solvencia=get_details_extra('solvencia', '1', 'moderado')))166 self.answer['solvencia']=get_details_extra('solvencia', '1', 'moderado')167 168 @Rule(Fact(action='find_state'),Fact(fd=P(lambda fd: fd > 1.1) & P(lambda fd: fd < 1.4)))169 def solvencia_4(self):170 self.declare(Fact(solvencia=get_details_extra('solvencia', '1', 'sobresaliente')))171 self.answer['solvencia']=get_details_extra('solvencia', '1', 'sobresaliente')172 173 @Rule(Fact(action='find_state'),Fact(fd=P(lambda fd: fd > 0.8) & P(lambda fd: fd < 1.1)))174 def solvencia_5(self):175 self.declare(Fact(solvencia=get_details_extra('solvencia', '1', 'excelente')))176 self.answer['solvencia']=get_details_extra('solvencia', '1', 'excelente')177 178 #-------------------------------------------------------------------------------------------------179 180 @Rule(Fact(action='find_state'),Fact(fd=P(lambda fd: fd > 0.0) & P(lambda fd: fd < 0.2)))181 def solvencia_6(self):182 self.declare(Fact(solvencia=get_details_extra('solvencia', '2', 'problematico')))183 self.answer['solvencia']=get_details_extra('solvencia', '2', 'problematico')184 185 @Rule(Fact(action='find_state'),Fact(fd=P(lambda fd: fd > 0.2) & P(lambda fd: fd < 0.4)))186 def solvencia_7(self):187 self.declare(Fact(solvencia=get_details_extra('solvencia', '2', 'mejorable')))188 self.answer['solvencia']=get_details_extra('solvencia', '2', 'mejorable')189 190 @Rule(Fact(action='find_state'),Fact(fd=P(lambda fd: fd > 0.4) & P(lambda fd: fd < 0.6)))191 def solvencia_8(self):192 self.declare(Fact(solvencia=get_details_extra('solvencia', '2', 'moderado')))193 self.answer['solvencia']=get_details_extra('solvencia', '2', 'moderado')194 195 @Rule(Fact(action='find_state'),Fact(fd=P(lambda fd: fd > 0.6) & P(lambda fd: fd < 0.8)))196 def solvencia_9(self):197 self.declare(Fact(solvencia=get_details_extra('solvencia', '2', 'sobresaliente')))198 self.answer['solvencia']=get_details_extra('solvencia', '2', 'sobresaliente')199 200 @Rule(Fact(action='find_state'),Fact(solvencia=MATCH.solvencia),salience = -998)201 def situation4(self, solvencia):202 print("SOLVENCIA: OK")203 # para la rentabilidad204 205 @Rule(Fact(action='find_state'),Fact(om=P(lambda om: om < 15.0)))206 def rentabilidad_1(self):207 self.declare(Fact(rentabilidad=get_details('rentabilidad', 'problematico')))208 self.answer['rentabilidad']=get_details('rentabilidad', 'problematico')209 210 @Rule(Fact(action='find_state'),Fact(om=P(lambda om: om > 15.0) & P(lambda om: om < 25.0)))211 def rentabilidad_2(self):212 self.declare(Fact(rentabilidad=get_details('rentabilidad', 'mejorable')))213 self.answer['rentabilidad']=get_details('rentabilidad', 'mejorable')214 215 @Rule(Fact(action='find_state'),Fact(om=P(lambda om: om > 25.0) & P(lambda om: om < 40.0)))216 def rentabilidad_3(self):217 self.declare(Fact(rentabilidad=get_details('rentabilidad', 'moderado')))218 self.answer['rentabilidad']=get_details('rentabilidad', 'moderado')219 220 @Rule(Fact(action='find_state'),Fact(om=P(lambda om: om > 40.0) & P(lambda om: om < 50.0)))221 def rentabilidad_4(self):222 self.declare(Fact(rentabilidad=get_details('rentabilidad', 'sobresaliente')))223 self.answer['rentabilidad']=get_details('rentabilidad', 'sobresaliente')224 225 @Rule(Fact(action='find_state'),Fact(om=P(lambda om: om > 50.0)))226 def rentabilidad_5(self):227 self.declare(Fact(rentabilidad=get_details('rentabilidad', 'excelente')))228 self.answer['rentabilidad']=get_details('rentabilidad', 'excelente')229 230 @Rule(Fact(action='find_state'),Fact(rentabilidad=MATCH.rentabilidad),salience = -998)231 def situation5(self, rentabilidad):232 print("RENTABILIDAD: OK")233 234 # para la eficiencia235 236 @Rule(Fact(action='find_state'),Fact(se=P(lambda se: se > 0.0) & P(lambda se: se < 4500.0)))237 def eficiencia_1(self):238 self.declare(Fact(eficiencia=get_details('eficiencia', 'problematico')))239 self.answer['eficiencia']=get_details('eficiencia', 'problematico')240 241 @Rule(Fact(action='find_state'),Fact(se=P(lambda se: se > 4500.0) & P(lambda se: se < 9000.0)))242 def eficiencia_2(self):243 self.declare(Fact(eficiencia=get_details('eficiencia', 'mejorable')))244 self.answer['eficiencia']=get_details('eficiencia', 'mejorable')245 246 @Rule(Fact(action='find_state'),Fact(se=P(lambda se: se > 9000.0) & P(lambda se: se < 12000.0)))247 def eficiencia_3(self):248 self.declare(Fact(eficiencia=get_details('eficiencia', 'moderado')))249 self.answer['eficiencia']=get_details('eficiencia', 'moderado')250 251 @Rule(Fact(action='find_state'),Fact(se=P(lambda se: se > 12000.0) & P(lambda se: se < 15000.0)))252 def eficiencia_4(self):253 self.declare(Fact(eficiencia=get_details('eficiencia', 'sobresaliente')))254 self.answer['eficiencia']=get_details('eficiencia', 'sobresaliente')255 256 @Rule(Fact(action='find_state'),Fact(se=P(lambda se: se > 15000.0)))257 def eficiencia_5(self):258 self.declare(Fact(eficiencia=get_details('eficiencia', 'excelente')))259 self.answer['eficiencia']=get_details('eficiencia', 'excelente')260 261 @Rule(Fact(action='find_state'),Fact(eficiencia=MATCH.eficiencia),salience = -998)262 def situation6(self, eficiencia):263 print("EFICIENCIA: OK")264 265if __name__ == "__main__":266 #For testing purposes only267 268 preprocess()269 params = {270 "free_cash_flow_to_total_debt":5.985886, 271 "accounts_ayable_turnover":0.545793, 272 "operating_margin":-84.875316, 273 "sales_per_employee": 566922.568600, ...

Full Screen

Full Screen

grocy.py

Source:grocy.py Github

copy

Full Screen

...52 raw_due_products = self._api_client.get_volatile_stock().due_products53 due_products = [Product(resp) for resp in raw_due_products]54 if get_details:55 for item in due_products:56 item.get_details(self._api_client)57 return due_products58 def overdue_products(self, get_details: bool = False) -> List[Product]:59 raw_overdue_products = self._api_client.get_volatile_stock().overdue_products60 overdue_products = [Product(resp) for resp in raw_overdue_products]61 if get_details:62 for item in overdue_products:63 item.get_details(self._api_client)64 return overdue_products65 def expired_products(self, get_details: bool = False) -> List[Product]:66 raw_expired_products = self._api_client.get_volatile_stock().expired_products67 expired_products = [Product(resp) for resp in raw_expired_products]68 if get_details:69 for item in expired_products:70 item.get_details(self._api_client)71 return expired_products72 def missing_products(self, get_details: bool = False) -> List[Product]:73 raw_missing_products = self._api_client.get_volatile_stock().missing_products74 missing_products = [Product(resp) for resp in raw_missing_products]75 if get_details:76 for item in missing_products:77 item.get_details(self._api_client)78 return missing_products79 def product(self, product_id: int) -> Product:80 resp = self._api_client.get_product(product_id)81 if resp:82 return Product(resp)83 def product_by_barcode(self, barcode: str) -> Product:84 resp = self._api_client.get_product_by_barcode(barcode)85 if resp:86 return Product(resp)87 def all_products(self) -> List[Product]:88 raw_products = self.get_generic_objects_for_type(EntityType.PRODUCTS)89 from pygrocy.grocy_api_client import ProductData90 product_datas = [ProductData(**product) for product in raw_products]91 return [Product(product) for product in product_datas]92 def chores(93 self, get_details: bool = False, query_filters: List[str] = None94 ) -> List[Chore]:95 raw_chores = self._api_client.get_chores(query_filters)96 chores = [Chore(chore) for chore in raw_chores]97 if get_details:98 for chore in chores:99 chore.get_details(self._api_client)100 return chores101 def execute_chore(102 self,103 chore_id: int,104 done_by: int = None,105 tracked_time: datetime = datetime.now(),106 skipped: bool = False,107 ):108 return self._api_client.execute_chore(chore_id, done_by, tracked_time, skipped)109 def chore(self, chore_id: int) -> Chore:110 resp = self._api_client.get_chore(chore_id)111 return Chore(resp)112 def add_product(113 self,114 product_id,115 amount: float,116 price: float,117 best_before_date: datetime = None,118 transaction_type: TransactionType = TransactionType.PURCHASE,119 ):120 return self._api_client.add_product(121 product_id, amount, price, best_before_date, transaction_type122 )123 def consume_product(124 self,125 product_id: int,126 amount: float = 1,127 spoiled: bool = False,128 transaction_type: TransactionType = TransactionType.CONSUME,129 allow_subproduct_substitution: bool = False,130 ):131 return self._api_client.consume_product(132 product_id, amount, spoiled, transaction_type, allow_subproduct_substitution133 )134 def consume_recipe(135 self,136 recipe_id: int,137 ):138 return self._api_client.consume_recipe(recipe_id)139 def open_product(140 self,141 product_id: int,142 amount: float = 1,143 allow_subproduct_substitution: bool = False,144 ):145 return self._api_client.open_product(146 product_id, amount, allow_subproduct_substitution147 )148 def inventory_product(149 self,150 product_id: int,151 new_amount: float,152 best_before_date: datetime = None,153 shopping_location_id: int = None,154 location_id: int = None,155 price: float = None,156 get_details: bool = True,157 ) -> Product:158 product = Product(159 self._api_client.inventory_product(160 product_id,161 new_amount,162 best_before_date,163 shopping_location_id,164 location_id,165 price,166 )167 )168 if get_details:169 product.get_details(self._api_client)170 return product171 def add_product_by_barcode(172 self,173 barcode: str,174 amount: float,175 price: float,176 best_before_date: datetime = None,177 get_details: bool = True,178 ) -> Product:179 product = Product(180 self._api_client.add_product_by_barcode(181 barcode, amount, price, best_before_date182 )183 )184 if get_details:185 product.get_details(self._api_client)186 return product187 def consume_product_by_barcode(188 self,189 barcode: str,190 amount: float = 1,191 spoiled: bool = False,192 get_details: bool = True,193 ) -> Product:194 product = Product(195 self._api_client.consume_product_by_barcode(barcode, amount, spoiled)196 )197 if get_details:198 product.get_details(self._api_client)199 return product200 def inventory_product_by_barcode(201 self,202 barcode: str,203 new_amount: float,204 best_before_date: datetime = None,205 location_id: int = None,206 price: float = None,207 get_details: bool = True,208 ) -> Product:209 product = Product(210 self._api_client.inventory_product_by_barcode(211 barcode, new_amount, best_before_date, location_id, price212 )213 )214 if get_details:215 product.get_details(self._api_client)216 return product217 def shopping_list(218 self, get_details: bool = False, query_filters: List[str] = None219 ) -> List[ShoppingListProduct]:220 raw_shoppinglist = self._api_client.get_shopping_list(query_filters)221 shopping_list = [ShoppingListProduct(resp) for resp in raw_shoppinglist]222 if get_details:223 for item in shopping_list:224 item.get_details(self._api_client)225 return shopping_list226 def add_missing_product_to_shopping_list(self, shopping_list_id: int = 1):227 return self._api_client.add_missing_product_to_shopping_list(shopping_list_id)228 def add_product_to_shopping_list(229 self,230 product_id: int,231 shopping_list_id: int = None,232 amount: float = None,233 quantity_unit_id: int = None,234 ):235 return self._api_client.add_product_to_shopping_list(236 product_id, shopping_list_id, amount, quantity_unit_id237 )238 def clear_shopping_list(self, shopping_list_id: int = 1):239 return self._api_client.clear_shopping_list(shopping_list_id)240 def remove_product_in_shopping_list(241 self, product_id: int, shopping_list_id: int = 1, amount: float = 1242 ):243 return self._api_client.remove_product_in_shopping_list(244 product_id, shopping_list_id, amount245 )246 def product_groups(self, query_filters: List[str] = None) -> List[Group]:247 raw_groups = self._api_client.get_product_groups(query_filters)248 return [Group(resp) for resp in raw_groups]249 def add_product_pic(self, product_id: int, pic_path: str):250 self._api_client.upload_product_picture(product_id, pic_path)251 return self._api_client.update_product_pic(product_id)252 def get_userfields(self, entity: str, object_id: int):253 return self._api_client.get_userfields(entity, object_id)254 def set_userfields(self, entity: str, object_id: int, key: str, value):255 return self._api_client.set_userfields(entity, object_id, key, value)256 def get_last_db_changed(self):257 return self._api_client.get_last_db_changed()258 def get_system_info(self) -> SystemInfo:259 raw_system_info = self._api_client.get_system_info()260 if raw_system_info:261 return SystemInfo(raw_system_info)262 def get_system_time(self) -> SystemTime:263 raw_system_time = self._api_client.get_system_time()264 if raw_system_time:265 return SystemTime(raw_system_time)266 def get_system_config(self) -> SystemConfig:267 raw_system_config = self._api_client.get_system_config()268 if raw_system_config:269 return SystemConfig(raw_system_config)270 def tasks(self, query_filters: List[str] = None) -> List[Task]:271 raw_tasks = self._api_client.get_tasks(query_filters)272 return [Task(task) for task in raw_tasks]273 def task(self, task_id: int) -> Task:274 resp = self._api_client.get_task(task_id)275 return Task(resp)276 def complete_task(self, task_id, done_time: datetime = datetime.now()):277 return self._api_client.complete_task(task_id, done_time)278 def meal_plan(279 self, get_details: bool = False, query_filters: List[str] = None280 ) -> List[MealPlanItem]:281 raw_meal_plan = self._api_client.get_meal_plan(query_filters)282 meal_plan = [MealPlanItem(data) for data in raw_meal_plan]283 if get_details:284 for item in meal_plan:285 item.get_details(self._api_client)286 return meal_plan287 def recipe(self, recipe_id: int) -> RecipeItem:288 recipe = self._api_client.get_recipe(recipe_id)289 if recipe:290 return RecipeItem(recipe)291 def batteries(292 self, query_filters: List[str] = None, get_details: bool = False293 ) -> List[Battery]:294 raw_batteries = self._api_client.get_batteries(query_filters)295 batteries = [Battery(bat) for bat in raw_batteries]296 if get_details:297 for item in batteries:298 item.get_details(self._api_client)299 return batteries300 def battery(self, battery_id: int) -> Battery:301 battery = self._api_client.get_battery(battery_id)302 if battery:303 return Battery(battery)304 def charge_battery(self, battery_id: int, tracked_time: datetime = datetime.now()):305 return self._api_client.charge_battery(battery_id, tracked_time)306 def add_generic(self, entity_type: EntityType, data):307 return self._api_client.add_generic(entity_type.value, data)308 def update_generic(self, entity_type: EntityType, object_id: int, updated_data):309 return self._api_client.update_generic(310 entity_type.value, object_id, updated_data311 )312 def delete_generic(self, entity_type: EntityType, object_id: int):...

Full Screen

Full Screen

oop.py

Source:oop.py Github

copy

Full Screen

...25# print("test")26# def set_details(self, name, age):27# self.name = name28# self.age = age29# def get_details(self):30# print(self.name, self.age)31 32# person1 = person()33# person1.test() # test 34# person.test(person1) # test35# person1.get_details()36# person1.set_details("Barry", 45)37# person1.get_details()38#! Static methods39# class Person:40# company = "Clarusway"41# def set_details(self, name, age):42# self.name = name43# self.age = age44# def get_details(self):45# print(self.name, self.age)46# @staticmethod47# def salute():48# print("Hi there!")49# person1 = Person()50# person1.salute()51#! Special Methods52# class Person:53# company = "Clarusway"54# def __init__(self, name, age):55# self.name = name56# self.age = age57 58# #? __str__ method59# def __str__(self):60# return f"{self.name}, {self.age}"61# def get_details(self):62# print(self.name, self.age)63# person1 = Person("Ahmet", 30)64# person1.get_details()65# liste = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]66# print(liste)67# print(person1)68# print(person1.__str__())69#! Encapsulation and Abstraction70# class Person:71# company = "Clarusway"72# def __init__(self, name, age):73# self.name = name74# self.age = age75# self._id = 12345 #! protected method76# self.__id2 = 4213 #! private method77# def __str__(self):78# return f"{self.name}, {self.age}"79# def get_details(self):80# print(self.name, self.age)81# person1 = Person("Ahmet", 30)82# print(person1._id)83# # print(person1.__id2)84# print(person1._Person__id2)85# print(person1.__dict__)86# liste = [4,2,9,11,5]87# liste.sort()88# print(liste)89#! Inheritance and Polymorphism90class Person:91 company = "Clarusway"92 def __init__(self, name, age):93 self.name = name94 self.age = age95 def __str__(self):96 return f"{self.name}, {self.age}"97 def get_details(self):98 print(self.name, self.age)99class Student:100 def __init__(self, grade):101 self.grade = grade102 def get_details(self):103 print(self.grade)104class Employee(Person, Student):105 def __init__(self, name, age, grade , salary):106 super().__init__(name, age)107 Student.__init__(self, grade)108 self.salary = salary 109 #! Overriding110 def get_details(self):111 # print(self.name, self.age, self.salary)112 super().get_details()113 print(self.grade)114emp1 = Employee("Ahmet", 30, 3,25000)...

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 tempest 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