direct: Use warnings module for more verbose deprecation prints

Closes #1067
Fixes #669
This commit is contained in:
Timothy Paustian 2021-03-09 18:32:36 +01:00 committed by rdb
parent ff80adc680
commit 2493c0689f
14 changed files with 476 additions and 394 deletions

View File

@ -11,7 +11,7 @@ from panda3d.core import Loader as PandaLoader
from direct.showbase.DirectObject import DirectObject
from direct.showbase.Loader import Loader
from direct.directnotify import DirectNotifyGlobal
import warnings
class Actor(DirectObject, NodePath):
"""
@ -1652,6 +1652,8 @@ class Actor(DirectObject, NodePath):
This method is deprecated. You should use setBlend() instead.
"""
if __debug__:
warnings.warn("This method is deprecated. You should use setBlend() instead.", DeprecationWarning, stacklevel=2)
self.setBlend(animBlend = True, blendType = blendType, partName = partName)
def disableBlend(self, partName = None):
@ -1661,6 +1663,8 @@ class Actor(DirectObject, NodePath):
This method is deprecated. You should use setBlend() instead.
"""
if __debug__:
warnings.warn("This method is deprecated. You should use setBlend() instead.", DeprecationWarning, stacklevel=2)
self.setBlend(animBlend = False, partName = partName)
def setControlEffect(self, animName, effect,

View File

@ -12,6 +12,7 @@ import io
import distutils.sysconfig as sysconf
import zipfile
import importlib
import warnings
from . import pefile
@ -1985,7 +1986,7 @@ class Freezer:
if append_offset:
# This is for legacy deploy-stub.
print("WARNING: Could not find blob header. Is deploy-stub outdated?")
warnings.warn("Could not find blob header. Is deploy-stub outdated?")
blob += struct.pack('<Q', blob_offset)
with open(target, 'wb') as f:

View File

@ -1,6 +1,7 @@
from panda3d.direct import CInterval
from .extension_native_helpers import Dtool_funcToMethod
from direct.directnotify.DirectNotifyGlobal import directNotify
import warnings
CInterval.DtoolClassDict["notify"] = directNotify.newCategory("Interval")
@ -18,7 +19,8 @@ del setT
#####################################################################
def play(self, t0 = 0.0, duration = None, scale = 1.0):
self.notify.error("CInterval.play() is deprecated, use start() instead")
if __debug__:
warnings.warn("CInterval.play() is deprecated, use start() instead", DeprecationWarning, stacklevel=2)
if duration: # None or 0 implies full length
self.start(t0, t0 + duration, scale)
else:
@ -29,7 +31,8 @@ del play
#####################################################################
def stop(self):
self.notify.error("CInterval.stop() is deprecated, use finish() instead")
if __debug__:
warnings.warn("CInterval.stop() is deprecated, use finish() instead", DeprecationWarning, stacklevel=2)
self.finish()
Dtool_funcToMethod(stop, CInterval)
@ -37,7 +40,8 @@ del stop
#####################################################################
def setFinalT(self):
self.notify.error("CInterval.setFinalT() is deprecated, use finish() instead")
if __debug__:
warnings.warn("CInterval.setFinalT() is deprecated, use finish() instead", DeprecationWarning, stacklevel=2)
self.finish()
Dtool_funcToMethod(setFinalT, CInterval)

View File

@ -10,11 +10,13 @@ of the NodePath class
from panda3d.core import NodePath
from .extension_native_helpers import Dtool_funcToMethod
import warnings
####################################################################
def id(self):
"""Deprecated. Returns a unique id identifying the NodePath instance"""
print("Warning: NodePath.id() is deprecated. Use hash(NodePath) or NodePath.get_key() instead.")
if __debug__:
warnings.warn("NodePath.id() is deprecated. Use hash(NodePath) or NodePath.get_key() instead.", DeprecationWarning, stacklevel=2)
return self.getKey()
Dtool_funcToMethod(id, NodePath)
@ -22,7 +24,8 @@ del id
#####################################################################
def getChildrenAsList(self):
"""Deprecated. Converts a node path's child NodePathCollection into a list"""
print("Warning: NodePath.getChildrenAsList() is deprecated. Use get_children() instead.")
if __debug__:
warnings.warn("NodePath.getChildrenAsList() is deprecated. Use get_children() instead.", DeprecationWarning, stacklevel=2)
return list(self.getChildren())
Dtool_funcToMethod(getChildrenAsList, NodePath)
@ -31,7 +34,8 @@ del getChildrenAsList
def printChildren(self):
"""Deprecated. Prints out the children of the bottom node of a node path"""
print("Warning: NodePath.printChildren() is deprecated.")
if __debug__:
warnings.warn("NodePath.printChildren() is deprecated.", DeprecationWarning, stacklevel=2)
for child in self.getChildren():
print(child.getName())
Dtool_funcToMethod(printChildren, NodePath)
@ -40,7 +44,8 @@ del printChildren
def removeChildren(self):
"""Deprecated. Deletes the children of the bottom node of a node path"""
print("Warning: NodePath.removeChildren() is deprecated. Use get_children().detach() instead.")
if __debug__:
warnings.warn("NodePath.removeChildren() is deprecated. Use get_children().detach() instead.", DeprecationWarning, stacklevel=2)
self.getChildren().detach()
Dtool_funcToMethod(removeChildren, NodePath)
del removeChildren
@ -48,7 +53,8 @@ del removeChildren
def toggleVis(self):
"""Deprecated. Toggles visibility of a nodePath"""
print("Warning: NodePath.toggleVis() is deprecated. Use is_hidden(), show() and hide() instead.")
if __debug__:
warnings.warn("NodePath.toggleVis() is deprecated. Use is_hidden(), show() and hide() instead.", DeprecationWarning, stacklevel=2)
if self.isHidden():
self.show()
return 1
@ -61,7 +67,8 @@ del toggleVis
def showSiblings(self):
"""Deprecated. Show all the siblings of a node path"""
print("Warning: NodePath.showSiblings() is deprecated.")
if __debug__:
warnings.warn("NodePath.showSiblings() is deprecated.", DeprecationWarning, stacklevel=2)
for sib in self.getParent().getChildren():
if sib.node() != self.node():
sib.show()
@ -71,7 +78,8 @@ del showSiblings
def hideSiblings(self):
"""Deprecated. Hide all the siblings of a node path"""
print("Warning: NodePath.hideSiblings() is deprecated.")
if __debug__:
warnings.warn("NodePath.hideSiblings() is deprecated.", DeprecationWarning, stacklevel=2)
for sib in self.getParent().getChildren():
if sib.node() != self.node():
sib.hide()
@ -81,7 +89,8 @@ del hideSiblings
def showAllDescendants(self):
"""Deprecated. Show the node path and all its children"""
print("Warning: NodePath.showAllDescendants() is deprecated.")
if __debug__:
warnings.warn("NodePath.showAllDescendants() is deprecated.", DeprecationWarning, stacklevel=2)
self.show()
for child in self.getChildren():
child.showAllDescendants()
@ -91,7 +100,8 @@ del showAllDescendants
def isolate(self):
"""Deprecated. Show the node path and hide its siblings"""
print("Warning: NodePath.isolate() is deprecated.")
if __debug__:
warnings.warn("NodePath.isolate() is deprecated.", DeprecationWarning, stacklevel=2)
self.showAllDescendants()
for sib in self.getParent().getChildren():
if sib.node() != self.node():
@ -102,10 +112,10 @@ del isolate
def remove(self):
"""Deprecated. Remove a node path from the scene graph"""
print("Warning: NodePath.remove() is deprecated. Use remove_node() instead.")
if __debug__:
warnings.warn("NodePath.remove() is deprecated. Use remove_node() instead.", DeprecationWarning, stacklevel=2)
# Send message in case anyone needs to do something
# before node is deleted
from direct.showbase.MessengerGlobal import messenger
messenger.send('preRemoveNodePath', [self])
# Remove nodePath
self.removeNode()
@ -115,7 +125,8 @@ del remove
def lsNames(self):
"""Deprecated. Walk down a tree and print out the path"""
print("Warning: NodePath.lsNames() is deprecated.")
if __debug__:
warnings.warn("NodePath.lsNames() is deprecated.", DeprecationWarning, stacklevel=2)
if self.isEmpty():
print("(empty)")
else:
@ -129,7 +140,8 @@ del lsNames
#####################################################################
def lsNamesRecurse(self, indentString=' '):
"""Deprecated. Walk down a tree and print out the path"""
print("Warning: NodePath.lsNamesRecurse() is deprecated.")
if __debug__:
warnings.warn("NodePath.lsNamesRecurse() is deprecated.", DeprecationWarning, stacklevel=2)
for nodePath in self.getChildren():
type = nodePath.node().getType().getName()
name = nodePath.getName()
@ -141,7 +153,8 @@ del lsNamesRecurse
#####################################################################
def reverseLsNames(self):
"""Deprecated. Walk up a tree and print out the path to the root"""
print("Warning: NodePath.reverseLsNames() is deprecated.")
if __debug__:
warnings.warn("NodePath.reverseLsNames() is deprecated.", DeprecationWarning, stacklevel=2)
ancestors = list(self.getAncestors())
ancestry = ancestors.reverse()
indentString = ""
@ -156,7 +169,8 @@ del reverseLsNames
#####################################################################
def getAncestry(self):
"""Deprecated. Get a list of a node path's ancestors"""
print("NodePath.getAncestry() is deprecated. Use get_ancestors() instead.")
if __debug__:
warnings.warn("NodePath.getAncestry() is deprecated. Use get_ancestors() instead.", DeprecationWarning, stacklevel=2)
ancestors = list(self.getAncestors())
ancestors.reverse()
return ancestors
@ -169,8 +183,8 @@ def pPrintString(self, other = None):
"""
Deprecated. pretty print
"""
print("NodePath.pPrintString() is deprecated.")
if __debug__:
warnings.warn("NodePath.pPrintString() is deprecated.", DeprecationWarning, stacklevel=2)
# Normally I would have put the if __debug__ around
# the entire funciton, the that doesn't seem to work
# with -extensions. Maybe someone will look into
@ -195,13 +209,15 @@ def pPrintString(self, other = None):
" 'Scale': (%s),\n" % scale.pPrintValues() +
" 'Shear': (%s),\n" % shear.pPrintValues() +
"}")
Dtool_funcToMethod(pPrintString, NodePath)
del pPrintString
#####################################################################
def printPos(self, other = None, sd = 2):
""" Deprecated. Pretty print a node path's pos """
print("NodePath.printPos() is deprecated.")
if __debug__:
warnings.warn("NodePath.printPos() is deprecated.", DeprecationWarning, stacklevel=2)
formatString = '%0.' + '%d' % sd + 'f'
if other:
pos = self.getPos(other)
@ -220,7 +236,8 @@ del printPos
def printHpr(self, other = None, sd = 2):
""" Deprecated. Pretty print a node path's hpr """
print("NodePath.printHpr() is deprecated.")
if __debug__:
warnings.warn("NodePath.printHpr() is deprecated.", DeprecationWarning, stacklevel=2)
formatString = '%0.' + '%d' % sd + 'f'
if other:
hpr = self.getHpr(other)
@ -239,7 +256,8 @@ del printHpr
def printScale(self, other = None, sd = 2):
""" Deprecated. Pretty print a node path's scale """
print("NodePath.printScale() is deprecated.")
if __debug__:
warnings.warn("NodePath.printScale() is deprecated.", DeprecationWarning, stacklevel=2)
formatString = '%0.' + '%d' % sd + 'f'
if other:
scale = self.getScale(other)
@ -258,7 +276,8 @@ del printScale
#####################################################################
def printPosHpr(self, other = None, sd = 2):
""" Deprecated. Pretty print a node path's pos and, hpr """
print("NodePath.printPosHpr() is deprecated.")
if __debug__:
warnings.warn("NodePath.printPosHpr() is deprecated.", DeprecationWarning, stacklevel=2)
formatString = '%0.' + '%d' % sd + 'f'
if other:
pos = self.getPos(other)
@ -282,7 +301,8 @@ del printPosHpr
#####################################################################
def printPosHprScale(self, other = None, sd = 2):
""" Deprecated. Pretty print a node path's pos, hpr, and scale """
print("NodePath.printPosHprScale() is deprecated.")
if __debug__:
warnings.warn("NodePath.printPosHprScale() is deprecated.", DeprecationWarning, stacklevel=2)
formatString = '%0.' + '%d' % sd + 'f'
if other:
pos = self.getPos(other)
@ -312,7 +332,8 @@ del printPosHprScale
def printTransform(self, other = None, sd = 2, fRecursive = 0):
"Deprecated."
print("NodePath.printTransform() is deprecated.")
if __debug__:
warnings.warn("NodePath.printTransform() is deprecated.", DeprecationWarning, stacklevel=2)
from panda3d.core import Vec3
fmtStr = '%%0.%df' % sd
name = self.getName()
@ -352,18 +373,21 @@ del printTransform
def iPos(self, other = None):
""" Deprecated. Set node path's pos to 0, 0, 0 """
print("NodePath.iPos() is deprecated.")
if __debug__:
warnings.warn("NodePath.iPos() is deprecated.", DeprecationWarning, stacklevel=2)
if other:
self.setPos(other, 0, 0, 0)
else:
self.setPos(0, 0, 0)
Dtool_funcToMethod(iPos, NodePath)
del iPos
#####################################################################
def iHpr(self, other = None):
""" Deprecated. Set node path's hpr to 0, 0, 0 """
print("NodePath.iHpr() is deprecated.")
if __debug__:
warnings.warn("NodePath.iHpr() is deprecated.", DeprecationWarning, stacklevel=2)
if other:
self.setHpr(other, 0, 0, 0)
else:
@ -374,7 +398,8 @@ del iHpr
#####################################################################
def iScale(self, other = None):
""" Deprecated. Set node path's scale to 1, 1, 1 """
print("NodePath.iScale() is deprecated.")
if __debug__:
warnings.warn("NodePath.iScale() is deprecated.", DeprecationWarning, stacklevel=2)
if other:
self.setScale(other, 1, 1, 1)
else:
@ -385,7 +410,8 @@ del iScale
#####################################################################
def iPosHpr(self, other = None):
""" Deprecated. Set node path's pos and hpr to 0, 0, 0 """
print("NodePath.iPosHpr() is deprecated.")
if __debug__:
warnings.warn("NodePath.iPosHpr() is deprecated.", DeprecationWarning, stacklevel=2)
if other:
self.setPosHpr(other, 0, 0, 0, 0, 0, 0)
else:
@ -396,7 +422,8 @@ del iPosHpr
#####################################################################
def iPosHprScale(self, other = None):
""" Deprecated. Set node path's pos and hpr to 0, 0, 0 and scale to 1, 1, 1 """
print("NodePath.iPosHprScale() is deprecated.")
if __debug__:
warnings.warn("NodePath.iPosHprScale() is deprecated.", DeprecationWarning, stacklevel=2)
if other:
self.setPosHprScale(other, 0, 0, 0, 0, 0, 0, 1, 1, 1)
else:
@ -461,11 +488,12 @@ def showCS(self, mask = None):
CameraBitmask) that indicates which particular collision
solids should be made visible; otherwise, all of them will be.
"""
print("NodePath.showCS() is deprecated. Use findAllMatches('**/+CollisionNode').show() instead.")
if __debug__:
warnings.warn("NodePath.showCS() is deprecated. Use findAllMatches('**/+CollisionNode').show() instead.", DeprecationWarning, stacklevel=2)
npc = self.findAllMatches('**/+CollisionNode')
for p in range(0, npc.getNumPaths()):
np = npc[p]
if (mask is None or (np.node().getIntoCollideMask() & mask).getWord()):
if (mask == None or (np.node().getIntoCollideMask() & mask).getWord()):
np.show()
Dtool_funcToMethod(showCS, NodePath)
@ -479,11 +507,12 @@ def hideCS(self, mask = None):
CameraBitmask) that indicates which particular collision
solids should be hidden; otherwise, all of them will be.
"""
print("NodePath.hideCS() is deprecated. Use findAllMatches('**/+CollisionNode').hide() instead.")
if __debug__:
warnings.warn("NodePath.hideCS() is deprecated. Use findAllMatches('**/+CollisionNode').hide() instead.", DeprecationWarning, stacklevel=2)
npc = self.findAllMatches('**/+CollisionNode')
for p in range(0, npc.getNumPaths()):
np = npc[p]
if (mask is None or (np.node().getIntoCollideMask() & mask).getWord()):
if (mask == None or (np.node().getIntoCollideMask() & mask).getWord()):
np.hide()
Dtool_funcToMethod(hideCS, NodePath)

