Best Python code snippet using fMBT_python
BlockTree.py
Source:BlockTree.py
...280 menu = QMenu()281 menu.addAction(action)282 if menu.exec_(self.mapToGlobal(point)):283 self.copyBlock(block)284 def _dumpItem(self, output, item, level=0, sep=' '):285 """286 Dumps an item to a string.287 Input:288 output[StringIO]: Where to write to289 item[QTreeWidgetItem]: item to display290 level[int]: indent level291 sep[str]: indent string292 """293 b = self._item_block_map.get(item)294 output.write("%s%s: %s: %s\n" % (sep*level, item.text(0), b.star, item.checkState(0) == Qt.Checked))295 child_count = item.childCount()296 for i in range(child_count):297 child = item.child(i)298 self._dumpItem(output, child, level+1, sep)299 def dumpTreeToString(self):300 """301 Dump the tree to a string.302 Return:303 str: A display of the current QTreeWidget304 """305 output = cStringIO.StringIO()306 for i in range(self.root_item.childCount()):307 child = self.root_item.child(i)308 self._dumpItem(output, child)309 return output.getvalue()310if __name__ == "__main__":311 from PyQt5.QtWidgets import QApplication, QMainWindow312 from InputTree import InputTree313 from ExecutableInfo import ExecutableInfo314 import sys315 if len(sys.argv) != 3:316 print("Usage: %s <exe> <input file>" % sys.argv[0])317 sys.exit(1)318 qapp = QApplication(sys.argv)319 main_win = QMainWindow()320 exe_info = ExecutableInfo()321 exe_info.setPath(sys.argv[1])322 tree = InputTree(exe_info)...
hdfview.py
Source:hdfview.py
...37 _fn += '.xdmf'38 _hyperx = self._blockx[2]39 _hypery = self._blocky[2]40 _hyperz = self._blockz[2]41 def _dumpItem(_moo, **kwargs):42 if 'text' in kwargs.keys():43 text = kwargs.pop('text')44 else:45 text = None46 _ret = ET.SubElement(_moo, 'DataItem', **kwargs)47 _ret.text = text48 return _ret49 def _dumpGeo(_moo):50 _ret = ET.SubElement(_moo, 'Geometry', GeometryType='VXVYVZ')51 _hyper = _dumpItem(_ret, 52 ItemType='HyperSlab',53 Dimensions='%i'%_hyperx54 )55 _dumpItem(_hyper,56 text = ''' 57 {} 58 {}59 {}'''.format(60 self._blockx[0],61 self._blockx[1],62 self._blockx[2]),63 Dimensions='3 1',64 Format = 'XML'65 )66 _dumpItem(_hyper,67 text= str(self._fn)+':/'+self._varx,68 Dimensions=str(self._sx),69 Precision="8",70 Format="HDF"71 )72 _hyper = _dumpItem(_ret, 73 ItemType='HyperSlab',74 Dimensions='%i'%_hypery75 )76 _dumpItem(_hyper,77 text = ''' 78 {} 79 {}80 {}'''.format(81 self._blocky[0],82 self._blocky[1],83 self._blocky[2]),84 Dimensions='3 1',85 Format = 'XML'86 )87 _dumpItem(_hyper,88 text= str(self._fn)+':/'+self._vary,89 Dimensions=str(self._sy),90 Precision="8",91 Format="HDF"92 )93 _hyper = _dumpItem(_ret, 94 ItemType='HyperSlab',95 Dimensions='%i'%_hyperz96 )97 _dumpItem(_hyper,98 text = ''' 99 {} 100 {}101 {}'''.format(102 self._blockz[0],103 self._blockz[1],104 self._blockz[2]),105 Dimensions='3 1',106 Format = 'XML'107 )108 _dumpItem(_hyper,109 text= str(self._fn)+':/'+self._varz,110 Dimensions=str(self._sz),111 Precision="8",112 Format="HDF"113 )114 return _ret115 def _dumpAttr(_moo, _var):116 _ret = ET.SubElement(_moo, "Attribute", Name=_var, AttributeType="Scalar", Center="Node")117 _shape = self._file[_var].shape118 _blockx = self._blockx[:]119 _blockx[0] += self._per[_var][1]120 _blocky = self._blocky[:]121 _blocky[0] += self._per[_var][0]122 _hyper = _dumpItem(_ret, ItemType="HyperSlab", Dimensions="{} {} {}".format(_hyperz, _hypery, _hyperx))123 _dumpItem(_hyper,124 text = ''' 125 {} {} {} 126 {} {} {}127 {} {} {}'''.format(128 self._blockz[0], _blocky[0], _blockx[0],129 self._blockz[1], _blocky[1], _blockx[1],130 self._blockz[2], _blocky[2], _blockx[2]),131 Dimensions = '3 3',132 Format = "XML")133 _dumpItem(_hyper,134 text = str(self._fn) + ':/' + _var,135 Dimensions = '{} {} {}'.format(_shape[0], _shape[1], _shape[2]),136 Precision = '8',137 Format = "HDF")138 return _ret139 # Output the Xdmf file140 _fn = Path(_fn).resolve().expanduser()141 # Start to generate the file142 _root = ET.Element('Xdmf', Version="2.0")143 _domain = ET.SubElement(_root, 'Domain')144 _grid = ET.SubElement(_domain, 'Grid', Name="Structured Grid", GridType="Uniform")145 # Topology146 ET.SubElement(_grid,147 "Topology",...
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!!