rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
for recClass in (MreWeap,MreActi,MreAlch,MreAppa,MreArmo,MreBook,MreClot,MreCont,MreCrea,MreDoor,MreFlor,MreFurn,MreIngr,MreKeym,MreLigh,MreMisc,MreNpc,MreQust,MreSgst,MreSlgm,):
for recClass in (MreWeap,MreActi,MreAlch,MreArmo,MreBook,MreCont,MreCrea,MreDoor,MreFlor,MreFurn,MreIngr,MreKeym,MreLigh,MreMisc,MreNpc,MreQust,MreTerm):
def initPatchFile(self,patchFile,loadMods): """Prepare to handle specified patch mod. All functions are called after this.""" Patcher.initPatchFile(self,patchFile,loadMods) self.id_data = {} #--Names keyed by long fid. self.srcClasses = set() #--Record classes actually provided by src mods/files. self.sourceMods = self.getConfigChecked() self.isActive = len(self.sourceMods) != 0 # self.masters = {} #--Type Fields recAttrs_class = self.recAttrs_class = {} for recClass in (MreWeap,MreActi,MreAlch,MreAppa,MreArmo,MreBook,MreClot,MreCont,MreCrea,MreDoor,MreFlor,MreFurn,MreIngr,MreKeym,MreLigh,MreMisc,MreNpc,MreQust,MreSgst,MreSlgm,): recAttrs_class[recClass] = ('script',) self.longTypes = set(('WEAP','ACTI','ALCH','APPA','ARMO','BOOK','CLOT','CONT','CREA','DOOR','FLOR','FURN','INGR','KEYM','LIGH','MISC','NPC_','QUST','SGST','SLGM'))
self.longTypes = set(('WEAP','ACTI','ALCH','APPA','ARMO','BOOK','CLOT','CONT','CREA','DOOR','FLOR','FURN','INGR','KEYM','LIGH','MISC','NPC_','QUST','SGST','SLGM'))
self.longTypes = set(('WEAP','ACTI','ALCH','ARMO','BOOK','CONT','CREA','DOOR','FLOR','FURN','INGR','KEYM','LIGH','MISC','NPC_','QUST','TERM'))
def initPatchFile(self,patchFile,loadMods): """Prepare to handle specified patch mod. All functions are called after this.""" Patcher.initPatchFile(self,patchFile,loadMods) self.id_data = {} #--Names keyed by long fid. self.srcClasses = set() #--Record classes actually provided by src mods/files. self.sourceMods = self.getConfigChecked() self.isActive = len(self.sourceMods) != 0 # self.masters = {} #--Type Fields recAttrs_class = self.recAttrs_class = {} for recClass in (MreWeap,MreActi,MreAlch,MreAppa,MreArmo,MreBook,MreClot,MreCont,MreCrea,MreDoor,MreFlor,MreFurn,MreIngr,MreKeym,MreLigh,MreMisc,MreNpc,MreQust,MreSgst,MreSlgm,): recAttrs_class[recClass] = ('script',) self.longTypes = set(('WEAP','ACTI','ALCH','APPA','ARMO','BOOK','CLOT','CONT','CREA','DOOR','FLOR','FURN','INGR','KEYM','LIGH','MISC','NPC_','QUST','SGST','SLGM'))
out.seek(-20,1)
out.seek(-recHeaderSize,1)
def copyPrev(size): ins.seek(-size,1) buff = ins.read(size) out.write(buff)
MelStructA('WLST','Ii', 'Weather', (FID,'weather'), 'chance'),
MelStruct('WLST','IiI', 'Weather', (FID,'weather'), 'chance', (FID,'global')),
# def loadData(self,record,ins,type,size,readId):
(self.folderCount,self.fileCount,lenFolderNames,lenFileNames,fileFlags,fileFlags2) = ins.unpack('6I',recHeaderSize)
(self.folderCount,self.fileCount,lenFolderNames,lenFileNames,fileFlags) = ins.unpack('5I',20)
def scan(self): """Reports on contents.""" ins = bolt.StructFile(self.path.s,'rb') #--Header ins.seek(4*4) (self.folderCount,self.fileCount,lenFolderNames,lenFileNames,fileFlags,fileFlags2) = ins.unpack('6I',recHeaderSize) #--FolderInfos (Initial) folderInfos = self.folderInfos = [] for index in range(self.folderCount): hash,subFileCount,offset = ins.unpack('Q2I',16) folderInfos.append([hash,subFileCount,offset]) #--Update folderInfos for index,folderInfo in enumerate(folderInfos): fileInfos = [] folderName = cstrip(ins.read(ins.unpack('B',1)[0])) folderInfos[index].extend((folderName,fileInfos)) for index in range(folderInfo[1]): filePos = ins.tell() hash,size,offset = ins.unpack('Q2I',16) fileInfos.append([hash,size,offset,'',filePos]) #--File Names fileNames = ins.read(lenFileNames) fileNames = fileNames.split('\x00')[:-1] namesIter = iter(fileNames) for folderInfo in folderInfos: fileInfos = folderInfo[-1] for index,fileInfo in enumerate(fileInfos): fileInfo[3] = namesIter.next() #--Done ins.close()
('Fallout - Sounds.bsa',1138162634),
('Fallout - Sound.bsa',1138162634),
def resetMTimes(self): """Reset dates of bsa files to 'correct' values.""" #--Fix the data of a few archive files bsaTimes = ( ('Fallout - MenuVoices.bsa',1138575220), ('Fallout - Meshes.bsa',1139433736), ('Fallout - Misc.bsa',1138660560), ('Fallout - Sounds.bsa',1138162634), ('Fallout - Textures.bsa',1138162934), ('Fallout - Voices.bsa',1138166742), ) for bsaFile,mtime in bsaTimes: dirs['mods'].join(bsaFile).mtime = mtime
if size == 102:
if size == 186:
def loadData(self,record,ins,type,size,readId): if size == 102: MelStruct.loadData(self,record,ins,type,size,readId) return elif size == 86: #--Else 86 byte record (skips dispVelocity, #-- dispFalloff, dispDampner, dispSize, and damage #-- Two junk? bytes are tacked onto the end #-- Hex editing and the CS confirms that it is NOT #-- damage, so it is probably just filler unpacked = ins.unpack('11f3Bs3Bs3BsB3s6f2s',size,readId) elif size == 62: #--Else 62 byte record (skips most everything #-- Two junk? bytes are tacked onto the end #-- No testing done, but assumed that its the same as the #-- previous truncated record. unpacked = ins.unpack('11f3Bs3Bs3BsB3s2s',size,readId) elif size == 42: #--Else 42 byte record (skips most everything #-- Two junk? bytes are tacked onto the end #-- No testing done, but assumed that its the same as the #-- previous truncated record. unpacked = ins.unpack('10f2s',size,readId) elif size == 2: #--Else 2 byte record (skips everything #-- Two junk? bytes are tacked onto the end #-- No testing done, but assumed that its the same as the #-- previous truncated record. unpacked = ins.unpack('2s',size,readId) else: raise "Unexpected size encountered for WATR subrecord: %s" % size unpacked = unpacked[:-1] unpacked += self.defaults[len(unpacked):] setter = record.__setattr__ for attr,value,action in zip(self.attrs,unpacked,self.actions): if callable(action): value = action(value) setter(attr,value) if self._debug: print unpacked
elif size == 86: unpacked = ins.unpack('11f3Bs3Bs3BsB3s6f2s',size,readId) elif size == 62: unpacked = ins.unpack('11f3Bs3Bs3BsB3s2s',size,readId) elif size == 42: unpacked = ins.unpack('10f2s',size,readId)
def loadData(self,record,ins,type,size,readId): if size == 102: MelStruct.loadData(self,record,ins,type,size,readId) return elif size == 86: #--Else 86 byte record (skips dispVelocity, #-- dispFalloff, dispDampner, dispSize, and damage #-- Two junk? bytes are tacked onto the end #-- Hex editing and the CS confirms that it is NOT #-- damage, so it is probably just filler unpacked = ins.unpack('11f3Bs3Bs3BsB3s6f2s',size,readId) elif size == 62: #--Else 62 byte record (skips most everything #-- Two junk? bytes are tacked onto the end #-- No testing done, but assumed that its the same as the #-- previous truncated record. unpacked = ins.unpack('11f3Bs3Bs3BsB3s2s',size,readId) elif size == 42: #--Else 42 byte record (skips most everything #-- Two junk? bytes are tacked onto the end #-- No testing done, but assumed that its the same as the #-- previous truncated record. unpacked = ins.unpack('10f2s',size,readId) elif size == 2: #--Else 2 byte record (skips everything #-- Two junk? bytes are tacked onto the end #-- No testing done, but assumed that its the same as the #-- previous truncated record. unpacked = ins.unpack('2s',size,readId) else: raise "Unexpected size encountered for WATR subrecord: %s" % size unpacked = unpacked[:-1] unpacked += self.defaults[len(unpacked):] setter = record.__setattr__ for attr,value,action in zip(self.attrs,unpacked,self.actions): if callable(action): value = action(value) setter(attr,value) if self._debug: print unpacked
unpacked = ins.unpack('2s',size,readId)
record.damage = ins.unpack('H',size,readId) return else: raise "Unexpected size encountered for WATR subrecord: %s" % size def dumpData(self,record,out): out.packSub(self.subType,'H',record.damage) class MelWatrDnam(MelStruct): """Handle older trucated DNAM for WATR subrecord.""" def loadData(self,record,ins,type,size,readId): if size == 196: MelStruct.loadData(self,record,ins,type,size,readId) return elif size == 184: unpacked = ins.unpack('10f3Bs3Bs3BsI32f',size,readId)
def loadData(self,record,ins,type,size,readId): if size == 102: MelStruct.loadData(self,record,ins,type,size,readId) return elif size == 86: #--Else 86 byte record (skips dispVelocity, #-- dispFalloff, dispDampner, dispSize, and damage #-- Two junk? bytes are tacked onto the end #-- Hex editing and the CS confirms that it is NOT #-- damage, so it is probably just filler unpacked = ins.unpack('11f3Bs3Bs3BsB3s6f2s',size,readId) elif size == 62: #--Else 62 byte record (skips most everything #-- Two junk? bytes are tacked onto the end #-- No testing done, but assumed that its the same as the #-- previous truncated record. unpacked = ins.unpack('11f3Bs3Bs3BsB3s2s',size,readId) elif size == 42: #--Else 42 byte record (skips most everything #-- Two junk? bytes are tacked onto the end #-- No testing done, but assumed that its the same as the #-- previous truncated record. unpacked = ins.unpack('10f2s',size,readId) elif size == 2: #--Else 2 byte record (skips everything #-- Two junk? bytes are tacked onto the end #-- No testing done, but assumed that its the same as the #-- previous truncated record. unpacked = ins.unpack('2s',size,readId) else: raise "Unexpected size encountered for WATR subrecord: %s" % size unpacked = unpacked[:-1] unpacked += self.defaults[len(unpacked):] setter = record.__setattr__ for attr,value,action in zip(self.attrs,unpacked,self.actions): if callable(action): value = action(value) setter(attr,value) if self._debug: print unpacked
MelString('TNAM','texture'),
MelString('FULL','full'), MelString('NNAM','texture'),
def loadData(self,record,ins,type,size,readId): if size == 102: MelStruct.loadData(self,record,ins,type,size,readId) return elif size == 86: #--Else 86 byte record (skips dispVelocity, #-- dispFalloff, dispDampner, dispSize, and damage #-- Two junk? bytes are tacked onto the end #-- Hex editing and the CS confirms that it is NOT #-- damage, so it is probably just filler unpacked = ins.unpack('11f3Bs3Bs3BsB3s6f2s',size,readId) elif size == 62: #--Else 62 byte record (skips most everything #-- Two junk? bytes are tacked onto the end #-- No testing done, but assumed that its the same as the #-- previous truncated record. unpacked = ins.unpack('11f3Bs3Bs3BsB3s2s',size,readId) elif size == 42: #--Else 42 byte record (skips most everything #-- Two junk? bytes are tacked onto the end #-- No testing done, but assumed that its the same as the #-- previous truncated record. unpacked = ins.unpack('10f2s',size,readId) elif size == 2: #--Else 2 byte record (skips everything #-- Two junk? bytes are tacked onto the end #-- No testing done, but assumed that its the same as the #-- previous truncated record. unpacked = ins.unpack('2s',size,readId) else: raise "Unexpected size encountered for WATR subrecord: %s" % size unpacked = unpacked[:-1] unpacked += self.defaults[len(unpacked):] setter = record.__setattr__ for attr,value,action in zip(self.attrs,unpacked,self.actions): if callable(action): value = action(value) setter(attr,value) if self._debug: print unpacked
MelWatrData('DATA', '11f3Bs3Bs3BsB3s10fH',('windVelocity',0.100), ('windDirection',90.0),('waveAmp',0.5),('waveFreq',1.0),('sunPower',50.0), ('reflectAmt',0.5),('fresnelAmt',0.0250),('xSpeed',0.0),('ySpeed',0.0), ('fogNear',27852.8),('fogFar',163840.0),('shallowRed',0),('shallowGreen',128), ('shallowBlue',128),('unused1',null1),('deepRed',0),('deepGreen',0), ('deepBlue',25),('unused2',null1),('reflRed',255),('reflGreen',255), ('reflBlue',255),('unused3',null1),('blend',50),('unused4',null3),('rainForce',0.1000), ('rainVelocity',0.6000),('rainFalloff',0.9850),('rainDampner',2.0000), ('rainSize',0.0100),('dispForce',0.4000),('dispVelocity', 0.6000), ('dispFalloff',0.9850),('dispDampner',10.0000),('dispSize',0.0500),('damage',0)),
MelFid('XNAM','effect'), MelWatrData('DATA','10f3Bs3Bs3BsI32fH',('windVelocity',0.100),('windDirection',90.0), ('waveAmp',0.5),('waveFreq',1.0),('sunPower',50.0),('reflectAmt',0.5), ('fresnelAmt',0.0250),('unknown1',0.0),('fogNear',27852.8),('fogFar',163840.0), ('shallowRed',0),('shallowGreen',128),('shallowBlue',128),('unused1',null1), ('deepRed',0),('deepGreen',0),('deepBlue',25),('unused2',null1), ('reflRed',255),('reflGreen',255),('reflBlue',255),('unused3',null1), ('unknown2',0), ('rainForce',0.1000),('rainVelocity',0.6000),('rainFalloff',0.9850),('rainDampner',2.0000),('rainSize',0.0100), ('dispForce',0.4000),('dispVelocity', 0.6000),('dispFalloff',0.9850),('dispDampner',10.0000),('dispSize',0.0500), ('noiseNormalsScale',1.8000),('noiseLayer1WindDirection',0.0000),('noiseLayer2WindDirection',-431602080.0500), ('noiseLayer3WindDirection',-431602080.0500),('noiseLayer1WindVelocity',0.0000), ('noiseLayer2WindVelocity',-431602080.0500),('noiseLayer3WindVelocity',-431602080.0500), ('noiseNormalsDepthFalloffStart',0.00000),('noiseNormalsDepthFalloffEnd',0.10000), ('fogAboveWaterAmount',1.00000),('noiseNormalsUvScale',500.00000), ('fogUnderWaterAmount',1.00000),('fogUnderWaterNear',0.00000),('fogUnderWaterFar',1000.00000), ('distortionAmount',250.00000),('shininess',100.00000),('reflectHdrMult',1.00000), ('lightRadius',10000.00000),('lightBrightness',1.00000), ('noiseLayer1UvScale',100.00000),('noiseLayer2UvScale',100.00000),('noiseLayer3UvScale',100.00000), ('damage',0)), MelWatrDnam('DNAM','10f3Bs3Bs3BsI35f',('windVelocity',0.100),('windDirection',90.0), ('waveAmp',0.5),('waveFreq',1.0),('sunPower',50.0),('reflectAmt',0.5), ('fresnelAmt',0.0250),('unknown1',0.0),('fogNear',27852.8),('fogFar',163840.0), ('shallowRed',0),('shallowGreen',128),('shallowBlue',128),('unused1',null1), ('deepRed',0),('deepGreen',0),('deepBlue',25),('unused2',null1), ('reflRed',255),('reflGreen',255),('reflBlue',255),('unused3',null1), ('unknown2',0), ('rainForce',0.1000),('rainVelocity',0.6000),('rainFalloff',0.9850),('rainDampner',2.0000),('rainSize',0.0100), ('dispForce',0.4000),('dispVelocity', 0.6000),('dispFalloff',0.9850),('dispDampner',10.0000),('dispSize',0.0500), ('noiseNormalsScale',1.8000),('noiseLayer1WindDirection',0.0000),('noiseLayer2WindDirection',-431602080.0500), ('noiseLayer3WindDirection',-431602080.0500),('noiseLayer1WindVelocity',0.0000), ('noiseLayer2WindVelocity',-431602080.0500),('noiseLayer3WindVelocity',-431602080.0500), ('noiseNormalsDepthFalloffStart',0.00000),('noiseNormalsDepthFalloffEnd',0.10000), ('fogAboveWaterAmount',1.00000),('noiseNormalsUvScale',500.00000), ('fogUnderWaterAmount',1.00000),('fogUnderWaterNear',0.00000),('fogUnderWaterFar',1000.00000), ('distortionAmount',250.00000),('shininess',100.00000),('reflectHdrMult',1.00000), ('lightRadius',10000.00000),('lightBrightness',1.00000), ('noiseLayer1UvScale',100.00000),('noiseLayer2UvScale',100.00000),('noiseLayer3UvScale',100.00000), ('noiseLayer1Amp',0.00000),('noiseLayer2Amp',0.00000),('noiseLayer3Amp',0.00000), ),
def loadData(self,record,ins,type,size,readId): if size == 102: MelStruct.loadData(self,record,ins,type,size,readId) return elif size == 86: #--Else 86 byte record (skips dispVelocity, #-- dispFalloff, dispDampner, dispSize, and damage #-- Two junk? bytes are tacked onto the end #-- Hex editing and the CS confirms that it is NOT #-- damage, so it is probably just filler unpacked = ins.unpack('11f3Bs3Bs3BsB3s6f2s',size,readId) elif size == 62: #--Else 62 byte record (skips most everything #-- Two junk? bytes are tacked onto the end #-- No testing done, but assumed that its the same as the #-- previous truncated record. unpacked = ins.unpack('11f3Bs3Bs3BsB3s2s',size,readId) elif size == 42: #--Else 42 byte record (skips most everything #-- Two junk? bytes are tacked onto the end #-- No testing done, but assumed that its the same as the #-- previous truncated record. unpacked = ins.unpack('10f2s',size,readId) elif size == 2: #--Else 2 byte record (skips everything #-- Two junk? bytes are tacked onto the end #-- No testing done, but assumed that its the same as the #-- previous truncated record. unpacked = ins.unpack('2s',size,readId) else: raise "Unexpected size encountered for WATR subrecord: %s" % size unpacked = unpacked[:-1] unpacked += self.defaults[len(unpacked):] setter = record.__setattr__ for attr,value,action in zip(self.attrs,unpacked,self.actions): if callable(action): value = action(value) setter(attr,value) if self._debug: print unpacked
(_('F Radroach Meat'), '%s '), (_('F. Radroach Meat'), '%s. '), (_('F - Radroach Meat'),'%s - '), (_('(F) Radroach Meat'),'(%s) '),
(_('F Radroach Meat'), '\x07\x07\x07\x07\x07%s '), (_('F. Radroach Meat'), '\x07\x07\x07\x07\x07%s. '), (_('F - Radroach Meat'),'\x07\x07\x07\x07\x07%s - '), (_('(F) Radroach Meat'),'\x07\x07\x07\x07\x07(%s) '),
def __init__(self): MultiTweakItem.__init__(self,_("Ingestibles"), _('Label ingestibles to sort by type. C: Chems, F: Food, S: Stimpack, A: Alcohol.'), 'ALCH', (_('F Radroach Meat'), '%s '), (_('F. Radroach Meat'), '%s. '), (_('F - Radroach Meat'),'%s - '), (_('(F) Radroach Meat'),'(%s) '), )
(_('S BB Gun'), '%s '), (_('S. BB Gun'), '%s. '), (_('S - BB Gun'),'%s - '), (_('(S) BB Gun'),'(%s) '),
(_('S BB Gun'), '\x07\x07%s '), (_('S. BB Gun'), '\x07\x07%s. '), (_('S - BB Gun'),'\x07\x07%s - '), (_('(S) BB Gun'),'\x07\x07(%s) '),
def __init__(self): MultiTweakItem.__init__(self,_("Weapons"), _('Label ammo and weapons to sort by type and damage.'), 'WEAP', (_('S BB Gun'), '%s '), (_('S. BB Gun'), '%s. '), (_('S - BB Gun'),'%s - '), (_('(S) BB Gun'),'(%s) '), ('----','----'), (_('S10 BB Gun'), '%s%02d '), (_('S10. BB Gun'), '%s%02d. '), (_('S10 - BB Gun'),'%s%02d - '), (_('(S10) BB Gun'),'(%s%02d) '), )
(_('S10 BB Gun'), '%s%02d '), (_('S10. BB Gun'), '%s%02d. '), (_('S10 - BB Gun'),'%s%02d - '), (_('(S10) BB Gun'),'(%s%02d) '),
(_('S10 BB Gun'), '\x07\x07%s%02d '), (_('S10. BB Gun'), '\x07\x07%s%02d. '), (_('S10 - BB Gun'),'\x07\x07%s%02d - '), (_('(S10) BB Gun'),'\x07\x07(%s%02d) '),
def __init__(self): MultiTweakItem.__init__(self,_("Weapons"), _('Label ammo and weapons to sort by type and damage.'), 'WEAP', (_('S BB Gun'), '%s '), (_('S. BB Gun'), '%s. '), (_('S - BB Gun'),'%s - '), (_('(S) BB Gun'),'(%s) '), ('----','----'), (_('S10 BB Gun'), '%s%02d '), (_('S10. BB Gun'), '%s%02d. '), (_('S10 - BB Gun'),'%s%02d - '), (_('(S10) BB Gun'),'(%s%02d) '), )
for blockType in ('WEAP',):
for blockType in ('AMMO','WEAP'):
def scanModFile(self,modFile,progress,patchFile): """Scans specified mod file to extract info. May add record to patch mod, but won't alter it.""" mapper = modFile.getLongMapper() #for blockType in ('AMMO','WEAP'): for blockType in ('WEAP',): modBlock = getattr(modFile,blockType) patchBlock = getattr(patchFile,blockType) id_records = patchBlock.id_records for record in modBlock.getActiveRecords(): if mapper(record.fid) not in id_records: record = record.getTypeCopy(mapper) patchBlock.setRecord(record)
ammoFormat = '\x07' for record in patchFile.AMMO.records: if not record.full: continue record.full = ammoFormat + record.full keep(record.fid) srcMod = record.fid[0] count[srcMod] = count.get(srcMod,0) + 1
def buildPatch(self,log,progress,patchFile): """Edits patch file as desired. Will write to log.""" count = {} format = self.choiceValues[self.chosen][0] showStat = '%02d' in format keep = patchFile.getKeeper() codes = getattr(patchFile,'weaponTags','BESMUTL') #ammoFormat = format.replace('%02d','',1) # for record in patchFile.AMMO.records: # if not record.full: continue # if record.full[0] in '+-=.()[]': continue # record.full = ammoFormat % 'A' + record.full # keep(record.fid) # srcMod = record.fid[0] # count[srcMod] = count.get(srcMod,0) + 1 for record in patchFile.WEAP.records: if not record.full: continue if record.full[0] in '+-=.()[]': continue if not record.etype in range(0,7): continue type = codes[record.etype] if showStat: record.full = format % (type,record.damage) + record.full else: record.full = format % type + record.full keep(record.fid) srcMod = record.fid[0] count[srcMod] = count.get(srcMod,0) + 1 #--Log log(_('* %s: %d') % (self.label,sum(count.values()))) for srcMod in modInfos.getOrdered(count.keys()): log(' * %s: %d' % (srcMod.s,count[srcMod]))
(_('A Naughty Nightwear'), '%s '), (_('A. Naughty Nightwear'), '%s. '), (_('A - Naughty Nightwear'),'%s - '), (_('(A) Naughty Nightwear'),'(%s) '),
(_('A Naughty Nightwear'), '\x07\x07\x07%s '), (_('A. Naughty Nightwear'), '\x07\x07\x07%s. '), (_('A - Naughty Nightwear'),'\x07\x07\x07%s - '), (_('(A) Naughty Nightwear'),'\x07\x07\x07(%s) '),
def buildPatch(self,log,progress,patchFile): """Edits patch file as desired. Will write to log.""" count = {} format = self.choiceValues[self.chosen][0] showStat = '%02d' in format keep = patchFile.getKeeper() codes = getattr(patchFile,'weaponTags','BESMUTL') #ammoFormat = format.replace('%02d','',1) # for record in patchFile.AMMO.records: # if not record.full: continue # if record.full[0] in '+-=.()[]': continue # record.full = ammoFormat % 'A' + record.full # keep(record.fid) # srcMod = record.fid[0] # count[srcMod] = count.get(srcMod,0) + 1 for record in patchFile.WEAP.records: if not record.full: continue if record.full[0] in '+-=.()[]': continue if not record.etype in range(0,7): continue type = codes[record.etype] if showStat: record.full = format % (type,record.damage) + record.full else: record.full = format % type + record.full keep(record.fid) srcMod = record.fid[0] count[srcMod] = count.get(srcMod,0) + 1 #--Log log(_('* %s: %d') % (self.label,sum(count.values()))) for srcMod in modInfos.getOrdered(count.keys()): log(' * %s: %d' % (srcMod.s,count[srcMod]))
(_('A01 Naughty Nightwear'), '%s%02d '), (_('A01. Naughty Nightwear'), '%s%02d. '), (_('A01 - Naughty Nightwear'),'%s%02d - '), (_('(A01) Naughty Nightwear'),'(%s%02d) '),
(_('A01 Naughty Nightwear'), '\x07\x07\x07%s%02d '), (_('A01. Naughty Nightwear'), '\x07\x07\x07%s%02d. '), (_('A01 - Naughty Nightwear'),'\x07\x07\x07%s%02d - '), (_('(A01) Naughty Nightwear'),'\x07\x07\x07(%s%02d) '),
def buildPatch(self,log,progress,patchFile): """Edits patch file as desired. Will write to log.""" count = {} format = self.choiceValues[self.chosen][0] showStat = '%02d' in format keep = patchFile.getKeeper() codes = getattr(patchFile,'weaponTags','BESMUTL') #ammoFormat = format.replace('%02d','',1) # for record in patchFile.AMMO.records: # if not record.full: continue # if record.full[0] in '+-=.()[]': continue # record.full = ammoFormat % 'A' + record.full # keep(record.fid) # srcMod = record.fid[0] # count[srcMod] = count.get(srcMod,0) + 1 for record in patchFile.WEAP.records: if not record.full: continue if record.full[0] in '+-=.()[]': continue if not record.etype in range(0,7): continue type = codes[record.etype] if showStat: record.full = format % (type,record.damage) + record.full else: record.full = format % type + record.full keep(record.fid) srcMod = record.fid[0] count[srcMod] = count.get(srcMod,0) + 1 #--Log log(_('* %s: %d') % (self.label,sum(count.values()))) for srcMod in modInfos.getOrdered(count.keys()): log(' * %s: %d' % (srcMod.s,count[srcMod]))
for recClass in (MreCont,MreDoor,):
for recClass in (MreCont,MreDoor,MreTerm):
def initPatchFile(self,patchFile,loadMods): """Prepare to handle specified patch mod. All functions are called after this.""" Patcher.initPatchFile(self,patchFile,loadMods) self.id_data = {} #--Names keyed by long fid. self.srcClasses = set() #--Record classes actually provided by src mods/files. self.sourceMods = self.getConfigChecked() self.isActive = len(self.sourceMods) != 0 #--Type Fields recAttrs_class = self.recAttrs_class = {} for recClass in (MreActi,MreAlch,MreAmmo,MreFurn,MreMisc,MreMstt,MreProj,MreWeap): recAttrs_class[recClass] = ('destructable',) for recClass in (MreCont,MreDoor,): # TODO: MreTerm recAttrs_class[recClass] = ('destructable','script',) for recClass in (MreLigh,): recAttrs_class[recClass] = ('script',) for recClass in (MreStat,): recAttrs_class[recClass] = ('model',) self.longTypes = set(('ACTI','ALCH','AMMO','FURN','MISC','MSTT','PROJ','WEAP','CONT','DOOR','LIGH','STAT', 'DEBR','EXPL','MGEF','SCPT','SPEL','SOUN','NPC_','WATR','TXST','ENCH','FLST','IPDS','STAT',''))
'DEBR','EXPL','MGEF','SCPT','SPEL','SOUN','NPC_','WATR','TXST','ENCH','FLST','IPDS','STAT',''))
'DEBR','EXPL','MGEF','SCPT','SPEL','SOUN','NPC_','WATR','TXST','ENCH','FLST','IPDS','STAT','NOTE','QUST'))
def initPatchFile(self,patchFile,loadMods): """Prepare to handle specified patch mod. All functions are called after this.""" Patcher.initPatchFile(self,patchFile,loadMods) self.id_data = {} #--Names keyed by long fid. self.srcClasses = set() #--Record classes actually provided by src mods/files. self.sourceMods = self.getConfigChecked() self.isActive = len(self.sourceMods) != 0 #--Type Fields recAttrs_class = self.recAttrs_class = {} for recClass in (MreActi,MreAlch,MreAmmo,MreFurn,MreMisc,MreMstt,MreProj,MreWeap): recAttrs_class[recClass] = ('destructable',) for recClass in (MreCont,MreDoor,): # TODO: MreTerm recAttrs_class[recClass] = ('destructable','script',) for recClass in (MreLigh,): recAttrs_class[recClass] = ('script',) for recClass in (MreStat,): recAttrs_class[recClass] = ('model',) self.longTypes = set(('ACTI','ALCH','AMMO','FURN','MISC','MSTT','PROJ','WEAP','CONT','DOOR','LIGH','STAT', 'DEBR','EXPL','MGEF','SCPT','SPEL','SOUN','NPC_','WATR','TXST','ENCH','FLST','IPDS','STAT',''))
patchFile.safeSave()
while True: try: patchFile.safeSave() except WindowsError: message = _("The patch cannot be written to (Data\\%s).\nIt might be locking by other processes.\nDo you want to retry or cancel?") % (patchName.s,) if balt.askWarning(self,fill(message,80),_("Couldn't write ")+patchName.s): continue raise break
def Execute(self,event=None): """Do the patch.""" self.EndModal(wx.ID_OK) patchName = self.patchInfo.name progress = balt.Progress(patchName.s,(' '*60+'\n')) try: #--Save configs patchConfigs = {'ImportedMods':set()} for patcher in self.patchers: patcher.saveConfig(patchConfigs) bosh.modInfos.table.setItem(patchName,'bash.patch.configs',patchConfigs) #--Do it log = bolt.LogFile(cStringIO.StringIO()) nullProgress = bolt.Progress() patchers = [patcher for patcher in self.patchers if patcher.isEnabled] patchFile = bosh.PatchFile(self.patchInfo,patchers) patchFile.initData(SubProgress(progress,0,0.1)) #try to speed this up! patchFile.initFactories(SubProgress(progress,0.1,0.2)) #no speeding needed/really possible (less than 1/4 second even with large LO) patchFile.scanLoadMods(SubProgress(progress,0.2,0.8)) #try to speed this up! patchFile.buildPatch(log,SubProgress(progress,0.8,0.9))#no speeding needed/really possible (less than 1/4 second even with large LO) #--Save progress(0.9,patchName.s+_('\nSaving...')) patchFile.safeSave() #--Cleanup self.patchInfo.refresh() modList.RefreshUI(patchName) #--Done progress.Destroy() #--Readme and log log.setHeader(None) log('{{CSS:wtxt_sand_small.css}}') logValue = log.out.getvalue() readme = bosh.modInfos.dir.join('Docs',patchName.sroot+'.txt') readme.open('w').write(logValue) bosh.modInfos.table.setItem(patchName,'doc',readme) #--Convert log/readme to wtxt and show log docsDir = bosh.modInfos.dir.join('Docs') bolt.WryeText.genHtml(readme,None,docsDir) balt.showWryeLog(self.parent,readme.root+'.html',patchName.s,icons=bashBlue) #--Select? message = _("Activate %s?") % (patchName.s,) if bosh.modInfos.isSelected(patchName) or balt.askYes(self.parent,message,patchName.s): try: oldFiles = bosh.modInfos.ordered[:] bosh.modInfos.select(patchName) changedFiles = bolt.listSubtract(bosh.modInfos.ordered,oldFiles) if len(changedFiles) > 1: statusBar.SetText(_("Masters Activated: ") + `len(changedFiles)-1`) except bosh.PluginsFullError: balt.showError(self,_("Unable to add mod %s because load list is full." ) % (fileName.s,)) modList.RefreshUI() except bosh.FileEditError, error: progress.Destroy() balt.showError(self,str(error),_("File Edit Error")) except: progress.Destroy() raise
class MelSounSndd(MelStruct): """SNDD is an older version of SNDX. Allow it to read in, but not set defaults or write."""
class MelSounSndx(MelStruct): """SNDX is a reduced version of SNDD. Allow it to read in, but not set defaults or write."""
def dumpData(self,record,out): """Conditionally dumps data.""" if record.entryType == 7 and self.subType == 'RDMD': MelOptStruct.dumpData(self,record,out)
record.staticAtten = 0 record.stopTime = 0 record.startTime = 0
record.point0 = 0 record.point1 = 0 record.point2 = 0 record.point3 = 0 record.point4 = 0 record.reverb = 0 record.priority = 0 record.unknown = "\0"*8
def loadData(self,record,ins,type,size,readId): MelStruct.loadData(self,record,ins,type,size,readId) record.staticAtten = 0 record.stopTime = 0 record.startTime = 0
MelSounSndd('SNDD','=2BbsH2s','minDistance', 'maxDistance', 'freqAdjustment', ('unused1',null1), (_flags,'flags'), ('unused2',null2)), MelOptStruct('SNDX','=2BbsH2sh2B',('minDistance',None), ('maxDistance',None), ('freqAdjustment',None), ('unused1',null1), (_flags,'flags',None), ('unused2',null2), ('staticAtten',None),('stopTime',None),('startTime',None),)
MelOptStruct('SNDD','=2BbsIh2B6HI8s',('minDistance',None), ('maxDistance',None), ('freqAdjustment',None), ('unused1',null1), (_flags,'flags',None),('staticAtten',None),('stopTime',None),('startTime',None), ('point0',0),('point1',0),('point2',0),('point3',0),('point4',0),('reverb',0),('priority',0),'unknown'), MelSounSndx('SNDX','=2BbsIh2B',('minDistance',None), ('maxDistance',None), ('freqAdjustment',None), ('unused1',null1), (_flags,'flags',None),('staticAtten',None),('stopTime',None),('startTime',None),), MelBase('ANAM','_anam'), MelBase('GNAM','_gnam'), MelBase('HNAM','_hnam'),
def dumpData(self,record,out): return
MelFid('SNAM','sound'),
MelGroup('destructable', MelBase('DEST','header'), MelStruct('DEST','IhH','health','count','flags'), MelGroups('stages', MelStruct('DSTD','=4B4I','health','index','damageStage','flags', 'selfDamagePerSecond',(FID,'explosion',None),(FID,'debris',None),'debrisCount'), MelString('DMDL','model'), MelBase('DMDT','dmdt'), MelBase('DSTF','footer'), ), ), MelFid('SNAM','soundLooping'), MelFid('VNAM','soundActivation'), MelFid('RNAM','radioStation'), MelFid('WNAM','waterType'),
def getEffectsSummary(self,mgef_school=None,mgef_name=None): """Return a text description of magic effects.""" mgef_school = mgef_school or bush.mgef_school mgef_name = mgef_name or bush.mgef_name buff = cStringIO.StringIO() avEffects = bush.actorValueEffects aValues = bush.actorValues buffWrite = buff.write if self.effects: school = mgef_school[self.effects[0].name] buffWrite(bush.actorValues[20+school] + '\n') for index,effect in enumerate(self.effects): if effect.scriptEffect: effectName = effect.scriptEffect.full or 'Script Effect' else: effectName = mgef_name[effect.name] if effect.name in avEffects: effectName = re.sub(_('(Attribute|Skill)'),aValues[effect.actorValue],effectName) buffWrite('o+*'[effect.recipient]+' '+effectName) if effect.magnitude: buffWrite(' '+`effect.magnitude`+'m') if effect.area: buffWrite(' '+`effect.area`+'a') if effect.duration > 1: buffWrite(' '+`effect.duration`+'d') buffWrite('\n') return buff.getvalue()
MelStructs('DSTD','=4B4I','stages','health','index','damageStage', 'flags','selfDamagePerSecond',(FID,'explosion',None), (FID,'debris',None),'debrisCount'), MelBase('DSTF','footer'),
MelStruct('DEST','IhH','health','count','flags'), MelGroups('stages', MelStruct('DSTD','=4B4I','health','index','damageStage','flags', 'selfDamagePerSecond',(FID,'explosion',None),(FID,'debris',None),'debrisCount'), MelString('DMDL','model'), MelBase('DMDT','_dmdt'), MelBase('DSTF','footer'), ),
def loadData(self,record,ins,type,size,readId): if size == 136: MelStruct.loadData(self,record,ins,type,size,readId) return elif size == 124: #--Else 124 byte record (skips sightUsage, semiAutomaticFireDelayMin and semiAutomaticFireDelayMax... unpacked = ins.unpack('Iff4B5fI4BffII11fIIffI',size,readId) elif size == 120: #--Else 120 byte record (skips resistType, sightUsage, semiAutomaticFireDelayMin and semiAutomaticFireDelayMax... unpacked = ins.unpack('Iff4B5fI4BffII11fIIff',size,readId) else: raise "Unexpected size encountered for WEAP:DNAM subrecord: %s" % size unpacked += self.defaults[len(unpacked):] setter = record.__setattr__ for attr,value,action in zip(self.attrs,unpacked,self.actions): if callable(action): value = action(value) setter(attr,value) if self._debug: print unpacked
(4,'ingredients'),
(4,'foods'), (5,'chems'), (6,'stimpacks'),
def dumpData(self,record,out): if not record.flags.isInterior: MelOptStruct.dumpData(self,record,out)
(8,'apparatus'),
def dumpData(self,record,out): if not record.flags.isInterior: MelOptStruct.dumpData(self,record,out)
(11,'spells'), (12,'magicItems'),
def dumpData(self,record,out): if not record.flags.isInterior: MelOptStruct.dumpData(self,record,out)
def loadData(self,record,ins,type,size,readId): if size == 52: MelStruct.loadData(self,record,ins,type,size,readId) return unpacked = ins.unpack('2iI7i2I',size,readId) unpacked += self.defaults[len(unpacked):] setter = record.__setattr__ for attr,value,action in zip(self.attrs,unpacked,self.actions): if callable(action): value = action(value) setter(attr,value) if self._debug: print unpacked, record.flags.getTrueAttrs()
def loadData(self,record,ins,type,size,readId): if size == 52: MelStruct.loadData(self,record,ins,type,size,readId) return #--Else 42 byte record (skips trainSkill, trainLevel,unused1... unpacked = ins.unpack('2iI7i2I',size,readId) unpacked += self.defaults[len(unpacked):] setter = record.__setattr__ for attr,value,action in zip(self.attrs,unpacked,self.actions): if callable(action): value = action(value) setter(attr,value) if self._debug: print unpacked, record.flags.getTrueAttrs()
MelClasData('DATA','2iI7i2IbB2s','primary1','primary2','specialization','major1','major2','major3','major4','major5','major6','major7',(_flags,'flags',0L),(aiService,'services',0L),('trainSkill',0),('trainLevel',0),('unused1',null2)),
MelClasData('DATA','4I2IbB2s','tagSkill1','tagSkill2','tagSkill3','tagSkill4',(_flags,'flags',0L),(aiService,'services',0L),('trainSkill',0),('trainLevel',0),('unused1',null2)),
def loadData(self,record,ins,type,size,readId): if size == 52: MelStruct.loadData(self,record,ins,type,size,readId) return #--Else 42 byte record (skips trainSkill, trainLevel,unused1... unpacked = ins.unpack('2iI7i2I',size,readId) unpacked += self.defaults[len(unpacked):] setter = record.__setattr__ for attr,value,action in zip(self.attrs,unpacked,self.actions): if callable(action): value = action(value) setter(attr,value) if self._debug: print unpacked, record.flags.getTrueAttrs()
out.write(rowFormat % (type,longid[0].s,longid[1],eid,name,sname))
out.write(rowFormat % (type,longid[0].s,longid[1],eid,name.replace('"', '""'),sname.replace('"', '""')))
def writeToText(self,textPath): """Exports type_id_name to specified text file.""" textPath = GPath(textPath) type_id_name = self.type_id_name type_id_sname = self.type_id_sname out = textPath.open('w') for type in sorted(type_id_name): if type in self.hasShortNameTypes: headFormat = '"%s","%s","%s","%s","%s","%s"\n' rowFormat = '"%s","%s","0x%06X","%s","%s","%s"\n' out.write(headFormat % (_('Type'),_('Mod Name'),_('ObjectIndex'),_('Editor Id'),_('Name'),_('Short Name'))) else: headFormat = '"%s","%s","%s","%s","%s"\n' rowFormat = '"%s","%s","0x%06X","%s","%s"\n' out.write(headFormat % (_('Type'),_('Mod Name'),_('ObjectIndex'),_('Editor Id'),_('Name'))) id_name = type_id_name[type] id_sname = type_id_sname.get(type, {}) longids = id_name.keys() longids.sort(key=lambda a: id_name[a][0]) longids.sort(key=itemgetter(0)) for longid in longids: eid,name = id_name[longid] if type in self.hasShortNameTypes: eid2,sname = id_sname.get(longid,(eid,'')) out.write(rowFormat % (type,longid[0].s,longid[1],eid,name,sname)) else: out.write(rowFormat % (type,longid[0].s,longid[1],eid,name)) out.close()
out.write(rowFormat % (type,longid[0].s,longid[1],eid,name))
out.write(rowFormat % (type,longid[0].s,longid[1],eid,name.replace('"', '""')))
def writeToText(self,textPath): """Exports type_id_name to specified text file.""" textPath = GPath(textPath) type_id_name = self.type_id_name type_id_sname = self.type_id_sname out = textPath.open('w') for type in sorted(type_id_name): if type in self.hasShortNameTypes: headFormat = '"%s","%s","%s","%s","%s","%s"\n' rowFormat = '"%s","%s","0x%06X","%s","%s","%s"\n' out.write(headFormat % (_('Type'),_('Mod Name'),_('ObjectIndex'),_('Editor Id'),_('Name'),_('Short Name'))) else: headFormat = '"%s","%s","%s","%s","%s"\n' rowFormat = '"%s","%s","0x%06X","%s","%s"\n' out.write(headFormat % (_('Type'),_('Mod Name'),_('ObjectIndex'),_('Editor Id'),_('Name'))) id_name = type_id_name[type] id_sname = type_id_sname.get(type, {}) longids = id_name.keys() longids.sort(key=lambda a: id_name[a][0]) longids.sort(key=itemgetter(0)) for longid in longids: eid,name = id_name[longid] if type in self.hasShortNameTypes: eid2,sname = id_sname.get(longid,(eid,'')) out.write(rowFormat % (type,longid[0].s,longid[1],eid,name,sname)) else: out.write(rowFormat % (type,longid[0].s,longid[1],eid,name)) out.close()
MelStructs('CNTO','Ii','items',(FID,'item'),'count'),
MelGroups('items', MelStruct('CNTO','Ii',(FID,'item',None),('count',1)), MelOptStruct('COED','IIf',(FID,'owner',None),(FID,'glob',None),('condition',1.0)), ), MelGroup('destructable', MelBase('DEST','header'), MelStruct('DEST','IhH','health','count','flags'), MelGroups('stages', MelStruct('DSTD','=4B4I','health','index','damageStage','flags', 'selfDamagePerSecond',(FID,'explosion',None),(FID,'debris',None),'debrisCount'), MelString('DMDL','model'), MelBase('DMDT','_dmdt'), MelBase('DSTF','footer'), ), ),
# def loadData(self,record,ins,type,size,readId):
MelString('DNAM','upperLayer'),
MelString('ANAM','layer2'), MelString('BNAM','layer3'),
def loadData(self,record,ins,type,size,readId): if size == 136: MelStruct.loadData(self,record,ins,type,size,readId) return elif size == 124: #--Else 124 byte record (skips sightUsage, semiAutomaticFireDelayMin and semiAutomaticFireDelayMax... unpacked = ins.unpack('Iff4B5fI4BffII11fIIffI',size,readId) elif size == 120: #--Else 120 byte record (skips resistType, sightUsage, semiAutomaticFireDelayMin and semiAutomaticFireDelayMax... unpacked = ins.unpack('Iff4B5fI4BffII11fIIff',size,readId) else: raise "Unexpected size encountered for WEAP:DNAM subrecord: %s" % size unpacked += self.defaults[len(unpacked):] setter = record.__setattr__ for attr,value,action in zip(self.attrs,unpacked,self.actions): if callable(action): value = action(value) setter(attr,value) if self._debug: print unpacked
MelStructA('NAM0','3Bs3Bs3Bs3Bs','colors','riseRed','riseGreen','riseBlue',('unused1',null1),
MelBase('LNAM','unknown1'), MelStruct('ONAM','4B','cloudSpeed0','cloudSpeed1','cloudSpeed3','cloudSpeed4'), MelBase('PNAM','_pnam'), MelStructA('NAM0','3Bs3Bs3Bs3Bs','colors', 'riseRed','riseGreen','riseBlue',('unused1',null1),
def loadData(self,record,ins,type,size,readId): if size == 136: MelStruct.loadData(self,record,ins,type,size,readId) return elif size == 124: #--Else 124 byte record (skips sightUsage, semiAutomaticFireDelayMin and semiAutomaticFireDelayMax... unpacked = ins.unpack('Iff4B5fI4BffII11fIIffI',size,readId) elif size == 120: #--Else 120 byte record (skips resistType, sightUsage, semiAutomaticFireDelayMin and semiAutomaticFireDelayMax... unpacked = ins.unpack('Iff4B5fI4BffII11fIIff',size,readId) else: raise "Unexpected size encountered for WEAP:DNAM subrecord: %s" % size unpacked += self.defaults[len(unpacked):] setter = record.__setattr__ for attr,value,action in zip(self.attrs,unpacked,self.actions): if callable(action): value = action(value) setter(attr,value) if self._debug: print unpacked
MelStruct('FNAM','4f','fogDayNear','fogDayFar','fogNightNear','fogNightFar'), MelStruct('HNAM','14f', 'eyeAdaptSpeed', 'blurRadius', 'blurPasses', 'emissiveMult', 'targetLum', 'upperLumClamp', 'brightScale', 'brightClamp', 'lumRampNoTex', 'lumRampMin', 'lumRampMax', 'sunlightDimmer', 'grassDimmer', 'treeDimmer'),
MelStruct('FNAM','6f','fogDayNear','fogDayFar','fogNightNear','fogNightFar','fogDayPower','fogNightPower'), MelBase('INAM','_inam'),
def loadData(self,record,ins,type,size,readId): if size == 136: MelStruct.loadData(self,record,ins,type,size,readId) return elif size == 124: #--Else 124 byte record (skips sightUsage, semiAutomaticFireDelayMin and semiAutomaticFireDelayMax... unpacked = ins.unpack('Iff4B5fI4BffII11fIIffI',size,readId) elif size == 120: #--Else 120 byte record (skips resistType, sightUsage, semiAutomaticFireDelayMin and semiAutomaticFireDelayMax... unpacked = ins.unpack('Iff4B5fI4BffII11fIIff',size,readId) else: raise "Unexpected size encountered for WEAP:DNAM subrecord: %s" % size unpacked += self.defaults[len(unpacked):] setter = record.__setattr__ for attr,value,action in zip(self.attrs,unpacked,self.actions): if callable(action): value = action(value) setter(attr,value) if self._debug: print unpacked
recAttrs_class[recClass] = ('model','bodyParts','nift_p','bloodSprayPath','bloodDecalPath')
recAttrs_class[recClass] = ('model','bodyParts','nift_p','bodyPartData','impactDataset')
def initPatchFile(self,patchFile,loadMods): """Prepare to handle specified patch mod. All functions are called after this.""" Patcher.initPatchFile(self,patchFile,loadMods) self.id_data = {} #--Names keyed by long fid. self.srcClasses = set() #--Record classes actually provided by src mods/files. self.sourceMods = self.getConfigChecked() self.isActive = len(self.sourceMods) != 0 #--Type Fields recAttrs_class = self.recAttrs_class = {} for recClass in (MreBsgn,MreLscr, MreClas, MreLtex, MreRegn): recAttrs_class[recClass] = ('iconPath',) for recClass in (MreActi, MreDoor, MreFlor, MreFurn, MreGras, MreStat): recAttrs_class[recClass] = ('model',) for recClass in (MreAlch, MreAmmo, MreAppa, MreBook, MreIngr, MreKeym, MreLigh, MreMisc, MreSgst, MreSlgm, MreTree): recAttrs_class[recClass] = ('largeIconPath','smallIconPath','model') for recClass in (MreWeap,): recAttrs_class[recClass] = ('largeIconPath','smallIconPath','model','shellCasingModel','scopeModel','worldModel','firstPersonModel','animationType','gripAnimation','reloadAnimation') for recClass in (MreArmo, MreClot): recAttrs_class[recClass] = ('maleBody','maleWorld','maleIconPath','maleIcon','femaleBody','femaleWorld','femaleIconPath','femaleIcon','flags') for recClass in (MreCrea,): recAttrs_class[recClass] = ('model','bodyParts','nift_p','bloodSprayPath','bloodDecalPath') for recClass in (MreMgef,): recAttrs_class[recClass] = ('iconPath','model','effectShader','enchantEffect','light') for recClass in (MreEfsh,): recAttrs_class[recClass] = ('particleTexture','fillTexture') for recClass in (MreTxst,): recAttrs_class[recClass] = ('baseImage','normalMap','environmentMapMask','growMap','parallaxMap','environmentMap','decalData','flags') for recClass in (MreExpl,): recAttrs_class[recClass] = ('imagespaceModifier','light','impactdataset','placedImpactObject') for recClass in (MreIpct,): recAttrs_class[recClass] = ('model','effectDuration','effectOrientation','angleThreshold','placementRadius','flags','minWidth','maxWidth','minHeight','maxHeight','depth','shininess','parallaxScale','parallaxPasses','decalFlags','red','green','blue','textureSet') for recClass in (MreIpds,): recAttrs_class[recClass] = ('stone','dirt','grass','metal','wood','organic','cloth','water','hollowMetal','organicBug','organicGlow') for recClass in (MreProj,): recAttrs_class[recClass] = ('model','light','muzzleFlash','explosion','muzzleFlashDuration','fadeDuration','muzzleFlashPath') #--Needs Longs self.longTypes = set(('BSGN','LSCR','CLAS','LTEX','REGN','ACTI','DOOR','FLOR','FURN','GRAS','STAT','ALCH','AMMO','BOOK','INGR','KEYM','LIGH','MISC','SGST','SLGM','WEAP','TREE','ARMO','CLOT','CREA','MGEF','EFSH','TXST','EXPL','IPCT','IPDS','PROJ'))
recAttrs_class[recClass] = ('iconPath','model','effectShader','enchantEffect','light')
recAttrs_class[recClass] = ('iconPath','model','effectShader','objectDisplayShader','light')
def initPatchFile(self,patchFile,loadMods): """Prepare to handle specified patch mod. All functions are called after this.""" Patcher.initPatchFile(self,patchFile,loadMods) self.id_data = {} #--Names keyed by long fid. self.srcClasses = set() #--Record classes actually provided by src mods/files. self.sourceMods = self.getConfigChecked() self.isActive = len(self.sourceMods) != 0 #--Type Fields recAttrs_class = self.recAttrs_class = {} for recClass in (MreBsgn,MreLscr, MreClas, MreLtex, MreRegn): recAttrs_class[recClass] = ('iconPath',) for recClass in (MreActi, MreDoor, MreFlor, MreFurn, MreGras, MreStat): recAttrs_class[recClass] = ('model',) for recClass in (MreAlch, MreAmmo, MreAppa, MreBook, MreIngr, MreKeym, MreLigh, MreMisc, MreSgst, MreSlgm, MreTree): recAttrs_class[recClass] = ('largeIconPath','smallIconPath','model') for recClass in (MreWeap,): recAttrs_class[recClass] = ('largeIconPath','smallIconPath','model','shellCasingModel','scopeModel','worldModel','firstPersonModel','animationType','gripAnimation','reloadAnimation') for recClass in (MreArmo, MreClot): recAttrs_class[recClass] = ('maleBody','maleWorld','maleIconPath','maleIcon','femaleBody','femaleWorld','femaleIconPath','femaleIcon','flags') for recClass in (MreCrea,): recAttrs_class[recClass] = ('model','bodyParts','nift_p','bloodSprayPath','bloodDecalPath') for recClass in (MreMgef,): recAttrs_class[recClass] = ('iconPath','model','effectShader','enchantEffect','light') for recClass in (MreEfsh,): recAttrs_class[recClass] = ('particleTexture','fillTexture') for recClass in (MreTxst,): recAttrs_class[recClass] = ('baseImage','normalMap','environmentMapMask','growMap','parallaxMap','environmentMap','decalData','flags') for recClass in (MreExpl,): recAttrs_class[recClass] = ('imagespaceModifier','light','impactdataset','placedImpactObject') for recClass in (MreIpct,): recAttrs_class[recClass] = ('model','effectDuration','effectOrientation','angleThreshold','placementRadius','flags','minWidth','maxWidth','minHeight','maxHeight','depth','shininess','parallaxScale','parallaxPasses','decalFlags','red','green','blue','textureSet') for recClass in (MreIpds,): recAttrs_class[recClass] = ('stone','dirt','grass','metal','wood','organic','cloth','water','hollowMetal','organicBug','organicGlow') for recClass in (MreProj,): recAttrs_class[recClass] = ('model','light','muzzleFlash','explosion','muzzleFlashDuration','fadeDuration','muzzleFlashPath') #--Needs Longs self.longTypes = set(('BSGN','LSCR','CLAS','LTEX','REGN','ACTI','DOOR','FLOR','FURN','GRAS','STAT','ALCH','AMMO','BOOK','INGR','KEYM','LIGH','MISC','SGST','SLGM','WEAP','TREE','ARMO','CLOT','CREA','MGEF','EFSH','TXST','EXPL','IPCT','IPDS','PROJ'))
recAttrs_class[recClass] = ('imagespaceModifier','light','impactdataset','placedImpactObject')
recAttrs_class[recClass] = ('imageSpaceModifier','light','impactDataset','placedImpactObject')
def initPatchFile(self,patchFile,loadMods): """Prepare to handle specified patch mod. All functions are called after this.""" Patcher.initPatchFile(self,patchFile,loadMods) self.id_data = {} #--Names keyed by long fid. self.srcClasses = set() #--Record classes actually provided by src mods/files. self.sourceMods = self.getConfigChecked() self.isActive = len(self.sourceMods) != 0 #--Type Fields recAttrs_class = self.recAttrs_class = {} for recClass in (MreBsgn,MreLscr, MreClas, MreLtex, MreRegn): recAttrs_class[recClass] = ('iconPath',) for recClass in (MreActi, MreDoor, MreFlor, MreFurn, MreGras, MreStat): recAttrs_class[recClass] = ('model',) for recClass in (MreAlch, MreAmmo, MreAppa, MreBook, MreIngr, MreKeym, MreLigh, MreMisc, MreSgst, MreSlgm, MreTree): recAttrs_class[recClass] = ('largeIconPath','smallIconPath','model') for recClass in (MreWeap,): recAttrs_class[recClass] = ('largeIconPath','smallIconPath','model','shellCasingModel','scopeModel','worldModel','firstPersonModel','animationType','gripAnimation','reloadAnimation') for recClass in (MreArmo, MreClot): recAttrs_class[recClass] = ('maleBody','maleWorld','maleIconPath','maleIcon','femaleBody','femaleWorld','femaleIconPath','femaleIcon','flags') for recClass in (MreCrea,): recAttrs_class[recClass] = ('model','bodyParts','nift_p','bloodSprayPath','bloodDecalPath') for recClass in (MreMgef,): recAttrs_class[recClass] = ('iconPath','model','effectShader','enchantEffect','light') for recClass in (MreEfsh,): recAttrs_class[recClass] = ('particleTexture','fillTexture') for recClass in (MreTxst,): recAttrs_class[recClass] = ('baseImage','normalMap','environmentMapMask','growMap','parallaxMap','environmentMap','decalData','flags') for recClass in (MreExpl,): recAttrs_class[recClass] = ('imagespaceModifier','light','impactdataset','placedImpactObject') for recClass in (MreIpct,): recAttrs_class[recClass] = ('model','effectDuration','effectOrientation','angleThreshold','placementRadius','flags','minWidth','maxWidth','minHeight','maxHeight','depth','shininess','parallaxScale','parallaxPasses','decalFlags','red','green','blue','textureSet') for recClass in (MreIpds,): recAttrs_class[recClass] = ('stone','dirt','grass','metal','wood','organic','cloth','water','hollowMetal','organicBug','organicGlow') for recClass in (MreProj,): recAttrs_class[recClass] = ('model','light','muzzleFlash','explosion','muzzleFlashDuration','fadeDuration','muzzleFlashPath') #--Needs Longs self.longTypes = set(('BSGN','LSCR','CLAS','LTEX','REGN','ACTI','DOOR','FLOR','FURN','GRAS','STAT','ALCH','AMMO','BOOK','INGR','KEYM','LIGH','MISC','SGST','SLGM','WEAP','TREE','ARMO','CLOT','CREA','MGEF','EFSH','TXST','EXPL','IPCT','IPDS','PROJ'))
rgb_str = 'rgb('+str(int(color_intensity))+',0,0)' return ImageColor.getrgb(rgb_str)
color_rgb = color_table[int(log_rebase)] return ImageColor.getrgb(color_table[int(log_rebase)])
def getColor(hit_c): global hit_count_max global hit_count_min global hit_count_logmin global hit_count_logrange log_v = math.floor(math.log(hit_c)/math.log(2)) log_rebase = log_v - hit_count_logmin color_intensity=log_rebase*(255 / hit_count_logrange) rgb_str = 'rgb('+str(int(color_intensity))+',0,0)' return ImageColor.getrgb(rgb_str)
for y in range(10):
for y in range(BOTTOM_LEGEND_PX):
def getColor(hit_c): global hit_count_max global hit_count_min global hit_count_logmin global hit_count_logrange log_v = math.floor(math.log(hit_c)/math.log(2)) log_rebase = log_v - hit_count_logmin color_intensity=log_rebase*(255 / hit_count_logrange) rgb_str = 'rgb('+str(int(color_intensity))+',0,0)' return ImageColor.getrgb(rgb_str)
print 'NEW POST: %s: %s (%s)' % (entry.title, entry.link.replace("http://www.streetgeek.com.au/portal/modules.php?name=Forums&file=viewtopic&p=", "http://fj.streetgeek.com.au/"), feed) irc.action(CHANNEL, 'found a new post on %s: %s: %s' % (str(feed), str(entry.title.strip()), str(entry.link.strip().replace("http://www.streetgeek.com.au/portal/modules.php?name=Forums&file=viewtopic&p=", "http://fj.streetgeek.com.au/"))))
link = str(entry.link.replace("http://www.streetgeek.com.au/portal/modules.php?name=Forums&file=viewtopic&p=", "http://fj.streetgeek.com.au/")) print 'NEW POST: %s: %s (%s)' % (entry.title, link, feed) irc.action(CHANNEL, 'found a new post on %s: %s: %s' % (str(feed), str(entry.title), link))
def announce_post(irc, feed, entry): global CHANNEL print 'NEW POST: %s: %s (%s)' % (entry.title, entry.link.replace("http://www.streetgeek.com.au/portal/modules.php?name=Forums&file=viewtopic&p=", "http://fj.streetgeek.com.au/"), feed) irc.action(CHANNEL, 'found a new post on %s: %s: %s' % (str(feed), str(entry.title.strip()), str(entry.link.strip().replace("http://www.streetgeek.com.au/portal/modules.php?name=Forums&file=viewtopic&p=", "http://fj.streetgeek.com.au/"))))
message_buffer.append([event.nick, msg[:200], True])
message_buffer.append([event.nick, event.text[:200], True])
def handle_ctcp(event, match): global message_buffer, MAX_MESSAGES, CHANNEL if event.channel == CHANNEL: if event.args[0] == "ACTION": message_buffer.append([event.nick, msg[:200], True]) message_buffer = message_buffer[-MAX_MESSAGES:] return
self.channels.remove(channel)
del self.channels[channel.name]
def cleanup(self): # do some cleanup tasks to free some memory # hopefully python's resource counter will properly detect the object as something # that can be disposed of to_delete = [] for channel in self.channels.values(): if len(channel.members) == 0: to_delete.append(channel) for channel in to_delete: self.channels.remove(channel) del to_delete
self.bind(self._welcome_join, RPL_WELCOME)
def start_channels(self, chans): self._startChannels = chans self.bind(self._welcome_join, RPL_WELCOME)
e = re.compile(parts[1], re.I)
e = re.compile(parts[1])
def handle_pubmsg(connection, event): global message_buffer, MAX_MESSAGES, last_message nick = event.source().partition("!")[0] msg = event.arguments()[0] if msg.startswith('s/'): # handle regex parts = msg.split('/') # now flood protect! now = datetime.now() delta = now - last_message last_message = now if delta < timedelta(seconds=5): # 5 seconds between requests # any more are ignored print "Flood protection hit, %s of %s seconds were waited" % (delta.seconds, timedelta(seconds=5).seconds) connection.kick(event.target(), nick, 'Flood protection activated') return if len(message_buffer) == 0: connection.privmsg(event.target(), '%s: message buffer is empty' % nick) return if len(parts) == 3: connection.privmsg(event.target(), '%s: invalid regular expression, you forgot the trailing slash, dummy' % nick) return if len(parts) != 4: # not a valid regex connection.privmsg(event.target(), '%s: invalid regular expression, not the right amount of slashes' % nick) return # find messages matching the string if len(parts[1]) == 0: connection.privmsg(event.target(), '%s: original string is empty' % nick) return ignore_case = 'i' in parts[3] e = None try: if ignore_case: e = re.compile(parts[1], re.I) else: e = re.compile(parts[1], re.I) except Exception, ex: connection.privmsg(event.target(), '%s: failure compiling regular expression: %s' % (nick, ex)) return # now we have a valid regular expression matcher! for x in range(len(message_buffer)-1, -1, -1): if e.search(message_buffer[x][1]) != None: # match found! new_message = [] # replace the message in the buffer try: new_message = [message_buffer[x][0], e.sub(parts[2], message_buffer[x][1]).replace('\n','').replace('\r','')[:200]] del message_buffer[x] message_buffer.append(new_message) except Exception, ex: connection.privmsg(event.target(), '%s: failure replacing: %s' % (nick, ex)) return # now print the new text print new_message connection.privmsg(event.target(), ('<%s> %s' % (new_message[0], new_message[1]))[:200]) return # no match found connection.privmsg(event.target(), '%s: no match found' % nick) else: # add to buffer message_buffer.append([nick, msg[:200]]) # trim the buffer message_buffer = message_buffer[-MAX_MESSAGES:]
self.textures.append(tex.name)
print(tex.name) texObj = texList.getTexture(tex.name) if(texObj != None): print(texObj.name + " " + texObj.fileName) self.textures.append(texObj.fileName)
def populate(self, obj, texList): self.name = obj.name.replace(".", "_")
f.write("<MATERIAL NUMMAPS\"" + str(len(self.textures)) + "\">\n")
f.write("<MATERIAL NUMMAPS=\"" + str(len(self.textures)) + "\">\n")
def save(self, directory):
self.textures = cal3dTextures()
def getModel(self):
return min(voltage_color_list, key=(lambda a: xyYnorm(a[1])))
return min(voltage_color_list, key=(lambda a: xyYnorm(xyYdiff(a[1], target_color))))
def findBestColor(measured_color_red, measured_color_green, measured_color_blue, target_color): """ findBestColor returns a color, which is nearest targetColor. * measured_color -- contains the measured colors for each channel * target_color """ voltage_color_list = [] voltage_color_list.extend( measured_color_red ) voltage_color_list.extend( measured_color_green ) voltage_color_list.extend( measured_color_blue ) return min(voltage_color_list, key=(lambda a: xyYnorm(a[1])))
conf.registerPlugin('PackageInfo', True)
PackageInfo = conf.registerPlugin('PackageInfo', True)
def anything(prompt, default=None): """Because supybot is pure fail""" from supybot.questions import expect return expect(prompt, [], default=default)
"""
""" % (release, release)
def makeSource(release): return """deb http://archive.ubuntu.com/ubuntu/ %s main restricted universe multiverse
aptdir = something("Which directory should be used for the apt cache when looking up packages?", default=supybot.directories.data.dirize('aptdir'))
aptdir = something("Which directory should be used for the apt cache when looking up packages?", default=conf.supybot.directories.data.dirize('aptdir'))
def anything(prompt, default=None): """Because supybot is pure fail""" from supybot.questions import expect return expect(prompt, [], default=default)
while aptdir.beginswith('/var'):
while aptdir.startswith('/var'):
def anything(prompt, default=None): """Because supybot is pure fail""" from supybot.questions import expect return expect(prompt, [], default=default)
for release in default_dist:
try: os.makedirs(aptdir) except OSError: pass for release in default_dists:
def anything(prompt, default=None): """Because supybot is pure fail""" from supybot.questions import expect return expect(prompt, [], default=default)
fd = fileutils.open(filename)
fd = open(filename, 'wb')
def anything(prompt, default=None): """Because supybot is pure fail""" from supybot.questions import expect return expect(prompt, [], default=default)
release = "%s-%s" % sub filename = os.path.join(aptdir, "%s.list" % release)
sub_release = "%s-%s" % (release, sub) filename = os.path.join(aptdir, "%s.list" % sub_release)
def anything(prompt, default=None): """Because supybot is pure fail""" from supybot.questions import expect return expect(prompt, [], default=default)
fd.write(makeSource(release))
fd.write(makeSource(sub_release))
def anything(prompt, default=None): """Because supybot is pure fail""" from supybot.questions import expect return expect(prompt, [], default=default)
(e, o) = commands.getstatusoutput(update_apt) if e != 0:
if commands.getstatus(update_apt) != 0:
def anything(prompt, default=None): """Because supybot is pure fail""" from supybot.questions import expect return expect(prompt, [], default=default)
(e, o) = commands.statusoutput('which apt-file') if e != 0:
if commands.getstatusoutput('which apt-file') != 0:
def anything(prompt, default=None): """Because supybot is pure fail""" from supybot.questions import expect return expect(prompt, [], default=default)
(e, o) = commands.getstatusoutput(update_apt_file) if e != 0:
if commands.getstatusoutput(update_apt_file) != 0:
def anything(prompt, default=None): """Because supybot is pure fail""" from supybot.questions import expect return expect(prompt, [], default=default)
ztc.installPackage(zopyx.imgmap)
ztc.installPackage(zopyx.tinymceplugins.imgmap)
def setUp(cls): fiveconfigure.debug_mode = True ztc.installPackage(zopyx.imgmap) fiveconfigure.debug_mode = False
for anchor in soup.find('a'):
for anchor in soup.findAll('a'):
def __call__(self):
result.append(dict(name=name, text=text)) return
result.append(dict(name=name, text=name)) return demjson.encode(result)
def __call__(self):
def create_button(self, button_name): button = QPushButton(button_name) button.setFlat(True) button.setCheckable(True) button.clicked.connect(self.clickedButton) return button def update_label_buttons(self): label_vlayout = self.create_choice_list("Labels") self.label_buttongroup = QButtonGroup() for label_name in self.label_names: button = QPushButton(label_name) button.setFlat(True) button.setCheckable(True) button.clicked.connect(self.clickedLabelButton) label_vlayout.addWidget(button) self.label_buttongroup.addButton(button) if label_name == self.last_checked_label: button.setChecked(True)
def __init__(self, parent=None): QWidget.__init__(self, parent)
self.hlayout.addLayout(label_vlayout)
self.hlayout.setAlignment(Qt.AlignLeft) self.hlayout.addWidget(self.label_button_list)
def update_label_buttons(self): label_vlayout = self.create_choice_list("Labels") self.label_buttongroup = QButtonGroup() for label_name in self.label_names: button = QPushButton(label_name) button.setFlat(True) button.setCheckable(True) button.clicked.connect(self.clickedLabelButton) label_vlayout.addWidget(button) self.label_buttongroup.addButton(button) if label_name == self.last_checked_label: button.setChecked(True)
print self.hlayout.parent()
def init_button_lists(self): for label_name in self.label_names: button = self.label_button_list.add_button(label_name) button.clicked.connect(self.clickedLabelButton)
def update_label_buttons(self): label_vlayout = self.create_choice_list("Labels") self.label_buttongroup = QButtonGroup() for label_name in self.label_names: button = QPushButton(label_name) button.setFlat(True) button.setCheckable(True) button.clicked.connect(self.clickedLabelButton) label_vlayout.addWidget(button) self.label_buttongroup.addButton(button) if label_name == self.last_checked_label: button.setChecked(True)
def update_buttons(self): layout = self.hlayout.takeAt(1) for button in self.property_buttons: button.hide() del button
for key, property_values in self.properties.iteritems(): if key in ["type", "class"]: continue button_list = ButtonListWidget(key) for value in property_values: button_list.add_button(value) button_list.hide() print key self.property_button_lists[key] = button_list self.hlayout.addWidget(button_list)
def update_buttons(self): layout = self.hlayout.takeAt(1) for button in self.property_buttons: button.hide() del button
dynamic_hlayout = QHBoxLayout() self.property_buttons = [] if self.last_checked_label != None: for key in self.label_properties[self.last_checked_label].keys(): if key in ["type", "class"]: continue vlayout = self.create_choice_list(key) buttongroup = QButtonGroup() for value in self.properties[key]: button = self.create_button(value) self.property_buttons.append(button) vlayout.addWidget(button) buttongroup.addButton(button) dynamic_hlayout.addLayout(vlayout) self.hlayout.addLayout(dynamic_hlayout)
def show_only_label_properties(self, label_name): print "sdf", self.property_button_lists for name, button_list in self.property_button_lists.iteritems(): if name in self.label_properties[label_name].keys(): button_list.show() else: button_list.hide()
def update_buttons(self): layout = self.hlayout.takeAt(1) for button in self.property_buttons: button.hide() del button
return self.label_buttongroup.checkedButton() def create_choice_list(self, list_name, elements = []): vlayout = QVBoxLayout() vlayout.setSpacing(0) vlayout.addWidget(QLabel("<center><b>" + list_name + "</b></center>")) if len(elements) > 0: buttongroup = QButtonGroup() for element in elements: self.create_button(element) return vlayout
return self.label_button_list.get_checked_button()
def get_checked_label_button(self): return self.label_buttongroup.checkedButton()
print label_name, self.last_checked_label
print "ButtonArea:", label_name, self.last_checked_label
def clickedLabelButton(self): button = self.get_checked_label_button() label_name = str(button.text()) if label_name != self.last_checked_label: print label_name, self.last_checked_label self.last_checked_label = label_name self.update_buttons()
self.update_buttons()
self.show_only_label_properties(label_name)
def clickedLabelButton(self): button = self.get_checked_label_button() label_name = str(button.text()) if label_name != self.last_checked_label: print label_name, self.last_checked_label self.last_checked_label = label_name self.update_buttons()
self.update_label_buttons() self.update_buttons()
self.init_button_lists()
def load(self, config_filepath): execfile(config_filepath) #if self.get_checked_label_button() == None: # if len(self.label_buttongroup.buttons()) != 0: # self.label_buttongroup.buttons()[0].setChecked(True) # #self.last_checked_label = str(self.get_checked_label_button().text()) self.update_label_buttons() self.update_buttons()
print change
def itemChange(self, change, value): print change if change == QGraphicsItem.ItemScenePositionHasChanged: self.updateModel() return AnnotationGraphicsItem.itemChange(self, change, value)
print "updateModel (point)", self.data_
def updateModel(self): if not self._delayedDirty(): self.data_['x'] = self.scenePos().x() self.data_['y'] = self.scenePos().y() print "updateModel (point)", self.data_ self.index().model().setData(self.index(), QVariant(self.data_), DataRole)
def __init__(self, scene, model=None):
def __init__(self, scene, mode=None):
def __init__(self, scene, model=None): self.scene_ = scene self.mode_ = None
self.mode_ = None
self.mode_ = mode
def __init__(self, scene, model=None): self.scene_ = scene self.mode_ = None
item = QGraphicsEllipseItem(QRectF(pos.x()-1, pos.y()-1, 2, 2)) self.scene().addItem(item)
ann = {'type': 'point', 'x': event.pos().x(), 'y': event.pos().y()} index.model().addAnnotation(index, ann)
def mousePressEvent(self, event, index): pos = event.scenePos() # TODO create it in the model instead item = QGraphicsEllipseItem(QRectF(pos.x()-1, pos.y()-1, 2, 2)) self.scene().addItem(item)
def __init__(self, scene, model=None): ItemInserter.__init__(self, scene, model)
def __init__(self, scene, mode=None): ItemInserter.__init__(self, scene, mode)
def __init__(self, scene, model=None): ItemInserter.__init__(self, scene, model) self.current_item_ = None self.init_pos_ = None
pos = event.scenePos() rect = QRectF(self.init_pos_.x(), self.init_pos_.y(), pos.x() - self.init_pos_.x(), pos.y() - self.init_pos_.y()) self.current_item_.setRect(rect.normalized())
rect = QRectF(self.init_pos_, event.scenePos()).normalized() self.current_item_.setRect(rect)
def mouseMoveEvent(self, event, index): if self.current_item_ is not None: assert self.init_pos_ is not None pos = event.scenePos() rect = QRectF(self.init_pos_.x(), self.init_pos_.y(), pos.x() - self.init_pos_.x(), pos.y() - self.init_pos_.y()) self.current_item_.setRect(rect.normalized())
print "added rect:", self.current_item_
def mouseReleaseEvent(self, event, index): if self.current_item_ is not None: if self.current_item_.rect().width() > 1 and \ self.current_item_.rect().height() > 1: # TODO commit to the model print "added rect:", self.current_item_ rect = self.current_item_.rect() ann = {'type': 'rect', 'x': rect.x(), 'y': rect.y(), 'width': rect.width(), 'height': rect.height()} index.model().addAnnotation(index, ann) self.scene().removeItem(self.current_item_) self.current_item_ = None self.init_pos_ = None
def __init__(self, scene, model=None): ItemInserter.__init__(self, scene, model)
def __init__(self, scene, mode=None): ItemInserter.__init__(self, scene, mode)
def __init__(self, scene, model=None): ItemInserter.__init__(self, scene, model) self.current_item_ = None
self.addItemInserter('point', PointItemInserter(self)) self.addItemInserter('rect', RectItemInserter(self)) self.addItemInserter('poly', PolygonItemInserter(self)) self.addItemInserter('polygon', PolygonItemInserter(self)) self.setMode({'type': 'rect'})
self.addItemInserter('point', PointItemInserter(self)) self.addItemInserter('rect', RectItemInserter(self)) self.addItemInserter('ratiorect', FixedRatioRectItemInserter(self)) self.addItemInserter('poly', PolygonItemInserter(self)) self.addItemInserter('polygon', PolygonItemInserter(self)) self.setMode(None)
def __init__(self, parent=None): super(AnnotationScene, self).__init__(parent)
if event.key() == ord('A'): index = self.currentIndex() if not index.isValid(): return self.model().addAnnotation(index, {'type':'beer', 'alc': '5.1', 'name': 'rothaus'}) if event.key() == ord('D'): index = self.currentIndex() if not index.isValid(): return self.model().removeAnnotation(index)
def keyPressEvent(self, event): ## handle deletions of items if event.key() == Qt.Key_Delete: index = self.currentIndex() if not index.isValid(): return parent = self.model().parent(index) self.model().removeRow(index.row(), parent)
self.setCurrentFileIndex(next_index)
self.setCurrentIndex(next_index)
def gotoNext(self): # TODO move this to the scene if self.model_ is not None and self.current_index_ is not None: next_index = self.model_.getNextIndex(self.current_index_) self.setCurrentFileIndex(next_index)
self.setCurrentFileIndex(next_index)
self.setCurrentIndex(next_index)
def gotoPrevious(self): # TODO move this to the scene if self.model_ is not None and self.current_index_ is not None: next_index = self.model_.getNextIndex(self.current_index_) self.setCurrentFileIndex(next_index)
next_index = self.model_.getNextIndex(self.current_index_) self.setCurrentIndex(next_index)
prev_index = self.model_.getPreviousIndex(self.current_index_) self.setCurrentIndex(prev_index)
def gotoPrevious(self): # TODO move this to the scene if self.model_ is not None and self.current_index_ is not None: next_index = self.model_.getNextIndex(self.current_index_) self.setCurrentIndex(next_index)
self.setFrameStyle(QFrame.NoFrame)
self.setStyleSheet("QFrame { border: 3px solid black }");
def __init__(self, parent=None): QGraphicsView.__init__(self, parent) self.setRenderHint(QPainter.Antialiasing) self.setRenderHint(QPainter.TextAntialiasing) self.setFrameStyle(QFrame.NoFrame)
self.setFrameStyle(QFrame.Panel)
self.setStyleSheet("QFrame { border: 3px solid red }");
def activate(self): if not self.active_: self.active_ = True self.setFocus(Qt.OtherFocusReason) self.setFrameStyle(QFrame.Panel) self.update()
self.setFrameStyle(QFrame.NoFrame)
self.setStyleSheet("QFrame { border: 3px solid black }");
def deactivate(self): if self.active_: self.active_ = False self.clearFocus() self.setFrameStyle(QFrame.NoFrame) self.update()
self.update() self.updateGeometry()
def update_buttons(self): layout = self.hlayout.takeAt(1)
def get_bands(bitwised_band): """Returns all the bitwised bands in ``bitwised_band``""" return [band for band in MM_NETWORK_BANDS if band & bitwised_band]
def set_bands(self, bands, current):
def set_prefs(self, prefs, current):
def set_prefs(self, modes, current):
def set_prefs(self, prefs, current): model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_INT)
for value in prefs:
for value in [MM_NETWORK_MODE_ANY] + get_network_modes(modes):
def set_prefs(self, prefs, current): model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_INT)
if self.username is not None:
if self.username:
def save(self): props = { 'connection': { 'name': 'connection', 'id': self.name, 'type': 'gsm', 'uuid': self.uuid, 'autoconnect': self.autoconnect}, 'gsm': { 'name': 'gsm', 'number': '*99#', 'apn': self.apn.strip()}, 'ppp': { 'name': 'ppp', 'refuse-pap': True, 'refuse-chap': True, 'refuse-eap': True, 'refuse-mschap': True, 'refuse-mschapv2': True}, 'serial': { 'name': 'serial', 'baud': 115200}, 'ipv4': { 'name': 'ipv4', 'addresses': [], 'method': 'auto', 'ignore-auto-dns': self.static_dns, 'routes': []}, }
if True: height = 420 GLADE_FILE = os.path.join(GLADE_DIR, "VMC-reduced.glade") else: height = WIN_HEIGHT GLADE_FILE = os.path.join(GLADE_DIR, "VMC.glade")
height = 420 GLADE_FILE = os.path.join(GLADE_DIR, "bcm.glade")
def __init__(self, ctrl):
set_voucher_entry_view(ussd_voucher_update_response)
self.view.set_voucher_entry_view(ussd_voucher_update_response)
def check_voucher_update_response(self, ussd_voucher_update_response): device = self.model.get_device() # ok my job is to work out what happened after a credit voucher update message was sent. # we can have three possibilities, it was succesfull, the voucher code was wrong, or you tried with # an illegal number too many times. For now I only do something when it works, the other two # possibilities I just report the error provided by the network. if (ussd_voucher_update_response.find('TopUp successful') == -1): # ok we got a -1 from our 'find' so it failed just log for now as we report the message to the view no matter what happens. logger.info("payt-controoler check_voucher_update_response - topup failed: " + ussd_voucher_update_response)
logger.info("INFO profile.py: model - save properties dictionary is: %s" %props )
def save(self):
gprs_items = [item for item in self._get_month(offset) if item.is_gprs]
gprs_items = [item for item in self._get_month(offset) if item.is_gprs()]
def get_transferred_gprs(self, offset): # filter out all the items that respond True to "is_gprs" gprs_items = [item for item in self._get_month(offset) if item.is_gprs] # get a list with the total transferred for every item and sum them up result = sum((item.total() for item in gprs_items)) if offset == 0: result += self.twog_session return result