@rbac(('owner', 'user'))
    def get_metadata(self, traitpath, metaname=None):
        """Retrieve the metadata associated with the trait found using
        traitpath.  If metaname is None, return the entire metadata dictionary
        for the specified trait. Otherwise, just return the specified piece
        of metadata.  If the specified piece of metadata is not part of
        the trait, None is returned.
        """
        childname, _, restofpath = traitpath.partition('.')
        if restofpath:
            obj = getattr(self, childname, Missing)
            if obj is Missing:
                return self._get_metadata_failed(traitpath, metaname)
            elif hasattr(obj, 'get_metadata'):
                return obj.get_metadata(restofpath, metaname)
            else:
                # if the thing being accessed is an attribute of a Variable's
                # data object, then we can assume that the iotype of the
                # attribute is the same as the iotype of the Variable.
                t = self.get_trait(childname)
                if t is not None and t.iotype and metaname == 'iotype':
                    return t.iotype
                else:
                    self._get_metadata_failed(traitpath, metaname)

        varname, _, _ = traitpath.partition('[')
        try:
            mdict = self._trait_metadata[varname]
        except __HOLE__:
            t = self.get_trait(varname)
            if t:
                t = t.trait_type
                mdict = t._metadata.copy()
                # vartypename isn't present in the metadata of traits
                # that don't inherit from Variable, so fake it out here
                # so we'll be consistent across all traits
                mdict.setdefault('vartypename', t.__class__.__name__)
            else:
                mdict = self._get_metadata_failed(traitpath, None)
            self._trait_metadata[varname] = mdict

        if metaname is None:
            return mdict
        else:
            return mdict.get(metaname, None)
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.main/src/openmdao/main/container.py/Container.get_metadata