diff --git a/libotp/__init__.py b/libotp/__init__.py index e709f2c..1bbd01a 100644 --- a/libotp/__init__.py +++ b/libotp/__init__.py @@ -1,5 +1,5 @@ -from movement.CImpulse import CImpulse -from movement.CMover import CMover -from movement.CMoverGroup import CMoverGroup -from nametag import * -from settings.Settings import Settings +from .movement.CImpulse import CImpulse +from .movement.CMover import CMover +from .movement.CMoverGroup import CMoverGroup +from .nametag import * +from .settings.Settings import Settings diff --git a/libotp/movement/CMover.py b/libotp/movement/CMover.py index 8e85cd7..290ea64 100644 --- a/libotp/movement/CMover.py +++ b/libotp/movement/CMover.py @@ -64,7 +64,7 @@ class CMover: self.dt = clockDelta - self.dtClock self.dtClock = clockDelta - for cImpulse in self.cImpulses.values(): + for cImpulse in list(self.cImpulses.values()): cImpulse.process(self.getDt()) def addShove(self, shove): diff --git a/libotp/movement/CMoverGroup.py b/libotp/movement/CMoverGroup.py index 254baa2..8c3520f 100644 --- a/libotp/movement/CMoverGroup.py +++ b/libotp/movement/CMoverGroup.py @@ -37,6 +37,6 @@ class CMoverGroup: self.dt = clockDelta - self.dtClock self.dtClock = clockDelta - for cMover in self.cMovers.values(): + for cMover in list(self.cMovers.values()): cMover.processCImpulses(self.dt) cMover.integrate() diff --git a/libotp/nametag/ChatBalloon.py b/libotp/nametag/ChatBalloon.py index 2735847..cd123a7 100644 --- a/libotp/nametag/ChatBalloon.py +++ b/libotp/nametag/ChatBalloon.py @@ -1,7 +1,7 @@ from direct.directnotify import DirectNotifyGlobal from panda3d.core import * -import NametagGlobals +from . import NametagGlobals class ChatBalloon: @@ -30,7 +30,7 @@ class ChatBalloon: if node.isGeomNode(): return node - for i in xrange(node.getNumChildren()): + for i in range(node.getNumChildren()): n = ChatBalloon.find_geom_node(node.getChild(i)) if n: return n @@ -43,7 +43,7 @@ class ChatBalloon: return None child = None - for i in xrange(node.getNumChildren()): + for i in range(node.getNumChildren()): child = node.getChild(i) if child.getName() == 'middle': return n @@ -58,7 +58,7 @@ class ChatBalloon: if node.getName() == 'chatBalloon': return self.scan_balloon(node) - for i in xrange(node.getNumChildren()): + for i in range(node.getNumChildren()): if self.scan(node.getChild(i)): return True @@ -67,7 +67,7 @@ class ChatBalloon: def scan_balloon(self, node): self.m_copy_node = node.copySubgraph() - for i in xrange(node.getNumChildren()): + for i in range(node.getNumChildren()): child = node.getChild(i) if child.getName() == 'top': self.m_top_node = child diff --git a/libotp/nametag/ClickablePopup.py b/libotp/nametag/ClickablePopup.py index c1fe122..369b0ee 100644 --- a/libotp/nametag/ClickablePopup.py +++ b/libotp/nametag/ClickablePopup.py @@ -1,7 +1,7 @@ from direct.showbase.DirectObject import DirectObject from panda3d.core import * -import NametagGlobals +from . import NametagGlobals class PopupMouseWatcherRegion(MouseWatcherRegion): diff --git a/libotp/nametag/MarginManager.py b/libotp/nametag/MarginManager.py index e56ec4c..bd931a7 100644 --- a/libotp/nametag/MarginManager.py +++ b/libotp/nametag/MarginManager.py @@ -154,7 +154,7 @@ class MarginManager(PandaNode): if cell.m_available and not cell.m_np: cells.append(i) - for handle in self.m_popups.values(): + for handle in list(self.m_popups.values()): v7 = handle.m_popup if handle.m_wants_visible and not v7.isVisible(): v8 = self.chooseCell(v7, cells) @@ -163,7 +163,7 @@ class MarginManager(PandaNode): def showVisibleResolveConflict(self): v4 = [] - for handle in self.m_popups.values(): + for handle in list(self.m_popups.values()): score = 0 if handle.m_wants_visible: score = handle.m_score @@ -190,7 +190,7 @@ class MarginManager(PandaNode): def update(self): num_want_visible = 0 - for handle in self.m_popups.values(): + for handle in list(self.m_popups.values()): popup = handle.m_popup handle.m_wants_visible = popup.considerVisible() if handle.m_wants_visible and handle.m_objcode: @@ -207,5 +207,5 @@ class MarginManager(PandaNode): else: self.showVisibleNoConflict() - for popup in self.m_popups.keys(): + for popup in list(self.m_popups.keys()): popup.frameCallback() diff --git a/libotp/nametag/MarginPopup.py b/libotp/nametag/MarginPopup.py index 989a51d..f9b6439 100644 --- a/libotp/nametag/MarginPopup.py +++ b/libotp/nametag/MarginPopup.py @@ -1,6 +1,6 @@ from panda3d.core import * -import NametagGlobals +from . import NametagGlobals class MarginPopup(PandaNode): diff --git a/libotp/nametag/Nametag.py b/libotp/nametag/Nametag.py index 16c97b3..040d002 100644 --- a/libotp/nametag/Nametag.py +++ b/libotp/nametag/Nametag.py @@ -1,7 +1,7 @@ from direct.interval.IntervalGlobal import * -from ClickablePopup import * -from _constants import * +from .ClickablePopup import * +from ._constants import * class Nametag(ClickablePopup): diff --git a/libotp/nametag/Nametag2d.py b/libotp/nametag/Nametag2d.py index 0daf302..1af23ca 100644 --- a/libotp/nametag/Nametag2d.py +++ b/libotp/nametag/Nametag2d.py @@ -2,10 +2,10 @@ import math from panda3d.core import * -import NametagGlobals -from MarginPopup import MarginPopup -from Nametag import Nametag -from _constants import * +from . import NametagGlobals +from .MarginPopup import MarginPopup +from .Nametag import Nametag +from ._constants import * class Nametag2d(Nametag, MarginPopup): @@ -74,7 +74,7 @@ class Nametag2d(Nametag, MarginPopup): return np.getPos(NametagGlobals._toon).lengthSquared() def considerVisible(self): - from NametagGroup import NametagGroup + from .NametagGroup import NametagGroup v2 = 0 do_update = True diff --git a/libotp/nametag/Nametag3d.py b/libotp/nametag/Nametag3d.py index 2bb5173..7b13145 100644 --- a/libotp/nametag/Nametag3d.py +++ b/libotp/nametag/Nametag3d.py @@ -2,9 +2,9 @@ import math from panda3d.core import * -import NametagGlobals -from Nametag import Nametag -from _constants import * +from . import NametagGlobals +from .Nametag import Nametag +from ._constants import * class Nametag3d(Nametag, PandaNode): diff --git a/libotp/nametag/NametagFloat2d.py b/libotp/nametag/NametagFloat2d.py index 57c1c70..3c48f3a 100644 --- a/libotp/nametag/NametagFloat2d.py +++ b/libotp/nametag/NametagFloat2d.py @@ -1,4 +1,4 @@ -from Nametag3d import Nametag3d +from .Nametag3d import Nametag3d class NametagFloat2d(Nametag3d): diff --git a/libotp/nametag/NametagFloat3d.py b/libotp/nametag/NametagFloat3d.py index 74394be..0c7bc28 100644 --- a/libotp/nametag/NametagFloat3d.py +++ b/libotp/nametag/NametagFloat3d.py @@ -1,4 +1,4 @@ -from Nametag3d import Nametag3d +from .Nametag3d import Nametag3d class NametagFloat3d(Nametag3d): diff --git a/libotp/nametag/NametagGroup.py b/libotp/nametag/NametagGroup.py index 70574f2..ad8cb4b 100644 --- a/libotp/nametag/NametagGroup.py +++ b/libotp/nametag/NametagGroup.py @@ -1,9 +1,9 @@ from panda3d.core import * -import NametagGlobals -from Nametag2d import Nametag2d -from Nametag3d import Nametag3d -from _constants import * +from . import NametagGlobals +from .Nametag2d import Nametag2d +from .Nametag3d import Nametag3d +from ._constants import * class NametagGroup: @@ -282,7 +282,7 @@ class NametagGroup: def addNametag(self, nametag): if nametag.m_group: - print 'Attempt to add %s twice to %s.' % (nametag.__class__.__name__, self.m_name) + print('Attempt to add %s twice to %s.' % (nametag.__class__.__name__, self.m_name)) return nametag.m_group = self @@ -294,7 +294,7 @@ class NametagGroup: def removeNametag(self, nametag): if not nametag.m_group: - print 'Attempt to removed %s twice from %s.' % (nametag.__class__.__name__, self.m_name) + print('Attempt to removed %s twice from %s.' % (nametag.__class__.__name__, self.m_name)) return if self.m_manager: diff --git a/libotp/nametag/WhisperPopup.py b/libotp/nametag/WhisperPopup.py index b258bb8..5a82faf 100644 --- a/libotp/nametag/WhisperPopup.py +++ b/libotp/nametag/WhisperPopup.py @@ -1,5 +1,5 @@ -from ClickablePopup import * -from MarginPopup import * +from .ClickablePopup import * +from .MarginPopup import * class WhisperPopup(ClickablePopup, MarginPopup): diff --git a/libotp/nametag/__init__.py b/libotp/nametag/__init__.py index 10c788f..bdc402e 100644 --- a/libotp/nametag/__init__.py +++ b/libotp/nametag/__init__.py @@ -1,13 +1,13 @@ -import NametagGlobals -from ChatBalloon import ChatBalloon -from ClickablePopup import ClickablePopup -from MarginManager import MarginManager -from MarginPopup import MarginPopup -from Nametag import Nametag -from Nametag2d import Nametag2d -from Nametag3d import Nametag3d -from NametagFloat2d import NametagFloat2d -from NametagFloat3d import NametagFloat3d -from NametagGroup import NametagGroup -from WhisperPopup import WhisperPopup -from _constants import * +from . import NametagGlobals +from .ChatBalloon import ChatBalloon +from .ClickablePopup import ClickablePopup +from .MarginManager import MarginManager +from .MarginPopup import MarginPopup +from .Nametag import Nametag +from .Nametag2d import Nametag2d +from .Nametag3d import Nametag3d +from .NametagFloat2d import NametagFloat2d +from .NametagFloat3d import NametagFloat3d +from .NametagGroup import NametagGroup +from .WhisperPopup import WhisperPopup +from ._constants import * diff --git a/libtoontown/__init__.py b/libtoontown/__init__.py index ceb1915..5c9ddcf 100644 --- a/libtoontown/__init__.py +++ b/libtoontown/__init__.py @@ -1,4 +1,4 @@ from libpandadna import * -from pets.CPetBrain import CPetBrain -from pets.CPetChase import CPetChase -from pets.CPetFlee import CPetFlee +from .pets.CPetBrain import CPetBrain +from .pets.CPetChase import CPetChase +from .pets.CPetFlee import CPetFlee diff --git a/otp/otpbase/OTPLocalizer.py b/otp/otpbase/OTPLocalizer.py index f2802a3..303a243 100644 --- a/otp/otpbase/OTPLocalizer.py +++ b/otp/otpbase/OTPLocalizer.py @@ -15,7 +15,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 diff --git a/otp/otpbase/PythonUtil.py b/otp/otpbase/PythonUtil.py index e74894d..df7c74c 100644 --- a/otp/otpbase/PythonUtil.py +++ b/otp/otpbase/PythonUtil.py @@ -3,7 +3,7 @@ import sys __all__ = ['enumerate', 'nonRepeatingRandomList', 'describeException', 'pdir', 'choice'] -if not hasattr(__builtin__, 'enumerate'): +if not hasattr(builtins, 'enumerate'): def enumerate(L): """Returns (0, L[0]), (1, L[1]), etc., allowing this syntax: for i, item in enumerate(L): @@ -148,7 +148,7 @@ def quantizeVec(vec, divisor): vec[2] = quantize(vec[2], divisor) def isClient(): - if hasattr(__builtin__, 'simbase') and not hasattr(__builtin__, 'base'): + if hasattr(builtins, 'simbase') and not hasattr(builtins, 'base'): return False return True diff --git a/toontown/cogdominium/CogdoFlyingLegalEagle.py b/toontown/cogdominium/CogdoFlyingLegalEagle.py index c28529f..e4cbca8 100644 --- a/toontown/cogdominium/CogdoFlyingLegalEagle.py +++ b/toontown/cogdominium/CogdoFlyingLegalEagle.py @@ -15,7 +15,7 @@ from .CogdoFlyingUtil import swapAvatarShadowPlacer from . import CogdoUtil from . import CogdoFlyingGameGlobals as Globals -class CogdoFlyingLegalEagle(DirectObject, FSM): +class CogdoFlyingLegalEagle(FSM, DirectObject): CollSphereName = 'CogdoFlyingLegalEagleSphere' CollisionEventName = 'CogdoFlyingLegalEagleCollision' InterestCollName = 'CogdoFlyingLegalEagleInterestCollision' diff --git a/toontown/effects/FireworkShowMixin.py b/toontown/effects/FireworkShowMixin.py index aa13895..3bcfadb 100644 --- a/toontown/effects/FireworkShowMixin.py +++ b/toontown/effects/FireworkShowMixin.py @@ -135,7 +135,6 @@ class FireworkShowMixin: def restoreCameraLens(self): hood = self.getHood() - from toontown.hood import * if isinstance(hood, OZHood.OZHood): base.camLens.setFar(SpeedwayCameraFar) elif isinstance(hood, GSHood.GSHood): @@ -177,7 +176,6 @@ class FireworkShowMixin: self.fireworkShow.begin(timeStamp) self.fireworkShow.reparentTo(root) hood = self.getHood() - from toontown.hood import * if isinstance(hood, TTHood.TTHood): self.fireworkShow.setPos(150, 0, 80) self.fireworkShow.setHpr(90, 0, 0) diff --git a/toontown/estate/GardenGlobals.py b/toontown/estate/GardenGlobals.py index 91fa458..994b034 100644 --- a/toontown/estate/GardenGlobals.py +++ b/toontown/estate/GardenGlobals.py @@ -298,7 +298,7 @@ if ACCELERATOR_USED_FROM_SHTIKER_BOOK: del PlantAttributes[202] def getTreeTrackAndLevel(typeIndex): - track = typeIndex / 7 + track = int(typeIndex / 7) level = typeIndex % 7 return (track, level) diff --git a/toontown/parties/PartyEditor.py b/toontown/parties/PartyEditor.py index 911d64e..87e37a5 100644 --- a/toontown/parties/PartyEditor.py +++ b/toontown/parties/PartyEditor.py @@ -1,5 +1,4 @@ import time -from sets import Set from pandac.PandaModules import Vec3, Vec4, Point3, TextNode, VBase4 from direct.gui.DirectGui import DirectFrame, DirectButton, DirectLabel, DirectScrolledList, DirectCheckButton from direct.gui import DirectGuiGlobals @@ -14,7 +13,7 @@ from toontown.parties import PartyUtils from toontown.parties.PartyEditorGrid import PartyEditorGrid from toontown.parties.PartyEditorListElement import PartyEditorListElement -class PartyEditor(DirectObject, FSM): +class PartyEditor(FSM, DirectObject): notify = directNotify.newCategory('PartyEditor') def __init__(self, partyPlanner, parent): @@ -172,13 +171,13 @@ class PartyEditor(DirectObject, FSM): def getMutuallyExclusiveActivities(self): currentActivities = self.partyEditorGrid.getActivitiesOnGrid() - actSet = Set([]) + actSet = set([]) for act in currentActivities: actSet.add(act[0]) result = None for mutuallyExclusiveTuples in PartyGlobals.MutuallyExclusiveActivities: - mutSet = Set(mutuallyExclusiveTuples) + mutSet = set(mutuallyExclusiveTuples) inter = mutSet.intersection(actSet) if len(inter) > 1: result = inter diff --git a/toontown/quest/QuestParser.py b/toontown/quest/QuestParser.py index 21be84e..ac39940 100644 --- a/toontown/quest/QuestParser.py +++ b/toontown/quest/QuestParser.py @@ -49,7 +49,7 @@ def clear(): def readFile(filename): global curId scriptFile = StreamReader(vfs.openReadFile(filename, 1), 1) - gen = tokenize.generate_tokens(scriptFile.readline) + gen = tokenize.tokenize(scriptFile.readline) line = getLineOfTokens(gen) while line is not None: if line == []: @@ -73,7 +73,7 @@ def getLineOfTokens(gen): if token[0] == tokenize.ENDMARKER: return None while token[0] != tokenize.NEWLINE and token[0] != tokenize.NL: - if token[0] == tokenize.COMMENT: + if token[0] in (tokenize.COMMENT, tokenize.ENCODING): pass elif token[0] == tokenize.OP and token[1] == '-': nextNeg = 1 diff --git a/toontown/racing/KartShopGui.py b/toontown/racing/KartShopGui.py index 859854c..42642a6 100644 --- a/toontown/racing/KartShopGui.py +++ b/toontown/racing/KartShopGui.py @@ -27,7 +27,7 @@ BTA_OPTIONS = PythonUtil.Enum('Ok', -1) KS_TEXT_SIZE_BIG = TTLocalizer.KSGtextSizeBig KS_TEXT_SIZE_SMALL = TTLocalizer.KSGtextSizeSmall -class KartShopGuiMgr(object, DirectObject.DirectObject): +class KartShopGuiMgr(DirectObject.DirectObject, object): notify = DirectNotifyGlobal.directNotify.newCategory('KartShopGuiMgr') class MainMenuDlg(DirectFrame): diff --git a/toontown/safezone/DistributedFindFour.py b/toontown/safezone/DistributedFindFour.py index 688abaf..d77b673 100644 --- a/toontown/safezone/DistributedFindFour.py +++ b/toontown/safezone/DistributedFindFour.py @@ -15,6 +15,7 @@ from toontown.toonbase import ToontownGlobals from direct.distributed.ClockDelta import * from otp.otpbase import OTPGlobals from direct.showbase import PythonUtil +from random import * class DistributedFindFour(DistributedNode.DistributedNode): @@ -605,7 +606,6 @@ class DistributedFindFour(DistributedNode.DistributedNode): else: hasfound = False while hasfound == False: - from random import * x = randint(0, 6) if self.board[0][x] == 0: self.d_requestMove(x) diff --git a/toontown/toon/Toon.py b/toontown/toon/Toon.py index 7568312..dfb8fea 100644 --- a/toontown/toon/Toon.py +++ b/toontown/toon/Toon.py @@ -337,7 +337,7 @@ def loadPhaseAnims(phaseStr = 'phase_3', loadFlag = 1): base.localAvatar.unloadAnims([anim[0]], 'torso', None) for key in list(HeadDict.keys()): - if string.find(key, 'd') >= 0: + if key.find('d') >= 0: for anim in animList: if loadFlag: pass @@ -382,7 +382,7 @@ def compileGlobalAnimList(): TorsoAnimDict[key][anim[0]] = file for key in list(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] diff --git a/toontown/toonbase/TTLocalizer.py b/toontown/toonbase/TTLocalizer.py index 2e9c279..7dfce6d 100644 --- a/toontown/toonbase/TTLocalizer.py +++ b/toontown/toonbase/TTLocalizer.py @@ -15,7 +15,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 diff --git a/toontown/uberdog/DataStore.py b/toontown/uberdog/DataStore.py index 2d5ec9d..d412a49 100644 --- a/toontown/uberdog/DataStore.py +++ b/toontown/uberdog/DataStore.py @@ -1,7 +1,6 @@ from direct.directnotify import DirectNotifyGlobal from pandac.PandaModules import ConfigVariableBool from direct.task import Task -from string import maketrans import pickle import os import sys @@ -136,7 +135,7 @@ class DataStore: self.close() if self.wantAnyDbm: lt = time.asctime(time.localtime()) - trans = maketrans(': ', '__') + trans = ': '.maketrans('__') t = lt.translate(trans) head, tail = os.path.split(self.filepath) newFileName = 'UDStoreBak' + t