How to use select_contains method in lettuce_webdriver

Best Python code snippet using lettuce_webdriver_python

SelectLayersByString.py

Source:SelectLayersByString.py Github

copy

Full Screen

1#! /usr/bin/env python2# -*- Mode: Python -*-3# -*- coding: ascii -*-4"""5Select layers by string6"""7import lwsdk8from lwsdk.pris import recall, store9__author__ = "Makoto Sekiguchi"10__date__ = "Dec 5 2018"11__copyright__ = "Copyright (C) 2018 naru design"12__version__ = "1.03"13__maintainer__ = "Makoto Sekiguchi"14__status__ = "Release"15__lwver__ = "11"16list_history_title = ["String", "FG Layer", "Select others BG"]17class HistoryData():18 def __init__(self):19 self.string = ''20 self.select_contains = 021 self.select_others = 022class NoForegroundLayer(Exception):23 def __str__(self):24 return "No Foreground Layer"25class SelectLayersByString(lwsdk.ICommandSequence):26 def __init__(self, context):27 super(SelectLayersByString, self).__init__()28 self.text_string = None29 self.hchoice_contains = None30 self.bool_others = None31 self.list_history = None32 self.button_remove = None33 self.bool_sort_history = None34 self.history = []35 self.selection = []36 self.sort_history = True37 self.last_string = None38 self.last_select_contains = 039 self.last_others = 040 # list_history name callback41 def nameCallback(self, control, user_data, row, column):42 if row < 0:43 return list_history_title[column]44 if column == 0:45 return self.history[row].string46 elif column == 1:47 return 'Contains' if self.history[row].select_contains else 'Not contains'48 else:49 return 'On' if self.history[row].select_others else 'Off'50 # list_history count callback51 def countCallback(self, control, user_data):52 if self.history == None:53 return 054 return len(self.history)55 # list_history column callback56 def columnCallback(self, control, user_data, column):57 if column >= len(list_history_title):58 return 059 return 15060 # list_history select callback61 def selectCallback(self, control, user_data, row, selecting):62 if row < 0:63 for i in range(len(self.selection)):64 self.selection[i] = False65 else:66 if selecting == 1:67 self.selection[row] = True68 self.text_string.set_str(self.history[row].string)69 self.hchoice_contains.set_int(not self.history[row].select_contains)70 self.bool_others.set_int(self.history[row].select_others)71 else:72 self.selection[row] = False73 self.refresh_button_remove()74 # toggle remove button enable/disable75 def refresh_button_remove(self):76 if self.selection.count(True) > 0:77 self.button_remove.enable()78 else:79 self.button_remove.ghost()80 # read history81 def read_history(self):82 self.history = recall("history", [])83 self.selection = [False] * len(self.history)84 self.sort_history = recall("sort_history", True)85 self.last_string = recall("last_string", "")86 self.last_select_contains = recall("last_select_contains", 0)87 self.last_others = recall("last_others", 0)88 # write history89 def write_history(self):90 store("history", self.history)91 store("sort_history", self.sort_history)92 store("last_string", self.last_string)93 store("last_select_contains", self.last_select_contains)94 store("last_others", self.last_others)95 # check duplicate history96 def search_history(self, history):97 if self.history != None:98 for index, data in enumerate(self.history):99 if data.string == history.string and data.select_contains == history.select_contains \100 and data.select_others == history.select_others:101 return index102 return - 1103 # remove history104 def remove_history(self, control, user_data):105 len_selection = len(self.selection)106 for i in range(len_selection):107 if self.selection[i]:108 self.history.pop(i - len_selection)109 while self.selection.count(True) > 0:110 self.selection.remove(True)111 self.list_history.redraw()112 self.list_history.set_addr_int([-1])113 self.refresh_button_remove()114 self.write_history()115 # move history record forward116 def move_history_record_forward(self, index):117 tmp = self.history.pop(index)118 self.history.insert(0, tmp)119 # add history120 def add_history(self, history):121 index = self.search_history(history)122 if index < 0 and len(history.string) > 0:123 self.history.insert(0, history)124 if index > 0 and self.sort_history:125 self.move_history_record_forward(index)126 # select layers127 def select_layers(self, mod, data):128 obj_funcs = lwsdk.LWObjectFuncs()129 state_query = lwsdk.LWStateQueryFuncs()130 obj_name = state_query.object()131 layer_list = state_query.layerList(lwsdk.OPLYR_NONEMPTY, obj_name)132 # there is no mesh !133 if layer_list == '':134 message_funcs = lwsdk.LWMessageFuncs()135 message_funcs.error('No mesh data', '')136 return lwsdk.AFUNC_OK137 current_obj = obj_funcs.focusObject()138 layers = layer_list.split(' ')139 foreground_layers = []140 background_layers = []141 for layer in layers:142 layer_int = int(layer) - 1143 # layer name is (unnamed), display None144 layer_name = obj_funcs.layerName(current_obj, layer_int)145 if layer_name == None:146 layer_name = ''147 if data.select_contains == (0 if layer_name.find(data.string) < 0 else 1):148 foreground_layers.append(layer)149 else:150 background_layers.append(layer)151 if len(foreground_layers) == 0:152 raise NoForegroundLayer()153 if len(foreground_layers) > 0:154 cs_options = lwsdk.marshall_dynavalues(' '.join(foreground_layers))155 cs_setlayer = mod.lookup(mod.data, "SETALAYER")156 mod.execute(mod.data, cs_setlayer, cs_options, lwsdk.OPSEL_USER)157 if len(background_layers) > 0 and data.select_others:158 cs_options = lwsdk.marshall_dynavalues(' '.join(background_layers))159 cs_setlayer = mod.lookup(mod.data, "setblayer")160 mod.execute(mod.data, cs_setlayer, cs_options, lwsdk.OPSEL_USER)161 # set default values162 def set_default_values(self):163 if len(self.history) > 0:164 self.text_string.set_str(self.last_string)165 self.hchoice_contains.set_int(not self.last_select_contains)166 self.bool_others.set_int(self.last_others)167 self.bool_sort_history.set_int(self.sort_history)168 def process(self, mod_command):169 self.read_history()170 ui = lwsdk.LWPanels()171 panel = ui.create('Select layers by string ' + __version__ + ' - ' + __copyright__)172 self.text_string = panel.str_ctl("String", 50)173 self.hchoice_contains = panel.hchoice_ctl("Select FG Layer", ('Contains string', 'Not contains string'))174 self.bool_others = panel.bool_ctl("Select others as BG Layer")175 self.bool_sort_history = panel.bool_ctl("Move the last condition up if they match")176 self.list_history = panel.multilist_ctl('History', 450, 10, self.nameCallback, self.countCallback, self.columnCallback)177 self.button_remove = panel.button_ctl("Remove")178 self.button_remove.ghost()179 self.list_history.set_select(self.selectCallback)180 self.button_remove.set_event(self.remove_history)181 self.set_default_values()182 if panel.open(lwsdk.PANF_BLOCKING | lwsdk.PANF_CANCEL) == 0:183 ui.destroy(panel)184 return lwsdk.AFUNC_OK185 history = HistoryData()186 history.string = self.text_string.get_str()187 history.select_contains = not self.hchoice_contains.get_int()188 history.select_others = self.bool_others.get_int()189 self.last_string = history.string190 self.last_select_contains = history.select_contains191 self.last_others = history.select_others192 self.sort_history = self.bool_sort_history.get_int()193 self.add_history(history)194 self.write_history()195 try:196 self.select_layers(mod_command, history)197 except NoForegroundLayer:198 message_funcs = lwsdk.LWMessageFuncs()199 message_funcs.error('No foreground layer', '')200 finally:201 return lwsdk.AFUNC_OK202 ui.destroy(panel)203 return lwsdk.AFUNC_OK204ServerTagInfo = [205 ("SK_SelectLayersByString", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH),206 ("SK_SelectLayersByString", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH),207 ("Utilities/SK_SelectLayersByString", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH)208]...

