diff options
author | Christian Heimes <cheimes@redhat.com> | 2018-01-03 12:11:15 +0100 |
---|---|---|
committer | Christian Heimes <cheimes@redhat.com> | 2018-01-09 07:53:28 +0100 |
commit | f60b2c590684c8ffc2c6ce2efa7a99f0193f42a1 (patch) | |
tree | ac7d90b6b40904187245156ec0a9c2eec8d73679 /ipaserver/plugins/group.py | |
parent | 73ee9ff40e7026ce264d0445db96fa16a33ed589 (diff) | |
download | freeipa-f60b2c590684c8ffc2c6ce2efa7a99f0193f42a1.tar.gz freeipa-f60b2c590684c8ffc2c6ce2efa7a99f0193f42a1.tar.xz freeipa-f60b2c590684c8ffc2c6ce2efa7a99f0193f42a1.zip |
LGTM: raise handle_not_found()
Turn calls "handle_not_found()" into "raise handle_not_found()" to
indicate control flow chance. It makes the code easier to understand,
the control flow more obvious and helps static analyzers.
It's OK to raise here because handle_not_found() always raises an
exception.
https://pagure.io/freeipa/issue/7344
Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Fraser Tweedale <ftweedal@redhat.com>
Diffstat (limited to 'ipaserver/plugins/group.py')
-rw-r--r-- | ipaserver/plugins/group.py | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/ipaserver/plugins/group.py b/ipaserver/plugins/group.py index 5e9427239..2d6aba149 100644 --- a/ipaserver/plugins/group.py +++ b/ipaserver/plugins/group.py @@ -659,17 +659,27 @@ class group_detach(LDAPQuery): try: user_attrs = ldap.get_entry(user_dn) except errors.NotFound: - self.obj.handle_not_found(*keys) - is_managed = self.obj.has_objectclass(user_attrs['objectclass'], 'mepmanagedentry') + raise self.obj.handle_not_found(*keys) + is_managed = self.obj.has_objectclass( + user_attrs['objectclass'], 'mepmanagedentry' + ) if (not ldap.can_write(user_dn, "objectclass") or - not (ldap.can_write(user_dn, "mepManagedEntry")) and is_managed): - raise errors.ACIError(info=_('not allowed to modify user entries')) + not ldap.can_write(user_dn, "mepManagedEntry") + and is_managed): + raise errors.ACIError( + info=_('not allowed to modify user entries') + ) group_attrs = ldap.get_entry(group_dn) - is_managed = self.obj.has_objectclass(group_attrs['objectclass'], 'mepmanagedby') + is_managed = self.obj.has_objectclass( + group_attrs['objectclass'], 'mepmanagedby' + ) if (not ldap.can_write(group_dn, "objectclass") or - not (ldap.can_write(group_dn, "mepManagedBy")) and is_managed): - raise errors.ACIError(info=_('not allowed to modify group entries')) + not ldap.can_write(group_dn, "mepManagedBy") + and is_managed): + raise errors.ACIError( + info=_('not allowed to modify group entries') + ) objectclasses = user_attrs['objectclass'] try: |