general: For compatibility with Panda3D 1.8.1, don't do string.foo(bar), do bar.foo().

This commit is contained in:
Sam Edwards 2013-10-06 20:37:07 -06:00
parent 6d8dd6f87e
commit 3f0a989ded
28 changed files with 50 additions and 55 deletions

View file

@ -146,7 +146,7 @@ class MagicWordManager(DistributedObject.DistributedObject):
elif wordIs('~avId'):
self.setMagicWordResponse(str(localAvatar.doId))
elif wordIs('~doId'):
name = string.strip(word[6:])
name = word[6:].strip()
objs = self.identifyDistributedObjects(name)
if len(objs) == 0:
response = '%s is unknown.' % name
@ -184,13 +184,13 @@ class MagicWordManager(DistributedObject.DistributedObject):
self.setMagicWordResponse(response)
else:
tm.extraSkew = 0.0
skew = string.strip(word[5:])
skew = word[5:].strip()
if skew != '':
tm.extraSkew = float(skew)
globalClockDelta.clear()
tm.handleHotkey()
elif wordIs('~period'):
timeout = string.strip(word[7:])
timeout = word[7:].strip()
if timeout != '':
seconds = int(timeout)
self.cr.stopPeriodTimer()
@ -618,7 +618,7 @@ class MagicWordManager(DistributedObject.DistributedObject):
return
nextWord = word[b + 1:]
name = string.strip(word[5:b])
name = word[5:b].strip()
id = self.identifyAvatar(name)
if id == None:
self.setMagicWordResponse("Don't know who %s is." % name)
@ -631,7 +631,7 @@ class MagicWordManager(DistributedObject.DistributedObject):
def identifyDistributedObjects(self, name):
result = []
lowerName = string.lower(name)
lowerName = name.lower()
for obj in self.cr.doId2do.values():
className = obj.__class__.__name__
try:
@ -639,7 +639,7 @@ class MagicWordManager(DistributedObject.DistributedObject):
except:
name = className
if string.lower(name) == lowerName or string.lower(className) == lowerName or string.lower(className) == 'distributed' + lowerName:
if name.lower() == lowerName or className.lower() == lowerName or className.lower() == 'distributed' + lowerName:
result.append((name, obj))
return result
@ -666,7 +666,7 @@ class MagicWordManager(DistributedObject.DistributedObject):
return
def getCSBitmask(self, str):
words = string.lower(str).split()
words = str.lower().split()
if len(words) == 0:
return None
invalid = ''
@ -717,7 +717,7 @@ class MagicWordManager(DistributedObject.DistributedObject):
return None
def showfont(self, fontname):
fontname = string.strip(string.lower(fontname))
fontname = string.lower(fontname.strip())
font = self.getFontByName(fontname)
if font == None:
self.setMagicWordResponse('Unknown font: %s' % fontname)
@ -842,9 +842,9 @@ class MagicWordManager(DistributedObject.DistributedObject):
if isinstance(av, self.GameAvatarClass) and av.getName() == name:
return av.doId
lowerName = string.lower(name)
lowerName = name.lower()
for av in Avatar.Avatar.ActiveAvatars:
if isinstance(av, self.GameAvatarClass) and string.strip(string.lower(av.getName())) == lowerName:
if isinstance(av, self.GameAvatarClass) and string.lower(av.getName(.strip())) == lowerName:
return av.doId
try:

View file

@ -40,7 +40,7 @@ ThoughtPrefix = '.'
def isThought(message):
if len(message) == 0:
return 0
elif string.find(message, ThoughtPrefix, 0, len(ThoughtPrefix)) >= 0:
elif message.find(ThoughtPrefix, 0, len(ThoughtPrefix)) >= 0:
return 1
else:
return 0

View file

@ -24,7 +24,7 @@ ThoughtPrefix = '.'
def isThought(message):
if len(message) == 0:
return 0
elif string.find(message, ThoughtPrefix, 0, len(ThoughtPrefix)) >= 0:
elif message.find(ThoughtPrefix, 0, len(ThoughtPrefix)) >= 0:
return 1
else:
return 0

View file

@ -208,7 +208,7 @@ class TalkAssistant(DirectObject.DirectObject):
return 0
elif len(message) == 0:
return 0
elif string.find(message, ThoughtPrefix, 0, len(ThoughtPrefix)) >= 0:
elif message.find(ThoughtPrefix, 0, len(ThoughtPrefix)) >= 0:
return 1
else:
return 0

View file

