Source code for aac.plugins.root_schema_must_have_name
"""__init__.py module for the Root schema must have name plugin."""# WARNING - DO NOT EDIT - YOUR CHANGES WILL NOT BE PROTECTED.# This file is auto-generated by the aac gen-plugin and may be overwritten.fromtypingimportAnyfromos.pathimportjoin,dirnamefromaac.execute.aac_execution_resultimport(ExecutionResult,)fromaac.executeimporthookimplfromaac.context.language_contextimportLanguageContextfromaac.context.definitionimportDefinitionfromaac.execute.plugin_runnerimportPluginRunnerfromaac.plugins.root_schema_must_have_name.root_schema_must_have_name_implimport(plugin_name,)fromaac.plugins.root_schema_must_have_name.root_schema_must_have_name_implimport(root_schema_has_name,)root_schema_must_have_name_aac_file_name="root_schema_must_have_name.aac"
[docs]defrun_root_schema_has_name(instance:Any,definition:Definition,defining_schema,arguments:Any)->ExecutionResult:"""Check every schema with a root key and ensure there is a field called name."""returnroot_schema_has_name(instance,definition,defining_schema)
[docs]@hookimpldefregister_plugin()->None:""" Returns information about the plugin. Returns: A collection of information about the plugin and what it contributes. """active_context=LanguageContext()root_schema_must_have_name_aac_file=join(dirname(__file__),root_schema_must_have_name_aac_file_name)definitions=active_context.parse_and_load(root_schema_must_have_name_aac_file)root_schema_must_have_name_plugin_definition=[definitionfordefinitionindefinitionsifdefinition.name==plugin_name][0]plugin_instance=root_schema_must_have_name_plugin_definition.instanceforfile_to_loadinplugin_instance.definition_sources:active_context.parse_and_load(file_to_load)plugin_runner=PluginRunner(plugin_definition=root_schema_must_have_name_plugin_definition)plugin_runner.add_constraint_callback("Root schema has name",run_root_schema_has_name)active_context.register_plugin_runner(plugin_runner)