Full Screen

Full Screen

sqlalchemy_core_filters.py

Source:sqlalchemy_core_filters.py Github

copy

Full Screen

...34 print_result(stmt)35def select_not_like():36 stmt = employees.select().where(employees.c.LastName.not_like("Pe%k"))37 print_result(stmt)38def select_contains():39 stmt = employees.select().where(employees.c.LastName.contains("u"))40 print_result(stmt)41def select_startswith():42 stmt = employees.select().where(employees.c.LastName.startswith("D"))43 print_result(stmt)44def select_endswith():45 stmt = employees.select().where(employees.c.LastName.endswith("n"))46 print_result(stmt)47def select_in_():48 stmt = employees.select().where(employees.c.Id.in_([1,2,3]))49 print_result(stmt)50def select_not_in():51 stmt = employees.select().where(employees.c.Id.not_in([1,2,3]))52 print_result(stmt)53def select_with_python_and():54 stmt = employees.select().where(55 (employees.c.Id ==7) & (employees.c.LastName =="King")56 )57 print_result(stmt)58def select_and_():59 stmt = employees.select().where(60 and_((employees.c.Id == 7), (employees.c.LastName == "King"))61 )62 print_result(stmt)63def select_multiple_where():64 stmt = employees.select().where(employees.c.Id == 7).where(employees.c.LastName == "King")65 print_result(stmt)66def select_with_python_or():67 stmt = employees.select().where(68 (employees.c.Id ==2) | (employees.c.Id ==3)69 )70 print_result(stmt)71def select_or_():72 stmt = employees.select().where(73 or_((employees.c.Id == 2), (employees.c.Id == 3))74 )75 print_result(stmt)76def select_partial():77 stmt= select(employees.c.LastName, employees.c.FirstName).where(employees.c.Id == 4)78 print_result(stmt)79if __name__ == '__main__':80 print("----- select_all() ----")81 select_all()82 print("----- select_equals() ----")83 select_equals()84 print("----- select_not_equals() ----")85 select_not_equals86 print("----- select_greater_than() ----")87 select_greater_than()88 print("----- select_less_than() ----")89 select_less_than()90 print("----- select_like() ----")91 select_like()92 print("----- select_not_like() ----")93 select_not_like()94 print("----- select_contains() ----")95 select_contains()96 print("----- select_startswith() ----")97 select_startswith()98 print("----- select_endswith() ----")99 select_endswith()100 print("----- select_in_() ----")101 select_in_()102 print("----- select_not_in() ----")103 select_not_in()104 print("----- select_with_python_and() ----")105 select_with_python_and()106 print("----- select_and_() ----")107 select_and_()108 print("----- select_multiple_where() ----")109 select_multiple_where()...