@ -513,9 +513,9 @@ class OTPClientRepository(ClientRepositoryBase):
if downloadParFilename.exists():
downloadPar = open(downloadParFilename.toOsSpecific())
for line in downloadPar.readlines():
i = string.find(line, 'VALIDATE_DOWNLOAD=')
i = line.find('VALIDATE_DOWNLOAD=')
if i != -1:
self.validateDownload = string.strip(line[i + 18:])
self.validateDownload = line[i + 18:].strip()
break
def getServerVersion(self):

View file

@ -448,7 +448,7 @@ class FriendSecret(DirectFrame, StateData.StateData):
def __enterSecret(self, secret):
self.enterSecret.set('')
secret = string.strip(secret)
secret = secret.strip()
if not secret:
self.exit()
return

View file

@ -188,7 +188,7 @@ class LauncherBase(DirectObject):
downloadServerString = self.getValue('DOWNLOAD_SERVER', '')
self.notify.info('Download Server List %s' % downloadServerString)
self.downloadServerList = []
for name in string.split(downloadServerString, ';'):
for name in downloadServerString.split(';'):
url = URLSpec(name, 1)
self.downloadServerList.append(url)
@ -921,7 +921,7 @@ class LauncherBase(DirectObject):
if self.linesInProgress[i].find(phase) > -1:
nameSizeTuple = self.linesInProgress[i].split()
numSize = nameSizeTuple[1].split('L')
sum += string.atoi(numSize[0])
sum += numSize[0].atoi()
return sum

View file

@ -60,7 +60,7 @@ class Entity(DirectObject):
return self.getZoneEntity().getNodePath()
def privGetSetter(self, attrib):
setFuncName = 'set%s%s' % (string.upper(attrib[0]), attrib[1:])
setFuncName = 'set%s%s' % (attrib[0].upper(), attrib[1:])
if hasattr(self, setFuncName):
return getattr(self, setFuncName)
return None

View file

@ -24,11 +24,11 @@ class EntityTypeRegistry:
return filename
fileLines = file(getPyExtVersion(EntityTypes.__file__)).readlines()
hv.hashString(string.join(fileLines, ''))
hv.hashString(fileLines.join(''))
s = str(hv.asHex())
s += '.'
fileLines = file(getPyExtVersion(self.entTypeModule.__file__)).readlines()
hv.hashString(string.join(fileLines, ''))
hv.hashString(fileLines.join(''))
s += str(hv.asHex())
self.hashStr = s
getPyExtVersion = None

View file

@ -305,7 +305,7 @@ class LevelSpec:
entType2ids = self.getEntType2ids(entIds)
types = sortList(entType2ids.keys(), firstTypes)
for type in types:
str += t(1) + '# %s\n' % string.upper(type)
str += t(1) + '# %s\n' % type.upper()
entIds = entType2ids[type]
entIds.sort()
for entId in entIds:

View file

@ -22,7 +22,7 @@ class PropSpinner(Entity):
nameParts = name.split('_')
axis = nameParts[2]
rate = 0
neg = string.upper(nameParts[3][0]) == 'N'
neg = nameParts[3][0].upper() == 'N'
if neg:
nameParts[3] = nameParts[3][1:]
try:

View file

@ -14,7 +14,7 @@ def getLanguage():
print 'OTPLocalizer: Running in language: %s' % language
if language == 'english':
_languageModule = 'otp.otpbase.OTPLocalizer' + string.capitalize(language)
_languageModule = 'otp.otpbase.OTPLocalizer' + language.capitalize()
else:
checkLanguage = 1
_languageModule = 'otp.otpbase.OTPLocalizer_' + language

View file

@ -229,13 +229,13 @@ class ToontownMagicWordManager(MagicWordManager.MagicWordManager):
self.setMagicWordResponse(response)
else:
tm.extraSkew = 0.0
skew = string.strip(word[5:])
skew = word[5:].strip()
if skew != '':
tm.extraSkew = float(skew)
globalClockDelta.clear()
tm.handleHotkey()
elif wordIs('~period'):
timeout = string.strip(word[7:])
timeout = word[7:].strip()
if timeout != '':
seconds = int(timeout)
base.cr.stopPeriodTimer()
@ -679,7 +679,7 @@ class ToontownMagicWordManager(MagicWordManager.MagicWordManager):
def identifyDistributedObjects(self, name):
result = []
lowerName = string.lower(name)
lowerName = name.lower()
for obj in base.cr.doId2do.values():
className = obj.__class__.__name__
try:
@ -687,13 +687,13 @@ class ToontownMagicWordManager(MagicWordManager.MagicWordManager):
except:
name = className
if string.lower(name) == lowerName or string.lower(className) == lowerName or string.lower(className) == 'distributed' + lowerName:
if name.lower() == lowerName or className.lower() == lowerName or className.lower() == 'distributed' + lowerName:
result.append((name, obj))
return result
def getCSBitmask(self, str):
words = string.lower(str).split()
words = str.lower().split()
if len(words) == 0:
return None
invalid = ''

