mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-26 21:50:20 +00:00
Don't overwrite existing attributes with an empty list (#594)
* Don't overwrite existing attributes with an empty list * Also check for empty lists in __eq__
This commit is contained in:
parent
8ec0c4cf42
commit
83947b0e29
1 changed files with 3 additions and 3 deletions
|
@ -54,8 +54,8 @@ class PlexObject(object):
|
||||||
return '<%s>' % ':'.join([p for p in [self.__class__.__name__, uid, name] if p])
|
return '<%s>' % ':'.join([p for p in [self.__class__.__name__, uid, name] if p])
|
||||||
|
|
||||||
def __setattr__(self, attr, value):
|
def __setattr__(self, attr, value):
|
||||||
# dont overwrite an attr with None unless its a private variable
|
# Don't overwrite an attr with None or [] unless it's a private variable
|
||||||
if value is not None or attr.startswith('_') or attr not in self.__dict__:
|
if value not in [None, []] or attr.startswith('_') or attr not in self.__dict__:
|
||||||
self.__dict__[attr] = value
|
self.__dict__[attr] = value
|
||||||
|
|
||||||
def _clean(self, value):
|
def _clean(self, value):
|
||||||
|
@ -283,7 +283,7 @@ class PlexPartialObject(PlexObject):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return other is not None and self.key == other.key
|
return other not in [None, []] and self.key == other.key
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
return hash(repr(self))
|
return hash(repr(self))
|
||||||
|
|
Loading…
Reference in a new issue