Full Screen

Full Screen

TestStateQuery.py

Source:TestStateQuery.py Github

copy

Full Screen

1#! /usr/bin/env python2# -*- Mode: Python -*-3# -*- coding: ascii -*-4"""5Dump layer name list6layer containing the mesh7"""8import lwsdk9__lwver__ = "11"10class HistoryData():11 def __init__(self):12 self.string = ''13 self.select_contains = False14 self.select_others = False15class DumpLayerNameCM(lwsdk.ICommandSequence):16 def __init__(self, context):17 super(DumpLayerNameCM, self).__init__()18 def selectLayers(self, data):19 obj_funcs = lwsdk.LWObjectFuncs()20 state_query = lwsdk.LWStateQueryFuncs()21 obj_name = state_query.object()22 layer_list = state_query.layerList(lwsdk.OPLYR_NONEMPTY, obj_name)23 # there is no mesh !24 if layer_list == '':25 message_funcs = lwsdk.LWMessageFuncs()26 message_funcs.error('No mesh data', '')27 return lwsdk.AFUNC_OK28 current_obj = obj_funcs.focusObject()29 layers = layer_list.split(' ')30 foreground_layers = []31 background_layers = []32 for layer in layers:33 layer_int = int(layer) - 134 # layer name is (unnamed), display None35 layer_name = obj_funcs.layerName(current_obj, layer_int)36 if layer_name == None:37 layer_name = ''38 if data.select_contains == (False if layer_name.find(data.string) < 0 else True):39 foreground_layers.append(layer)40 else:41 background_layers.append(layer)42 print('foreground_layers')43 print(foreground_layers)44 print('background_layers')45 print(background_layers)46 def process(self, mod_command):47 data = HistoryData48 data.string = "aaa"49 data.select_contains = True50 data.select_others = False51 self.selectLayers(data)52 return lwsdk.AFUNC_OK53ServerTagInfo = [54 ("LW_DumpLayerNameCM", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH),55 ("LW_DumpLayerNameCM", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH),56 ("Utilities/LW_DumpLayerNameCM", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH)57]58ServerRecord = {lwsdk.CommandSequenceFactory(...

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