Beispiel #1
0
    def set_encoder_params(self, encoder_name, params):
        if not isinstance(params, dict):
            raise TypeError(
                "Encoder parameters must be specified as a dictionary.")
        enc = None
        for encoder in self.encoders:
            if encoder['name'] == encoder_name:
                enc = encoder['class']
                break

        if not enc:
            raise ExfilEncoder(
                'Encoder \'{}\' not found.'.format(encoder_name))

        for k in params.keys():
            if 'encode' not in k and 'decode' not in k:
                raise ExfilEncoder(
                    'Missing \'encode\' and/or \'decode\' for decoder \'{}\''.
                    format(encoder_name))
            for param in enc.requiredParams[k]:
                if param not in params[k]:
                    raise ExfilEncoder(
                        'Missing required parameter \'{}\' for encoder \'{}\' ({}).'
                        .format(param, encoder_name, k))
                enc.set_params(params)
Beispiel #2
0
    def set_encoder_params(self, encoder_name, params):
        enc = None
        for encoder in self.encoders:
            # won't allow multiple encoders with same name
            if encoder['name'] == encoder_name:
                enc = encoder['class']
                break

        if not enc:
            raise ExfilEncoder('Encoder {} not found.'.format(encoder_name))

        enc.set_params(params)
Beispiel #3
0
    def encoder_config(self, encoder_name):
        for encoder in self.encoders:
            if encoder['name'] == encoder_name:
                return encoder['class'].params

        raise ExfilEncoder('Encoder {} not found'.format(encoder_name))