def jslint(files, fix = False, relax = False, fail = True): System.check_package('java') files = FileList.check(files) options = [] command = "" options.append('--jslint_error=optional_type_marker') options.append('--jslint_error=blank_lines_at_top_level') options.append('--jslint_error=indentation') # This covers jsdoctoolkit 2 tags = '--custom_jsdoc_tags=homepage,version,ignore,returns,example,function,requires,name,namespace,property,static,constant,default,location,copyright,memberOf,lends,fileOverview' # This covers jsdoc3 as well tags += ',module,abstract,file,kind,summary,description,event,exception,exports,fires,global,inner,instance,member,var,memberof,mixes,mixin,arg,argument,readonly,since,todo,public' options.append(tags) if fix == True: header = "Fix JS lint" command = "fixjsstyle %s %s " % ( ' '.join(options) , ' '.join(files)) else: header = "JS lint" command = "gjslint %s %s " % ( ' '.join(options) , ' '.join(files)) if relax == True: command += ' | grep -v "Line too long"' result = sh(command, header = "%s (%s files)" % (header, len(files)) ) error = re.search('Found\s([0-9]+)\serrors', result) if fail and error: console.fail( ' :puke:\n' + error.group())
def jslint(files, fix = False, relax = False, fail = True): System.check_package('java') files = FileList.check(files) options = [] command = "" options.append('--jslint_error=optional_type_marker') options.append('--jslint_error=blank_lines_at_top_level') options.append('--jslint_error=indentation') options.append('--custom_jsdoc_tags=homepage,version,ignore,returns,example,function,requires,name,namespace,property,static,constant,default,location,copyright,memberOf,lends,fileOverview') if fix == True: header = "Fix JS lint" command = "fixjsstyle %s %s " % ( ' '.join(options) , ' '.join(files)) else: header = "JS lint" command = "gjslint %s %s " % ( ' '.join(options) , ' '.join(files)) if relax == True: command += ' | grep -v "Line too long"' result = sh(command, header = "%s (%s files)" % (header, len(files)) ) error = re.search('Found\s([0-9]+)\serrors', result) if fail and error: console.fail( ' :puke:\n' + error.group())
def jsdoc3(files, destination, template = None, fail = True): System.check_package('java') files = FileList.check(files) redirect = '' if not template: template = "templates/gristaupe" if template == "templates/gristaupe": redirect = destination destination = "console" jsdoc = os.path.join(__get_datas_path(), 'jsdoc3') out = Std() output = sh('cd "%s"; java -classpath lib/js.jar org.mozilla.javascript.tools.shell.Main -debug -modules nodejs_modules -modules rhino_modules -modules . jsdoc.js\ --destination "%s" --template "%s" %s' % (jsdoc, destination, template, '"' + '" "'.join(files) + '"'), header = "Generating js doc v3", output = False, std = out) if fail and out.code: console.fail(out.err) if template == "templates/gristaupe": writefile(redirect, out.out); console.confirm(' JSON Doc generated in "%s"' % redirect) else: console.confirm(' JSON Doc generated in "%s"' % destination) return out.out
def bootstrap(): System.debug("Bootstrapping") config_file = globals.CONFIG_FOLDER + "/" + globals.SERVER_NAME + ".yml" f_config = open(config_file) config = yaml.safe_load(f_config) f_config.close() System.debug("Using port " + str(config["network"]["port"]))
def jsdoc(files, folder, template = None, fail = True): System.check_package('java') files = FileList.check(files) if not template: template = "%s/templates/gris_taupe" % jsdoc jsdoc = os.path.join(__get_datas_path(), 'jsdoc-toolkit') output = sh("java -jar %s/jsrun.jar %s/app/run.js -d=%s -t=%s -a %s" % (jsdoc, jsdoc, folder, template, ' '.join(files)), header = "Generating js doc", output = True) if fail and output: console.fail(output) console.confirm(' Doc generated in "%s"' % folder)
def create(self, path, python = "python", force = False): console.header(' * Creating env "%s" ...' % (path)) if not force and exists(os.path.join(path, 'bin', 'activate')): self.__path = path console.confirm(' Env "%s" already created. Use "force=True" to override it' % path) return True check = System.check_package('virtualenv') version = System.get_package_version(python) console.log(' Python version : %s ...' % version) result = sh("virtualenv -p %s %s --no-site-packages " % (python, path), header = False, output = False) console.debug(result) console.confirm(' Env "%s" created' % path) self.__path = path
def sphericalReflector() : # source ppos = [0,0,0] pdir = [0,0,1] s0 = Source("light source",Placement(ppos,pdir)) s0.exampleRays(0.04) # spherical reflector ppos = [0,0,0.20] pdir = [0,0,1] pdim = [0.05,0.05,0.01] sr = SphericalSurface("spherical", Volume.circ,pdim,Placement(ppos,pdir),Material(Material.mirror,1.0),-0.10) # plane stop ppos = [0,0,0.1] pdir = [0,0,-1] pdim = [0.05,0.05,0.01] ss = PlaneSurface("stop",Volume.circ,pdim,Placement(ppos,pdir),Material(Material.refract,1.0)) s = System() s.append(s0) s.append(sr) s.append(ss) r = s.propagate() d = Display3D.Display3D(s,r) d.Draw()
def minify(in_file, out_file = None, verbose=False): System.check_package('java') if not isinstance(in_file, str): raise Exception("Minify : single file only") if not out_file: out_file = in_file in_type = __get_ext(out_file) org_size = os.path.getsize(in_file) console.header('- Minifying %s (%.2f kB)' % (__pretty(in_file), org_size / 1024.0)) if in_type == 'js': __minify_js(in_file, out_file + '.tmp', verbose) else: __minify_css(in_file, out_file + '.tmp', verbose) copyfile(out_file + '.tmp', out_file) os.remove(out_file + '.tmp') new_size = os.path.getsize(out_file) #avoid division by zero if not new_size: console.fail('Compression fail') console.info(' ~ Original: %.2f kB' % (org_size / 1024.0)) console.info(' ~ Compressed: %.2f kB' % (new_size / 1024.0)) if not org_size: return console.confirm(' %s ( Reduction : %.1f%% )' % (out_file, (float(org_size - new_size) / org_size * 100)))
def test_pickling_exceptions(): exc = System.Exception("test") dumped = pickle.dumps(exc) loaded = pickle.loads(dumped) assert exc.args == loaded.args
try: x.NOT_SO_DYNAMIC = "0" Fail("TypeError should have been thrown!") except TypeError, e: self.assertEqual(e.message, "expected UInt64, got str") finally: self.assertEqual(x.NOT_SO_DYNAMIC, 3) #Make sure it's not a static property y = X() self.assertEqual(y.NOT_SO_DYNAMIC, 0) self.assertEqual(x.NOT_SO_DYNAMIC, 3) #As a .NET property self.assertEqual( x.GetType().GetProperty("NOT_SO_DYNAMIC").GetValue(x, None), 3) x.GetType().GetProperty("NOT_SO_DYNAMIC").SetValue( x, System.UInt64(4), None) self.assertEqual(x.NOT_SO_DYNAMIC, 4) self.assertEqual( x.GetType().GetProperty("NOT_SO_DYNAMIC").GetValue(x, None), 4) #WPF interop #TODO! #TODO:@skip("multiple_execute") def test_critical_parameterless_constructor(self): ''' Ensure that CSharp can new up a Python type that has a parameterless constructor. ''' global called import clr clr.AddReference("IronPythonTest")
print('') # Produce WAV: if o.reverse: # MP3 --> WAV cmnd = 'mpg123 -w "%s.wav" "%s"' % (baseout,f) else: # OGG --> WAV cmnd = 'oggdec "%s" -o "%s.wav"' % (f,baseout) if o.verbose: print(cmnd) if not o.dryrun: S.cli(cmnd) # Encode WAV to OGG or MP3: if o.reverse: # WAV --> OGG (and delete WAV) fmt = 'oggenc -q {0} "{1}.wav" -o "{1}.{2}" && rm -f "{1}.wav"' cmnd = fmt.format(o.quality, baseout, oext) else: # WAV --> MP2 (and delete WAV) cmnd = 'lame --vbr-new -V 0 "%s.wav" "%s.%s" && rm -f "%s.wav"' % (baseout,baseout,oext,baseout) if o.verbose: print(cmnd) if not o.dryrun:
def nonEmpty(self): print('登录失败!', System.func_name()) System.dialog(self, '错误', "用户名 / 密码不能为空!")
def SetText(self, text): self.label.Content = text self.window.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Render, System.Action(self.SizeUpdater))
def GetSupportedRevitFiles(batchRvtConfig): supportedRevitFileList = None revitFileListData = batchRvtConfig.ReadRevitFileListData(Output) if revitFileListData is not None: supportedRevitFileList = list( revit_file_list.SupportedRevitFileInfo(revitFilePathData) for revitFilePathData in revitFileListData) nonExistentRevitFileList = list( supportedRevitFileInfo for supportedRevitFileInfo in supportedRevitFileList if (not supportedRevitFileInfo.IsCloudModel() and not RevitFileExists(supportedRevitFileInfo))) supportedRevitFileList = list( supportedRevitFileInfo for supportedRevitFileInfo in supportedRevitFileList if (supportedRevitFileInfo.IsCloudModel() or RevitFileExists(supportedRevitFileInfo))) unsupportedRevitFileList = list( supportedRevitFileInfo for supportedRevitFileInfo in supportedRevitFileList if not HasAllowedRevitVersion(batchRvtConfig, supportedRevitFileInfo)) unsupportedRevitFilePathRevitFileList = list( supportedRevitFileInfo for supportedRevitFileInfo in supportedRevitFileList if (not supportedRevitFileInfo.IsCloudModel() and not HasSupportedRevitFilePath(supportedRevitFileInfo))) supportedRevitFileList = list( supportedRevitFileInfo for supportedRevitFileInfo in supportedRevitFileList if ((supportedRevitFileInfo.IsCloudModel() or RevitFileExists(supportedRevitFileInfo)) and (HasAllowedRevitVersion(batchRvtConfig, supportedRevitFileInfo) ) and (supportedRevitFileInfo.IsCloudModel() or HasSupportedRevitFilePath(supportedRevitFileInfo))) ).OrderBy(lambda supportedRevitFileInfo: GetRevitFileSize( supportedRevitFileInfo) if not supportedRevitFileInfo.IsCloudModel( ) else System.Int64(0) # dummy file size value for Cloud models ).ToList() nonExistentCount = len(nonExistentRevitFileList) unsupportedCount = len(unsupportedRevitFileList) unsupportedRevitFilePathCount = len( unsupportedRevitFilePathRevitFileList) if nonExistentCount > 0: Output() Output("WARNING: The following Revit Files do not exist (" + str(nonExistentCount) + "):") for supportedRevitFileInfo in nonExistentRevitFileList: batch_rvt_monitor_util.ShowSupportedRevitFileInfo( supportedRevitFileInfo, Output) if unsupportedCount > 0: Output() Output( "WARNING: The following Revit Files are of an unsupported version (" + str(unsupportedCount) + "):") for supportedRevitFileInfo in unsupportedRevitFileList: batch_rvt_monitor_util.ShowSupportedRevitFileInfo( supportedRevitFileInfo, Output) if unsupportedRevitFilePathCount > 0: Output() Output( "WARNING: The following Revit Files have an unsupported file path (" + str(unsupportedRevitFilePathCount) + "):") for supportedRevitFileInfo in unsupportedRevitFilePathRevitFileList: batch_rvt_monitor_util.ShowSupportedRevitFileInfo( supportedRevitFileInfo, Output) return supportedRevitFileList
0,a,0, 0,0,c, ] atoms=[ [ "A", m ], [ "B", m ], ] sites=[ [ 0,0,0, 0 ], [ a/s3,0,c/2, 1 ], ] bonds=[ [ 0,1, System.modAxial([ a/s3,0, c/2], 23.198000,[-2.576000,-2.576000,1.981000]) ], [ 1,0, System.modAxial([-a/s3,0,-c/2], 23.198000,[-2.576000,-2.576000,1.981000]) ], [ 0,0, System.modAxial([ 0, a,0], 11.793000,[ 2.374000, 2.374000, 1.525000]) ], [ 1,1, System.modAxial([ 0, a,0], 11.793000,[ 2.374000, 2.374000, 1.525000]) ], [ 0,1, System.modAxial([-2*a/s3,0, c/2], -9.944000,[ 2.284000, 2.284000, 1.981000]) ], [ 1,0, System.modAxial([ 2*a/s3,0,-c/2], -9.944000,[ 2.284000, 2.284000, 1.981000]) ], [ 0,0, System.modAxial([ 0,0,c], 0.00,[-0.622000,-0.622000,-0.610000]) ], [ 1,1, System.modAxial([ 0,0,c], 0.00,[-0.622000,-0.622000,-0.610000]) ], [ 0,1, System.modAxial([ 5*a/(2*s3), a/2, c/2], 3.557000,[ 0.539000, 0.539000,-0.648000]) ], [ 1,0, System.modAxial([-5*a/(2*s3),-a/2,-c/2], 3.557000,[ 0.539000, 0.539000,-0.648000]) ],
def test_builtin_attributes(self): import System def AssignMethodOfBuiltin(): def mylen(): pass l = list() l.len = mylen self.assertRaises(AttributeError, AssignMethodOfBuiltin) def DeleteMethodOfBuiltin(): l = list() del l.len self.assertRaises(AttributeError, DeleteMethodOfBuiltin) def SetAttrOfBuiltin(): l = list() l.attr = 1 self.assertRaises(AttributeError, SetAttrOfBuiltin) def SetDictElementOfBuiltin(): l = list() l.__dict__["attr"] = 1 self.assertRaises(AttributeError, SetDictElementOfBuiltin) def SetAttrOfCLIType(): d = System.DateTime() d.attr = 1 self.assertRaises(AttributeError, SetAttrOfCLIType) def SetDictElementOfCLIType(): d = System.DateTime() d.__dict__["attr"] = 1 self.assertRaises(AttributeError, SetDictElementOfCLIType) self.assertRaisesMessage(TypeError, "vars() argument must have __dict__ attribute", vars, list()) self.assertRaisesMessage(TypeError, "vars() argument must have __dict__ attribute", vars, System.DateTime())
def NewCharacter(): # (Line 10) const cp = getcurpl(); EUDTraceLog(10) cp = f_getcurpl() # (Line 11) setloc("temp", 322, 280); EUDTraceLog(11) f_setloc("temp", 322, 280) # (Line 12) bwrite(0x65FD00 + 18424 + v.unitNum[cp], 71); // 그래픽 시민 EUDTraceLog(12) f_bwrite(0x65FD00 + 18424 + v.unitNum[cp], 71) # (Line 13) bwrite(0x65FD00 + 14776 + cp, 130); // 무기 NONE EUDTraceLog(13) f_bwrite(0x65FD00 + 14776 + cp, 130) # (Line 14) if(sys.single == false) CenterView("temp"); _t1 = EUDIf() EUDTraceLog(14) if _t1(sys.single == False): # (Line 15) user.character[cp] = sys.SetNextUnitEPD(); EUDTraceLog(14) DoActions(CenterView("temp")) EUDEndIf() EUDTraceLog(15) _ARRW(user.character, cp) << (sys.SetNextUnitEPD()) # (Line 16) CreateUnit(1, v.unitNum[cp], "temp", cp); # (Line 18) user.inMap[cp] = 1; EUDTraceLog(16) DoActions(CreateUnit(1, v.unitNum[cp], "temp", cp)) EUDTraceLog(18) _ARRW(user.inMap, cp) << (1) # (Line 19) user.isAlive[cp] = 1; EUDTraceLog(19) _ARRW(user.isAlive, cp) << (1) # (Line 20) user.level[cp] = 1; EUDTraceLog(20) _ARRW(user.level, cp) << (1) # (Line 21) user.maxHP[cp] = v.defaultHP; EUDTraceLog(21) _ARRW(user.maxHP, cp) << (v.defaultHP) # (Line 22) user.maxMP[cp] = v.defaultMP; EUDTraceLog(22) _ARRW(user.maxMP, cp) << (v.defaultMP) # (Line 23) user.mp[cp] = v.defaultMP; EUDTraceLog(23) _ARRW(user.mp, cp) << (v.defaultMP) # (Line 24) user.physDmg[cp] = v.defaultDmg; EUDTraceLog(24) _ARRW(user.physDmg, cp) << (v.defaultDmg) # (Line 26) stats.SetHP(); EUDTraceLog(26) stats.SetHP() # (Line 27) sys.Heal(); EUDTraceLog(27) sys.Heal() # (Line 29) stats.RefreshExp(); EUDTraceLog(29) stats.RefreshExp() # (Line 30) SetMemoryXEPD(user.character[cp] + 0x08F / 4, SetTo, user.level[cp] << 24, 0xFF000000); # (Line 32) item.AddItem(10000, 2, 1, 1, false); EUDTraceLog(30) DoActions(SetMemoryXEPD(user.character[cp] + 0x08F // 4, SetTo, _LSH(user.level[cp],24), 0xFF000000)) EUDTraceLog(32) item.AddItem(10000, 2, 1, 1, False) # (Line 33) item.AddItem(10000, 3, 1, 1, false); EUDTraceLog(33) item.AddItem(10000, 3, 1, 1, False) # (Line 34) item.AddItem(10000, 1, 1, 1, false); EUDTraceLog(34) item.AddItem(10000, 1, 1, 1, False) # (Line 35) item.AddItem(10000, 1, 2, 2, false); EUDTraceLog(35) item.AddItem(10000, 1, 2, 2, False) # (Line 36) item.AddItem(10000, 1, 16, 3, false); EUDTraceLog(36) item.AddItem(10000, 1, 16, 3, False) # (Line 37) item.AddItem(10000, 1, 17, 4, false); EUDTraceLog(37) item.AddItem(10000, 1, 17, 4, False) # (Line 38) status.stats[cp] = status.USER_STATUS; EUDTraceLog(38) _ARRW(status.stats, cp) << (status.USER_STATUS) # (Line 39) user.posX[cp], user.posY[cp] = dwbreak(dwread_epd(user.character[cp] + 0x28 / 4))[[0,1]]; EUDTraceLog(39) _SV([_ARRW(user.posX, cp), _ARRW(user.posY, cp)], [_SRET(f_dwbreak(f_dwread_epd(user.character[cp] + 0x28 // 4)), [0, 1])]) # (Line 40) equip.EquipWeapon(1); EUDTraceLog(40) equip.EquipWeapon(1)
def test_class_default_repr(): """Test the default __repr__ implementation for managed objects.""" s = System.String("this is a test") assert repr(s).startswith("<System.String object")
polymers.append(poly) except Exception, e: logger.exception(e) fh.close() logger.removeHandler(fh) logger.removeHandler(ch) if np.any(params.box_grid_shape==0): logger.warning("\n> no box size information provided, skipping system generation...") fh.close() logger.removeHandler(fh) logger.removeHandler(ch) return if params.mode=="gromacs": logger.info("\n> generating system...\n") system=System(polymers,ff,params) system.create_system(mypath=folder) logger.info("\n> All done! Thank you for using Assemble! <") fh.close() logger.removeHandler(fh) logger.removeHandler(ch) if __name__=="__main__": #get database filename #infile="input_tmp" infile=str(sys.argv[2]) run(infile)
def test_class_default_str(): """Test the default __str__ implementation for managed objects.""" s = System.String("this is a test") assert str(s) == "this is a test"
def ToNetObj(data): import System import Latino import LatinoInterfaces #if hasattr(data, "netObj"): # return data.netObj if isinstance(data, LatinoObject): return data.load() if isinstance(data, dict): if not len(data): return System.Collections.Generic.Dictionary[System.Object, System.Object]() else: key = ToNetObj(data.keys()[0]) val = ToNetObj(data.values()[0]) for tryIndex in [0, 1]: try: if not tryIndex: d = System.Collections.Generic.Dictionary[type(key), type(val)]() else: d = System.Collections.Generic.Dictionary[ System.Object, System.Object]() for key, val in data.items(): k = ToNetObj(key) v = ToNetObj(val) d[k] = v return d except: pass return System.Object() if isinstance(data, list): if not len(data): return System.Collections.Generic.List[System.Object]() else: dataNet = ToNetObj(data[0]) for tryIndex in [0, 1]: try: if not tryIndex: l = System.Collections.Generic.List[type(dataNet)]() else: l = System.Collections.Generic.List[System.Object]() for i, val in enumerate(data): l.Add(ToNetObj(val)) return l except: pass return System.Object() if isinstance(data, tuple): if not len(data): return System.Collections.Generic.LinkedList[System.Object]() else: dataNet = ToNetObj(data[0]) for tryIndex in [0, 1]: try: if not tryIndex: a = System.Collections.Generic.LinkedList[type( dataNet)]() else: a = System.Collections.Generic.LinkedList[ System.Object]() for i, val in enumerate(data): a.AddLast(ToNetObj(val)) return a except: pass return System.Object() if MAP_TO_PYTHON_OBJECTS: if isinstance(data, Document): #name,text,annotations,features d = Latino.Workflows.TextMining.Document(data.name, data.text) latino_object_set_feature_values(d, data.features) d.AddAnnotations(ToNetObj(data.annotations)) return d elif isinstance(data, Annotation): a = Latino.Workflows.TextMining.Annotation(data.span_start, data.span_end, data.type) latino_object_set_feature_values(a, data.features) return a elif isinstance(data, DocumentCorpus): d = LatinoInterfaces.DocumentCorpus() d.AddRange(ToNetObj(data.documents)) latino_object_set_feature_values(d, data.features) return d elif isinstance(data, BowDataset): cx = data.sparse_bow_matrix.tocoo( ) #A sparse matrix in COOrdinate format. if data.labels and cx.shape[0] != len(data.labels): raise Exception( "Nekaj gnilega je v dezeli Danski, sporoci maticu.") sparse_vectors = [ Latino.SparseVector[System.Double]() for _ in range(cx.shape[0]) ] #empty SparseVectors for (i, j, v) in izip(cx.row, cx.col, cx.data): sparse_vectors[i][j] = v ds = Latino.Model.LabeledDataset[ System.String, Latino.SparseVector[System.Double]]() for i, ex in enumerate(sparse_vectors): label = data.labels[i] if data.labels else '' ds.Add(label, ex) return ds elif isinstance(data, DictionaryProbDist): p = Latino.Model.Prediction[System.Double]() genType = p.GetType().GetGenericTypeDefinition() KeyDats = [] for key, score in data._prob_dict.items(): KeyDats.append(Latino.KeyDat[System.Double, System.String](score, key)) aaa = Latino.ArrayList[Latino.KeyDat[System.Double, System.String]]( ToNetObj(KeyDats)) p.AddRange(Latino.ArrayList[Latino.KeyDat[System.Double, System.String]]( ToNetObj(KeyDats))) # elif genType.Equals(Latino.Model.Prediction): # probs=dict([(keyDat.Dat,keyDat.Key) for keyDat in data.Inner]) # return DictionaryProbDist(prob_dict=probs) return p return data
##################################################### # Property by Your Engineering Solutions (Y.E.S.) # # Engineers: Lorans Hirmez, Brandon Fong # ##################################################### ### LIBRARIES ### from MaxPower_Classes import Max_Power_Wind, Max_Power_Solar from IO import RPI_Handler import MaxPower_Classes import System import threading # Init System.init(); MaxPower_Classes.init(); # I do not want this thread to call any IO functions # I think I have to though because ReadInfrared is an async event def do(): ### TIMER ### THREAD_Timer = threading.Thread(target=System.timer); ### WIND ### THREAD_Max_Power_Wind_Get_TORQUE = threading.Thread(target=Max_Power_Wind.Get_Torque); THREAD_Max_Power_Wind_Get_RPM = threading.Thread(target=RPI_Handler.ReadInfrared) ### SOLAR ### THREAD_Max_Power_Solar_Get_SOLAR_POWER = threading.Thread(target=Max_Power_Solar.Get_Solar_Power); # Starts threading the functions
from CFGTree import * from System import * s = System() quit = True while quit: s.show() answer , correct = s.check() if correct == True: if answer == '5': quit = False
def ToGuid(guidOrGuidText): return System.Guid(guidOrGuidText) if not isinstance( guidOrGuidText, System.Guid) else guidOrGuidText
def getsysinfo(self): self.mac_lineEdit.setText(System.mac()) self.proces_lineEdit.setText(System.processor()) self.localip_lineEdit.setText(System.locip())
def SetAttrOfCLIType(): d = System.DateTime() d.attr = 1
def Go(self,uri): self.web.Navigate(System.Uri(uri, System.UriKind.RelativeOrAbsolute)); def Back(self):
def SetDictElementOfCLIType(): d = System.DateTime() d.__dict__["attr"] = 1
def loginError(self): print('登录失败!', System.func_name()) System.dialog(self, '错误', "请检查用户名/密码!")
def test_special_array_creation(): """Test using the Array[<type>] syntax for creating arrays.""" from Python.Test import ISayHello1, InterfaceTest, ShortEnum from System import Array inst = InterfaceTest() value = Array[System.Boolean]([True, True]) assert value[0] is True assert value[1] is True assert value.Length == 2 value = Array[bool]([True, True]) assert value[0] is True assert value[1] is True assert value.Length == 2 value = Array[System.Byte]([0, 255]) assert value[0] == 0 assert value[1] == 255 assert value.Length == 2 value = Array[System.SByte]([0, 127]) assert value[0] == 0 assert value[1] == 127 assert value.Length == 2 value = Array[System.Char]([u'A', u'Z']) assert value[0] == u'A' assert value[1] == u'Z' assert value.Length == 2 value = Array[System.Char]([0, 65535]) assert value[0] == unichr(0) assert value[1] == unichr(65535) assert value.Length == 2 value = Array[System.Int16]([0, 32767]) assert value[0] == 0 assert value[1] == 32767 assert value.Length == 2 value = Array[System.Int32]([0, 2147483647]) assert value[0] == 0 assert value[1] == 2147483647 assert value.Length == 2 value = Array[int]([0, 2147483647]) assert value[0] == 0 assert value[1] == 2147483647 assert value.Length == 2 value = Array[System.Int64]([0, long(9223372036854775807)]) assert value[0] == 0 assert value[1] == long(9223372036854775807) assert value.Length == 2 # there's no explicit long type in python3, use System.Int64 instead if PY2: value = Array[long]([0, long(9223372036854775807)]) assert value[0] == 0 assert value[1] == long(9223372036854775807) assert value.Length == 2 value = Array[System.UInt16]([0, 65000]) assert value[0] == 0 assert value[1] == 65000 assert value.Length == 2 value = Array[System.UInt32]([0, long(4294967295)]) assert value[0] == 0 assert value[1] == long(4294967295) assert value.Length == 2 value = Array[System.UInt64]([0, long(18446744073709551615)]) assert value[0] == 0 assert value[1] == long(18446744073709551615) assert value.Length == 2 value = Array[System.Single]([0.0, 3.402823e38]) assert value[0] == 0.0 assert value[1] == 3.402823e38 assert value.Length == 2 value = Array[System.Double]([0.0, 1.7976931348623157e308]) assert value[0] == 0.0 assert value[1] == 1.7976931348623157e308 assert value.Length == 2 value = Array[float]([0.0, 1.7976931348623157e308]) assert value[0] == 0.0 assert value[1] == 1.7976931348623157e308 assert value.Length == 2 value = Array[System.Decimal]([System.Decimal.Zero, System.Decimal.One]) assert value[0] == System.Decimal.Zero assert value[1] == System.Decimal.One assert value.Length == 2 value = Array[System.String](["one", "two"]) assert value[0] == "one" assert value[1] == "two" assert value.Length == 2 value = Array[str](["one", "two"]) assert value[0] == "one" assert value[1] == "two" assert value.Length == 2 value = Array[ShortEnum]([ShortEnum.Zero, ShortEnum.One]) assert value[0] == ShortEnum.Zero assert value[1] == ShortEnum.One assert value.Length == 2 value = Array[System.Object]([inst, inst]) assert value[0].__class__ == inst.__class__ assert value[1].__class__ == inst.__class__ assert value.Length == 2 value = Array[InterfaceTest]([inst, inst]) assert value[0].__class__ == inst.__class__ assert value[1].__class__ == inst.__class__ assert value.Length == 2 value = Array[ISayHello1]([inst, inst]) assert value[0].__class__ == inst.__class__ assert value[1].__class__ == inst.__class__ assert value.Length == 2 inst = System.Exception("badness") value = Array[System.Exception]([inst, inst]) assert value[0].__class__ == inst.__class__ assert value[1].__class__ == inst.__class__ assert value.Length == 2
def grading_system(): gradingSystem = System.System() gradingSystem.load_data() return gradingSystem
def _get_model_media(self): model = [] try: self.db_cmd.CommandText = '''select distinct * from media order by deleted ASC''' sr = self.db_cmd.ExecuteReader() pk = [] while(sr.Read()): try: if canceller.IsCancellationRequested: break if sr[1] is None or sr[6] is None: continue if sr[0] is None or sr[0] == 0: continue media_type = sr[6] media_id = sr[0] deleted = sr[19] #remove duplication if media_id in pk: continue else: pk.append(media_id) #audio convert if media_type == "audio": audio = MediaFile.AudioFile() audio.FileName = self._db_reader_get_string_value(sr, 7) audio.Path = self._db_reader_get_string_value(sr, 1) #audio.NodeOrUrl.Init(path) audio.Size = self._db_reader_get_int_value(sr, 2) addTime = self._db_reader_get_int_value(sr, 3) audio.AddTime = self._get_timestamp(addTime) audio.Description = self._db_reader_get_string_value(sr, 17) media_log = self._get_media_log(sr[0]) for log in media_log: video.Logs.Add(log) modifyTime = self._db_reader_get_int_value(sr, 4) audio.FileSuffix = self._db_reader_get_string_value(sr, 5) audio.MimeType = self._db_reader_get_string_value(sr, 5) audio.ModifyTime = self._get_timestamp(modifyTime) audio.Album = self._db_reader_get_string_value(sr, 14) audio.Artist = self._db_reader_get_string_value(sr, 13) if not IsDBNull(sr[12]): hours = int(sr[12])/3600 minutes = (int(sr[12])-hours*3600)/60 seconds = int(sr[12])-hours*3600-minutes*60 audio.Duration = System.TimeSpan(hours, minutes, seconds) #image convert elif media_type == "image": image = MediaFile.ImageFile() image.FileName = self._db_reader_get_string_value(sr, 7) image.Path = self._db_reader_get_string_value(sr, 1) #image.NodeOrUrl.Init(path) image.Size = self._db_reader_get_int_value(sr, 2) addTime = self._db_reader_get_int_value(sr, 3) image.FileSuffix = self._db_reader_get_string_value(sr, 5) image.MimeType = self._db_reader_get_string_value(sr, 5) image.AddTime = self._get_timestamp(addTime) image.Description = self._db_reader_get_string_value(sr, 17) location = Base.Location(image) coordinate = Base.Coordinate() if not IsDBNull(sr[8]): coordinate.Latitude = float(sr[8]) if not IsDBNull(sr[9]): coordinate.Longitude = float(sr[9]) coordinate.Type = CoordinateType.Google if self.coordinate_type == COORDINATE_TYPE_GOOGLE else CoordinateType.GPS location.Coordinate = coordinate location.Time = image.AddTime location.AddressName = self._db_reader_get_string_value(sr, 10) location.SourceType = LocationSourceType.Media image.Location = location media_log = self._get_media_log(sr[0]) for log in media_log: image.Logs.Add(log) modifyTime = self._db_reader_get_int_value(sr, 4) image.ModifyTime = self._get_timestamp(modifyTime) image.Height = self._db_reader_get_int_value(sr, 16) image.Width = self._db_reader_get_int_value(sr, 15) takenDate = self._db_reader_get_int_value(sr, 11) image.TakenDate = self._get_timestamp(takenDate) image.Thumbnail = self._get_media_thumbnail(media_id) image.Aperture = self._db_reader_get_string_value(sr,18) image.Artist = self._db_reader_get_string_value(sr,13) image.ColorSpace = self._db_reader_get_string_value(sr,19) image.ExifVersion = self._db_reader_get_string_value(sr,20) image.ExposureProgram = self._db_reader_get_string_value(sr,21) image.ExposureTime = self._db_reader_get_string_value(sr,22) image.FocalLength = self._db_reader_get_string_value(sr,23) image.ISO = self._db_reader_get_string_value(sr,24) image.Make = self._db_reader_get_string_value(sr,25) image.Model = self._db_reader_get_string_value(sr,26) image.Resolution = self._db_reader_get_string_value(sr,27) image.Software = self._db_reader_get_string_value(sr,28) image.XResolution = self._db_reader_get_string_value(sr,29) if image.XResolution is not '': image.XResolution = image.XResolution + ' dpi' image.YResolution = self._db_reader_get_string_value(sr,30) if image.YResolution is not '': image.YResolution = image.YResolution + ' dpi' image.SourceFile = self._get_source_file(str(sr[31])) image.Deleted = self._convert_deleted_status(sr[32]) #location = Base.Location(image) #coordinate = Base.Coordinate() #if not IsDBNull(sr[8]): # coordinate.Latitude = float(sr[8]) #if not IsDBNull(sr[9]): # coordinate.Longitude = float(sr[9]) # coordinate.Type = CoordinateType.Google if self.coordinate_type == COORDINATE_TYPE_GOOGLE else CoordinateType.GPS #location.Coordinate = coordinate #location.Time = image.AddTime #location.AddressName = self._db_reader_get_string_value(sr, 10) if not IsDBNull(sr[9]): model.append(location) model.append(image) #video convert elif media_type == "video": video = MediaFile.VideoFile() video.FileName = self._db_reader_get_string_value(sr, 7) video.Path = self._db_reader_get_string_value(sr, 1) #video.NodeOrUrl.Init(path) video.Size = self._db_reader_get_int_value(sr, 2) addTime = self._db_reader_get_int_value(sr, 3) video.FileSuffix = self._db_reader_get_string_value(sr, 5) video.MimeType = self._db_reader_get_string_value(sr, 5) video.AddTime = self._get_timestamp(addTime) video.Description = self._db_reader_get_string_value(sr, 17) location = Base.Location(video) coordinate = Base.Coordinate() if not IsDBNull(sr[8]): coordinate.Latitude = float(sr[8]) if not IsDBNull(sr[9]): coordinate.Longitude = float(sr[9]) coordinate.Type = CoordinateType.Google if self.coordinate_type == COORDINATE_TYPE_GOOGLE else CoordinateType.GPS location.Coordinate = coordinate location.Time = video.AddTime location.AddressName = self._db_reader_get_string_value(sr, 10) location.SourceType = LocationSourceType.Media video.Location = location media_log = self._get_media_log(sr[0]) for log in media_log: video.Logs.Add(log) modifyTime = self._db_reader_get_int_value(sr, 4) takenDate = self._db_reader_get_int_value(sr, 11) video.TakenDate = self._get_timestamp(takenDate) video.ModifyTime = self._get_timestamp(modifyTime) if not IsDBNull(sr[12]): hours = int(sr[12])/3600 minutes = (int(sr[12])-hours*3600)/60 seconds = int(sr[12])-hours*3600-minutes*60 video.Duration = System.TimeSpan(hours, minutes, seconds) video.SourceFile = self._get_source_file(str(sr[31])) video.Deleted = self._convert_deleted_status(sr[32]) #location = Base.Location(video) #coordinate = Base.Coordinate() #if not IsDBNull(sr[8]): # coordinate.Latitude = float(sr[8]) #if not IsDBNull(sr[9]): # coordinate.Longitude = float(sr[9]) # coordinate.Type = CoordinateType.Google if self.coordinate_type == COORDINATE_TYPE_GOOGLE else CoordinateType.GPS #location.Coordinate = coordinate #location.Time = video.AddTime #location.AddressName = self._db_reader_get_string_value(sr, 10) if not IsDBNull(sr[9]): model.append(location) model.append(video) except: traceback.print_exc() sr.Close() except: pass return model
0,a,0, 0,0,c, ] atoms=[ [ "A", m ], [ "B", m ], ] sites=[ [ 0,0,0, 0 ], [ a/sqrt(3),0,c/2, 1 ], ] bonds=[ [ 0,1, System.axial([ a/sqrt(3),0, c/2], 10.483,-0.309) ], [ 1,0, System.axial([-a/sqrt(3),0,-c/2], 10.483,-0.309) ], [ 0,0, System.axial([ 0, a,0], 10.099,-0.292) ], [ 1,1, System.axial([ 0, a,0], 10.099,-0.292) ], [ 0,1, System.axial([-2*a/sqrt(3),0, c/2], -0.222,-0.246) ], [ 1,0, System.axial([ 2*a/sqrt(3),0,-c/2], -0.222,-0.246) ], [ 0,0, System.axial([ 0,0,c], 0.305,-0.490) ], [ 1,1, System.axial([ 0,0,c], 0.305,-0.490) ], [ 0,1, System.axial([ 5*a/(2*sqrt(3)), a/2, c/2], 0.748, 0.013) ], [ 1,0, System.axial([-5*a/(2*sqrt(3)),-a/2,-c/2], 0.748, 0.013) ], [ 0,0, System.axial([ a*sqrt(3),0,0], 0.529, 0.091) ],
def test_array(self): import System try: a = System.Array() except Exception, e: self.assertEqual(e.__class__, TypeError)
[ 0,1, -2*a/sqrt(3),0,c/2, -1.496, 0.000, 0.965, 0.000,-0.937, 0.000, 0.965, 0.000,-1.066 ], [ 1,0, 2*a/sqrt(3),0,-c/2, -1.496, 0.000, 0.965, 0.000,-0.937, 0.000, 0.965, 0.000,-1.066 ], [ 0,0, 0,0,c, 0.080, 0.000, 0.000, 0.000, 0.080, 0.000, 0.000, 0.000,-3.897 ], [ 1,1, 0,0,c, 0.080, 0.000, 0.000, 0.000, 0.080, 0.000, 0.000, 0.000,-3.897 ], [ 0,1, System.axial([5*a/(2*sqrt(3)),a/2,c/2], 0.488,-0.011) ], [ 1,0, System.axial([-5*a/(2*sqrt(3)),-a/2,-c/2], 0.488,-0.011) ], [ 0,0, System.axial([ a*sqrt(3),0,0], 1.213, 0.318) ], [ 1,1, System.axial([ a*sqrt(3),0,0], 1.213, 0.318) ], [ 0,0, System.axial([-a*sqrt(3),0,0], 1.213, 0.318) ], [ 1,1, System.axial([-a*sqrt(3),0,0], 1.213, 0.318) ], [ 0,0, System.axial([0,a,c], 1.048,-0.133) ], [ 1,1, System.axial([0,a,c], 1.048,-0.133) ], [ 0,0, System.axial([0,2*a,0], -0.344, 0.040) ], [ 1,1, System.axial([0,2*a,0], -0.344, 0.040) ], ] System.write(cell,atoms,sites,bonds,"hcp")
pass except SyntaxError: pass # /BUG # BUG 319 IOError not raised. if is_silverlight == False: try: fp = file('thisfiledoesnotexistatall.txt') except IOError: pass # /BUG # verify we can raise & catch CLR exceptions try: raise System.Exception('Hello World') except System.Exception, e: Assert(type(e) == System.Exception) # BUG 481 Trying to pass raise in Traceback should cause an error until it is implemented try: raise StopIteration( "BadTraceback"), "somedata", "a string is not a traceback" Assert(False, "fell through raise for some reason") except StopIteration: Assert(False) except TypeError: pass try: raise TypeError
0,a,0, 0,0,c, ] atoms=[ [ "A", m ], [ "B", m ], ] sites=[ [ 0,0,0, 0 ], [ a/s3,0,c/2, 1 ], ] bonds=[ [ 0,1, System.modAxial([ a/s3,0, c/2], 41.380000,[-3.030000,-3.030000,-17.210000]) ], [ 1,0, System.modAxial([-a/s3,0,-c/2], 41.380000,[-3.030000,-3.030000,-17.210000]) ], [ 0,0, System.modAxial([ 0, a,0], 22.280000,[ 0.171000, 0.171000, 3.780000]) ], [ 1,1, System.modAxial([ 0, a,0], 22.280000,[ 0.171000, 0.171000, 3.780000]) ], [ 0,1, System.modAxial([-2*a/s3,0, c/2], -8.330000,[ 1.100000, 1.100000, 0.220000]) ], [ 1,0, System.modAxial([ 2*a/s3,0,-c/2], -8.330000,[ 1.100000, 1.100000, 0.220000]) ], [ 0,0, System.modAxial([ 0,0,c], 0.00,[0.680000,0.680000,12.200000]) ], [ 1,1, System.modAxial([ 0,0,c], 0.00,[0.680000,0.680000,12.200000]) ], [ 0,1, System.modAxial([ 5*a/(2*s3), a/2, c/2], 2.260000,[ 0.170000, 0.170000,0.020000]) ], [ 1,0, System.modAxial([-5*a/(2*s3),-a/2,-c/2], 2.260000,[ 0.170000, 0.170000,0.020000]) ],
def testSpecialArrayCreation(self): """Test using the Array[<type>] syntax for creating arrays.""" from Python.Test import ISayHello1, InterfaceTest, ShortEnum from System import Array inst = InterfaceTest() value = Array[System.Boolean]([True, True]) self.assertTrue(value[0] == True) self.assertTrue(value[1] == True) self.assertTrue(value.Length == 2) value = Array[bool]([True, True]) self.assertTrue(value[0] == True) self.assertTrue(value[1] == True) self.assertTrue(value.Length == 2) value = Array[System.Byte]([0, 255]) self.assertTrue(value[0] == 0) self.assertTrue(value[1] == 255) self.assertTrue(value.Length == 2) value = Array[System.SByte]([0, 127]) self.assertTrue(value[0] == 0) self.assertTrue(value[1] == 127) self.assertTrue(value.Length == 2) value = Array[System.Char]([u'A', u'Z']) self.assertTrue(value[0] == u'A') self.assertTrue(value[1] == u'Z') self.assertTrue(value.Length == 2) value = Array[System.Char]([0, 65535]) self.assertTrue(value[0] == unichr(0)) self.assertTrue(value[1] == unichr(65535)) self.assertTrue(value.Length == 2) value = Array[System.Int16]([0, 32767]) self.assertTrue(value[0] == 0) self.assertTrue(value[1] == 32767) self.assertTrue(value.Length == 2) value = Array[System.Int32]([0, 2147483647]) self.assertTrue(value[0] == 0) self.assertTrue(value[1] == 2147483647) self.assertTrue(value.Length == 2) value = Array[int]([0, 2147483647]) self.assertTrue(value[0] == 0) self.assertTrue(value[1] == 2147483647) self.assertTrue(value.Length == 2) value = Array[System.Int64]([0, 9223372036854775807L]) self.assertTrue(value[0] == 0) self.assertTrue(value[1] == 9223372036854775807L) self.assertTrue(value.Length == 2) value = Array[long]([0, 9223372036854775807L]) self.assertTrue(value[0] == 0) self.assertTrue(value[1] == 9223372036854775807L) self.assertTrue(value.Length == 2) value = Array[System.UInt16]([0, 65000]) self.assertTrue(value[0] == 0) self.assertTrue(value[1] == 65000) self.assertTrue(value.Length == 2) value = Array[System.UInt32]([0, 4294967295L]) self.assertTrue(value[0] == 0) self.assertTrue(value[1] == 4294967295L) self.assertTrue(value.Length == 2) value = Array[System.UInt64]([0, 18446744073709551615L]) self.assertTrue(value[0] == 0) self.assertTrue(value[1] == 18446744073709551615L) self.assertTrue(value.Length == 2) value = Array[System.Single]([0.0, 3.402823e38]) self.assertTrue(value[0] == 0.0) self.assertTrue(value[1] == 3.402823e38) self.assertTrue(value.Length == 2) value = Array[System.Double]([0.0, 1.7976931348623157e308]) self.assertTrue(value[0] == 0.0) self.assertTrue(value[1] == 1.7976931348623157e308) self.assertTrue(value.Length == 2) value = Array[float]([0.0, 1.7976931348623157e308]) self.assertTrue(value[0] == 0.0) self.assertTrue(value[1] == 1.7976931348623157e308) self.assertTrue(value.Length == 2) value = Array[System.Decimal]( [System.Decimal.Zero, System.Decimal.One]) self.assertTrue(value[0] == System.Decimal.Zero) self.assertTrue(value[1] == System.Decimal.One) self.assertTrue(value.Length == 2) value = Array[System.String](["one", "two"]) self.assertTrue(value[0] == "one") self.assertTrue(value[1] == "two") self.assertTrue(value.Length == 2) value = Array[str](["one", "two"]) self.assertTrue(value[0] == "one") self.assertTrue(value[1] == "two") self.assertTrue(value.Length == 2) value = Array[ShortEnum]([ShortEnum.Zero, ShortEnum.One]) self.assertTrue(value[0] == ShortEnum.Zero) self.assertTrue(value[1] == ShortEnum.One) self.assertTrue(value.Length == 2) value = Array[System.Object]([inst, inst]) self.assertTrue(value[0].__class__ == inst.__class__) self.assertTrue(value[1].__class__ == inst.__class__) self.assertTrue(value.Length == 2) value = Array[InterfaceTest]([inst, inst]) self.assertTrue(value[0].__class__ == inst.__class__) self.assertTrue(value[1].__class__ == inst.__class__) self.assertTrue(value.Length == 2) value = Array[ISayHello1]([inst, inst]) self.assertTrue(value[0].__class__ == inst.__class__) self.assertTrue(value[1].__class__ == inst.__class__) self.assertTrue(value.Length == 2) inst = System.Exception("badness") value = Array[System.Exception]([inst, inst]) self.assertTrue(value[0].__class__ == inst.__class__) self.assertTrue(value[1].__class__ == inst.__class__) self.assertTrue(value.Length == 2)
def test_unified_exception_semantics(): """Test unified exception semantics.""" e = System.Exception('Something bad happened') assert isinstance(e, Exception) assert isinstance(e, System.Exception)
0,a,0, 0,0,c, ] atoms=[ [ "A", m ], [ "B", m ], ] sites=[ [ 0,0,0, 0 ], [ a/s3,0,c/2, 1 ], ] bonds=[ [ 0,1, System.modAxial([ a/s3,0, c/2], 10.247500,[-1.927800,-1.927800,3.687200]) ], [ 1,0, System.modAxial([-a/s3,0,-c/2], 10.247500,[-1.927800,-1.927800,3.687200]) ], [ 0,0, System.modAxial([ 0, a,0], 10.540600,[ -0.073300, -0.073300, 0.140200]) ], [ 1,1, System.modAxial([ 0, a,0], 10.540600,[ -0.073300, -0.073300, 0.140200]) ], [ 0,1, System.modAxial([-2*a/s3,0, c/2], -2.386000,[ 0.860300, 0.860300, -1.645500]) ], [ 1,0, System.modAxial([ 2*a/s3,0,-c/2], -2.386000,[ 0.860300, 0.860300, -1.645500]) ], [ 0,0, System.modAxial([ 0,0,c], -1.4887,[-0.252700,-0.252700,0.4833]) ], [ 1,1, System.modAxial([ 0,0,c], -1.4887,[-0.252700,-0.252700,0.4833]) ], [ 0,1, System.modAxial([ 5*a/(2*s3), a/2, c/2], 1.816200,[ 0.031400, 0.031400,-0.060100]) ], [ 1,0, System.modAxial([-5*a/(2*s3),-a/2,-c/2], 1.816200,[ 0.031400, 0.031400,-0.060100]) ],
def getaccountinfo(self): self.compname_lineEdit.setText(System.compn()) self.accname_lineEdit.setText(System.accn()) self.os_lineEdit.setText(System.bestu())
0,a,0, 0,0,c, ] atoms=[ [ "A", m ], [ "B", m ], ] sites=[ [ 0,0,0, 0 ], [ a/s3,0,c/2, 1 ], ] bonds=[ [ 0,1, System.modAxial([ a/s3,0, c/2], 15.491100,[-2.421600,-2.421600,-3.782400]) ], [ 1,0, System.modAxial([-a/s3,0,-c/2], 15.491100,[-2.421600,-2.421600,-3.782400]) ], [ 0,0, System.modAxial([ 0, a,0], 12.870400,[ -1.157100, -1.157100, -1.807300]) ], [ 1,1, System.modAxial([ 0, a,0], 12.870400,[ -1.157100, -1.157100, -1.807300]) ], [ 0,1, System.modAxial([-2*a/s3,0, c/2], -0.481900,[ 0.608800, 0.608800, -0.950900]) ], [ 1,0, System.modAxial([ 2*a/s3,0,-c/2], -0.481900,[ 0.608800, 0.608800, -0.950900]) ], [ 0,0, System.modAxial([ 0,0,c], -0.8846,[0.078500,0.078500,0.1226]) ], [ 1,1, System.modAxial([ 0,0,c], -0.8846,[0.078500,0.078500,0.1226]) ], [ 0,1, System.modAxial([ 5*a/(2*s3), a/2, c/2], -0.295500,[ 0.177400, 0.177400,0.277100]) ], [ 1,0, System.modAxial([-5*a/(2*s3),-a/2,-c/2], -0.295500,[ 0.177400, 0.177400,0.277100]) ],
cell=[ a,b, 0, a, 0,c, 0,b,c ] atoms=[ [ "In", m ], ] sites=[ [ 0,0,0, 0 ], ] bonds=[ [ 0,0, System.axial([ a, 0, c], 12.316,-2.064) ], [ 0,0, System.axial([ a, b, 0], 16.763,-2.759) ], [ 0,0, System.axial([2*a, 0, 0], 1.278, 0.929) ], [ 0,0, System.axial([ 0, 0,2*c], 1.695, 0.294) ], [ 0,0, System.axial([2*a, b, c], -0.452, 0.002) ], [ 0,0, System.axial([ a, b,2*c], -0.601, 0.268) ], [ 0,0, System.axial([2*a, 0,2*c], -0.423,-0.216) ], [ 0,0, System.axial([2*a,2*b, 0], -1.130, 0.033) ], [ 0,0, System.axial([3*a,1*b, 0], 0.167, 0.000) ], [ 0,0, System.axial([ a, 0,3*c], -0.026, 0.000) ], [ 0,0, System.axial([3*a, 0,1*c], 0.225, 0.000) ], ] System.write(cell,atoms,sites,bonds,"fct")
def RunLater(ctrl,handler): ctrl.Dispatcher.BeginInvoke(System.Action(handler))
def analyse(phrase,username): global action global code global infos global reponse type="" resIn,resOut="","" act,typeAct,rep="","","" if re.search("[A-Z].*",phrase): m=re.search("[A-Z].*",phrase) resIn=m.group(0) if action=="":#gestion passage initial if re.search("(calcul|combien|pythagore|thales|perimetre|surface|volume|triangle)?[-+]?\d+",phrase,re.IGNORECASE) or re.search("([-+]?\d+)+",phrase): #if re.search("toto",phrase): if re.search("[triangle,rectangle]",phrase,re.IGNORECASE): phrase+=" pythagore" type="T" rep=Math.run(phrase) else: possible=0 for file in listeFichiers: fichier=open("database/"+file,"r") for ligne in fichier: temp=ligne.split(";") mots=temp[0] i=0 while i < len(mots): if re.search(mots,phrase,re.IGNORECASE): t=mots.split(".*") if len(t)>possible: possible=len(t) typeAct=temp[1] act=temp[2] reponse=temp[3] i+=2 type="T" listRep=reponse.split("/") rep=choice(listRep) #remplacement du %IN% dans l'action listeAct=act.split(" ") for i in range(len(listeAct)): if listeAct[i].strip()=="%IN%": #listeAct[i]="'"+resIn.strip()+"'" listeAct[i]="'"+phrase.strip()+"'" act=" ".join(listeAct) if typeAct=="bash":#récupération des infos en plus if re.search("%OUT%",reponse): resOut=subprocess.check_output(act,shell=True) else: resOut=System.command(act) elif typeAct=="python": resOut,infos=eval(act) action=infos[0] code=infos[1] listeMot=rep.split(" ") #remplacement des %IN% et %OUT% dans la réponse if typeAct!="python" or (typeAct=="python" and code==0):#si reponse directe for i in range(len(listeMot)): if listeMot[i].strip()=="%OUT%": try: resOut=resOut.decode() except: resOut=resOut listeMot[i]=resOut.strip() for i in range(len(listeMot)): if listeMot[i].strip()=="%IN%": listeMot[i]=resIn.strip() rep=" ".join(listeMot) else:# si besoin de precision, on affiche le resultat de la fonction try: rep=resOut.decode() except: rep=resOut if action=="fichier" and code==0: type="F" else: type="T" if code==0: action,infos="","" elif action!="": type="T" if re.search("annule",phrase,re.IGNORECASE): infos=[] code=0 action="" else: fct=infos[len(infos)-1] resOut,infos=eval(fct+"("+str(code)+",'"+str(phrase)+"',"+str(infos)+")") code=infos[1] if code==0: action="" infos=[] listRep=reponse.split("/") rep=choice(listRep) listeMot=rep.split(" ") for i in range(len(listeMot)): if listeMot[i].strip()=="%OUT%": try: resOut=resOut.decode() except: resOut=resOut listeMot[i]=resOut.strip() for i in range(len(listeMot)): if listeMot[i].strip()=="%IN%": listeMot[i]=resIn.strip() rep=" ".join(listeMot) else: action="" code=0 infos=[] try: resOut=resOut.decode() except: resOut=resOut rep=resOut else: type="T" rep=reponse if re.search("\d{4}-\d{2}-\d{2}",rep): #reformattage des dates m=re.search("\d{4}-\d{2}-\d{2}",rep) date=m.group(0) d=date.split("-") newDate=d[2]+" "+d[1]+ " "+d[0] rep=re.sub("\d{4}-\d{2}-\d{2}",newDate,rep) rep=re.sub("T\d+:\d+","",rep)#suppression de l'heure reponse=Config.defaultResponse return type,str(rep.strip())
0,a,0, 0,0,c, ] atoms=[ [ "A", m ], [ "B", m ], ] sites=[ [ 0,0,0, 0 ], [ a/s3,0,c/2, 1 ], ] bonds=[ [ 0,1, System.modAxial([ a/s3,0, c/2], 23.239000,[-1.628000,-1.628000,-3.641000]) ], [ 1,0, System.modAxial([-a/s3,0,-c/2], 23.239000,[-1.628000,-1.628000,-3.641000]) ], [ 0,0, System.modAxial([ 0, a,0], 10.124000,[ 1.456000, 1.456000, 0.150000]) ], [ 1,1, System.modAxial([ 0, a,0], 10.124000,[ 1.456000, 1.456000, 0.150000]) ], [ 0,1, System.modAxial([-2*a/s3,0, c/2], -6.393000,[ 1.212000, 1.212000, 1.511000]) ], [ 1,0, System.modAxial([ 2*a/s3,0,-c/2], -6.393000,[ 1.212000, 1.212000, 1.511000]) ], [ 0,0, System.modAxial([ 0,0,c], 0.00,[-0.178000,-0.178000,-0.083000]) ], [ 1,1, System.modAxial([ 0,0,c], 0.00,[-0.178000,-0.178000,-0.083000]) ], [ 0,1, System.modAxial([ 5*a/(2*s3), a/2, c/2], 1.392000,[ 0.456000, 0.456000,-0.582000]) ], [ 1,0, System.modAxial([-5*a/(2*s3),-a/2,-c/2], 1.392000,[ 0.456000, 0.456000,-0.582000]) ],
def test_array(): import System try: a = System.Array() except Exception, e: AreEqual(e.__class__, TypeError)
def SetIcon(self,icon): self.Icon = BitmapFrame.Create(System.Uri(icon, System.UriKind.RelativeOrAbsolute)) if os.path.exists(icon) else None def SetMenuBar(self,menu): self.menu = menu
def RaiseSystemException(): raise System.SystemException()
def f17(): v.InstanceDateTimeField = System.DateTime(500000) def f18(): v.InstanceSimpleStructField = SimpleStruct(12340)
0,a,0, 0,0,c, ] atoms=[ [ "A", m ], [ "B", m ], ] sites=[ [ 0,0,0, 0 ], [ a/s3,0,c/2, 1 ], ] bonds=[ [ 0,1, System.modAxial([ a/s3,0, c/2], 10.150000,[-0.594000,-0.594000,-2.003000]) ], [ 1,0, System.modAxial([-a/s3,0,-c/2], 10.150000,[-0.594000,-0.594000,-2.003000]) ], [ 0,0, System.modAxial([ 0, a,0], 29.235000,[ -3.484000, -3.484000, -3.347000]) ], [ 1,1, System.modAxial([ 0, a,0], 29.235000,[ -3.484000, -3.484000, -3.347000]) ], [ 0,1, System.modAxial([-2*a/s3,0, c/2], 3.004000,[ -0.145000, -0.145000, 0.803000]) ], [ 1,0, System.modAxial([ 2*a/s3,0,-c/2], 3.004000,[ -0.145000, -0.145000, 0.803000]) ], [ 0,0, System.modAxial([ 0,0,c], 0.00,[0.162000,0.162000,-0.075000]) ], [ 1,1, System.modAxial([ 0,0,c], 0.00,[0.162000,0.162000,-0.075000]) ], [ 0,1, System.modAxial([ 5*a/(2*s3), a/2, c/2], -0.353100,[ 0.309000, 0.309000,-0.011000]) ], [ 1,0, System.modAxial([-5*a/(2*s3),-a/2,-c/2], -0.353100,[ 0.309000, 0.309000,-0.011000]) ],
def f17(): t.__dict__['InstanceDateTimeField'].__set__(v, System.DateTime(500000)) def f18(): t.__dict__['InstanceSimpleStructField'].__set__(v, SimpleStruct(12340))
0,a,0, 0,0,c, ] atoms=[ [ "A", m ], [ "B", m ], ] sites=[ [ 0,0,0, 0 ], [ a/s3,0,c/2, 1 ], ] bonds=[ [ 0,1, System.modAxial([ a/s3,0, c/2], 39.74,[-3.77,-3.77,-12.88]) ], [ 1,0, System.modAxial([-a/s3,0,-c/2], 39.74,[-3.77,-3.77,-12.88]) ], [ 0,0, System.modAxial([ 0, a,0], 22.80,[-0.70,-0.70, 3.28]) ], [ 1,1, System.modAxial([ 0, a,0], 22.80,[-0.70,-0.70, 3.28]) ], [ 0,1, System.modAxial([-2*a/s3,0, c/2], -4.60,[-0.39,-0.39, -1.45]) ], [ 1,0, System.modAxial([ 2*a/s3,0,-c/2], -4.60,[-0.39,-0.39, -1.45]) ], [ 0,0, System.modAxial([ 0,0,c], 4.40,[ 0.43, 0.43, 4.00]) ], [ 1,1, System.modAxial([ 0,0,c], 4.40,[ 0.43, 0.43, 4.00]) ], [ 0,1, System.modAxial([ 5*a/(2*s3), a/2, c/2], 1.95,[ 0.28, 0.28, -0.26]) ], [ 1,0, System.modAxial([-5*a/(2*s3),-a/2,-c/2], 1.95,[ 0.28, 0.28, -0.26]) ],
def clear_data(self): System.clear_data(self)
] bonds=[ [ 0,0,1.0*a,1.0*a,0.0*a,4.3726, 4.5798, 0.0, 4.5798, 4.3726, 0.0, 0.0, 0.0, -0.2264 ], [ 0,0,2.0*a,0.0*a,0.0*a,-2.3562, 0.0, 0.0, 0.0, 0.0773, 0.0, 0.0, 0.0, 0.0773 ], [ 0,0,2.0*a,1.0*a,1.0*a,0.2058, -0.0496, -0.0496, -0.0496, 0.3169, -0.0547, -0.0496, -0.0547, 0.3169 ], [ 0,0,2.0*a,2.0*a,0.0*a,0.1231, 0.1505, 0.0, 0.1505, 0.1231, 0.0, 0.0, 0.0, 0.0114 ], [ 0,0,3.0*a,1.0*a,0.0*a,-0.0525, 0.0193, 0.0, 0.0193, -0.0992, 0.0, 0.0, 0.0, -0.1044 ], [ 0,0,2.0*a,2.0*a,2.0*a,-0.3316, -0.2194, -0.2194, -0.2194, -0.3316, -0.2194, -0.2194, -0.2194, -0.3316 ], [ 0,0,3.0*a,2.0*a,1.0*a,0.1057, -0.0068, 0.0763, -0.0068, -0.1138, 0.005, 0.0763, 0.005, 0.0263 ], [ 0,0,4.0*a,0.0*a,0.0*a,-0.0009, 0.0, 0.0, 0.0, 0.2219, 0.0, 0.0, 0.0, 0.2219 ], ] System.write(cell,atoms,sites,bonds,"cubic")
monsters.alliedhealing(cmonster, cmlist) elif which == 2: monsters.steallife(myguy, cmlist[i]) myguy.temphealth = temphealth if (m1.type == 4) or (m1.type == 7): monsters.rapidregen(m1) if xp >= 15: print "LEVEL UP!!!!!!!!!!!!!!!!!!!!!!!!!" myguy = classes.levelup(myguy) xp -= 15 if myguy.temphealth <= 0: if (choice != 2): break if choice == 2: if myguy.lives != 0: myguy = System.healerspecial(myguy, healthholder) if myguy.temphealth > myguy.health: myguy.temphealth = myguy.health if myguy.temphealth <= 0: text.dead() elif gk1.temphealth <= 0: text.conclusion()