How to use visual_icon method in Kiwi

Best Python code snippet using Kiwi_python

hanoi.py

Source:hanoi.py Github

copy

Full Screen

1class bcolors:2 HEADER = '\033[95m'3 OKBLUE = '\033[94m'4 OKGREEN = '\033[92m'5 WARNING = '\033[93m'6 FAIL = '\033[91m'7 ENDC = '\033[0m'8 BOLD = '\033[1m'9 UNDERLINE = '\033[4m'10class ring:11 value = 012 def __init__(self,int_value):13 self.value = int_value14 self.visual = '='15 self.visual_len = len(self.visual)16 self.color = ''17 def __str__(self):18 return str(self.value)19 __repr__ = __str__20 21def size_to_diameter(size):22 return(size * 2) -123def diameter_to_visual(diameter, visual_icon):24 return(diameter * visual_icon)25def generate_ring(size,m_size,visual_icon):26 current_ring_diameter = size_to_diameter(size)27 max_ring_diameter = size_to_diameter(m_size) 28 visual_string = diameter_to_visual(current_ring_diameter, visual_icon) 29 visual_string = visual_string.rjust(max_ring_diameter - (m_size - size))30 visual_string = visual_string.ljust(max_ring_diameter)31 return(visual_string)32def generate_peg(lst,m_size):33 peg = []34 for ring in lst:35 visual_ring = generate_ring(ring.value,m_size,ring.visual)36 peg.append(visual_ring)37 for index in range(m_size - len(lst) + 1):38 peg_piece = generate_ring(1,m_size,'|')39 peg.append(peg_piece)40 return(peg)41def generate_pegs(pegs,m_size):42 visual_pegs = []43 for peg in pegs:44 visual_peg = generate_peg(peg,m_size)45 visual_pegs.append(visual_peg)46 return(visual_pegs)47 48def print_visual_pegs(pegs):49 reversed_pegs = []50 for peg in pegs:51 reversed_pegs.append(reversed(peg))52 for x, y, z in zip(*reversed_pegs):53 pass54 print(x, y, z) 55def moveVisual(pegs,m_size,init_peg, final_peg):56 moving = pegs[init_peg].pop()57 if (len(pegs[final_peg]) != 0) and (moving.value > pegs[final_peg][-1].value):58 print("Cannot complete action. Moving ring is begger than upper ring on peg")59 else:60 pegs[final_peg].append(moving)61 visual_pegs = generate_pegs(pegs,m_size)62 print_visual_pegs(visual_pegs)63 return(pegs)64 65def recursive(height,m_size,pegs,initPeg, finalPeg, oppositePeg):66 if height > 0:67 pegs = recursive(height-1,m_size,pegs,initPeg,oppositePeg,finalPeg)68 pegs = moveRing(pegs,m_size,initPeg,finalPeg)69 pegs = recursive(height-1,m_size, pegs, oppositePeg,finalPeg,initPeg)70 return(pegs)71def moveRing(pegs,m_size,initPeg,finalPeg):72 print("Moving Ring from",initPeg,"to",finalPeg)73 pegs = moveVisual(pegs,m_size, initPeg,finalPeg)74 return(pegs)75def user_input():76 # Creating number of rings 77 no_rings = True78 while no_rings:79 try:80 rings = int(input("How many rings?: "))81 if rings >=0:82 no_rings = False83 except Exception:84 pass85 return(rings)86def tower_of_hannoi(rings):87 ring_list = [ring(rings - int_value) for int_value in range(rings)]88 odd = not int(len(ring_list)) % 2 == 089 expected_num_turns = 2**rings - 190 print('Expected Number of turns:', expected_num_turns)91 pegs = [ [] for _ in range(3) ]92 pegs[0] = ring_list93# ===========================================================================94# <<It's not recursive>>, you said. <<Its a bit more complicated>>, you said95# ===========================================================================96 visual_pegs = generate_pegs(pegs,rings)97 print_visual_pegs(visual_pegs)98 recursive(rings,rings,pegs,0,2,1)99rings = user_input()...

Full Screen

Full Screen

admin.py

Source:admin.py Github

copy

Full Screen

...41 </span>42 ''',43 test_execution.color, test_execution.color)44 colored_color.short_description = 'color'45 def visual_icon(self, test_execution):46 return format_html(47 '''48 <span class="{}" style="font-size: 18px; color: {};"></span>49 ''',50 test_execution.icon, test_execution.color51 )52 visual_icon.short_description = 'icon'53admin.site.register(TestRun, TestRunAdmin)...

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