Skip to content

Commit 8f7f614

Browse files
committed
Maya Python3 Support: modernize "safe" options
1 parent d24d353 commit 8f7f614

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+155
-124
lines changed

python/IECoreMaya/BoxParameterUI.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
import IECore
3838
import IECoreMaya
39+
from six.moves import range
3940

4041
class BoxParameterUI( IECoreMaya.ParameterUI ) :
4142

python/IECoreMaya/ClassVectorParameterUI.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
import IECore
4040
import IECoreMaya
41+
from six.moves import range
4142

4243
## A ParameterUI for ClassVectorParameters. Supports the following Parameter userData entries :
4344
#

python/IECoreMaya/DAGPathParameter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def getDAGPathValue( self ) :
164164
return dp
165165
except:
166166
if self.mustExist :
167-
raise Exception, "Node '%s' does not exist!" % dagNodePath
167+
raise Exception("Node '%s' does not exist!" % dagNodePath)
168168
return None
169169

170170
IECore.registerRunTimeTyped( DAGPathParameter )

python/IECoreMaya/DAGPathVectorParameter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from maya.OpenMaya import *
3737
import re
3838

39-
from DAGPathParameter import DAGPathParameter
39+
from .DAGPathParameter import DAGPathParameter
4040

4141
"""
4242
Parameter class for specifying a list of Maya DAG paths.
@@ -172,7 +172,7 @@ def getDAGPathVectorValue( self ) :
172172
result.append( dp )
173173
except:
174174
if self.mustExist :
175-
raise Exception, "Node '%s' does not exist!" % dagNodePath
175+
raise Exception("Node '%s' does not exist!" % dagNodePath)
176176

177177
return result
178178

python/IECoreMaya/FileBrowser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ def __getItemsForPath( self, path, *args ) :
296296

297297
try:
298298
fullDirContents = os.listdir( self.__path )
299-
except Exception, e :
300-
print e
299+
except Exception as e :
300+
print(e)
301301
maya.cmds.evalDeferred( 'import maya.cmds; maya.cmds.confirmDialog( b="OK", title="Error retrieving file list...", message="%s" )' % e )
302302
return
303303

python/IECoreMaya/FnDagNode.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,16 @@
3838
import maya.cmds
3939

4040
import IECore
41-
import StringUtil
41+
from . import StringUtil
42+
import six
4243

4344
## This class extends Maya's MFnDagNode to add assorted helper functions.
4445
class FnDagNode( maya.OpenMaya.MFnDagNode ) :
4546

4647
## \param obj - MObject, This can also be a string or an MObjectHandle.
4748
def __init__( self, obj ) :
4849

49-
if isinstance( obj, str ) or isinstance( obj, unicode ) :
50+
if isinstance( obj, str ) or isinstance( obj, six.text_type ) :
5051

5152
obj = StringUtil.dependencyNodeFromString( obj )
5253

python/IECoreMaya/FnOpHolder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#
3333
##########################################################################
3434

35-
from FnParameterisedHolder import FnParameterisedHolder
35+
from .FnParameterisedHolder import FnParameterisedHolder
3636

3737
import maya.cmds
3838

python/IECoreMaya/FnParameterisedHolder.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@
4141

4242
import IECore
4343

44-
import _IECoreMaya
45-
import StringUtil
44+
from . import _IECoreMaya
45+
from . import StringUtil
46+
import six
47+
from six.moves import zip
4648

4749
## A function set for operating on the various IECoreMaya::ParameterisedHolder
4850
# types. This allows setting and getting of plug and parameter values, and
@@ -53,7 +55,7 @@ class FnParameterisedHolder( maya.OpenMaya.MFnDependencyNode ) :
5355
# either be an MObject or a node name in string or unicode form.
5456
def __init__( self, object ) :
5557

56-
if isinstance( object, str ) or isinstance( object, unicode ) :
58+
if isinstance( object, str ) or isinstance( object, six.text_type ) :
5759
object = StringUtil.dependencyNodeFromString( object )
5860

5961
maya.OpenMaya.MFnDependencyNode.__init__( self, object )
@@ -173,7 +175,7 @@ def parameterPlugPath( self, parameter ) :
173175
# of the maya plug or its OpenMaya.MPlug instance.
174176
def plugParameter( self, plug ) :
175177

176-
if isinstance( plug, str ) or isinstance( plug, unicode ) :
178+
if isinstance( plug, str ) or isinstance( plug, six.text_type ) :
177179
plug = StringUtil.plugFromString( plug )
178180

179181
return _IECoreMaya._parameterisedHolderPlugParameter( self, plug )
@@ -298,7 +300,7 @@ def _classParameterStates( self, parameter=None, parentParameterPath="", result=
298300

299301
classInfo = parameter.getClasses( True )
300302
if classInfo :
301-
classInfo = zip( *classInfo )
303+
classInfo = list(zip( *classInfo ))
302304
else :
303305
classInfo = [ [], [], [], [] ]
304306

python/IECoreMaya/FnSceneShape.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242
import IECore
4343
import IECoreScene
4444
import IECoreMaya
45-
import StringUtil
45+
from . import StringUtil
46+
import six
47+
from six.moves import range
4648

4749

4850
## A function set for operating on the IECoreMaya::SceneShape type.
@@ -73,7 +75,7 @@ class FnSceneShape( maya.OpenMaya.MFnDagNode ) :
7375
# either be an MObject or a node name in string or unicode form.
7476
# Note: Most of the member functions assume that this function set is initialized with the full dag path.
7577
def __init__( self, object ) :
76-
if isinstance( object, basestring ) :
78+
if isinstance( object, six.string_types ) :
7779
object = StringUtil.dagPathFromString( object )
7880

7981
maya.OpenMaya.MFnDagNode.__init__( self, object )
@@ -163,7 +165,7 @@ def selectedComponentNames( self ) :
163165
## Selects the components specified by the passed names.
164166
def selectComponentNames( self, componentNames ) :
165167
if not isinstance( componentNames, set ) :
166-
if isinstance( componentNames, basestring ):
168+
if isinstance( componentNames, six.string_types ):
167169
componentNames = set( (componentNames, ) )
168170
else:
169171
componentNames = set( componentNames )
@@ -284,7 +286,7 @@ def __createChild( self, childName, sceneFile, sceneRoot, drawGeo = False, drawC
284286
# Set visible if I have any of the draw flags in my hierarchy, otherwise set hidden
285287
if drawTagsFilter:
286288
childTags = fnChild.sceneInterface().readTags( IECoreScene.SceneInterface.EveryTag )
287-
commonTags = filter( lambda x: str(x) in childTags, drawTagsFilter.split() )
289+
commonTags = [x for x in drawTagsFilter.split() if str(x) in childTags]
288290
if not commonTags:
289291
dgMod.newPlugValueBool( fnChildTransform.findPlug( "visibility" ), False )
290292
else:

python/IECoreMaya/FnTransientParameterisedHolderNode.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
import maya.OpenMaya
3838
import maya.cmds
3939
import IECoreMaya
40-
import _IECoreMaya
41-
import StringUtil
40+
from . import _IECoreMaya
41+
from . import StringUtil
4242

4343
class FnTransientParameterisedHolderNode( IECoreMaya.FnParameterisedHolder ) :
4444

0 commit comments

Comments
 (0)