# Path: AXUI/logger/logger.py
# LOGGER = logging.getLogger(logger_config.logger_name)
# 
# Path: AXUI/exceptions.py
# class DriverException(AXUI_BaseException):
#     pass


from AXUI.logger import LOGGER
from AXUI.exceptions import DriverException
from selenium.webdriver.common.by import By
'''
translate AXUI identifier to Windows UIA searchCondition
'''


class ID_Translater(object):
    '''
    translate parsed identifier to accordingly selenium find identifier
    '''
    def __init__(self, parsed_identifier):
        self.parsed_identifier = parsed_identifier

    def get_translated(self):
        '''
        get translated result from parsed identifier
        '''
        if len(self.parsed_identifier) == 2:
            name = self.parsed_identifier[0]
            value = self.parsed_identifier[1]
            try:
                getattr(By, name.upper())
            except AttributeError:
                LOGGER.error("identifier not support: %s" , name)
                raise DriverException("identifier not support: %s" % name)
            return getattr(By, name.upper()), value
        else:

# Path: AXUI/logger/logger.py
# LOGGER = logging.getLogger(logger_config.logger_name)
# 
# Path: AXUI/exceptions.py
# class DriverException(AXUI_BaseException):
#     pass


# Path: AXUI/driver/selenium_driver/Translater.py
from AXUI.logger import LOGGER
from AXUI.exceptions import DriverException
from selenium.webdriver.common.by import By

'''
translate AXUI identifier to Windows UIA searchCondition
'''


class ID_Translater(object):
    '''
    translate parsed identifier to accordingly selenium find identifier
    '''
    def __init__(self, parsed_identifier):
        self.parsed_identifier = parsed_identifier

    def get_translated(self):
        '''
        get translated result from parsed identifier
        '''
        if len(self.parsed_identifier) == 2:
            name = self.parsed_identifier[0]
            value = self.parsed_identifier[1]
            try:
                getattr(By, name.upper())
            except AttributeError:
                LOGGER.error("identifier not support: %s" , name)
                raise DriverException("identifier not support: %s" % name)
            return getattr(By, name.upper()), value
        else:

            LOGGER.error("Get error parsed_id: %s" , repr(self.parsed_identifier))