How to use make_new method in autotest

Best Python code snippet using autotest_python

Questions.py

Source:Questions.py Github

copy

Full Screen

...33 update.message.reply_text(34 "To get in accept privacy policy\nTo start again say /start"35 )36 return ConversationHandler.END37 return self.make_new(update, context)38 class Filter(BaseFilter):39 def filter(self, message):40 try:41 txt = message.text42 return txt in ("Yes", "No")43 except AttributeError:44 return False45 filter = Filter()46 key_verbose_name = "Telegram Chat ID"47 key_name = "id"48class Phone:49 def make(self, update, context):50 em1 = emojize(":telephone:", use_aliases=True)51 em2 = emojize(":mobile_phone:", use_aliases=True)52 _contact_button = KeyboardButton(53 text=em1 + " Send your phone number " + em2, request_contact=True54 )55 _markup = ReplyKeyboardMarkup([[_contact_button]], one_time_keyboard=True)56 update.message.reply_text(57 text="Click on the below button",58 reply_markup=_markup,59 )60 return self.num61 def process(self, update, context):62 chat_id = update.message.chat_id63 Hunter.objects.create(id=chat_id, phone=update.message.contact.phone_number)64 return self.make_new(update, context)65 filter = Filters.contact66 key_verbose_name = "Numero di Telefono"67 key_name = "phone"68class Name:69 def make(self, update, context):70 update.message.reply_text("Tell me your name")71 return self.num72 def process(self, update, context):73 hunter = Hunter.objects.get(id=update.message.chat_id)74 hunter.name = update.message.text75 hunter.save()76 return self.make_new(update, context)77 class Filter(BaseFilter):78 def filter(self, message):79 try:80 txt = message.text81 return all(x.isalpha() or x.isspace() or x == "'" for x in txt)82 except:83 return False84 filter = Filter()85 key_verbose_name = "Nome"86 key_name = "name"87class Surname:88 def make(self, update, context):89 update.message.reply_text("Tell me your surname")90 return self.num91 def process(self, update, context):92 hunter = Hunter.objects.get(id=update.message.chat_id)93 hunter.surname = update.message.text94 hunter.save()95 return self.make_new(update, context)96 filter = Name.filter97 key_verbose_name = "Cognome"98 key_name = "surname"99class Age:100 def make(self, update, context):101 update.message.reply_text("how old are you? Es. 20")102 return self.num103 def process(self, update, context):104 hunter = Hunter.objects.get(id=update.message.chat_id)105 hunter.age = int(update.message.text)106 hunter.save()107 return self.make_new(update, context)108 class Filter(BaseFilter):109 def filter(self, message):110 try:111 txt = message.text112 return (txt.isdigit()) and 16 < int(txt) < 40113 except AttributeError:114 return False115 filter = Filter()116 key_verbose_name = "Età"117 key_name = "age"118class Uni:119 def make(self, update, context):120 update.message.reply_text(121 "Do you attend university? Which one? "122 )123 return self.num124 def process(self, update, context):125 hunter = Hunter.objects.get(id=update.message.chat_id)126 hunter.uni = update.message.text127 hunter.save()128 return self.make_new(update, context)129 class Filter(BaseFilter):130 def filter(self, message):131 try:132 txt = message.text133 return True134 except AttributeError:135 return False136 filter = Filter()137 key_verbose_name = "Università"138 key_name = "uni"139class Time:140 def make(self, update, context):141 update.message.reply_text(142 "Tell me when you will come and when you will go away"143 )144 return self.num145 def process(self, update, context):146 hunter = Hunter.objects.get(id=update.message.chat_id)147 hunter.tframe = update.message.text148 hunter.save()149 return self.make_new(update, context)150 filter = Uni.filter151 key_verbose_name = "Tempistica"152 key_name = "tframe"153class Perc:154 def make(self, update, context):155 update.message.reply_text(156 "Tell me the probability you come to play (percentage)? Es. 99\n"157 )158 return self.num159 def process(self, update, context):160 hunter = Hunter.objects.get(id=update.message.chat_id)161 hunter.perc = int(update.message.text)162 hunter.save()163 return self.make_new(update, context)164 class Filter(BaseFilter):165 def filter(self, message):166 try:167 txt = message.text168 return txt.isdigit() and 1 <= int(txt) <= 100169 except AttributeError:170 return False171 filter = Filter()172 key_verbose_name = "Probabilità di presenza (%)"173 key_name = "perc"174# Handling the process of assigning a captain175class Grouping: # others questions are in personalQuestions.py176 def make(self, update, context):177 MAX_MEMBERS_PER_TEAM = Bot_Table.objects.first().max_team_size178 BUTTONS = [[i] for i in cap_anag_list(MAX_MEMBERS_PER_TEAM)]179 random.shuffle(BUTTONS)180 BUTTONS.insert(0, ["Create your team"])181 _markup = ReplyKeyboardMarkup(BUTTONS, one_time_keyboard=True)182 update.message.reply_text("Choose your Captain", reply_markup=_markup)183 return self.num184 def process(self, update, context):185 choice = update.message.text186 hunter = Hunter.objects.get(id=update.message.chat_id)187 if choice == "Create your team":188 update.message.reply_text(189 "Contact the admin. "190 "If you wish to join another team say /stop, then /start e start again."191 )192 queue = Queue.objects.create(situation="Requested own team", hunter=hunter)193 return self.make_new(update, context)194 cap_anag = choice195 queue = Queue.objects.create(situation="waiting", hunter=hunter)196 create_nodes(cap_anag, queue)197 handle_queue(hunter, context)198 return self.make_new(update, context)199 class Filter(BaseFilter):200 def filter(self, message):201 try:202 txt = message.text203 MAX_MEMBERS_PER_TEAM = Bot_Table.objects.first().max_team_size204 flat_buttons = cap_anag_list(MAX_MEMBERS_PER_TEAM)205 flat_buttons.insert(0, "Create your team")206 return txt in flat_buttons207 except AttributeError:208 return False209 filter = Filter()210 key_verbose_name = "Status dell'iscrizione"211 key_name = "queue"212# what happens when conversation_handler.END is triggered...

