Best Python code snippet using behave
utility_grid.py
Source:utility_grid.py
...4"""5from dash import html, dcc6import dash_bootstrap_components as dbc7from utilities import make_link, make_listgroup_item, dbc_url8def make_row(example_class_name):9 return dbc.Row(10 [11 dbc.Col(html.Div(example_class_name, className="bg-light")),12 dbc.Col(html.Div(example_class_name, className="bg-light")),13 dbc.Col(html.Div(example_class_name, className="bg-light")),14 ],15 className=example_class_name + " my-2 border border-danger",16 )17gx_size_code = """18Note: To help show the spacing: 19- The `Container` has `className="bg-secondary"` 20- Each `Row` also has `className=" my-2 border border-danger"` 21- The `Col` content has `className="bg-light"`22 23```24def make_row(example_class_name):25 return dbc.Row(26 [27 dbc.Col(html.Div(example_class_name, className="bg-light")),28 dbc.Col(html.Div(example_class_name, className="bg-light")),29 dbc.Col(html.Div(example_class_name, className="bg-light")),30 ],31 className=example_class_name + " my-2 border border-danger",32 )33 34gx_size_preview = dbc.Container(35 [36 make_row("default"),37 make_row("gx-0"),38 make_row("gx-1"),39 make_row("gx-2"),40 make_row("gx-3"),41 make_row("gx-4"),42 make_row("gx-5"),43 ],44 fluid=True,45 className="bg-secondary",46)47```"""48gx_size_preview = dbc.Container(49 [50 make_row("default"),51 make_row("gx-0"),52 make_row("gx-1"),53 make_row("gx-2"),54 make_row("gx-3"),55 make_row("gx-4"),56 make_row("gx-5"),57 ],58 fluid=True,59 className="bg-secondary",60)61gy_size_code = """62Note: To help show the spacing: 63- The `Container` has `className="bg-secondary"` 64- Each `Row` also has `className=" my-2 border border-danger"` 65- The `Col` content has `className="bg-light"`66 67```68def make_row(example_class_name):69 return dbc.Row(70 [71 dbc.Col(html.Div(example_class_name, className="bg-light")),72 dbc.Col(html.Div(example_class_name, className="bg-light")),73 dbc.Col(html.Div(example_class_name, className="bg-light")),74 ],75 className=example_class_name + " my-2 border border-danger",76 )77gy_size_preview = dbc.Container(78 [79 make_row("default"),80 make_row("gy-0"),81 make_row("gy-1"),82 make_row("gy-2"),83 make_row("gy-3"),84 make_row("gy-4"),85 make_row("gy-5"),86 ],87 fluid=True,88 className="bg-secondary",89)90```"""91gy_size_preview = dbc.Container(92 [93 make_row("default"),94 make_row("gy-0"),95 make_row("gy-1"),96 make_row("gy-2"),97 make_row("gy-3"),98 make_row("gy-4"),99 make_row("gy-5"),100 ],101 fluid=True,102 className="bg-secondary",103)104g_size_code = """105Note: To help show the spacing: 106- The `Container` has `className="bg-secondary"` 107- Each `Row` also has `className=" my-2 border border-danger"` 108- The `Col` content has `className="bg-light"`109 110```111def make_row(example_class_name):112 return dbc.Row(113 [114 dbc.Col(html.Div(example_class_name, className="bg-light")),115 dbc.Col(html.Div(example_class_name, className="bg-light")),116 dbc.Col(html.Div(example_class_name, className="bg-light")),117 ],118 className=example_class_name + " my-2 border border-danger",119 )120g_size_preview = dbc.Container(121 [122 make_row("default"),123 make_row("g-0"),124 make_row("g-1"),125 make_row("g-2"),126 make_row("g-3"),127 make_row("g-4"),128 make_row("g-5"),129 ],130 fluid=True,131 className="bg-secondary",132)133```"""134g_size_preview = dbc.Container(135 [136 make_row("default"),137 make_row("g-0"),138 make_row("g-1"),139 make_row("g-2"),140 make_row("g-3"),141 make_row("g-4"),142 make_row("g-5"),143 ],144 fluid=True,145 className="bg-secondary",146)147gx_dev_size_code = """148Make responsive layouts by setting different gutters at breakpoints for device or viewport sizes: 149gx-{sm|md|lg|xl|xxl}-{0|1|2|3|4|5} 150```151gx_dev_size_preview = dbc.Container(152 [153 html.H5("Change the screen size to see how the gutters change"),154 dbc.Row(155 [156 dbc.Col(html.Div("col1", className="border bg-light")),...
login.py
Source:login.py
...13 """14 self.request = request15 self._ = request.getText16 self.cfg = request.cfg17 def make_row(self, label, cell, **kw):18 """ Create a row in the form table.19 """20 self._table.append(html.TR().extend([21 html.TD(**kw).extend([html.B().append(label), ' ']),22 html.TD().extend(cell),23 ]))24 def asHTML(self):25 """ Create the complete HTML form code. """26 _ = self._27 request = self.request28 action = "%s%s" % (request.script_root, request.path)29 hints = []30 for authm in request.cfg.auth:31 hint = authm.login_hint(request)32 if hint:33 hints.append(hint)34 self._form = html.FORM(action=action, name="loginform", id="loginform")35 self._table = html.TABLE(border="0")36 # Use the user interface language and direction37 lang_attr = request.theme.ui_lang_attr()38 self._form.append(html.Raw('<div class="userpref"%s>' % lang_attr))39 self._form.append(html.INPUT(type="hidden", name="action", value="login"))40 self._form.append(self._table)41 for hint in hints:42 self._form.append(html.P().append(html.Raw(hint)))43 self._form.append(html.Raw("</div>"))44 cfg = request.cfg45 if 'username' in cfg.auth_login_inputs:46 self.make_row(_('Name'), [47 html.INPUT(48 type="text", size="32", name="name",49 ),50 ])51 if 'password' in cfg.auth_login_inputs:52 self.make_row(_('Password'), [53 html.INPUT(54 type="password", size="32", name="password",55 ),56 ])57 # Restrict type of input available for OpenID input58 # based on wiki configuration.59 if 'openid_identifier' in cfg.auth_login_inputs:60 if len(cfg.openidrp_allowed_op) == 1:61 self.make_row(_('OpenID'), [62 html.INPUT(63 type="hidden", name="openid_identifier",64 value=cfg.openidrp_allowed_op[0]65 ),66 ])67 elif len(cfg.openidrp_allowed_op) > 1:68 op_select = html.SELECT(name="openid_identifier",69 id="openididentifier")70 for op_uri in cfg.openidrp_allowed_op:71 op_select.append(html.OPTION(value=op_uri).append(72 html.Raw(op_uri)))73 self.make_row(_('OpenID'), [op_select, ])74 else:75 self.make_row(_('OpenID'), [76 html.INPUT(77 type="text", size="32", name="openid_identifier",78 id="openididentifier"79 ),80 ])81 # Need both hidden field and submit values for auto-submit to work82 self.make_row('', [83 html.INPUT(type="hidden", name="login", value=_('Login')),84 html.INPUT(85 type="submit", name='login', value=_('Login')86 ),87 ])88 # Automatically submit the form if only a single OpenID Provider is allowed89 if 'openid_identifier' in cfg.auth_login_inputs and len(cfg.openidrp_allowed_op) == 1:90 self._form.append("""<script type="text/javascript">91<!--//92document.getElementById("loginform").submit();93//-->94</script>95""")96 return unicode(self._form)...
UserRegister.py
Source:UserRegister.py
...48 self._form.append(html.Raw('<div class="userpref"%s>' % lang_attr))49 self._form.append(html.INPUT(type="hidden", name="action", value="userregister"))50 self._form.append(self._table)51 self._form.append(html.Raw("</div>"))52 def make_row(self, label, cell, **kw):53 """ Create a row in the form table.54 """55 self._table.append(html.TR().extend([56 html.TD(**kw).extend([html.B().append(label), ' ']),57 html.TD().extend(cell),58 ]))59 def asHTML(self):60 """ Create the complete HTML form code. """61 _ = self._62 self.make_form()63 #register interface64 buttons = [65 # IMPORTANT: login should be first to be the default66 # button when a user click enter.67 ('login', _('Create New Account')),68 ]69 70 self.make_row(_('Name'), [71 html.INPUT(72 type="text", size="36", name="username", value="NewUser"73 ),74 ' ', _('(Use FirstnameLastname)', formatted=False),75 ])76 self.make_row(_('Password'), [77 html.INPUT(78 type="password", size="36", name="password",79 ),80 ' ', 81 ])82 self.make_row(_('Password repeat'), [83 html.INPUT(84 type="password", size="36", name="password2",85 ),86 ' ', _('(Only when changing passwords)'),87 ])88 self.make_row(_('Email'), [89 html.INPUT(90 type="text", size="36", name="email", value=""91 ),92 ' ',93 ])94 # Add buttons95 button_cell = []96 for name, label in buttons:97 button_cell.extend([98 html.INPUT(type="submit", name=name, value=label),99 ' ',100 ])101 self.make_row('', button_cell)102 103 return unicode(self._form)104def execute(macro, arguments):105 answer = UserRegisterForm(macro.request).asHTML()...
create_images.py
Source:create_images.py
1import Image2import cPickle3import numpy as np4import matplotlib.pyplot as plt5def make_row(data, num_cols):6 row = []7 for c in range(num_cols):8 im = data[c]9 if im.shape[-1] == 1:10 cmap = plt.cm.get_cmap()11 # if renormalize:12 # distrib[b] /= (np.max(distrib[b]) + 1e-6)13 im = cmap(np.squeeze(im))[:, :, :3]14 im = (im * 255).astype(np.uint8)15 im = np.pad(im,[(5,5), (5,5),(0,0)], 'constant', constant_values=[(255,255), (255,255),(0,0)])16 row.append(im)17 row = np.concatenate(row,axis=1)18 return row19class ImageMethod():20 def __init__(self, file):21 dict = cPickle.load(open(file, "rb"))22 self.image0 = dict['image0']23 self.image0_mask0 = dict['image0_mask0']24 self.image0_mask1 = dict['image0_mask1']25 self.image1 = dict['image1']26 self.image1_only0 = dict['image1_only0']27 self.image1_only1 = dict['image1_only1']28 self.image1_mask0 = dict['image1_mask0']29 self.image1_mask1 = dict['image1_mask1']30 self.depth0 = dict['depth0']31 self.depth1 = dict['depth1']32 self.depth1_only0 = dict['depth1_only0']33 self.depth1_only1 = dict['depth1_only1']34 self.gen_image1 = dict['gen_image1']35 self.gen_image1_only0 = dict['gen_image1_only0']36 self.gen_image1_only1 = dict['gen_image1_only1']37 self.gen_image1_mask0 = dict['gen_image1_mask0']38 self.gen_image1_mask1 = dict['gen_image1_mask1']39 self.gen_depth1 = dict['gen_depth1']40 self.gen_depth1_only0 = dict['gen_depth1_only0']41 self.gen_depth1_only1 = dict['gen_depth1_only1']42def create_images():43 imrows = []44 data1 = ImageMethod('/home/frederik/Documents/catkin_ws/src/dynamic_multiview_3d/tensorflowdata/multi_obj/fully_conv/modeldata/imgdata.pkl')45 data2 = ImageMethod('/home/frederik/Documents/catkin_ws/src/dynamic_multiview_3d/tensorflowdata/multi_obj/col_d_masks_combimg_sepimage/modeldata/imgdata.pkl')46 num_cols = 1047 imrows.append(make_row(data1.image0, num_cols))48 imrows.append(make_row(data1.image0_mask0, num_cols))49 imrows.append(make_row(data1.image0_mask1, num_cols))50 imrows.append(make_row(data1.gen_image1, num_cols))51 imrows.append(make_row(data1.gen_depth1, num_cols))52 imrows.append(make_row(data2.gen_image1, num_cols))53 imrows.append(make_row(data2.gen_depth1, num_cols))54 imrows.append(make_row(data1.image1, num_cols))55 imrows.append(make_row(data1.depth1, num_cols))56 image = np.concatenate(imrows, axis=0)57 file = '/home/frederik/Documents/catkin_ws/src/dynamic_multiview_3d/tensorflowdata/multi_obj/out_images/comp1.png'58 Image.fromarray(image).save(file)59if __name__ == '__main__':...
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!!