Skip to content

Commit

Permalink
Skips read() call within Plug __repr__ if the plug's apiType is of ty…
Browse files Browse the repository at this point in the history
…pe Mfn.kCompoundAttribute
  • Loading branch information
chelloiaco committed Feb 22, 2024
1 parent b482bef commit 019abe4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2674,12 +2674,16 @@ def __str__(self):
return str(self.read())

def __repr__(self):
cls_name = '{}.{}'.format(__name__, self.__class__.__name__)
if self._mplug.attribute().apiType() == om.MFn.kCompoundAttribute:
return '{}("{}", "{}")'.format(cls_name,
self.node().name(),
self.name())
read_val = self.read()
if isinstance(read_val, string_types):
# Add surrounding single quotes, indicating the value is a string
read_val = '"{}"'.format(read_val)

cls_name = '{}.{}'.format(__name__, self.__class__.__name__)
return '{}("{}", "{}") == {}'.format(cls_name,
self.node().name(),
self.name(),
Expand Down Expand Up @@ -7818,7 +7822,7 @@ def __hash__(self):
def __repr__(self):
"""Avoid repr depicting the full contents of this dict"""
cls_name = '{}.{}'.format(__name__, self.__class__.__name__)
return "<{} : '{}'>".format(cls_name, self["name"])
return 'cmdx.{}("{}")'.format(cls_name, self["name"])

def __new__(cls, *args, **kwargs):
"""Support for using name of assignment
Expand Down

0 comments on commit 019abe4

Please sign in to comment.