View File

@ -4,6 +4,7 @@ Methods to extend functionality of the VBase3 class
from panda3d.core import VBase3
from .extension_native_helpers import Dtool_funcToMethod
import warnings
def pPrintValues(self):
"""
@ -17,7 +18,8 @@ def asTuple(self):
"""
Returns the vector as a tuple.
"""
print("Warning: VBase3.asTuple() is no longer needed and deprecated. Use the vector directly instead.")
if __debug__:
warnings.warn("VBase3.asTuple() is no longer needed and deprecated. Use the vector directly instead.", DeprecationWarning, stacklevel=2)
return tuple(self)
Dtool_funcToMethod(asTuple, VBase3)
del asTuple

View File

@ -4,6 +4,7 @@ Methods to extend functionality of the VBase4 class
from panda3d.core import VBase4
from .extension_native_helpers import Dtool_funcToMethod
import warnings
def pPrintValues(self):
"""
@ -17,7 +18,8 @@ def asTuple(self):
"""
Returns the vector as a tuple.
"""
print("Warning: VBase4.asTuple() is no longer needed and deprecated. Use the vector directly instead.")
if __debug__:
warnings.warn("VBase4.asTuple() is no longer needed and deprecated. Use the vector directly instead.", DeprecationWarning, stacklevel=2)
return tuple(self)
Dtool_funcToMethod(asTuple, VBase4)
del asTuple

