From ed755f75ecda7b08ff3244bfd75dd4567162f270 Mon Sep 17 00:00:00 2001 From: Benety Goh Date: Fri, 4 Mar 2022 15:34:37 -0500 Subject: SERVER-63748 provide __str__ functions for Privilege and AccessCheck --- buildscripts/idl/idl/syntax.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'buildscripts/idl') diff --git a/buildscripts/idl/idl/syntax.py b/buildscripts/idl/idl/syntax.py index e554971ee26..a79785459a8 100644 --- a/buildscripts/idl/idl/syntax.py +++ b/buildscripts/idl/idl/syntax.py @@ -558,6 +558,19 @@ class Privilege(common.SourceLocation): super(Privilege, self).__init__(file_name, line, column) + def __str__(self): + # type: () -> str + """ + Return formatted privilege information. + + Example privilege message: + location: test.idl: (17, 4), resource_pattern: exact_namespace, action_type: ['find', 'insert', 'update', 'remove'], agg_stage: None + """ + location = super(Privilege, self).__str__() + msg = "location: %s, resource_pattern: %s, action_type: %s, agg_stage: %s" % ( + location, self.resource_pattern, self.action_type, self.agg_stage) + return msg # type: ignore + class AccessCheck(common.SourceLocation): """IDL access check information.""" @@ -571,6 +584,18 @@ class AccessCheck(common.SourceLocation): super(AccessCheck, self).__init__(file_name, line, column) + def __str__(self): + # type: () -> str + """ + Return formatted access check information. + + Example access check message: + location: test.idl: (17, 4), check: get_single_user, privilege: (location: test.idl: (18, 6), resource_pattern: exact_namespace, action_type: ['find', 'insert', 'update', 'remove'], agg_stage: None + """ + location = super(AccessCheck, self).__str__() + msg = "location: %s, check: %s, privilege: %s" % (location, self.check, self.privilege) + return msg # type: ignore + class AccessChecks(common.SourceLocation): """IDL access checks information.""" -- cgit v1.2.1