Best Python code snippet using playwright-python
keyboard_shortcuts.py
Source:keyboard_shortcuts.py
...31Keyboard shortcuts for Navigation.32"""33def navigate_back():34 """Navigate back in browsing history one page visit."""35 if OSHelper.is_mac():36 type(text='[', modifier=KeyModifier.CMD)37 else:38 type(text=Key.LEFT, modifier=KeyModifier.ALT)39def navigate_forward():40 """Navigate forward in browsing history one page visit."""41 if OSHelper.is_mac():42 type(text=']', modifier=KeyModifier.CMD)43 else:44 type(text=']', modifier=KeyModifier.ALT)45def navigate_home():46 """Navigate the browser to whatever is set as the Home page."""47 type(text=Key.HOME, modifier=KeyModifier.ALT)48def open_file_picker():49 """Open the system file picker."""50 if OSHelper.is_mac():51 type(text='o', modifier=KeyModifier.CMD)52 else:53 type(text='o', modifier=KeyModifier.CTRL)54def select_location_bar():55 """Set focus to the location bar."""56 if OSHelper.is_mac():57 type(text='l', modifier=KeyModifier.CMD)58 else:59 type(text='l', modifier=KeyModifier.CTRL)60 # Wait to allow the location bar to become responsive.61 time.sleep(Settings.DEFAULT_UI_DELAY_LONG)62def select_folder_location_bar():63 """Set focus to the location bar/open folder popup in previously opened file manager64 (e.g. "Open file", "Import bookmark") to navigate to path"""65 if OSHelper.is_mac():66 type(text='g', modifier=[KeyModifier.SHIFT, KeyModifier.CMD])67 else:68 type(text='l', modifier=KeyModifier.CTRL)69def reload_page():70 """Reload the current web page."""71 if OSHelper.is_mac():72 type(text='r', modifier=KeyModifier.CMD)73 else:74 type(text='r', modifier=KeyModifier.CTRL)75def force_reload_page():76 """Reload the current web page with cache override."""77 if OSHelper.is_mac():78 type(text='r', modifier=[KeyModifier.CMD, KeyModifier.SHIFT])79 else:80 type(text='r', modifier=[KeyModifier.CTRL, KeyModifier.SHIFT])81def stop_page_load():82 """Stop the current in progress web page from loading."""83 type(text=Key.ESC)84# End of Navigation keyboard shortcuts.85# Keyboard shortcuts for Current Page.86def scroll_down():87 """Scroll down one increment (equivalent to 3 mousewheel steps)."""88 type(text=Key.DOWN)89def scroll_up():90 """Scroll up one increment (equivalent to 3 mousewheel steps)."""91 type(text=Key.UP)92def page_down():93 """Jump down one screen."""94 type(text=Key.SPACE)95def page_up():96 """Jump up one screen."""97 type(text=Key.SPACE, modifier=KeyModifier.SHIFT)98def page_end():99 """Jump to the bottom of the page."""100 type(text=Key.END)101def page_home():102 """Jump to the top of the page."""103 type(text=Key.HOME)104def focus_next_item():105 """Focus next actionable item."""106 type(text=Key.TAB)107def focus_previous_item():108 """Focus previous actionable item."""109 type(text=Key.TAB, modifier=KeyModifier.SHIFT)110def next_frame():111 """Move to the next frame (can be in content or in chrome)."""112 type(text=Key.F6)113def previous_frame():114 """Move to the previous frame (can be in content or in chrome)."""115 type(text=Key.F6, modifier=KeyModifier.SHIFT)116def open_print_page():117 """Open the Print dialog."""118 if OSHelper.is_mac():119 type(text='p', modifier=KeyModifier.CMD)120 else:121 type(text='p', modifier=KeyModifier.CTRL)122def open_save_page():123 """Open the Save dialog."""124 if OSHelper.is_mac():125 type(text='s', modifier=KeyModifier.CMD)126 else:127 type(text='s', modifier=KeyModifier.CTRL)128def zoom_in():129 """Zoom in one increment."""130 if OSHelper.is_mac():131 type(text='+', modifier=KeyModifier.CMD)132 else:133 type(text='+', modifier=KeyModifier.CTRL)134def zoom_out():135 """Zoom out one increment."""136 if OSHelper.is_mac():137 type(text='-', modifier=KeyModifier.CMD)138 else:139 type(text='-', modifier=KeyModifier.CTRL)140def restore_zoom():141 """Restores zoom level to page default."""142 if OSHelper.is_mac():143 type(text='0', modifier=KeyModifier.CMD)144 else:145 type(text='0', modifier=KeyModifier.CTRL)146# End of Current Page keyboard shortcuts.147# Keyboard shortcuts for Editing.148def edit_copy():149 """Copy selection to clipboard."""150 if OSHelper.is_mac():151 type(text='c', modifier=KeyModifier.CMD)152 else:153 type(text='c', modifier=KeyModifier.CTRL)154def edit_cut():155 """Cut selection to clipboard."""156 if OSHelper.is_mac():157 type(text='x', modifier=KeyModifier.CMD)158 else:159 type(text='x', modifier=KeyModifier.CTRL)160def edit_delete():161 """Delete selected text.162 If nothing is selected, delete previous character.163 """164 type(text=Key.DELETE)165def edit_paste():166 """Paste contents of the clipboard to the focused text field."""167 if OSHelper.is_mac():168 type(text='v', modifier=KeyModifier.CMD)169 else:170 type(text='v', modifier=KeyModifier.CTRL)171def edit_paste_plain():172 """Paste contents of the clipboard, as plain text, to the focused text field."""173 if OSHelper.is_mac():174 type(text='v', modifier=[KeyModifier.CMD, KeyModifier.SHIFT])175 else:176 type(text='v', modifier=[KeyModifier.CTRL, KeyModifier.SHIFT])177def edit_redo():178 """Redo the last operation of Undo."""179 if OSHelper.is_mac():180 type(text='z', modifier=[KeyModifier.CMD, KeyModifier.SHIFT])181 else:182 type(text='z', modifier=[KeyModifier.CTRL, KeyModifier.SHIFT])183def edit_select_all():184 """Selects the entire contents of focused field or page."""185 if OSHelper.is_mac():186 type(text='a', modifier=KeyModifier.CMD)187 else:188 type(text='a', modifier=KeyModifier.CTRL)189def edit_undo():190 """Undoes the previous operation."""191 if OSHelper.is_mac():192 type(text='z', modifier=KeyModifier.CMD)193 else:194 type(text='z', modifier=KeyModifier.CTRL)195# End of Editing keyboard shortcuts.196# Keyboard shortcuts for Search.197def open_find():198 """Open the find toolbar."""199 if OSHelper.is_mac():200 type(text='f', modifier=KeyModifier.CMD)201 else:202 type(text='f', modifier=KeyModifier.CTRL)203def find_next():204 """Find next occurrence of term, if find is already active on a search term.205 Find next (again) can also find the next occurrence of a term without opening the find toolbar.206 """207 if OSHelper.is_mac():208 type(text='g', modifier=KeyModifier.CMD)209 else:210 type(text='g', modifier=KeyModifier.CTRL)211def find_previous():212 """Find the previous occurrence of term, if find is already active on a search term.213 Find previous can also find the previous occurrence of a term without opening the find toolbar.214 """215 if OSHelper.is_mac():216 type(text='g', modifier=[KeyModifier.CMD, KeyModifier.SHIFT])217 else:218 type(text='g', modifier=[KeyModifier.CTRL, KeyModifier.SHIFT])219def quick_find():220 """Quick find opens simple find toolbar that remains active for only six seconds."""221 if OSHelper.is_mac():222 type(text='/', modifier=KeyModifier.CMD)223 else:224 type(text='/', modifier=KeyModifier.CTRL)225def quick_find_link():226 """Quick find opens simple find link toolbar that remains active for only six seconds."""227 if OSHelper.is_mac():228 type(text="'", modifier=KeyModifier.CMD)229 else:230 type(text="'", modifier=KeyModifier.CTRL)231def close_find():232 """Close the regular find toolbar or quick find toolbar, if it has focus."""233 type(text=Key.ESC)234def select_search_bar():235 """If the search bar is present, select the search bar, otherwise this selects the location bar."""236 if OSHelper.is_mac():237 type(text='k', modifier=KeyModifier.CMD)238 else:239 type(text='k', modifier=KeyModifier.CTRL)240 time.sleep(Settings.DEFAULT_UI_DELAY_LONG)241def change_search_next():242 """If the search bar has focus, change the search engine to the next in the list.243 (side effect: this also opens the search engine manager, if it wasn't already open).244 """245 if OSHelper.is_mac():246 type(text=Key.DOWN, modifier=KeyModifier.CMD)247 else:248 type(text=Key.DOWN, modifier=KeyModifier.CTRL)249def change_search_previous():250 """If the search bar has focus, change the search engine to the previous in the list.251 (side effect: this also opens the search engine manager, if it wasn't already open).252 """253 if OSHelper.is_mac():254 type(text=Key.UP, modifier=KeyModifier.CMD)255 else:256 type(text=Key.UP, modifier=KeyModifier.CTRL)257def open_search_manager():258 """If the search bar has focus, open the search engine manager."""259 type(text=Key.DOWN, modifier=KeyModifier.ALT)260# End of Search keyboard shortcuts.261# Keyboard shortcuts for Windows & Tabs.262def close_tab():263 """Close the currently focused tab (Except for app tabs)."""264 if OSHelper.is_mac():265 type(text='w', modifier=KeyModifier.CMD)266 else:267 type(text='w', modifier=KeyModifier.CTRL)268def close_window():269 """Close the currently focused window."""270 if OSHelper.is_mac():271 type(text='w', modifier=[KeyModifier.CMD, KeyModifier.SHIFT])272 else:273 type(text='w', modifier=[KeyModifier.CTRL, KeyModifier.SHIFT])274def force_close():275 """Move to the previous frame (can be in content or in chrome)."""276 type(text=Key.F4, modifier=KeyModifier.ALT)277 type(text='u', modifier=KeyModifier.CTRL)278def change_window_view():279 """Change the focus on another window."""280 if OSHelper.is_mac():281 type(text=Key.TAB, modifier=KeyModifier.CMD)282 else:283 type(text=Key.TAB, modifier=KeyModifier.ALT)284def full_screen():285 """Toggle full screen mode."""286 if OSHelper.is_mac():287 type(text='f', modifier=[KeyModifier.CMD, KeyModifier.SHIFT])288 else:289 type(text=Key.F11)290def maximize_window():291 """Maximize the browser window to fill the screen.292 This is NOT Full Screen mode.293 """294 if OSHelper.is_mac():295 # There is no keyboard shortcut for this on Mac. We'll do it the old fashioned way.296 # This image is of the three window control buttons at top left of the window.297 # We have to resize the window to ensure maximize works properly in all cases.298 window_controls_pattern = Pattern('window_controls.png')299 controls_location = find(window_controls_pattern)300 xcoord = controls_location.x301 ycoord = controls_location.y302 width, height = window_controls_pattern.get_size()303 drag_start = Location(xcoord + 70, ycoord + 5)304 drag_end = Location(xcoord + 75, ycoord + 5)305 Mouse().drag_and_drop(drag_start, drag_end, duration=0.1)306 # Alt key changes maximize button from full screen to maximize window.307 maximize_button = window_controls_pattern.target_offset(width / 2 - 3, 0)308 key_down(Key.ALT)309 click(maximize_button)310 key_up(Key.ALT)311 elif OSHelper.is_windows():312 type(text=Key.UP, modifier=KeyModifier.WIN)313 else:314 type(text=Key.UP, modifier=[KeyModifier.CTRL, KeyModifier.META])315 time.sleep(Settings.DEFAULT_UI_DELAY)316def minimize_window():317 """Minimize the browser window to the application launch bar."""318 if OSHelper.is_mac():319 type(text='m', modifier=KeyModifier.CMD)320 elif OSHelper.is_windows():321 type(text=Key.DOWN, modifier=KeyModifier.WIN)322 else:323 type(text=Key.DOWN, modifier=[KeyModifier.CTRL, KeyModifier.META])324 time.sleep(Settings.DEFAULT_UI_DELAY)325def new_tab():326 """Open a new browser tab."""327 if OSHelper.is_mac():328 type(text='t', modifier=KeyModifier.CMD)329 else:330 type(text='t', modifier=KeyModifier.CTRL)331 time.sleep(Settings.DEFAULT_UI_DELAY)332def new_window():333 """Open a new browser window."""334 if OSHelper.is_mac():335 type(text='n', modifier=KeyModifier.CMD)336 else:337 type(text='n', modifier=KeyModifier.CTRL)338def new_private_window():339 """Open a new private browser window."""340 if OSHelper.is_mac():341 type(text='p', modifier=[KeyModifier.CMD, KeyModifier.SHIFT])342 else:343 type(text='p', modifier=[KeyModifier.CTRL, KeyModifier.SHIFT])344def next_tab():345 """Focus the next tab (one over to the right)."""346 type(text=Key.TAB, modifier=KeyModifier.CTRL)347def previous_tab():348 """Focus the previous tab (one over to the left)."""349 type(text=Key.TAB, modifier=[KeyModifier.CTRL, KeyModifier.SHIFT])350def quit_firefox():351 """Quit the browser."""352 # Press the ESC key to exit any modal dialogs that might prevent key capture.353 type(text=Key.ESC)354 # Wait before quitting Firefox to avoid concurrency.355 time.sleep(1)356 if OSHelper.is_mac():357 type(text='q', modifier=KeyModifier.CMD)358 elif OSHelper.is_windows():359 type(text='q', modifier=[KeyModifier.CTRL, KeyModifier.SHIFT])360 else:361 type(text='q', modifier=KeyModifier.CTRL)362def select_tab(num):363 """Select a given tab (only 1-8).364 param: num is a string 1-8. example: '4'.365 """366 if OSHelper.is_mac():367 type(text=str(num), modifier=KeyModifier.CMD)368 elif OSHelper.is_windows():369 type(text=str(num), modifier=KeyModifier.CTRL)370 else:371 type(text=str(num), modifier=KeyModifier.ALT)372 373def select_last_tab():374 """Select the last tab."""375 if OSHelper.is_mac():376 type(text='9', modifier=KeyModifier.CMD)377 elif OSHelper.is_windows():378 type(text='9', modifier=[KeyModifier.CTRL, KeyModifier.SHIFT])379 else:380 type(text='9', modifier=KeyModifier.CTRL)381def toggle_audio():382 """Mute/Unmute audio."""383 type(text='m', modifier=KeyModifier.CTRL)384def undo_close_tab():385 """Re-opens the previously closed tab."""386 if OSHelper.is_mac():387 type(text='t', modifier=[KeyModifier.CMD, KeyModifier.SHIFT])388 else:389 type(text='t', modifier=[KeyModifier.CTRL, KeyModifier.SHIFT])390def undo_close_window():391 """Re-opens the previously closed browser window."""392 if OSHelper.is_mac():393 type(text='n', modifier=[KeyModifier.CMD, KeyModifier.SHIFT])394 else:395 type(text='n', modifier=[KeyModifier.CTRL, KeyModifier.SHIFT])396# End of Windows & Tabs keyboard shortcuts.397# Keyboard shortcuts for History & Bookmarks.398def history_sidebar():399 """Toggle open/close the history sidebar."""400 if OSHelper.is_mac():401 type(text='h', modifier=[KeyModifier.CMD, KeyModifier.SHIFT])402 else:403 type(text='h', modifier=KeyModifier.CTRL)404def clear_recent_history():405 """Open the Clear Recent History dialog."""406 if OSHelper.is_mac():407 type(text=Key.DELETE, modifier=[KeyModifier.CMD, KeyModifier.SHIFT])408 else:409 type(text=Key.DELETE, modifier=[KeyModifier.CTRL, KeyModifier.SHIFT])410def bookmark_all_tabs():411 """Open the Bookmark All Tabs dialog."""412 if OSHelper.is_mac():413 type(text='d', modifier=[KeyModifier.CMD, KeyModifier.SHIFT])414 else:415 type(text='d', modifier=[KeyModifier.CTRL, KeyModifier.SHIFT])416 # Wait for the Bookmark All Tabs dialog to be opened.417 time.sleep(Settings.DEFAULT_UI_DELAY_LONG)418def bookmark_page():419 """Bookmark the current page."""420 if OSHelper.is_mac():421 type(text='d', modifier=KeyModifier.CMD)422 else:423 type(text='d', modifier=KeyModifier.CTRL)424 try:425 wait(LocationBar.STAR_BUTTON_STARRED, 10)426 logger.debug('Page was successfully bookmarked')427 except FindError:428 raise APIHelperError('Page can not be bookmarked')429def bookmarks_sidebar(option: str):430 """Toggle open/close the bookmarks sidebar."""431 if OSHelper.is_mac():432 type(text='b', modifier=KeyModifier.CMD)433 else:434 type(text='b', modifier=KeyModifier.CTRL)435 bookmark_sidebar_header_pattern = SidebarBookmarks.BOOKMARKS_HEADER436 if option == 'open':437 try:438 wait(bookmark_sidebar_header_pattern, 10)439 logger.debug('Sidebar is opened.')440 except FindError:441 raise APIHelperError('Sidebar is NOT present on the page, aborting.')442 elif option == 'close':443 try:444 wait_vanish(bookmark_sidebar_header_pattern, 10)445 logger.debug('Sidebar is closed.')446 except FindError:447 raise APIHelperError('Sidebar is NOT closed, aborting.')448 else:449 raise APIHelperError('Option is not supported, aborting')450def open_library():451 """Open the Library window."""452 if OSHelper.is_mac():453 type(text='b', modifier=[KeyModifier.CMD, KeyModifier.SHIFT])454 elif OSHelper.is_windows():455 type(text='b', modifier=[KeyModifier.CTRL, KeyModifier.SHIFT])456 else:457 type(text='o', modifier=[KeyModifier.CTRL, KeyModifier.SHIFT])458# End History & Bookmarks keyboard shortcuts.459# Keyboard shortcuts for Tools.460def open_addons():461 """Open the Add-ons Manager page."""462 if OSHelper.is_mac():463 type(text='a', modifier=[KeyModifier.CMD, KeyModifier.SHIFT])464 else:465 type(text='a', modifier=[KeyModifier.CTRL, KeyModifier.SHIFT])466def open_downloads():467 """Open the Downloads dialog."""468 if OSHelper.is_mac():469 type(text='j', modifier=KeyModifier.CMD)470 elif OSHelper.is_windows():471 type(text='j', modifier=KeyModifier.CTRL)472 else:473 type(text='y', modifier=[KeyModifier.CTRL, KeyModifier.SHIFT])474def open_page_source():475 """Open the current page's page source."""476 if OSHelper.is_mac():477 type(text='u', modifier=KeyModifier.CMD)478 else:479 type(text='u', modifier=KeyModifier.CTRL)480def open_web_console():481 """Opens the Web Console."""482 if OSHelper.is_mac():483 type(text='k', modifier=[KeyModifier.CMD, KeyModifier.ALT])484 else:485 type(text='k', modifier=[KeyModifier.CTRL, KeyModifier.SHIFT])486def open_web_developer_menu():487 """488 Open the Web_developer tool.489 """490 type(text=Key.F2, modifier=KeyModifier.SHIFT)491def open_browser_console():492 """493 Opens the Browser Console.494 """495 if OSHelper.is_mac():496 type(text="j", modifier=[KeyModifier.CMD, KeyModifier.SHIFT])497 else:498 type(text="j", modifier=[KeyModifier.CTRL, KeyModifier.SHIFT])499def restart_via_console():500 """501 restarts Firefox if web console is opened502 """503 if OSHelper.is_mac():504 type(text='r', modifier=[KeyModifier.CMD, KeyModifier.ALT])505 else:506 type(text='r', modifier=[KeyModifier.CTRL, KeyModifier.ALT])507def open_firefox_menu():508 """509 Opens Firefox top menu510 """511 if OSHelper.is_linux():512 key_down(Key.ALT)513 time.sleep(0.5)514 key_up(Key.ALT)515 elif OSHelper.is_windows():516 type(Key.ALT)517def delete_selected_file():518 """Delete selected file/files inside a folder."""519 if OSHelper.is_mac():520 type(text=Key.BACKSPACE, modifier=KeyModifier.CMD)521 elif OSHelper.get_os_version() == 'win7':522 type(text=Key.DELETE)523 type(text='y')524 else:525 type(text=Key.DELETE)526def release_often_used_keys():527 """528 Releases often used keys529 """530 key_up(KeyModifier.SHIFT)531 key_up(KeyModifier.CTRL)532 key_up(KeyModifier.ALT)533 if OSHelper.is_mac():534 key_up(KeyModifier.CMD)535 if OSHelper.is_windows():536 key_up(KeyModifier.WIN)...
intelc.py
Source:intelc.py
1"""SCons.Tool.icl2Tool-specific initialization for the Intel C/C++ compiler.3Supports Linux and Windows compilers, v7 and up.4There normally shouldn't be any need to import this module directly.5It will usually be imported through the generic SCons.Tool.Tool()6selection method.7"""8#9# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The SCons Foundation10#11# Permission is hereby granted, free of charge, to any person obtaining12# a copy of this software and associated documentation files (the13# "Software"), to deal in the Software without restriction, including14# without limitation the rights to use, copy, modify, merge, publish,15# distribute, sublicense, and/or sell copies of the Software, and to16# permit persons to whom the Software is furnished to do so, subject to17# the following conditions:18#19# The above copyright notice and this permission notice shall be included20# in all copies or substantial portions of the Software.21#22# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY23# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE24# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND25# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE26# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION27# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION28# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.29#30__revision__ = "src/engine/SCons/Tool/intelc.py 4043 2009/02/23 09:06:45 scons"31import math, sys, os.path, glob, string, re32is_windows = sys.platform == 'win32'33is_win64 = is_windows and (os.environ['PROCESSOR_ARCHITECTURE'] == 'AMD64' or 34 (os.environ.has_key('PROCESSOR_ARCHITEW6432') and35 os.environ['PROCESSOR_ARCHITEW6432'] == 'AMD64'))36is_linux = sys.platform == 'linux2'37is_mac = sys.platform == 'darwin'38if is_windows:39 import SCons.Tool.msvc40elif is_linux:41 import SCons.Tool.gcc42elif is_mac:43 import SCons.Tool.gcc44import SCons.Util45import SCons.Warnings46# Exceptions for this tool47class IntelCError(SCons.Errors.InternalError):48 pass49class MissingRegistryError(IntelCError): # missing registry entry50 pass51class MissingDirError(IntelCError): # dir not found52 pass53class NoRegistryModuleError(IntelCError): # can't read registry at all54 pass55def uniquify(s):56 """Return a sequence containing only one copy of each unique element from input sequence s.57 Does not preserve order.58 Input sequence must be hashable (i.e. must be usable as a dictionary key)."""59 u = {}60 for x in s:61 u[x] = 162 return u.keys()63def linux_ver_normalize(vstr):64 """Normalize a Linux compiler version number.65 Intel changed from "80" to "9.0" in 2005, so we assume if the number66 is greater than 60 it's an old-style number and otherwise new-style.67 Always returns an old-style float like 80 or 90 for compatibility with Windows.68 Shades of Y2K!"""69 # Check for version number like 9.1.026: return 91.02670 m = re.match(r'([0-9]+)\.([0-9]+)\.([0-9]+)', vstr)71 if m:72 vmaj,vmin,build = m.groups()73 return float(vmaj) * 10 + float(vmin) + float(build) / 1000.;74 else:75 f = float(vstr)76 if is_windows:77 return f78 else:79 if f < 60: return f * 10.080 else: return f81def check_abi(abi):82 """Check for valid ABI (application binary interface) name,83 and map into canonical one"""84 if not abi:85 return None86 abi = abi.lower()87 # valid_abis maps input name to canonical name88 if is_windows:89 valid_abis = {'ia32' : 'ia32',90 'x86' : 'ia32',91 'ia64' : 'ia64',92 'em64t' : 'em64t',93 'amd64' : 'em64t'}94 if is_linux:95 valid_abis = {'ia32' : 'ia32',96 'x86' : 'ia32',97 'x86_64' : 'x86_64',98 'em64t' : 'x86_64',99 'amd64' : 'x86_64'}100 if is_mac:101 valid_abis = {'ia32' : 'ia32',102 'x86' : 'ia32',103 'x86_64' : 'x86_64',104 'em64t' : 'x86_64'}105 try:106 abi = valid_abis[abi]107 except KeyError:108 raise SCons.Errors.UserError, \109 "Intel compiler: Invalid ABI %s, valid values are %s"% \110 (abi, valid_abis.keys())111 return abi112def vercmp(a, b):113 """Compare strings as floats,114 but Intel changed Linux naming convention at 9.0"""115 return cmp(linux_ver_normalize(b), linux_ver_normalize(a))116def get_version_from_list(v, vlist):117 """See if we can match v (string) in vlist (list of strings)118 Linux has to match in a fuzzy way."""119 if is_windows:120 # Simple case, just find it in the list121 if v in vlist: return v122 else: return None123 else:124 # Fuzzy match: normalize version number first, but still return125 # original non-normalized form.126 fuzz = 0.001127 for vi in vlist:128 if math.fabs(linux_ver_normalize(vi) - linux_ver_normalize(v)) < fuzz:129 return vi130 # Not found131 return None132def get_intel_registry_value(valuename, version=None, abi=None):133 """134 Return a value from the Intel compiler registry tree. (Windows only)135 """136 # Open the key:137 if is_win64:138 K = 'Software\\Wow6432Node\\Intel\\Compilers\\C++\\' + version + '\\'+abi.upper()139 else:140 K = 'Software\\Intel\\Compilers\\C++\\' + version + '\\'+abi.upper()141 try:142 k = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE, K)143 except SCons.Util.RegError:144 raise MissingRegistryError, \145 "%s was not found in the registry, for Intel compiler version %s, abi='%s'"%(K, version,abi)146 # Get the value:147 try:148 v = SCons.Util.RegQueryValueEx(k, valuename)[0]149 return v # or v.encode('iso-8859-1', 'replace') to remove unicode?150 except SCons.Util.RegError:151 raise MissingRegistryError, \152 "%s\\%s was not found in the registry."%(K, valuename)153def get_all_compiler_versions():154 """Returns a sorted list of strings, like "70" or "80" or "9.0"155 with most recent compiler version first.156 """157 versions=[]158 if is_windows:159 if is_win64:160 keyname = 'Software\\WoW6432Node\\Intel\\Compilers\\C++'161 else:162 keyname = 'Software\\Intel\\Compilers\\C++'163 try:164 k = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE,165 keyname)166 except WindowsError:167 return []168 i = 0169 versions = []170 try:171 while i < 100:172 subkey = SCons.Util.RegEnumKey(k, i) # raises EnvironmentError173 # Check that this refers to an existing dir.174 # This is not 100% perfect but should catch common175 # installation issues like when the compiler was installed176 # and then the install directory deleted or moved (rather177 # than uninstalling properly), so the registry values178 # are still there.179 ok = False180 for try_abi in ('IA32', 'IA32e', 'IA64', 'EM64T'):181 try:182 d = get_intel_registry_value('ProductDir', subkey, try_abi)183 except MissingRegistryError:184 continue # not found in reg, keep going185 if os.path.exists(d): ok = True186 if ok:187 versions.append(subkey)188 else:189 try:190 # Registry points to nonexistent dir. Ignore this191 # version.192 value = get_intel_registry_value('ProductDir', subkey, 'IA32')193 except MissingRegistryError, e:194 # Registry key is left dangling (potentially195 # after uninstalling).196 print \197 "scons: *** Ignoring the registry key for the Intel compiler version %s.\n" \198 "scons: *** It seems that the compiler was uninstalled and that the registry\n" \199 "scons: *** was not cleaned up properly.\n" % subkey200 else:201 print "scons: *** Ignoring "+str(value)202 i = i + 1203 except EnvironmentError:204 # no more subkeys205 pass206 elif is_linux:207 for d in glob.glob('/opt/intel_cc_*'):208 # Typical dir here is /opt/intel_cc_80.209 m = re.search(r'cc_(.*)$', d)210 if m:211 versions.append(m.group(1))212 for d in glob.glob('/opt/intel/cc*/*'):213 # Typical dir here is /opt/intel/cc/9.0 for IA32,214 # /opt/intel/cce/9.0 for EMT64 (AMD64)215 m = re.search(r'([0-9.]+)$', d)216 if m:217 versions.append(m.group(1))218 elif is_mac:219 for d in glob.glob('/opt/intel/cc*/*'):220 # Typical dir here is /opt/intel/cc/9.0 for IA32,221 # /opt/intel/cce/9.0 for EMT64 (AMD64)222 m = re.search(r'([0-9.]+)$', d)223 if m:224 versions.append(m.group(1))225 versions = uniquify(versions) # remove dups226 versions.sort(vercmp)227 return versions228def get_intel_compiler_top(version, abi):229 """230 Return the main path to the top-level dir of the Intel compiler,231 using the given version.232 The compiler will be in <top>/bin/icl.exe (icc on linux),233 the include dir is <top>/include, etc.234 """235 if is_windows:236 if not SCons.Util.can_read_reg:237 raise NoRegistryModuleError, "No Windows registry module was found"238 top = get_intel_registry_value('ProductDir', version, abi)239 if not os.path.exists(os.path.join(top, "Bin", "icl.exe")):240 raise MissingDirError, \241 "Can't find Intel compiler in %s"%(top)242 elif is_mac or is_linux:243 # first dir is new (>=9.0) style, second is old (8.0) style.244 dirs=('/opt/intel/cc/%s', '/opt/intel_cc_%s')245 if abi == 'x86_64':246 dirs=('/opt/intel/cce/%s',) # 'e' stands for 'em64t', aka x86_64 aka amd64247 top=None248 for d in dirs:249 if os.path.exists(os.path.join(d%version, "bin", "icc")):250 top = d%version251 break252 if not top:253 raise MissingDirError, \254 "Can't find version %s Intel compiler in %s (abi='%s')"%(version,top, abi)255 return top256def generate(env, version=None, abi=None, topdir=None, verbose=0):257 """Add Builders and construction variables for Intel C/C++ compiler258 to an Environment.259 args:260 version: (string) compiler version to use, like "80"261 abi: (string) 'win32' or whatever Itanium version wants262 topdir: (string) compiler top dir, like263 "c:\Program Files\Intel\Compiler70"264 If topdir is used, version and abi are ignored.265 verbose: (int) if >0, prints compiler version used.266 """267 if not (is_mac or is_linux or is_windows):268 # can't handle this platform269 return270 if is_windows:271 SCons.Tool.msvc.generate(env)272 elif is_linux:273 SCons.Tool.gcc.generate(env)274 elif is_mac:275 SCons.Tool.gcc.generate(env)276 # if version is unspecified, use latest277 vlist = get_all_compiler_versions()278 if not version:279 if vlist:280 version = vlist[0]281 else:282 # User may have specified '90' but we need to get actual dirname '9.0'.283 # get_version_from_list does that mapping.284 v = get_version_from_list(version, vlist)285 if not v:286 raise SCons.Errors.UserError, \287 "Invalid Intel compiler version %s: "%version + \288 "installed versions are %s"%(', '.join(vlist))289 version = v290 # if abi is unspecified, use ia32291 # alternatives are ia64 for Itanium, or amd64 or em64t or x86_64 (all synonyms here)292 abi = check_abi(abi)293 if abi is None:294 if is_mac or is_linux:295 # Check if we are on 64-bit linux, default to 64 then.296 uname_m = os.uname()[4]297 if uname_m == 'x86_64':298 abi = 'x86_64'299 else:300 abi = 'ia32'301 else:302 if is_win64:303 abi = 'em64t'304 else:305 abi = 'ia32'306 if version and not topdir:307 try:308 topdir = get_intel_compiler_top(version, abi)309 except (SCons.Util.RegError, IntelCError):310 topdir = None311 if not topdir:312 # Normally this is an error, but it might not be if the compiler is313 # on $PATH and the user is importing their env.314 class ICLTopDirWarning(SCons.Warnings.Warning):315 pass316 if (is_mac or is_linux) and not env.Detect('icc') or \317 is_windows and not env.Detect('icl'):318 SCons.Warnings.enableWarningClass(ICLTopDirWarning)319 SCons.Warnings.warn(ICLTopDirWarning,320 "Failed to find Intel compiler for version='%s', abi='%s'"%321 (str(version), str(abi)))322 else:323 # should be cleaned up to say what this other version is324 # since in this case we have some other Intel compiler installed325 SCons.Warnings.enableWarningClass(ICLTopDirWarning)326 SCons.Warnings.warn(ICLTopDirWarning,327 "Can't find Intel compiler top dir for version='%s', abi='%s'"%328 (str(version), str(abi)))329 if topdir:330 if verbose:331 print "Intel C compiler: using version %s (%g), abi %s, in '%s'"%\332 (repr(version), linux_ver_normalize(version),abi,topdir)333 if is_linux:334 # Show the actual compiler version by running the compiler.335 os.system('%s/bin/icc --version'%topdir)336 if is_mac:337 # Show the actual compiler version by running the compiler.338 os.system('%s/bin/icc --version'%topdir)339 env['INTEL_C_COMPILER_TOP'] = topdir340 if is_linux:341 paths={'INCLUDE' : 'include',342 'LIB' : 'lib',343 'PATH' : 'bin',344 'LD_LIBRARY_PATH' : 'lib'}345 for p in paths.keys():346 env.PrependENVPath(p, os.path.join(topdir, paths[p]))347 if is_mac:348 paths={'INCLUDE' : 'include',349 'LIB' : 'lib',350 'PATH' : 'bin',351 'LD_LIBRARY_PATH' : 'lib'}352 for p in paths.keys():353 env.PrependENVPath(p, os.path.join(topdir, paths[p]))354 if is_windows:355 # env key reg valname default subdir of top356 paths=(('INCLUDE', 'IncludeDir', 'Include'),357 ('LIB' , 'LibDir', 'Lib'),358 ('PATH' , 'BinDir', 'Bin'))359 # We are supposed to ignore version if topdir is set, so set360 # it to the emptry string if it's not already set.361 if version is None:362 version = ''363 # Each path has a registry entry, use that or default to subdir364 for p in paths:365 try:366 path=get_intel_registry_value(p[1], version, abi)367 # These paths may have $(ICInstallDir)368 # which needs to be substituted with the topdir.369 path=path.replace('$(ICInstallDir)', topdir + os.sep)370 except IntelCError:371 # Couldn't get it from registry: use default subdir of topdir372 env.PrependENVPath(p[0], os.path.join(topdir, p[2]))373 else:374 env.PrependENVPath(p[0], string.split(path, os.pathsep))375 # print "ICL %s: %s, final=%s"%(p[0], path, str(env['ENV'][p[0]]))376 if is_windows:377 env['CC'] = 'icl'378 env['CXX'] = 'icl'379 env['LINK'] = 'xilink'380 else:381 env['CC'] = 'icc'382 env['CXX'] = 'icpc'383 # Don't reset LINK here;384 # use smart_link which should already be here from link.py.385 #env['LINK'] = '$CC'386 env['AR'] = 'xiar'387 env['LD'] = 'xild' # not used by default388 # This is not the exact (detailed) compiler version,389 # just the major version as determined above or specified390 # by the user. It is a float like 80 or 90, in normalized form for Linux391 # (i.e. even for Linux 9.0 compiler, still returns 90 rather than 9.0)392 if version:393 env['INTEL_C_COMPILER_VERSION']=linux_ver_normalize(version)394 if is_windows:395 # Look for license file dir396 # in system environment, registry, and default location.397 envlicdir = os.environ.get("INTEL_LICENSE_FILE", '')398 K = ('SOFTWARE\Intel\Licenses')399 try:400 k = SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE, K)401 reglicdir = SCons.Util.RegQueryValueEx(k, "w_cpp")[0]402 except (AttributeError, SCons.Util.RegError):403 reglicdir = ""404 defaultlicdir = r'C:\Program Files\Common Files\Intel\Licenses'405 licdir = None406 for ld in [envlicdir, reglicdir]:407 # If the string contains an '@', then assume it's a network408 # license (port@system) and good by definition.409 if ld and (string.find(ld, '@') != -1 or os.path.exists(ld)):410 licdir = ld411 break412 if not licdir:413 licdir = defaultlicdir414 if not os.path.exists(licdir):415 class ICLLicenseDirWarning(SCons.Warnings.Warning):416 pass417 SCons.Warnings.enableWarningClass(ICLLicenseDirWarning)418 SCons.Warnings.warn(ICLLicenseDirWarning,419 "Intel license dir was not found."420 " Tried using the INTEL_LICENSE_FILE environment variable (%s), the registry (%s) and the default path (%s)."421 " Using the default path as a last resort."422 % (envlicdir, reglicdir, defaultlicdir))423 env['ENV']['INTEL_LICENSE_FILE'] = licdir424def exists(env):425 if not (is_mac or is_linux or is_windows):426 # can't handle this platform427 return 0428 try:429 versions = get_all_compiler_versions()430 except (SCons.Util.RegError, IntelCError):431 versions = None432 detected = versions is not None and len(versions) > 0433 if not detected:434 # try env.Detect, maybe that will work435 if is_windows:436 return env.Detect('icl')437 elif is_linux:438 return env.Detect('icc')439 elif is_mac:440 return env.Detect('icc')441 return detected442# end of file443# Local Variables:444# tab-width:4445# indent-tabs-mode:nil446# End:...
Tools.py
Source:Tools.py
...19 @staticmethod20 def is_windows():21 return 'Windows' in PlatformHolder.PLATFORM_NAME22 @staticmethod23 def is_mac():24 return 'Darwin' in PlatformHolder.PLATFORM_NAME25 @staticmethod26 def is_linux():27 return 'Linux' in PlatformHolder.PLATFORM_NAME28def set_title(title):29 if PlatformHolder.is_mac():30 os.system("osascript -e 'tell application \"Terminal\" to set custom title of front window to \"%s\"'" % title)31def get_title():32 if PlatformHolder.is_mac():33 name = call("osascript -e 'tell application \"Terminal\" to get custom title of front window'")34 if len(name) > 0:35 name = str(name[0]).strip()36 return name37def close_terminal_window(title):38 if PlatformHolder.is_mac():39 os.system("osascript -e 'tell application \"Terminal\" to close (every window whose custom title is \"%s\")'" % title)40def close_process(pid):41 if PlatformHolder.is_windows():42 pass43 else:44 os.system('kill -9 %s' % pid)45def call_terminal(arg):46 if PlatformHolder.is_windows():47 subprocess.call('start cmd /K %s' % arg, shell=True)48 else:49 os.system('open -a /Applications/Utilities/Terminal.app %s' % arg)50def call(*args):51 try:52 return subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True).communicate()53 except Exception as exc:54 return exc55def get_parent_id(pid):56 if not PlatformHolder.is_windows():57 result = call('ps -p %s -o ppid=' % pid)58 if len(result) > 0:59 return str(result[0]).strip()60def get_terminal_id():61 if not PlatformHolder.is_windows():62 return get_parent_id(get_parent_id(get_parent_id(os.getppid())))63def get_address_local():64 for interface_name in get_interfaces():65 interface = get_interface(interface_name)66 if PlatformHolder.is_windows():67 net = interface.get('IP Address')68 elif PlatformHolder.is_mac():69 net = interface.get('inet')70 else:71 net = interface.get('inet addr')72 if net and net.startswith('127.'):73 return net74def get_address():75 net = None76 for interface_name in get_interfaces():77 interface = get_interface(interface_name)78 if PlatformHolder.is_windows():79 net = interface.get('IP Address')80 elif PlatformHolder.is_mac():81 if interface.get('status') == 'active':82 net = interface.get('inet')83 else:84 i = interface.get('inet addr')85 if i and not i.startswith('127.'):86 net = interface.get('inet addr')87 if net:88 return net89def get_interfaces():90 if PlatformHolder.is_windows():91 interfaces = subprocess.check_output('netsh interface show interface', shell=True).split('\n')[3:]92 return [item.split(' ')[-1].strip() for item in interfaces if item.strip() != '']93 elif PlatformHolder.is_mac():94 return subprocess.check_output('ifconfig -lu', shell=True).split(' ')95 else:96 interfaces = subprocess.check_output('ifconfig -s', shell=True).split('\n')[1:]97 return [item.split(' ')[0].strip() for item in interfaces]98def get_interface(interface_name):99 interface = {'name': interface_name}100 if PlatformHolder.is_windows():101 items = subprocess.check_output('netsh interface ip show addresses "%s"' % interface_name, shell=True).split('\n')102 items = [item.strip().split(':') for item in items[2:] if item.strip() != '']103 for item in items:104 try:105 interface.update({item[0].strip(): item[1].strip()})106 except IndexError:107 pass108 elif PlatformHolder.is_mac():109 for line in subprocess.check_output('ifconfig %s' % interface_name, shell=True).split('\n'):110 if '\t' in line:111 line = line.replace('\t', '')112 line = line.split(' ', 1)113 if len(line) > 1:114 items = str(line[1]).split(' ')115 interface.update({line[0].replace(':', '').strip(): items[0].strip()})116 count = 0117 for index in range(0, len(items)):118 try:119 interface.update({items[count].strip(): items[count + 1].strip()})120 except IndexError:121 pass122 count += 2123 else:124 items = subprocess.check_output('ifconfig %s | grep "Link\|inet"' % interface_name, shell=True).split('\n')125 items = [item.strip().split(':', 1) for item in items]126 for item in items:127 if item[0] and item[-1]:128 interface[item[0]] = item[-1].split(' ')[0].strip()129 return interface130def route_path():131 """132 Change the os directory to the current site.133 """134 os.chdir(up_path(get_path()))135def new_window_path():136 return '%s/new-window.command' % up_path(up_path(get_path()))137def up_path(path):138 return os.path.abspath(os.path.join(path, os.pardir))139def get_path():140 return os.path.realpath(inspect.getfile(inspect.currentframe()))141def clear_screen():142 """143 Clear the terminal/cmd screen.144 """145 if PlatformHolder.is_windows():146 os.system('cls')147 else:148 os.system('clear')149def terminate():150 """151 Destroy all pythons.152 """153 if PlatformHolder.is_windows():154 os.system('taskkill -f -im python.exe')155 else:156 os.system('sudo pkill -9 Python')157def get_epoch(date):158 return int(time.mktime(time.strptime(str(date), '%Y-%m-%d %H:%M:%S')))159def human_time(epoch=time.time()):160 """161 Return a human readable epoch.162 :param epoch:163 """164 return time.strftime("%a, %d %b %Y %I:%M:%S %p", time.localtime(epoch))165def human_gmt_time(epoch=time.time()):166 """167 Return a human readable epoch.168 :param epoch:169 """170 return time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(epoch))171def split_extension(filename):172 """173 Returns the name, ext of the given filename.174 :param filename: filename to split175 """176 name, ext = os.path.splitext(filename)177 ext = ext.replace(".", "")178 return name, ext179def get_files(path):180 """181 Parses through a directory and finds all files.182 :rtype : list183 :param path: path to parent of the files184 """185 try:186 return [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f)) and not f.startswith('.')]187 except OSError:188 return []189def applications():190 if os.path.isdir("/Applications"):191 return os.listdir("/Applications")192 return []193def open_in_browser(browser, url):194 if PlatformHolder.is_mac():195 if not browser:196 browser = 'Safari'197 for app in applications():198 if app.lower().find(browser.lower()) != -1:199 subprocess.call(["open", "-a", app, url])200 elif PlatformHolder.is_windows():201 if not browser:202 browser = 'iexplore'...
vscode.py
Source:vscode.py
1from talon import Context, actions, ui, Module, app, clip2from typing import List, Union3is_mac = app.platform == "mac"4ctx = Context()5mod = Module()6mod.apps.vscode = "app.name: Code.exe"7mod.apps.vscode = "app.name: Visual Studio Code"8mod.apps.vscode = "app.name: Code"9mod.apps.vscode = "app.name: Code - OSS"10ctx.matches = r"""11app: vscode12"""13@ctx.action_class("win")14class win_actions:15 def filename():16 title = actions.win.title()17 # this doesn't seem to be necessary on VSCode for Mac18 # if title == "":19 # title = ui.active_window().doc20 if is_mac:21 result = title.split(" â ")[0]22 else:23 result = title.split(" - ")[0]24 if "." in result:25 return result26 return ""27 def file_ext():28 return actions.win.filename().split(".")[-1]29@ctx.action_class("edit")30class edit_actions:31 def find(text: str):32 if is_mac:33 actions.key("cmd-f")34 else:35 actions.key("ctrl-f")36 actions.insert(text)37 def line_swap_up():38 actions.key("alt-up")39 def line_swap_down():40 actions.key("alt-down")41 def line_clone():42 actions.key("shift-alt-down")43 def jump_line(n: int):44 actions.user.vscode("workbench.action.gotoLine")45 actions.insert(str(n))46 actions.key("enter")47@mod.action_class48class Actions:49 def vscode(command: str):50 """Execute command via command palette. Preserves the clipboard."""51 # Clip is noticeably faster than insert52 if not is_mac:53 actions.key("ctrl-shift-p")54 else:55 actions.key("cmd-shift-p")56 actions.user.paste(f"{command}")57 actions.key("enter")58 def vscode_ignore_clipboard(command: str):59 """Execute command via command palette. Does NOT preserve the clipboard for commands like copyFilePath"""60 clip.set_text(f"{command}")61 if not is_mac:62 actions.key("ctrl-shift-p")63 else:64 actions.key("cmd-shift-p")65 actions.edit.paste()66 actions.key("enter")67@ctx.action_class("user")68class user_actions:69 # snippet.py support beginHelp close70 def snippet_search(text: str):71 actions.user.vscode("Insert Snippet")72 actions.insert(text)73 def snippet_insert(text: str):74 """Inserts a snippet"""75 actions.user.vscode("Insert Snippet")76 actions.insert(text)77 actions.key("enter")78 def snippet_create():79 """Triggers snippet creation"""80 actions.user.vscode("Preferences: Configure User Snippets")81 # snippet.py support end82 def tab_jump(number: int):83 if number < 10:84 if is_mac:85 actions.key("ctrl-{}".format(number))86 else:87 actions.key("alt-{}".format(number))88 def tab_final():89 if is_mac:90 actions.key("ctrl-0")91 else:92 actions.key("alt-0")93 # splits.py support begin94 def split_number(index: int):95 """Navigates to a the specified split"""96 if index < 9:97 if is_mac:98 actions.key("cmd-{}".format(index))99 else:100 actions.key("ctrl-{}".format(index))101 # splits.py support end102 # find_and_replace.py support begin103 def find(text: str):104 """Triggers find in current editor"""105 if is_mac:106 actions.key("cmd-f")107 else:108 actions.key("ctrl-f")109 if text:110 actions.insert(text)111 def find_next():112 actions.key("enter")113 def find_previous():114 actions.key("shift-enter")115 def find_everywhere(text: str):116 """Triggers find across project"""117 if is_mac:118 actions.key("cmd-shift-f")119 else:120 actions.key("ctrl-shift-f")121 if text:122 actions.insert(text)123 def find_toggle_match_by_case():124 """Toggles find match by case sensitivity"""125 if is_mac:126 actions.key("alt-cmd-c")127 else:128 actions.key("alt-c")129 def find_toggle_match_by_word():130 """Toggles find match by whole words"""131 if is_mac:132 actions.key("cmd-alt-w")133 else:134 actions.key("alt-w")135 def find_toggle_match_by_regex():136 """Toggles find match by regex"""137 if is_mac:138 actions.key("cmd-alt-r")139 else:140 actions.key("alt-r")141 def replace(text: str):142 """Search and replaces in the active editor"""143 if is_mac:144 actions.key("alt-cmd-f")145 else:146 actions.key("ctrl-h")147 if text:148 actions.insert(text)149 def replace_everywhere(text: str):150 """Search and replaces in the entire project"""151 if is_mac:152 actions.key("cmd-shift-h")153 else:154 actions.key("ctrl-shift-h")155 if text:156 actions.insert(text)157 def replace_confirm():158 """Confirm replace at current position"""159 if is_mac:160 actions.key("shift-cmd-1")161 else:162 actions.key("ctrl-shift-1")163 def replace_confirm_all():164 """Confirm replace all"""165 if is_mac:166 actions.key("cmd-enter")167 else:168 actions.key("ctrl-alt-enter")169 def select_previous_occurrence(text: str):170 actions.edit.find(text)171 actions.sleep("100ms")172 actions.key("shift-enter esc")173 def select_next_occurrence(text: str):174 actions.edit.find(text)175 actions.sleep("100ms")176 actions.key("esc")...
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!