Best Python code snippet using fMBT_python
__init__.py
Source:__init__.py
1from __future__ import print_function, unicode_literals, absolute_import2import sys3success = True4in_ironpython = "IronPython" in sys.version5if in_ironpython:6 try:7 from .ironpython_clipboard import GetClipboardText, SetClipboardText8 except ImportError:9 from .no_clipboard import GetClipboardText, SetClipboardText10else:11 try:12 from .win32_clipboard import GetClipboardText, SetClipboardText13 except ImportError:14 from .no_clipboard import GetClipboardText, SetClipboardText15 16def send_data(lists):17 SetClipboardText(make_tab(lists))18 19def set_clipboard_text(toclipboard):20 SetClipboardText(str(toclipboard))21def make_tab(lists):22 if hasattr(lists, "tolist"):23 lists = lists.tolist()24 ut = []25 for rad in lists:26 if type(rad) in [list, tuple]:27 ut.append("\t".join(["%s"%x for x in rad]))28 else:29 ut.append("%s"%rad)30 return "\n".join(ut) 31 32def make_list_of_list(txt):33 def make_num(x):34 try:35 return int(x)36 except ValueError:37 try:38 return float(x)39 except ValueError:40 try:41 return complex(x)42 except ValueError:43 return x44 return x 45 ut = []46 flag = False47 for rad in [x for x in txt.split("\r\n") if x != ""]:48 raden=[make_num(x) for x in rad.split("\t")]49 if str in list(map(type,raden)):50 flag = True51 ut.append(raden)52 return ut, flag53def get_clipboard_text_and_convert(paste_list=False):54 """Get txt from clipboard. if paste_list==True the convert tab separated 55 data to list of lists. Enclose list of list in array() if all elements are 56 numeric"""57 txt = GetClipboardText()58 if txt:59 if paste_list and "\t" in txt:60 array, flag = make_list_of_list(txt)61 if flag:62 txt = repr(array)63 else:64 txt = "array(%s)"%repr(array)65 txt = "".join([c for c in txt if c not in " \t\r\n"])...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!