mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Use new-style raise syntax
The form`raise Error, value` is deprecated in favor of `raise Error(value)`, and will be removed in Python 3. Use the new syntax. Reviewed-By: Christian Heimes <cheimes@redhat.com> Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
committed by
Jan Cholasta
parent
8de13bd7dd
commit
d1187cbc6f
@@ -217,7 +217,7 @@ class IPAChangeConf:
|
||||
break
|
||||
|
||||
if 'delim' not in o:
|
||||
raise SyntaxError, 'Syntax Error: Unknown line format'
|
||||
raise SyntaxError('Syntax Error: Unknown line format')
|
||||
|
||||
o.update({'name':parts[0].strip(), 'type':'option', 'value':parts[1].rstrip()})
|
||||
return o
|
||||
|
||||
@@ -135,15 +135,15 @@ class ACI:
|
||||
def _parse_acistr(self, acistr):
|
||||
vstart = acistr.find('version 3.0')
|
||||
if vstart < 0:
|
||||
raise SyntaxError, "malformed ACI, unable to find version %s" % acistr
|
||||
raise SyntaxError("malformed ACI, unable to find version %s" % acistr)
|
||||
acimatch = ACIPat.match(acistr[vstart-1:])
|
||||
if not acimatch or len(acimatch.groups()) < 2:
|
||||
raise SyntaxError, "malformed ACI, match for version and bind rule failed %s" % acistr
|
||||
raise SyntaxError("malformed ACI, match for version and bind rule failed %s" % acistr)
|
||||
self._parse_target(acistr[:vstart-1])
|
||||
self.name = acimatch.group(1)
|
||||
bindperms = PermPat.match(acimatch.group(2))
|
||||
if not bindperms or len(bindperms.groups()) < 3:
|
||||
raise SyntaxError, "malformed ACI, permissions match failed %s" % acistr
|
||||
raise SyntaxError("malformed ACI, permissions match failed %s" % acistr)
|
||||
self.action = bindperms.group(1)
|
||||
self.permissions = bindperms.group(2).replace(' ','').split(',')
|
||||
self.set_bindrule(bindperms.group(3))
|
||||
@@ -155,20 +155,20 @@ class ACI:
|
||||
returns True if valid
|
||||
"""
|
||||
if not type(self.permissions) in (tuple, list):
|
||||
raise SyntaxError, "permissions must be a list"
|
||||
raise SyntaxError("permissions must be a list")
|
||||
for p in self.permissions:
|
||||
if not p.lower() in PERMISSIONS:
|
||||
raise SyntaxError, "invalid permission: '%s'" % p
|
||||
raise SyntaxError("invalid permission: '%s'" % p)
|
||||
if not self.name:
|
||||
raise SyntaxError, "name must be set"
|
||||
raise SyntaxError("name must be set")
|
||||
if not isinstance(self.name, six.string_types):
|
||||
raise SyntaxError, "name must be a string"
|
||||
raise SyntaxError("name must be a string")
|
||||
if not isinstance(self.target, dict) or len(self.target) == 0:
|
||||
raise SyntaxError, "target must be a non-empty dictionary"
|
||||
raise SyntaxError("target must be a non-empty dictionary")
|
||||
if not isinstance(self.bindrule, dict):
|
||||
raise SyntaxError, "bindrule must be a dictionary"
|
||||
raise SyntaxError("bindrule must be a dictionary")
|
||||
if not self.bindrule.get('operator') or not self.bindrule.get('keyword') or not self.bindrule.get('expression'):
|
||||
raise SyntaxError, "bindrule is missing a component"
|
||||
raise SyntaxError("bindrule is missing a component")
|
||||
return True
|
||||
|
||||
def set_target_filter(self, filter, operator="="):
|
||||
@@ -201,7 +201,7 @@ class ACI:
|
||||
|
||||
match = BindPat.match(bindrule)
|
||||
if not match or len(match.groups()) < 3:
|
||||
raise SyntaxError, "malformed bind rule"
|
||||
raise SyntaxError("malformed bind rule")
|
||||
self.set_bindrule_keyword(match.group(1))
|
||||
self.set_bindrule_operator(match.group(2))
|
||||
self.set_bindrule_expression(match.group(3).replace('"',''))
|
||||
|
||||
@@ -369,19 +369,19 @@ class LDAPUpdate:
|
||||
items = logical_line.split(':', 2)
|
||||
|
||||
if len(items) == 0:
|
||||
raise BadSyntax, "Bad formatting on line %s:%d: %s" % (data_source_name, lcount, logical_line)
|
||||
raise BadSyntax("Bad formatting on line %s:%d: %s" % (data_source_name, lcount, logical_line))
|
||||
|
||||
action = items[0].strip().lower()
|
||||
|
||||
if action not in self.action_keywords:
|
||||
raise BadSyntax, "Unknown update action '%s', data source=%s" % (action, data_source_name)
|
||||
raise BadSyntax("Unknown update action '%s', data source=%s" % (action, data_source_name))
|
||||
|
||||
if action == 'deleteentry':
|
||||
new_value = None
|
||||
disposition = "deleteentry"
|
||||
else:
|
||||
if len(items) != 3:
|
||||
raise BadSyntax, "Bad formatting on line %s:%d: %s" % (data_source_name, lcount, logical_line)
|
||||
raise BadSyntax("Bad formatting on line %s:%d: %s" % (data_source_name, lcount, logical_line))
|
||||
|
||||
attr = items[1].strip()
|
||||
# do not strip here, we need detect '::' due to base64 encoded
|
||||
@@ -497,7 +497,7 @@ class LDAPUpdate:
|
||||
else:
|
||||
# Process items belonging to dn
|
||||
if dn is None:
|
||||
raise BadSyntax, "dn is not defined in the update, data source=%s" % (data_source_name)
|
||||
raise BadSyntax("dn is not defined in the update, data source=%s" % (data_source_name))
|
||||
|
||||
# If continuation line, append to existing logical line & continue,
|
||||
# otherwise flush the previous item.
|
||||
@@ -736,7 +736,7 @@ class LDAPUpdate:
|
||||
e = self._get_entry(new_entry.dn)
|
||||
if len(e) > 1:
|
||||
# we should only ever get back one entry
|
||||
raise BadSyntax, "More than 1 entry returned on a dn search!? %s" % new_entry.dn
|
||||
raise BadSyntax("More than 1 entry returned on a dn search!? %s" % new_entry.dn)
|
||||
entry = e[0]
|
||||
found = True
|
||||
self.debug("Updating existing entry: %s", entry.dn)
|
||||
|
||||
Reference in New Issue
Block a user