Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit01802c0

Browse files
committed
define GitlabObject.__eq__() and __ne__() equivalence methods
1 parentf15a7cf commit01802c0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

‎gitlab/objects.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,14 @@ def as_dict(self):
491491
return {k:vfork,vinsix.iteritems(self.__dict__)
492492
if (notisinstance(v,BaseManager)andnotk[0]=='_')}
493493

494+
def__eq__(self,other):
495+
iftype(other)istype(self):
496+
returnself.as_dict()==other.as_dict()
497+
returnFalse
498+
499+
def__ne__(self,other):
500+
returnnotself.__eq__(other)
501+
494502

495503
classUserKey(GitlabObject):
496504
_url='/users/%(user_id)s/keys'
@@ -544,6 +552,15 @@ def unblock(self, **kwargs):
544552
raise_error_from_response(r,GitlabUnblockError)
545553
self.state='active'
546554

555+
def__eq__(self,other):
556+
iftype(other)istype(self):
557+
selfdict=self.as_dict()
558+
otherdict=other.as_dict()
559+
selfdict.pop(u'password',None)
560+
otherdict.pop(u'password',None)
561+
returnselfdict==otherdict
562+
returnFalse
563+
547564

548565
classUserManager(BaseManager):
549566
obj_cls=User

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp