Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General: Python3 update #10

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ pip-delete-this-directory.txt

# IDEA pycharm/intellij
.idea/
.DS_Store
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"discord.removeRemoteRepository": true,
"discord.lowerDetailsEditing": "line: {current_line}"
}
Binary file added dependencies/astron/darwin/astrond
Binary file not shown.
Binary file added dependencies/astron/darwin/astrond-arm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added dependencies/astron/darwin/libuv.1.dylib
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion dependencies/config/general.prc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ notify-level-DistributedNPCScientistAI info
want-pstats #f

# Audio:
audio-library-name p3fmod_audio
audio-library-name p3openal_audio

# Graphics:
aux-display pandagl
Expand Down
4 changes: 2 additions & 2 deletions otp/ai/AIZoneData.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __str__(self):
output += '\n'
totalColliders = 0
totalTraversers = 0
for currCollTrav in self._collTravs.values():
for currCollTrav in list(self._collTravs.values()):
totalTraversers += 1
totalColliders += currCollTrav.getNumColliders()

Expand Down Expand Up @@ -183,7 +183,7 @@ def __init__(self):
self._zone2data = {}

def destroy(self):
for zone, data in self._zone2data.items():
for zone, data in list(self._zone2data.items()):
data.destroy()

del self._zone2data
Expand Down
4 changes: 2 additions & 2 deletions otp/ai/BanManagerAI.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from otp.ai.MagicWordGlobal import *
from direct.showbase.DirectObject import DirectObject
import threading
import httplib
import http.client

class BanFSM(FSM):

Expand All @@ -23,7 +23,7 @@ def __init__(self, air, avId):

def performBan(self):
self.ejectPlayer()
print(self.accountId)
print((self.accountId))

def ejectPlayer(self):
av = self.air.doId2do.get(self.avId)
Expand Down
2 changes: 1 addition & 1 deletion otp/ai/GarbageLeakServerEventAggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _stopSending(self):
self._doLaterName = None

def _sendLeaks(self, task = None):
for desc, curNum in self._curLeakDesc2num.iteritems():
for desc, curNum in list(self._curLeakDesc2num.items()):
self._sentLeakDesc2num.setdefault(desc, 0)
num = curNum - self._sentLeakDesc2num[desc]
if num > 0:
Expand Down
6 changes: 3 additions & 3 deletions otp/ai/MagicWordGlobal.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ def __init__(self, name, func, types, access, doc):
self.doc = doc

def parseArgs(self, string):
maxArgs = self.func.func_code.co_argcount
minArgs = maxArgs - (len(self.func.func_defaults) if self.func.func_defaults else 0)
maxArgs = self.func.__code__.co_argcount
minArgs = maxArgs - (len(self.func.__defaults__) if self.func.__defaults__ else 0)

args = string.split(None, maxArgs-1)[:maxArgs]
if len(args) < minArgs:
Expand Down Expand Up @@ -153,7 +153,7 @@ def __call__(self, mw):

name = self.name
if name is None:
name = mw.func_name
name = mw.__name__

word = MagicWord(name, mw, self.types, self.access, mw.__doc__)
spellbook.addWord(word)
Expand Down
4 changes: 2 additions & 2 deletions otp/ai/MagicWordManagerAI.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def sendMagicWord(self, word, targetId):
if not os.path.exists('user/logs/mw'):
os.makedirs('user/logs/mw')

print("%s | %s : %s\n" % (now, invokerId, word))
print(("%s | %s : %s\n" % (now, invokerId, word)))

if os.getenv('DISTRICT_NAME', 'Test Canvas') == "Test Canvas":
return
Expand All @@ -60,7 +60,7 @@ def sendMagicWord(self, word, targetId):

