Replace removed Python 2 string-module functions
string.find/upper/join and string.letters were removed from the string module in Python 3, so these call sites raise AttributeError (or NameError) when reached. Replaced each with the str method equivalent: - otp/chat/ChatGlobals.py, ChatManager.py: string.find(message, ...) -> message.find(...) - otp/level/LevelSpec.py: string.upper(type) -> type.upper() - toontown/pets/PetBase.py, DistributedPetProxyAI.py, DistributedPetProxy.py: string.upper(valueName[0]) -> valueName[0].upper() - toontown/pets/PetshopGUI.py: string.join(descList, '\n') -> '\n'.join(descList) - toontown/shtiker/PhotoAlbumPage.py: string.letters -> string.ascii_letters (and added the missing import string) string.capwords and string.digits are still in the Py3 string module, so QuestPoster's capwords usage is untouched.
This commit is contained in:
parent
a5ecbb8b1e
commit
d519a8b71b
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -22,7 +22,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
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ class LevelSpec:
|
|||
entType2ids = self.getEntType2ids(entIds)
|
||||
types = sortList(list(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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -37,7 +37,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
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ 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:
|
||||
|
|
|
|||
|
|
@ -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('\n'.join(descList))
|
||||
self.petCost.append(cost)
|
||||
|
||||
def destroy(self):
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ from direct.gui.DirectGui import *
|
|||
from panda3d.core import *
|
||||
from toontown.toonbase import TTLocalizer
|
||||
import os
|
||||
import string
|
||||
from toontown.toonbase import ToontownGlobals
|
||||
|
||||
class PhotoAlbumPage(ShtikerPage.ShtikerPage):
|
||||
|
|
@ -88,7 +89,7 @@ class PhotoAlbumPage(ShtikerPage.ShtikerPage):
|
|||
|
||||
def renameDialog(self, str):
|
||||
separator = '_'
|
||||
validChars = string.letters + string.digits + ' -'
|
||||
validChars = string.ascii_letters + string.digits + ' -'
|
||||
str = [s for s in str if s in validChars]
|
||||
if not str:
|
||||
self.renameCleanup()
|
||||
|
|
|
|||
Loading…
Reference in New Issue