Esempio n. 1
0
class WavPackValidator():

    def __init__(self, sample_data):
        self._validator = Kunquat()
        self._sample_data = sample_data
        self._validation_error = None

    def is_data_valid(self):
        if self._validation_error:
            return False

        transaction = {
            'au_00/p_manifest.json'                   : {},
            'au_00/proc_00/p_manifest.json'           : { 'type': 'sample' },
            'au_00/proc_00/p_signal_type.json'        : 'voice',
            'au_00/proc_00/c/smp_000/p_sh_sample.json': {
                    'format': 'WavPack', 'freq' : 48000, },
            'au_00/proc_00/c/smp_000/p_sample.wv'     : self._sample_data,
        }

        for key, value in transaction.items():
            self._validator.set_data(key, value)

        try:
            self._validator.validate()
        except KunquatFormatError as e:
            self._validation_error = e['message']
            return False

        return True

    def get_validation_error(self):
        return self._validation_error
Esempio n. 2
0
class WavPackValidator():

    def __init__(self, sample_data):
        self._validator = Kunquat()
        self._sample_data = sample_data
        self._validation_error = None

    def is_data_valid(self):
        if self._validation_error:
            return False

        transaction = {
            'au_00/p_manifest.json'                   : {},
            'au_00/proc_00/p_manifest.json'           : { 'type': 'sample' },
            'au_00/proc_00/p_signal_type.json'        : 'voice',
            'au_00/proc_00/c/smp_000/p_sh_sample.json': {
                    'format': 'WavPack', 'freq' : 48000, },
            'au_00/proc_00/c/smp_000/p_sample.wv'     : self._sample_data,
        }

        for key, value in transaction.items():
            self._validator.set_data(key, value)

        try:
            self._validator.validate()
        except KunquatFormatError as e:
            self._validation_error = e['message']
            return False

        return True

    def get_validation_error(self):
        return self._validation_error
Esempio n. 3
0
class KqtiValidator():
    def __init__(self, contents):
        self._validator = Kunquat()
        self._contents = contents
        self._validation_error = None

    def get_validation_steps(self):
        target_prefix = 'au_00'
        for (au_key, value) in self._contents.items():
            yield
            key = '/'.join((target_prefix, au_key))
            self._validator.set_data(key, value)

    def is_valid(self):
        if self._validation_error:
            return False

        try:
            self._validator.validate()
        except KunquatFormatError as e:
            self._validation_error = e['message']
            return False
        return True

    def get_validation_error(self):
        return self._validation_error
Esempio n. 4
0
class KqtiValidator():

    def __init__(self, contents):
        self._validator = Kunquat()
        self._contents = contents
        self._validation_error = None

    def get_validation_steps(self):
        target_prefix = 'au_00'
        for (au_key, value) in self._contents.items():
            yield
            key = '/'.join((target_prefix, au_key))
            self._validator.set_data(key, value)

    def is_valid(self):
        if self._validation_error:
            return False

        try:
            self._validator.validate()
        except KunquatFormatError as e:
            self._validation_error = e['message']
            return False
        return True

    def get_validation_error(self):
        return self._validation_error
Esempio n. 5
0
class KqtiValidator():
    def __init__(self, contents, data_converters):
        self._validator = Kunquat()
        self._validator.set_loader_thread_count(
            cmdline.get_default_thread_count())
        self._contents = contents
        self._data_converters = data_converters
        self._validation_error = None
        self._progress = 0

    def get_progress(self):
        return self._progress

    def get_validation_steps(self):
        target_prefix = 'au_00'
        step_count = len(self._contents.items())
        for i, (au_key, value) in enumerate(self._contents.items()):
            yield
            key = '/'.join((target_prefix, au_key))

            try:
                self._data_converters.convert_key_and_data(key, value)
            except UnsupportedVersionError as e:
                version_data = self._contents.get('m_editor_version.json')
                self._validation_error = e.get_message('audio unit',
                                                       version_data)
                break
            except VersionError as e:
                self._validation_error = e.args[0]
                break

            self._validator.set_data(key, value)
            self._progress = i / step_count

    def is_valid(self):
        if self._validation_error:
            return False

        try:
            self._validator.validate()
        except KunquatFormatError as e:
            self._validation_error = e['message']
            return False
        return True

    def get_validation_error(self):
        return self._validation_error
Esempio n. 6
0
class KqtiValidator():

    def __init__(self, contents, data_converters):
        self._validator = Kunquat()
        self._validator.set_loader_thread_count(cmdline.get_default_thread_count())
        self._contents = contents
        self._data_converters = data_converters
        self._validation_error = None
        self._progress = 0

    def get_progress(self):
        return self._progress

    def get_validation_steps(self):
        target_prefix = 'au_00'
        step_count = len(self._contents.items())
        for i, (au_key, value) in enumerate(self._contents.items()):
            yield
            key = '/'.join((target_prefix, au_key))

            try:
                self._data_converters.convert_key_and_data(key, value)
            except UnsupportedVersionError as e:
                version_data = self._contents.get('m_editor_version.json')
                self._validation_error = e.get_message('audio unit', version_data)
                break
            except VersionError as e:
                self._validation_error = e.args[0]
                break

            self._validator.set_data(key, value)
            self._progress = i / step_count

    def is_valid(self):
        if self._validation_error:
            return False

        try:
            self._validator.validate()
        except KunquatFormatError as e:
            self._validation_error = e['message']
            return False
        return True

    def get_validation_error(self):
        return self._validation_error