Skip to content

Commit

Permalink
Added .id attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
mottosso committed Apr 6, 2015
1 parent a612964 commit c29311d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Version 1.0.15
--------------

- API: Plugin.repair_* documented and implemented by default
- API: Added lib.where()
- API: Added `.id` attribute to instances and plug-ins

Version 1.0.14
--------------
Expand Down
8 changes: 8 additions & 0 deletions pyblish/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
'LPT1', 'LPT2', 'LPT3', 'PRN', 'NUL')


class classproperty(object):
def __init__(self, getter):
self.getter = getter

def __get__(self, instance, owner):
return self.getter(owner)


def log(cls):
"""Decorator for attaching a logger to the class `cls`
Expand Down
8 changes: 8 additions & 0 deletions pyblish/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ def __str__(self):
def __repr__(self):
return u"%s.%s(%r)" % (__name__, type(self).__name__, self.__str__())

@pyblish.lib.classproperty
def id(cls):
return cls.__name__

def process(self, context, instances=None):
"""Perform processing upon context `context`
Expand Down Expand Up @@ -595,6 +599,10 @@ def __repr__(self):
def __str__(self):
return self.name

@property
def id(self):
return self.name

def __init__(self, name, parent=None):
super(Instance, self).__init__()
assert isinstance(name, basestring)
Expand Down

0 comments on commit c29311d

Please sign in to comment.