Sha256: a39af9b2191740b9ef865961f45406c5b80de12b07e5e7ebd741840158d77104

Contents?: true

Size: 1.24 KB

Versions: 6

Compression:

Stored size: 1.24 KB

Contents

from importlib import import_module

from javonet.core.handler.CommandHandler.AbstractCommandHandler import AbstractCommandHandler


class GetEnumItemHandler(AbstractCommandHandler):
    def __init__(self):
        self._required_parameters_count = 3

    def process(self, command):
        try:
            if len(command.payload) < self._required_parameters_count:
                raise Exception("CreateEnumHandler parameters mismatch!")
            clazz = command.payload[0]
            enum_name = command.payload[1]
            enum_value = command.payload[2]
            try:
                enum_type = getattr(clazz, enum_name)
            except AttributeError:
                fields = [field for field in dir(clazz) if not callable(getattr(clazz, field))]
                message = "Enum {} not found in class {}. Available enums:\n".format(enum_name, clazz.__name__)
                for field in fields:
                    message += "{}\n".format(field)
                raise AttributeError(message)
            return enum_type[enum_value]
        except Exception as e:
            exc_type, exc_value = type(e), e
            new_exc = exc_type(exc_value).with_traceback(e.__traceback__)
            raise new_exc from None

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
javonet-ruby-sdk-2.4.5 lib/javonet-ruby-sdk/Binaries/Python/Windows/X64/javonet/core/handler/CommandHandler/GetEnumItemHandler.py
javonet-ruby-sdk-2.4.4 lib/javonet-ruby-sdk/Binaries/Python/Windows/X64/javonet/core/handler/CommandHandler/GetEnumItemHandler.py
javonet-ruby-sdk-2.4.3 lib/javonet-ruby-sdk/Binaries/Python/Windows/X64/javonet/core/handler/CommandHandler/GetEnumItemHandler.py
javonet-ruby-sdk-2.4.2 lib/javonet-ruby-sdk/Binaries/Python/Windows/X64/javonet/core/handler/CommandHandler/GetEnumItemHandler.py
javonet-ruby-sdk-2.3.0 lib/javonet-ruby-sdk/Binaries/Python/Windows/X64/javonet/core/handler/CommandHandler/GetEnumItemHandler.py
javonet-ruby-sdk-2.2.0 lib/javonet-ruby-sdk/Binaries/Python/Windows/X64/javonet/core/handler/CommandHandler/GetEnumItemHandler.py