src/fedoidcmsg/operator.py
def evaluate_metadata_statement(self, metadata, keyjar=None):
        """
        Computes the resulting metadata statement from a compounded metadata
        statement.
        If something goes wrong during the evaluation an exception is raised

        :param metadata: The compounded metadata statement as a dictionary
        :return: A list of :py:class:`fedoidc.operator.LessOrEqual` 
            instances, one per FO.
        """

        # start from the innermost metadata statement and work outwards

        res = dict([(k, v) for k, v in metadata.items() if k not in IgnoreKeys])

        les = []

        if 'metadata_statements' in metadata:
            for fo, ms in metadata['metadata_statements'].items():
                if isinstance(ms, str):
                    ms = json.loads(ms)
                for _le in self.evaluate_metadata_statement(ms):
                    if isinstance(ms, Message):
                        le = LessOrEqual(sup=_le, **ms.to_dict())
                    else:  # Must be a dict
                        le = LessOrEqual(sup=_le, **ms)

                    if le.is_expired():
                        logger.error(
                            'This metadata statement has expired: {}'.format(ms)
                        )
                        logger.info('My time: {}'.format(utc_time_sans_frac()))
                        continue
                    le.eval(res)
                    les.append(le)
            return les
        else:  # this is the innermost
            try:
                _iss = metadata['iss']
            except:
                le = LessOrEqual()
                le.eval(res)
            else:
                le = LessOrEqual(iss=_iss, exp=metadata['exp'])
                le.eval(res)
            les.append(le)
            return les
def evaluate_metadata_statement(self, metadata, keyjar=None):
        """
        Computes the resulting metadata statement from a compounded metadata
        statement.
        If something goes wrong during the evaluation an exception is raised

        :param metadata: The compounded metadata statement as a dictionary
        :return: A list of :py:class:`fedoidc.operator.LessOrEqual` 
            instances, one per FO.
        """

        # start from the innermost metadata statement and work outwards

        res = dict([(k, v) for k, v in metadata.items() if k not in IgnoreKeys])

        les = []

        if 'metadata_statements' in metadata:
            for fo, ms in metadata['metadata_statements'].items():
                if isinstance(ms, str):
                    ms = json.loads(ms)
                for _le in self.evaluate_metadata_statement(ms):
                    if isinstance(ms, Message):
                        le = LessOrEqual(sup=_le, **ms.to_dict())
                    else:  # Must be a dict
                        le = LessOrEqual(sup=_le, **ms)

                    if le.is_expired():
                        logger.error(
                            'This metadata statement has expired: {}'.format(ms)
                        )
                        logger.info('My time: {}'.format(utc_time_sans_frac()))
                        continue
                    le.eval(res)
                    les.append(le)
            return les
        else:  # this is the innermost
            try:
                _iss = metadata['iss']
            except:
                le = LessOrEqual()
                le.eval(res)
            else:
                le = LessOrEqual(iss=_iss, exp=metadata['exp'])
                le.eval(res)
            les.append(le)
            return les
Computes the resulting metadata statement from a compounded metadata
        statement.
        If something goes wrong during the evaluation an exception is raised

        :param metadata: The compounded metadata statement as a dictionary
        :return: A list of :py:class:`fedoidc.operator.LessOrEqual` 
            instances, one per FO.