# Path: libraries/tools.py
# def get_setting(key, default=None):
#     """
#     get setting handled by ST
#     """
#     settings = load_settings("deviot.sublime-settings")
#     value = settings.get(key, default)
# 
#     try:
#         return eval(value)
#     except(NameError, SyntaxError, TypeError) as e:
#         return value
# 
# def save_setting(key, value=None, sys_options=False):
#     """
#     save setting handled by ST
#     """
#     settings = load_settings("deviot.sublime-settings")
# 
#     if(value is None):
#         settings.erase(key)
#     else:
#         settings.set(key, value)
# 
#     save_settings("deviot.sublime-settings")


from ..api import deviot
from .tools import get_setting, save_setting
from ..platformio.pio_bridge import PioBridge
from ..libraries.readconfig import ReadConfig
        from .file import File
        from .serial import serial_port_list
        from .tools import get_sysetting
            from ..platformio.compile import Compile
            from ..platformio.upload import Upload
        from .mdns.mdns import MDNSBrowser
        from .project_check import ProjectCheck
        config = ReadConfig()
        config.read(ini_path)

        environment = 'env:{0}'.format(self.board_id)

        # stop if environment wasn't initialized yet
        if(not config.has_section(environment)):
            return

        programmer_list = {
            'stk500v1': 'check',
            'stk500v2': 'avrmkii',
            'usbtiny': 'usbtiny',
            'arduinoisp': 'arduinoisp',
            'usbasp': 'usbasp',
            'dapa': 'parallel'
        }

        if(config.has_option(environment, 'upload_protocol')):
            option = config.get(environment, 'upload_protocol')[0]

            programmer = programmer_list[option]
            if(programmer == 'check'):
                flags = config.get(environment, 'upload_flags')
                if(flags == '-P$UPLOAD_PORT'):
                    option = 'avr'
                else:
                    option = 'arduinoasisp'
        else:
            option = False

# Path: libraries/tools.py
# def get_setting(key, default=None):
#     """
#     get setting handled by ST
#     """
#     settings = load_settings("deviot.sublime-settings")
#     value = settings.get(key, default)
# 
#     try:
#         return eval(value)
#     except(NameError, SyntaxError, TypeError) as e:
#         return value
# 
# def save_setting(key, value=None, sys_options=False):
#     """
#     save setting handled by ST
#     """
#     settings = load_settings("deviot.sublime-settings")
# 
#     if(value is None):
#         settings.erase(key)
#     else:
#         settings.set(key, value)
# 
#     save_settings("deviot.sublime-settings")


# Path: libraries/preferences_bridge.py
from ..api import deviot
from .tools import get_setting, save_setting
from ..platformio.pio_bridge import PioBridge
from ..libraries.readconfig import ReadConfig
        from .file import File
        from .serial import serial_port_list
        from .tools import get_sysetting
            from ..platformio.compile import Compile
            from ..platformio.upload import Upload
        from .mdns.mdns import MDNSBrowser
        from .project_check import ProjectCheck

        config = ReadConfig()
        config.read(ini_path)

        environment = 'env:{0}'.format(self.board_id)

        # stop if environment wasn't initialized yet
        if(not config.has_section(environment)):
            return

        programmer_list = {
            'stk500v1': 'check',
            'stk500v2': 'avrmkii',
            'usbtiny': 'usbtiny',
            'arduinoisp': 'arduinoisp',
            'usbasp': 'usbasp',
            'dapa': 'parallel'
        }

        if(config.has_option(environment, 'upload_protocol')):
            option = config.get(environment, 'upload_protocol')[0]

            programmer = programmer_list[option]
            if(programmer == 'check'):
                flags = config.get(environment, 'upload_flags')
                if(flags == '-P$UPLOAD_PORT'):
                    option = 'avr'
                else:
                    option = 'arduinoasisp'
        else:
            option = False

        save_setting('programmer_id', option)