From: Rob van der Linde Date: Tue, 27 Feb 2024 03:58:56 +0000 (+1300) Subject: netcmd: models: rename lookup methods to find for consistency X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=050984434754e164f9df49c95e37a2932b73c4b1;p=npower%2Fsamba-autobuild%2F.git netcmd: models: rename lookup methods to find for consistency There are a mixture of methods called either 'lookup' or 'find'. This dates back to when they raised LookupError, but these now raise NotFound. They should be all called 'find' for consistency. Signed-off-by: Rob van der Linde Reviewed-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- diff --git a/python/samba/netcmd/domain/auth/silo.py b/python/samba/netcmd/domain/auth/silo.py index 52a5523847c..f792e8a8542 100644 --- a/python/samba/netcmd/domain/auth/silo.py +++ b/python/samba/netcmd/domain/auth/silo.py @@ -147,7 +147,7 @@ class cmd_domain_auth_silo_create(Command): :param name: Either the DN or name of authentication policy """ try: - return AuthenticationPolicy.lookup(ldb, name) + return AuthenticationPolicy.find(ldb, name) except (ModelError, ValueError) as e: raise CommandError(e) @@ -264,7 +264,7 @@ class cmd_domain_auth_silo_modify(Command): :param name: Either the DN or name of authentication policy """ try: - return AuthenticationPolicy.lookup(ldb, name) + return AuthenticationPolicy.find(ldb, name) except (ModelError, ValueError) as e: raise CommandError(e) diff --git a/python/samba/netcmd/domain/claim/claim_type.py b/python/samba/netcmd/domain/claim/claim_type.py index 3b82b06405d..092cd4aa46c 100644 --- a/python/samba/netcmd/domain/claim/claim_type.py +++ b/python/samba/netcmd/domain/claim/claim_type.py @@ -88,9 +88,9 @@ class cmd_domain_claim_claim_type_create(Command): # Lookup attribute and class names in schema. try: - applies_to = [ClassSchema.lookup(ldb, name) for name in class_names] - attribute = AttributeSchema.lookup(ldb, attribute_name) - value_type = ValueType.lookup(ldb, attribute) + applies_to = [ClassSchema.find(ldb, name) for name in class_names] + attribute = AttributeSchema.find(ldb, attribute_name) + value_type = ValueType.find(ldb, attribute) except (ModelError, ValueError) as e: raise CommandError(e) @@ -206,8 +206,7 @@ class cmd_domain_claim_claim_type_modify(Command): # Change class names for claim type. if class_names is not None: try: - applies_to = [ClassSchema.lookup(ldb, name) - for name in class_names] + applies_to = [ClassSchema.find(ldb, name) for name in class_names] except (ModelError, ValueError) as e: raise CommandError(e) diff --git a/python/samba/netcmd/domain/models/auth_policy.py b/python/samba/netcmd/domain/models/auth_policy.py index a41c43a90b1..3ee6231568c 100644 --- a/python/samba/netcmd/domain/models/auth_policy.py +++ b/python/samba/netcmd/domain/models/auth_policy.py @@ -85,7 +85,7 @@ class AuthenticationPolicy(Model): return "msDS-AuthNPolicy" @staticmethod - def lookup(ldb, name): + def find(ldb, name): """Helper function to return auth policy or raise NotFound. :param ldb: Ldb connection diff --git a/python/samba/netcmd/domain/models/schema.py b/python/samba/netcmd/domain/models/schema.py index 221cd73eaf8..e70b737c048 100644 --- a/python/samba/netcmd/domain/models/schema.py +++ b/python/samba/netcmd/domain/models/schema.py @@ -58,8 +58,8 @@ class ClassSchema(Model): return "classSchema" @classmethod - def lookup(cls, ldb, name): - """Helper function to lookup class or raise NotFound. + def find(cls, ldb, name): + """Helper function to find class by name or raise NotFound. :param ldb: Ldb connection :param name: Class name @@ -107,8 +107,8 @@ class AttributeSchema(Model): return "attributeSchema" @classmethod - def lookup(cls, ldb, name): - """Helper function to lookup attribute or raise NotFound. + def find(cls, ldb, name): + """Helper function to find attribute by name or raise NotFound. :param ldb: Ldb connection :param name: Attribute name diff --git a/python/samba/netcmd/domain/models/value_type.py b/python/samba/netcmd/domain/models/value_type.py index 84fe27995cc..36363f88b91 100644 --- a/python/samba/netcmd/domain/models/value_type.py +++ b/python/samba/netcmd/domain/models/value_type.py @@ -67,7 +67,7 @@ class ValueType(Model): return "msDS-ValueType" @classmethod - def lookup(cls, ldb, attribute): + def find(cls, ldb, attribute): """Helper function to get ValueType by attribute or raise NotFound. :param ldb: Ldb connection @@ -91,6 +91,3 @@ class ValueType(Model): raise NotFound(f"Could not find claim value type for {attribute}.") return value_type - - def __str__(self): - return str(self.display_name)