View file

@ -179,7 +179,7 @@ class DistributedCCharBase(DistributedChar.DistributedChar):
if '%' in str:
str = copy.deepcopy(str)
avName = avatar.getName()
str = string.replace(str, '%', avName)
str = str.replace('%', avName)
track = Sequence()
if category != CCharChatter.GOODBYE:
curHpr = self.getHpr()

View file

@ -13,7 +13,6 @@ from toontown.cogdominium import CogdoEntityCreator
import string
class InGameEditorEntityBase(InGameEditorElement):
def __init__(self):
InGameEditorElement.__init__(self)

View file

@ -926,7 +926,7 @@ class HoodMgr(DirectObject.DirectObject):
return tunnelOriginList
def extractGroupName(self, groupFullName):
return string.split(groupFullName, ':', 1)[0]
return groupFullName.split(':', 1)[0]
def makeLinkTunnelName(self, hoodId, currentZone):
return '**/toph_' + self.getNameFromId(hoodId) + '_' + str(currentZone)

View file

@ -13,7 +13,6 @@ from direct.fsm import ClassicFSM, State
from direct.fsm import State
from toontown.toontowngui import TTDialog
import re
import string
from toontown.toonbase import TTLocalizer
import NameGenerator
import random
@ -537,7 +536,7 @@ class NameShop(StateData.StateData):
def match(npcName, name = name):
name = TextEncoder().encodeWtext(name)
name = string.strip(name)
name = name.strip()
return TextEncoder.upper(npcName) == TextEncoder.upper(name)
for npcId in NPCToons.NPCToonDict.keys():

View file

@ -538,7 +538,7 @@ class DistributedPatternGame(DistributedMinigame):
return self.__getRowPos(self.frontRowHome, self.frontRowXSpacing, index, len(self.avIdList))
def __setMinnieChat(self, str, giggle):
str = string.replace(str, '%s', self.getAvatar(self.localAvId).getName())
str = str.replace('%s', self.getAvatar(self.localAvId).getName())
self.minnie.setChatAbsolute(str, CFSpeech)
if giggle:
self.minnie.playDialogue('statementA', 1)

View file

@ -25,7 +25,7 @@ class DistributedPetProxy(DistributedObject.DistributedObject):
self.requiredMoodComponents = {}
def getSetterName(self, valueName, prefix = 'set'):
return '%s%s%s' % (prefix, string.upper(valueName[0]), valueName[1:])
return '%s%s%s' % (prefix, valueName[0].upper(), valueName[1:])
def setOwnerId(self, ownerId):
self.ownerId = ownerId

View file

@ -6,7 +6,6 @@ from toontown.pets import PetMood
from toontown.toonbase import ToontownGlobals
import random
import time
import string
import copy
BATTLE_TRICK_HP_MULTIPLIER = 10.0
@ -37,7 +36,7 @@ class DistributedPetProxyAI(DistributedObjectAI.DistributedObjectAI):
self.__generateDistMoodFuncs()
def getSetterName(self, valueName, prefix = 'set'):
return '%s%s%s' % (prefix, string.upper(valueName[0]), valueName[1:])
return '%s%s%s' % (prefix, valueName[0].upper(), valueName[1:])
def setDNA(self, dna):
head, ears, nose, tail, body, color, colorScale, eyes, gender = dna

View file

@ -1,11 +1,10 @@
from toontown.pets.PetConstants import AnimMoods
from toontown.pets import PetMood
import string
class PetBase:
def getSetterName(self, valueName, prefix = 'set'):
return '%s%s%s' % (prefix, string.upper(valueName[0]), valueName[1:])
return '%s%s%s' % (prefix, valueName[0].upper(), valueName[1:])
def getAnimMood(self):
if self.mood.getDominantMood() in PetMood.PetMood.ExcitedMoods:

View file

@ -358,7 +358,7 @@ class PetshopGUI(DirectObject):
descList.append('\t%s' % trait)
descList.append(TTLocalizer.PetshopDescCost % cost)
self.petDesc.append(string.join(descList, '\n'))
self.petDesc.append(descList.join('\n'))
self.petCost.append(cost)
def destroy(self):

View file