@magicWord(category=CATEGORY_COMMUNITY_MANAGER, types=[str])
def help(wordName=None):
print 'help called with %s' % (wordName)
print(('help called with %s' % (wordName)))
if not wordName:
return "What were you interested getting help for?"
word = spellbook.words.get(wordName.lower()) # look it up by its lower case value
Expand Down
4 changes: 2 additions & 2 deletions otp/ai/TimeManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def d_setFrameRate(self, fps, deviation, numAvs, locationCode, timeInLocation, t
'%0.03f,%0.03f' % cpuSpeed,
'%d,%d' % (numCpuCores, numLogicalCpus),
apiName)
print 'frame rate: %s' % info
print(('frame rate: %s' % info))
self.sendUpdate('setFrameRate', [fps,
deviation,
numAvs,
Expand Down Expand Up @@ -337,7 +337,7 @@ def getMacOsInfo(self, defaultOsInfo):
bugfix,
major,
minor)
except Exception, e:
except Exception as e:
self.notify.debug('getMacOsInfo %s' % str(e))

self.notify.debug('getMacOsInfo returning %s' % str(result))
Expand Down
2 changes: 1 addition & 1 deletion otp/avatar/DistributedAvatar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from toontown.toonbase import ToonPythonUtil as PythonUtil
from direct.task import Task
from pandac.PandaModules import *
from Avatar import Avatar
from .Avatar import Avatar
from otp.ai.MagicWordGlobal import *
from otp.otpbase import OTPGlobals
from toontown.battle.BattleProps import globalPropPool
Expand Down
6 changes: 3 additions & 3 deletions otp/avatar/DistributedPlayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ def setSystemMessage(self, aboutId, chatString, whisperType = WTSystem):
self.displayWhisper(aboutId, chatString, whisperType)

def displayWhisper(self, fromId, chatString, whisperType):
print 'Whisper type %s from %s: %s' % (whisperType, fromId, chatString)
print(('Whisper type %s from %s: %s' % (whisperType, fromId, chatString)))

def displayWhisperPlayer(self, playerId, chatString, whisperType):
print 'WhisperPlayer type %s from %s: %s' % (whisperType, playerId, chatString)
print(('WhisperPlayer type %s from %s: %s' % (whisperType, playerId, chatString)))

def whisperSCTo(self, msgIndex, sendToId, toPlayer):
messenger.send('wakeup')
Expand Down Expand Up @@ -239,7 +239,7 @@ def setTalkWhisper(self, fromAV, fromAC, avatarName, chat, mods, flags):
base.talkAssistant.receiveWhisperTalk(fromAV, avatarName, fromAC, None, self.doId, self.getName(), newText, scrubbed)

def displayTalkWhisper(self, fromId, avatarName, chatString, mods):
print 'TalkWhisper from %s: %s' % (fromId, chatString)
print(('TalkWhisper from %s: %s' % (fromId, chatString)))

def scrubTalk(self, chat, mods):
return chat
Expand Down
2 changes: 1 addition & 1 deletion otp/avatar/DistributedPlayerAI.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def accessLevel(accessLevel, storage='PERSISTENT', showGM=1):
if accessLevel not in accessName2Id:
return 'Invalid access level!'
accessLevel = accessName2Id[accessLevel]
if accessLevel not in accessName2Id.values():
if accessLevel not in list(accessName2Id.values()):
return 'Invalid access level!'
target = spellbook.getTarget()
invoker = spellbook.getInvoker()
Expand Down
2 changes: 1 addition & 1 deletion otp/avatar/Emote.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def __init__(self):
return

def isEnabled(self, index):
if isinstance(index, types.StringType):
if isinstance(index, bytes):
index = OTPLocalizer.EmoteFuncDict[index]
if self.emoteFunc == None:
return 0
Expand Down
21 changes: 3 additions & 18 deletions otp/avatar/LocalAvatar.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,22 +591,7 @@ def removeCameraPosition(self):
self.cameraPositions.remove(camPos)
self.nextCameraPos(1)

def printCameraPositions(self):
print '['
for i in xrange(len(self.cameraPositions)):
self.printCameraPosition(i)
print ','

print ']'

def printCameraPosition(self, index):
cp = self.cameraPositions[index]
print '(Point3(%0.2f, %0.2f, %0.2f),' % (cp[0][0], cp[0][1], cp[0][2])
print 'Point3(%0.2f, %0.2f, %0.2f),' % (cp[1][0], cp[1][1], cp[1][2])
print 'Point3(%0.2f, %0.2f, %0.2f),' % (cp[2][0], cp[2][1], cp[2][2])
print 'Point3(%0.2f, %0.2f, %0.2f),' % (cp[3][0], cp[3][1], cp[3][2])
print '%d,' % cp[4]
print ')',


def posCamera(self, lerp, time):
if not lerp:
Expand Down Expand Up @@ -1165,7 +1150,7 @@ def printCamPos(self):
node = base.camera.getParent()
pos = base.cam.getPos(node)
hpr = base.cam.getHpr(node)
print 'cam pos = ', `pos`, ', cam hpr = ', `hpr`
print('cam pos = ', repr(pos), ', cam hpr = ', repr(hpr))

def d_broadcastPositionNow(self):
self.d_clearSmoothing()
Expand Down Expand Up @@ -1232,7 +1217,7 @@ def d_setParent(self, parentToken):
DistributedSmoothNode.DistributedSmoothNode.d_setParent(self, parentToken)

def handlePlayerFriendWhisper(self, playerId, charMessage):
print 'handlePlayerFriendWhisper'
print('handlePlayerFriendWhisper')
self.displayWhisperPlayer(playerId, charMessage, WTNormal)

def canChat(self):
Expand Down
4 changes: 2 additions & 2 deletions otp/chat/ChatAgentAI.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from direct.distributed.MsgTypes import *
from time import gmtime, strftime
import json
import httplib
import http.client
import six

def to_bool(boolorstr):
Expand Down Expand Up @@ -58,7 +58,7 @@ def chatMessage(self, message, fakeChatMode):
self.sendUpdate('chatMessageAiToUd', [sender, message, chatMode])

def chatMessageResponse(self, sender, message, modifications, chatMode):
if sender not in self.air.doId2do.keys():
if sender not in list(self.air.doId2do.keys()):
# found an invalid sender!
return

Expand Down
4 changes: 2 additions & 2 deletions otp/chat/ChatGarbler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def garble(self, avatar, message):
newMessage = ''
numWords = random.randint(1, 7)
wordlist = OTPLocalizer.ChatGarblerDefault
for i in xrange(1, numWords + 1):
for i in range(1, numWords + 1):
wordIndex = random.randint(0, len(wordlist) - 1)
newMessage = newMessage + wordlist[wordIndex]
if i < numWords:
Expand All @@ -20,7 +20,7 @@ def garbleSingle(self, avatar, message):
newMessage = ''
numWords = 1
wordlist = OTPLocalizer.ChatGarblerDefault
for i in xrange(1, numWords + 1):
for i in range(1, numWords + 1):
wordIndex = random.randint(0, len(wordlist) - 1)
newMessage = newMessage + wordlist[wordIndex]
if i < numWords:
Expand Down
10 changes: 5 additions & 5 deletions otp/chat/TalkAssistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,12 @@ def fillWithTestText(self):
self.floodThreshold = hold

def printHistoryComplete(self):
print 'HISTORY COMPLETE'
print('HISTORY COMPLETE')
for message in self.historyComplete:
print '%s %s %s\n%s\n' % (message.getTimeStamp(),
print(('%s %s %s\n%s\n' % (message.getTimeStamp(),
message.getSenderAvatarName(),
message.getSenderAccountName(),
message.getBody())
message.getBody())))

def checkOpenTypedChat(self):
if base.localAvatar.commonChatFlags & OTPGlobals.CommonChat:
Expand Down Expand Up @@ -653,7 +653,7 @@ def sendGuildTalk(self, message):
if self.checkGuildTypedChat():
base.cr.guildManager.sendTalk(message)
else:
print 'Guild chat error'
print('Guild chat error')
error = ERROR_NO_GUILD_CHAT

return error
Expand Down Expand Up @@ -722,7 +722,7 @@ def sendGuildSpeedChat(self, type, msgIndex):
if self.checkGuildSpeedChat():
base.cr.guildManager.sendSC(msgIndex)
else:
print 'Guild Speedchat error'
print('Guild Speedchat error')
error = ERROR_NO_GUILD_CHAT
return error

Expand Down
10 changes: 5 additions & 5 deletions otp/distributed/ClientRepositoryBaseOR.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ def getObjectsOfClass(self, objClass):
""" returns dict of doId:object, containing all objects
that inherit from 'class'. returned dict is safely mutable. """
doDict = {}
for doId, do in self.doId2do.items():
for doId, do in list(self.doId2do.items()):
if isinstance(do, objClass):
doDict[doId] = do
return doDict
Expand All @@ -526,7 +526,7 @@ def getObjectsOfExactClass(self, objClass):
are exactly of type 'class' (neglecting inheritance). returned
dict is safely mutable. """
doDict = {}
for doId, do in self.doId2do.items():
for doId, do in list(self.doId2do.items()):
if do.__class__ == objClass:
doDict[doId] = do
return doDict
Expand Down Expand Up @@ -604,6 +604,6 @@ def _removeDelayDeletedDO(self, do):
def printDelayDeletes(self):
print('DelayDeletes:')
print('=============')
for obj in self._delayDeletedDOs.values():
print('%s\t%s (%s)\tdelayDeletes=%s' % (
obj.doId, safeRepr(obj), itype(obj), obj.getDelayDeleteNames()))
for obj in list(self._delayDeletedDOs.values()):
print(('%s\t%s (%s)\tdelayDeletes=%s' % (
obj.doId, safeRepr(obj), itype(obj), obj.getDelayDeleteNames())))
2 changes: 1 addition & 1 deletion otp/distributed/ClsendTracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def trackClientSendMsg(self, dataStr):
self._trimClsend()

def _trimClsend(self):
for i in xrange(self._clsendFlushNum):
for i in range(self._clsendFlushNum):
if self._logClsendOverflow:
self._logClsend(*self._clsendMsgs[0])
self._clsendMsgs = self._clsendMsgs[1:]
Expand Down
16 changes: 8 additions & 8 deletions otp/distributed/ConnectionRepository_override.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def readDCFile(self, dcFileNames=None):
if not readResult:
self.notify.error("Could not read dc file.")
self.hashVal = dcFile.getHash()
for n in xrange(dcFile.getNumImportModules()):
for n in range(dcFile.getNumImportModules()):
moduleName = dcFile.getImportModule(n)[:]
suffix = moduleName.split('/')
moduleName = suffix[0]
Expand All @@ -255,7 +255,7 @@ def readDCFile(self, dcFileNames=None):
elif self.dcSuffix == 'UD' and 'AI' in suffix: #HACK:
moduleName += 'AI'
importSymbols = []
for i in xrange(dcFile.getNumImportSymbols(n)):
for i in range(dcFile.getNumImportSymbols(n)):
symbolName = dcFile.getImportSymbol(n, i)
suffix = symbolName.split('/')
symbolName = suffix[0]
Expand All @@ -266,7 +266,7 @@ def readDCFile(self, dcFileNames=None):
symbolName += 'AI'
importSymbols.append(symbolName)
self.importModule(dcImports, moduleName, importSymbols)
for i in xrange(dcFile.getNumClasses()):
for i in range(dcFile.getNumClasses()):
dclass = dcFile.getClass(i)
number = dclass.getNumber()
className = dclass.getName() + self.dcSuffix
Expand All @@ -286,7 +286,7 @@ def readDCFile(self, dcFileNames=None):
continue
classDef = getattr(classDef, className)

if type(classDef) != types.ClassType and type(classDef) != types.TypeType:
if type(classDef) != type and type(classDef) != type:
self.notify.error("Symbol %s is not a class name." % (className))
else:
dclass.setClassDef(classDef)
Expand All @@ -297,15 +297,15 @@ def readDCFile(self, dcFileNames=None):
if self.hasOwnerView():
ownerDcSuffix = self.dcSuffix + 'OV'
ownerImportSymbols = {}
for n in xrange(dcFile.getNumImportModules()):
for n in range(dcFile.getNumImportModules()):
moduleName = dcFile.getImportModule(n)
suffix = moduleName.split('/')
moduleName = suffix[0]
suffix=suffix[1:]
if ownerDcSuffix in suffix:
moduleName = moduleName + ownerDcSuffix
importSymbols = []
for i in xrange(dcFile.getNumImportSymbols(n)):
for i in range(dcFile.getNumImportSymbols(n)):
symbolName = dcFile.getImportSymbol(n, i)
suffix = symbolName.split('/')
symbolName = suffix[0]
Expand All @@ -315,7 +315,7 @@ def readDCFile(self, dcFileNames=None):
importSymbols.append(symbolName)
ownerImportSymbols[symbolName] = None
self.importModule(dcImports, moduleName, importSymbols)
for i in xrange(dcFile.getNumClasses()):
for i in range(dcFile.getNumClasses()):
dclass = dcFile.getClass(i)
if ((dclass.getName()+ownerDcSuffix) in ownerImportSymbols):
number = dclass.getNumber()
Expand Down Expand Up @@ -347,7 +347,7 @@ def importModule(self, dcImports, moduleName, importSymbols):
if hasattr(module, "__all__"):
importSymbols = module.__all__
else:
importSymbols = module.__dict__.keys()
importSymbols = list(module.__dict__.keys())

for symbolName in importSymbols:
if hasattr(module, symbolName):
Expand Down
Loading