How to use add_elt method in fMBT

Best Python code snippet using fMBT_python

whiteboard.py

Source:whiteboard.py Github

copy

Full Screen

...24 # dict topics: keys are topics (strings) and values are ClientDialogSystems25 self.topics = dict()26 # dict subscribers: keys are subscribers (ClientDialogSystems) and values are topics (strings)27 self.subscribers = dict()28 def add_elt(self, key, value, d_txt):29 """30 Adds value to a dictionary (given by t_txt) at key31 :param key:32 :param value:33 :param d_txt:34 :return: 1 success / -1 error code35 """36 d = self.subscribers if d_txt == "subscriber" else self.topics37 if key not in d.keys():38 d[key] = list()39 if value in d[key]:40 return -141 d[key].append(value)42 return 143 def remove_elt(self, key, value, d_txt):44 """45 Same as add_elt but to remove the value.46 """47 d = self.subscribers if d_txt == "subscriber" else self.topics48 if key in d.keys():49 if value in d[key]:50 d[key].remove(value)51 if len(d[key]) == 0:52 del d[key]53 return 154 # print("IN remove_elt in whiboard.py, Could not unsubscribe")55 # print(key)56 # print(value)57 # print(d_txt)58 # print(d)59 return -160 def add_subscriber_to_topic(self, subscriber, topic):61 return self.add_elt(topic, subscriber, "topic")62 def add_topic_to_subscriber(self, subscriber, topic):63 return self.add_elt(subscriber, topic, "subscriber")64 def remove_subscriber_from_topic(self, subscriber, topic):65 return self.remove_elt(topic, subscriber, "topic")66 def remove_topic_from_subscriber(self, subscriber, topic):67 return self.remove_elt(subscriber, topic, "subscriber")68 def subscribe(self, subscriber, topic):69 v = self.add_subscriber_to_topic(subscriber, topic) + self.add_topic_to_subscriber(subscriber, topic)70 # if v != 2:71 # log.warning("%s already subscribed to %s." % (subscriber.name, topic))72 def unsubscribe(self, subscriber, topic):73 v = self.remove_subscriber_from_topic(subscriber, topic) + self.remove_topic_from_subscriber(subscriber, topic)74 # if v != 2:75 # log.warning("ERR, %s not subscribed to %s." % (subscriber.name, topic))76 def get_subscribers(self, topic):77 if topic in self.topics.keys():...

Full Screen

Full Screen

fonctions.py

Source:fonctions.py Github

copy

Full Screen

...93#print(f"reverse {reverse(l.premier)}")94print(f"reverse2 {reverse2(l.premier)}")95print(l)96l2 = Liste()97l2.add_elt(0)98l2.add_elt(1)99l2.add_elt(1)100l2.add_elt(1)101l2.add_elt(3)102l2.add_elt(4)103l2.add_elt(4)104l2.add_elt(7)105l2.add_elt(7)106l2.add_elt(7)107l2.add_elt(8)108print(l2)...

Full Screen

Full Screen

dxfloader.py

Source:dxfloader.py Github

copy

Full Screen

1import numpy as np2import ezdxf, sys, os3from pathgenerator import *4class DXFLoader():5 def load(filename):6 dwg = ezdxf.readfile(filename)7 msp = dwg.modelspace()8 item_list = list()9 vertex = list()10 for line in msp.query('LINE'):11 item_list.append(Line(line.dxf.start, line.dxf.end))12 vertex += [line.dxf.start, line.dxf.end]13 for arc in msp.query('ARC'):14 item = Arc(arc.dxf.center, arc.dxf.radius, arc.dxf.start_angle * math.pi / 180, arc.dxf.end_angle * math.pi / 180, True)15 vertex += [item.start, item.end]16 item_list.append(item)17 for polyline in msp.query('LWPOLYLINE'):18 # (x, y, [start_width, [end_width, [bulge]]])19 # TODO handle bulge20 points = polyline.get_points()21 prev_p = points[0]22 for p in points[1:]:23 item_list.append(Line(prev_p[:2], p[:2]))24 prev_p = p25 vertex += [points[0][:2], points[-1][:2]]26 if not item_list:27 raise Exception('Path is empty')28 if len(item_list) == 1:29 pass30 else:31 edge_list = np.empty((0,2), int)32 for n in range(len(vertex)):33 for m in range(n+1, len(vertex)):34 if(abs(vertex[n][0] - vertex[m][0]) < epsilon and abs(vertex[n][1] - vertex[m][1]) < epsilon):35 edge_list = np.vstack((edge_list, np.array((n,m))))36 degree = np.bincount(edge_list.flatten()).max()37 if degree > 2:38 raise Exception("Graph is not a path")39 path_gen = PathGenerator(item_list.pop(0))40 add_elt = True41 while add_elt:42 add_elt = False43 for n,i in enumerate(item_list):44 try:45 path_gen.append(i)46 item_list.pop(n)47 add_elt = True48 break49 except Exception:50 pass51 path_gen.reverse()52 add_elt = True53 while add_elt:54 add_elt = False55 for n,i in enumerate(item_list):56 try:57 path_gen.append(i)58 item_list.pop(n)59 add_elt = True60 break61 except Exception:62 pass63 if len(item_list) > 0:64 raise Exception("Non-connected graph")...

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