View File

@ -8,6 +8,7 @@ __all__ = ['OnscreenText', 'Plain', 'ScreenTitle', 'ScreenPrompt', 'NameConfirm'
from panda3d.core import *
from . import DirectGuiGlobals as DGG
import warnings
## These are the styles of text we might commonly see. They set the
## overall appearance of the text according to one of a number of
@ -304,6 +305,8 @@ class OnscreenText(NodePath):
.. deprecated:: 1.11.0
Use `.setTextX()` method instead.
"""
if __debug__:
warnings.warn("Use `.setTextX()` method instead.", DeprecationWarning, stacklevel=2)
self.setTextPos(x, self.__pos[1])
def setTextY(self, y):
@ -317,6 +320,8 @@ class OnscreenText(NodePath):
.. deprecated:: 1.11.0
Use `.setTextY()` method instead.
"""
if __debug__:
warnings.warn("Use `.setTextY()` method instead.", DeprecationWarning, stacklevel=2)
self.setTextPos(self.__pos[0], y)
def setTextPos(self, x, y=None):
@ -346,6 +351,8 @@ class OnscreenText(NodePath):
.. deprecated:: 1.11.0
Use `.setTextPos()` method or `.text_pos` property instead.
"""
if __debug__:
warnings.warn("Use `.setTextPos()` method or `.text_pos` property instead.", DeprecationWarning, stacklevel=2)
self.__pos = (x, y)
self.updateTransformMat()
@ -354,6 +361,8 @@ class OnscreenText(NodePath):
.. deprecated:: 1.11.0
Use `.getTextPos()` method or `.text_pos` property instead.
"""
if __debug__:
warnings.warn("Use `.getTextPos()` method or `.text_pos` property instead.", DeprecationWarning, stacklevel=2)
return self.__pos
pos = property(getPos)
@ -379,6 +388,8 @@ class OnscreenText(NodePath):
.. deprecated:: 1.11.0
Use ``setTextR(-roll)`` instead (note the negated sign).
"""
if __debug__:
warnings.warn("Use ``setTextR(-roll)`` instead (note the negated sign).", DeprecationWarning, stacklevel=2)
self.__roll = roll
self.updateTransformMat()
@ -387,6 +398,8 @@ class OnscreenText(NodePath):
.. deprecated:: 1.11.0
Use ``-getTextR()`` instead (note the negated sign).
"""
if __debug__:
warnings.warn("Use ``-getTextR()`` instead (note the negated sign).", DeprecationWarning, stacklevel=2)
return self.__roll
roll = property(getRoll, setRoll)
@ -424,7 +437,8 @@ class OnscreenText(NodePath):
.. deprecated:: 1.11.0
Use `.setTextScale()` method or `.text_scale` property instead.
"""
if __debug__:
warnings.warn("Use `.setTextScale()` method or `.text_scale` property instead.", DeprecationWarning, stacklevel=2)
if sy is None:
if isinstance(sx, tuple):
self.__scale = sx
@ -439,6 +453,8 @@ class OnscreenText(NodePath):
.. deprecated:: 1.11.0
Use `.getTextScale()` method or `.text_scale` property instead.
"""
if __debug__:
warnings.warn("Use `.getTextScale()` method or `.text_scale` property instead.", DeprecationWarning, stacklevel=2)
return self.__scale
scale = property(getScale, setScale)

View File

@ -4,6 +4,7 @@ from direct.task import Task
from direct.task.TaskManagerGlobal import taskMgr
from direct.showbase.DirectObject import DirectObject
from direct.directnotify.DirectNotifyGlobal import directNotify
import warnings
def remove_task():
@ -11,7 +12,8 @@ def remove_task():
total_motion_trails = len(MotionTrail.motion_trail_list)
if total_motion_trails > 0:
print("warning: %d motion trails still exist when motion trail task is removed" %(total_motion_trails))
if __debug__:
warnings.warn("%d motion trails still exist when motion trail task is removed" % (total_motion_trails), RuntimeWarning, stacklevel=2)
MotionTrail.motion_trail_list = []

View File

@ -5,6 +5,7 @@ from direct.showbase.PhysicsManagerGlobal import *
from direct.directnotify import DirectNotifyGlobal
import sys
import warnings
class ForceGroup(DirectObject):
@ -61,7 +62,7 @@ class ForceGroup(DirectObject):
# Get/set
def getName(self):
"""Deprecated: access .name directly instead."""
warnings.warn("Deprecated: access .name directly instead.", DeprecationWarning, stacklevel=2)
return self.name
def getNode(self):

View File

@ -12,7 +12,8 @@ the AppRunner at startup.
"""
if __debug__:
print('AppRunner has been removed and AppRunnerGlobal has been deprecated')
import warnings
warnings.warn("AppRunner has been removed and AppRunnerGlobal has been deprecated.", DeprecationWarning, stacklevel=2)
#: Contains the global :class:`~.AppRunner.AppRunner` instance, or None
#: if this application was not run from the runtime environment.

View File

@ -4,21 +4,30 @@ __all__ = []
from panda3d.core import (ConfigFlags, ConfigVariableBool, ConfigVariableInt,
ConfigVariableDouble, ConfigVariableString)
import warnings
def GetBool(sym, default=False):
if __debug__:
warnings.warn("This is deprecated. Use ConfigVariableBool instead", DeprecationWarning, stacklevel=2)
return ConfigVariableBool(sym, default, "DConfig", ConfigFlags.F_dconfig).value
def GetInt(sym, default=0):
if __debug__:
warnings.warn("This is deprecated. Use ConfigVariableInt instead", DeprecationWarning, stacklevel=2)
return ConfigVariableInt(sym, default, "DConfig", ConfigFlags.F_dconfig).value
def GetDouble(sym, default=0.0):
if __debug__:
warnings.warn("This is deprecated. Use ConfigVariableDouble instead", DeprecationWarning, stacklevel=2)
return ConfigVariableDouble(sym, default, "DConfig", ConfigFlags.F_dconfig).value
def GetString(sym, default=""):
if __debug__:
warnings.warn("This is deprecated. Use ConfigVariableString instead", DeprecationWarning, stacklevel=2)
return ConfigVariableString(sym, default, "DConfig", ConfigFlags.F_dconfig).value

View File

@ -8,6 +8,7 @@ from panda3d.core import *
from panda3d.core import Loader as PandaLoader
from direct.directnotify.DirectNotifyGlobal import *
from direct.showbase.DirectObject import DirectObject
import warnings
# You can specify a phaseChecker callback to check
# a modelPath to see if it is being loaded in the correct
@ -295,7 +296,8 @@ class Loader(DirectObject):
called after cancelRequest() has been performed.
This is now deprecated: call cb.cancel() instead. """
if __debug__:
warnings.warn("This is now deprecated: call cb.cancel() instead.", DeprecationWarning, stacklevel=2)
cb.cancel()
def isRequestPending(self, cb):
@ -304,7 +306,8 @@ class Loader(DirectObject):
been cancelled.
This is now deprecated: call cb.done() instead. """
if __debug__:
warnings.warn("This is now deprecated: call cb.done() instead.", DeprecationWarning, stacklevel=2)
return bool(cb.requests)
def loadModelOnce(self, modelPath):
@ -315,7 +318,8 @@ class Loader(DirectObject):
then attempt to load it from disk. Return a nodepath to
the model if successful or None otherwise
"""
Loader.notify.info("loader.loadModelOnce() is deprecated; use loader.loadModel() instead.")
if __debug__:
warnings.warn("loader.loadModelOnce() is deprecated; use loader.loadModel() instead.", DeprecationWarning, stacklevel=2)
return self.loadModel(modelPath, noCache = False)
@ -326,7 +330,8 @@ class Loader(DirectObject):
then attempt to load it from disk. Return a nodepath to
a copy of the model if successful or None otherwise
"""
Loader.notify.info("loader.loadModelCopy() is deprecated; use loader.loadModel() instead.")
if __debug__:
warnings.warn("loader.loadModelCopy() is deprecated; use loader.loadModel() instead.", DeprecationWarning, stacklevel=2)
return self.loadModel(modelPath, loaderOptions = loaderOptions, noCache = False)
@ -344,7 +349,8 @@ class Loader(DirectObject):
However, if you're loading a font, see loadFont(), below.
"""
Loader.notify.info("loader.loadModelNode() is deprecated; use loader.loadModel() instead.")
if __debug__:
warnings.warn("loader.loadModelNode() is deprecated; use loader.loadModel() instead.", DeprecationWarning, stacklevel=2)
model = self.loadModel(modelPath, noCache = False)
if model is not None:

View File

@ -72,6 +72,7 @@ if __debug__:
from direct.showbase import GarbageReport
from direct.directutil import DeltaProfiler
from . import OnScreenDebug
import warnings
@atexit.register
def exitfunc():
@ -2034,7 +2035,8 @@ class ShowBase(DirectObject.DirectObject):
"""
:deprecated: Use `.Loader.Loader.loadSfx()` instead.
"""
assert self.notify.warning("base.loadSfx is deprecated, use base.loader.loadSfx instead.")
if __debug__:
warnings.warn("base.loadSfx is deprecated, use base.loader.loadSfx instead.", DeprecationWarning, stacklevel=2)
return self.loader.loadSfx(name)
# This function should only be in the loader but is here for
@ -2044,7 +2046,8 @@ class ShowBase(DirectObject.DirectObject):
"""
:deprecated: Use `.Loader.Loader.loadMusic()` instead.
"""
assert self.notify.warning("base.loadMusic is deprecated, use base.loader.loadMusic instead.")
if __debug__:
warnings.warn("base.loadMusic is deprecated, use base.loader.loadMusic instead.", DeprecationWarning, stacklevel=2)
return self.loader.loadMusic(name)
def playSfx(

View File

@ -19,6 +19,7 @@ from panda3d.core import VirtualFileSystem, Notify, ClockObject, PandaSystem
from panda3d.core import ConfigPageManager, ConfigVariableManager
from panda3d.core import NodePath, PGTop
from . import DConfig as config
import warnings
__dev__ = config.GetBool('want-dev', __debug__)
@ -63,7 +64,8 @@ directNotify.setDconfigLevels()
def run():
"""Deprecated alias for :meth:`base.run() <.ShowBase.run>`."""
assert ShowBase.notify.warning("run() is deprecated, use base.run() instead")
if __debug__:
warnings.warn("run() is deprecated, use base.run() instead", DeprecationWarning, stacklevel=2)
base.run()