Source code for aac.plugins.print_defs.print_aac_definitions_impl
"""The AaC Print AaC Definitions plugin implementation module."""# NOTE: It is safe to edit this file.# This file is only initially generated by aac gen-plugin, and it won't be overwritten if the file already exists.fromaac.execute.aac_execution_resultimport(ExecutionResult,ExecutionStatus,ExecutionMessage,MessageLevel,)fromaac.context.language_contextimportLanguageContext,AAC_LANG_FILE_NAMEfromaac.context.definitionimportDefinitionfromaac.in_out.parser._parse_sourceimportparseimportyamlfromos.pathimportjoin,dirnamefromosimportlinesepimportinspectplugin_name="Print AaC Definitions"
[docs]defprint_defs(core_only:bool)->ExecutionResult:"""Print YAML representation of AaC language definitions."""messages:list[str]=[]context:LanguageContext=LanguageContext()definitions:list[Definition]=[]ifcore_only:definitions=parse(join(dirname(inspect.getfile(LanguageContext)),AAC_LANG_FILE_NAME))else:definitions=context.get_definitions()fordefinitionindefinitions:messages.append(yaml.dump(definition.structure))messages.append("---")output_message=ExecutionMessage(linesep.join(messages),MessageLevel.INFO,None,None)returnExecutionResult(plugin_name,"print-defs",ExecutionStatus.SUCCESS,[output_message])