Package: metainfoyaml2py
metainfo-yaml2pyA program for converting NOMAD metainfo YAML schemas into Python class definitions.Installationmetainfo-yaml2pycan be installed from PyPI using pip:pipinstallmetainfoyaml2pyYou can then run the program with:metainfo-yaml2py <target file>For developmentmetainfo-yaml2pyis currently under development and for installing and contributing you should clone the repository and install the package in editable mode (-e) using:pip install -e .ExampleRunningmetainfo-yaml2pyon the following YAML file (with the-nflag):definitions:name:Example Schemasections:Activity:description:|A base class for any activity in relation to an entity.This docstring can span multiple lines.quantities:start_time:description:|The starting date and time of the activity.type:Datetimem_annotations:eln:component:DateTimeEditQuantityend_time:description:|The ending date and time of the activity.type:Datetimem_annotations:eln:component:DateTimeEditQuantityEntity:description:|A base class for any entity which can be related to an activity.Will create the following python file:## Copyright The NOMAD Authors.## This file is part of NOMAD. See https://nomad-lab.eu for further info.## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at##     http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.#fromstructlog.stdlibimport(BoundLogger,)fromnomad.metainfoimport(Package,Quantity,Datetime,Section,)fromnomad.datamodel.dataimport(ArchiveSection,)m_package=Package(name='Example Schema')classActivity(ArchiveSection):'''A base class for any activity in relation to an entity.This docstring can span multiple lines.'''m_def=Section()start_time=Quantity(type=Datetime,description='''The starting date and time of the activity.''',a_eln={"component":"DateTimeEditQuantity"},)end_time=Quantity(type=Datetime,description='''The ending date and time of the activity.''',a_eln={"component":"DateTimeEditQuantity"},)defnormalize(self,archive,logger:BoundLogger)->None:'''The normalizer for the `Activity` class.Args:archive (EntryArchive): The archive containing the section that is beingnormalized.logger (BoundLogger): A structlog logger.'''super(Activity,self).normalize(archive,logger)classEntity(ArchiveSection):'''A base class for any entity which can be related to an activity.'''m_def=Section()defnormalize(self,archive,logger:BoundLogger)->None:'''The normalizer for the `Entity` class.Args:archive (EntryArchive): The archive containing the section that is beingnormalized.logger (BoundLogger): A structlog logger.'''super(Entity,self).normalize(archive,logger)m_package.__init_metainfo__()Command Line Interfacemetainfo-yaml2py--help
usage:metainfo-yaml2py[-h][-oOUTPUT_DIR][-n][-p]yaml_path

positionalarguments:yaml_pathThepathtotheYAMLschemathatshouldbeconvertedtoPythonclasses.

optionalarguments:-h,--helpshowthishelpmessageandexit-oOUTPUT_DIR,--output_dirOUTPUT_DIRThepathtotheoutputdirectoryoftheconversion.Defaultstothecurrentdirectory.-n,--normalizersAddemptynormalizerstoallclassdefinitions.-p,--pluginCreateallthenecessaryfilesforanomadplugin.