src/fedoidcmsg/entity.py
def gather_metadata_statements(self, fos=None, context=''):
        """
        Only gathers metadata statements and returns them.

        :param fos: Signed metadata statements from these Federation Operators
            should be added.
        :param context: context of the metadata exchange
        :return: Dictionary with signed Metadata Statements as values
        """

        if not context:
            context = self.context

        _res = {}
        if self.metadata_statements:
            try:
                cms = self.metadata_statements[context]
            except KeyError:
                if self.metadata_statements == {
                    'register': {},
                    'discovery': {},
                    'response': {}
                }:
                    # No superior so an FO then. Nothing to add ..
                    pass
                else:
                    logger.error(
                        'No metadata statements for this context: {}'.format(
                            context))
                    raise ValueError('Wrong context "{}"'.format(context))
            else:
                if cms != {}:
                    if fos is None:
                        fos = list(cms.keys())

                    for f in fos:
                        try:
                            val = cms[f]
                        except KeyError:
                            continue

                        if val.startswith('http'):
                            value_type = 'metadata_statement_uris'
                        else:
                            value_type = 'metadata_statements'

                        try:
                            _res[value_type][f] = val
                        except KeyError:
                            _res[value_type] = Message()
                            _res[value_type][f] = val

        return _res
def gather_metadata_statements(self, fos=None, context=''):
        """
        Only gathers metadata statements and returns them.

        :param fos: Signed metadata statements from these Federation Operators
            should be added.
        :param context: context of the metadata exchange
        :return: Dictionary with signed Metadata Statements as values
        """

        if not context:
            context = self.context

        _res = {}
        if self.metadata_statements:
            try:
                cms = self.metadata_statements[context]
            except KeyError:
                if self.metadata_statements == {
                    'register': {},
                    'discovery': {},
                    'response': {}
                }:
                    # No superior so an FO then. Nothing to add ..
                    pass
                else:
                    logger.error(
                        'No metadata statements for this context: {}'.format(
                            context))
                    raise ValueError('Wrong context "{}"'.format(context))
            else:
                if cms != {}:
                    if fos is None:
                        fos = list(cms.keys())

                    for f in fos:
                        try:
                            val = cms[f]
                        except KeyError:
                            continue

                        if val.startswith('http'):
                            value_type = 'metadata_statement_uris'
                        else:
                            value_type = 'metadata_statements'

                        try:
                            _res[value_type][f] = val
                        except KeyError:
                            _res[value_type] = Message()
                            _res[value_type][f] = val

        return _res
Only gathers metadata statements and returns them.

        :param fos: Signed metadata statements from these Federation Operators
            should be added.
        :param context: context of the metadata exchange
        :return: Dictionary with signed Metadata Statements as values