@ -389,7 +389,7 @@ class QuestPoster(DirectFrame):
rIconGeom = self.createSuitHead(holder)
lPos.setX(-0.18)
auxText = TTLocalizer.QuestPosterAuxFrom
infoText = string.capwords(quest.getLocationName())
infoText = quest.getLocationName().capwords()
if infoText == '':
infoText = TTLocalizer.QuestPosterAnywhere
elif quest.getType() == Quests.VisitQuest:
@ -867,7 +867,7 @@ class QuestPoster(DirectFrame):
lIconGeomScale = IMAGE_SCALE_SMALL
cogIcons.removeNode()
if not fComplete:
infoText = string.capwords(quest.getLocationName())
infoText = quest.getLocationName().capwords()
if infoText == '':
infoText = TTLocalizer.QuestPosterAnywhere
if fComplete:

View file

@ -18164,7 +18164,7 @@ def getNpcLocationDialog(fromNpcId, toNpcId):
def fillInQuestNames(text, avName = None, fromNpcId = None, toNpcId = None):
text = copy.deepcopy(text)
if avName != None:
text = string.replace(text, '_avName_', avName)
text = text.replace('_avName_', avName)
if toNpcId:
if toNpcId == ToonHQ:
toNpcName = TTLocalizer.QuestsHQOfficerFillin
@ -18179,10 +18179,10 @@ def fillInQuestNames(text, avName = None, fromNpcId = None, toNpcId = None):
else:
toNpcName = str(NPCToons.getNPCName(toNpcId))
where, buildingName, streetDesc = getNpcLocationDialog(fromNpcId, toNpcId)
text = string.replace(text, '_toNpcName_', toNpcName)
text = string.replace(text, '_where_', where)
text = string.replace(text, '_buildingName_', buildingName)
text = string.replace(text, '_streetDesc_', streetDesc)
text = text.replace('_toNpcName_', toNpcName)
text = text.replace('_where_', where)
text = text.replace('_buildingName_', buildingName)
text = text.replace('_streetDesc_', streetDesc)
return text

View file

@ -927,7 +927,7 @@ class Suit(Avatar.Avatar):
else:
self.setSuitClothes(self.loseActor)
else:
loseModel = 'phase_5/models/char/cog' + string.upper(self.style.body) + '_robot-lose-mod'
loseModel = 'phase_5/models/char/cog' + self.style.body.upper() + '_robot-lose-mod'
filePrefix, phase = TutorialModelDict[self.style.body]
loseAnim = 'phase_' + str(phase) + filePrefix + 'lose'
self.loseActor = Actor.Actor(loseModel, {'lose': loseAnim})
@ -951,7 +951,7 @@ class Suit(Avatar.Avatar):
return
def makeSkeleton(self):
model = 'phase_5/models/char/cog' + string.upper(self.style.body) + '_robot-zero'
model = 'phase_5/models/char/cog' + self.style.body.upper() + '_robot-zero'
anims = self.generateAnimDict()
anim = self.getCurrentAnim()
dropShadow = self.dropShadow

View file

@ -520,7 +520,7 @@ class SuitPlannerBase:
self.setupDNA()
def extractGroupName(self, groupFullName):
return string.split(groupFullName, ':', 1)[0]
return groupFullName.split(':', 1)[0]
def initDNAInfo(self):
numGraphs = self.dnaStore.discoverContinuity()

View file

@ -4,7 +4,6 @@ import ToonDNA
from direct.task.Task import Task
from toontown.suit import SuitDNA
from direct.actor import Actor
import string
from ToonHead import *
from pandac.PandaModules import *
from direct.interval.IntervalGlobal import *
@ -335,7 +334,7 @@ def loadPhaseAnims(phaseStr = 'phase_3', loadFlag = 1):
base.localAvatar.unloadAnims([anim[0]], 'torso', None)
for key in HeadDict.keys():
if string.find(key, 'd') >= 0:
if key.find('d') >= 0:
for anim in animList:
if loadFlag:
pass
@ -380,7 +379,7 @@ def compileGlobalAnimList():
TorsoAnimDict[key][anim[0]] = file
for key in HeadDict.keys():
if string.find(key, 'd') >= 0:
if key.find('d') >= 0:
HeadAnimDict.setdefault(key, {})
for anim in animList:
file = phaseStr + HeadDict[key] + anim[1]

View file

@ -14,7 +14,7 @@ def getLanguage():
print 'TTLocalizer: Running in language: %s' % language
if language == 'english':
_languageModule = 'toontown.toonbase.TTLocalizer' + string.capitalize(language)
_languageModule = 'toontown.toonbase.TTLocalizer' + language.capitalize()
else:
checkLanguage = 1
_languageModule = 'toontown.toonbase.TTLocalizer_' + language