Full Screen

Full Screen

plot_p.py

Source:plot_p.py Github

copy

Full Screen

...10 with open(filename) as f:11 for line in f:12 data = json.loads(line)13 if data['type'] == 'instances':14 new_instance = atomic_instance.make_new(data)15 all_attempts[new_instance.pid].append(new_instance)16 else:17 for line in sys.stdin:18 data = json.loads(line)19 if data['type'] == 'instances':20 new_instance = atomic_instance.make_new(data)21 all_attempts[new_instance.pid].append(new_instance)22 return all_attempts23class atomic_attempt:24 def __init__(self, attempt_type, start_at, end_at):25 self.attempt_type= attempt_type26 self.start_at = start_at27 self.end_at = end_at28 @staticmethod29 def make_new(attempts_data):30 attempts = list()31 for attempt in attempts_data:32 attempts.append(atomic_attempt(attempt['type'], attempt['start_at'], attempt['end_at']))33 return attempts34class atomic_instance:35 def __init__(self, pid, start_at, end_at, attempts, rset, wset):36 self.pid = pid37 self.start_at = start_at38 self.end_at = end_at39 self.attempts = attempts40 self.rset = rset41 self.wset = wset42 @staticmethod43 def make_new(data):44 pid = data['pid']45 start_at= data['start_at']46 end_at = data['end_at']47 attempts= atomic_attempt.make_new(data['attempts'])48 rset = set(data['rset'])49 wset = set(data['wset'])50 return atomic_instance(pid, start_at, end_at, attempts, rset, wset)51def compute_my_p(pids, conflicts):52 csets= list()53 left_p = set(pids)54 while len(left_p) > 0:55 cset = set()56 pid = left_p.pop()57 cset.add(pid)58 also_add = set(conflicts[pid]).difference(cset)59 while len(also_add) > 0:60 a = also_add.pop()61 cset.add(a)...

Full Screen

Full Screen

build.py

Source:build.py Github

copy

Full Screen

...11def address_bytes(abytes, address_el):12 container = find_first('address-bytes', address_el)13 for byte in abytes:14 text, length = byte15 make_new('address-byte', container, text, {'length': length})16def address_description(data, address_el):17 el = find_first('address-description', address_el)18 el.string = data19def address(text):20 abytes, description = parse.address(text)21 el = copy(templates.address)22 address_bytes(abytes, el)23 address_description(description, el)24 return el25def op_table(text):26 headers, rows = parse.op_table(text)27 t = copy(templates.table)28 def make_body_tr(row):29 tr = make_new('tr', t.tbody)30 [make_new('td', tr, field) for field in row]31 [make_new('th', t.thead.tr, h) for h in headers]32 [make_body_tr(r) for r in rows]...

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