<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> from __future__ import print_function <EOL> from __future__ import division <EOL> from __future__ import unicode_literals <EOL> import os <EOL> import shutil <EOL> import sublime <EOL> import re <EOL> import zipfile <EOL> import time <EOL> from . import pyarduino <EOL> from . import st_base <EOL> from . import st_menu <EOL> from . import st_console <EOL> def set_pyarduino ( ) : <EOL> user_path = st_base . get_stino_user_path ( ) <EOL> package_path = st_base . get_plugin_path ( ) <EOL> stino_path = os . path . join ( package_path , '<STR_LIT>' ) <EOL> pyarduino_path = os . path . join ( stino_path , '<STR_LIT>' ) <EOL> settings_path = os . path . join ( pyarduino_path , '<STR_LIT>' ) <EOL> settings = pyarduino . base . settings . Settings ( settings_path ) <EOL> settings . set ( '<STR_LIT>' , package_path ) <EOL> settings . set ( '<STR_LIT>' , user_path ) <EOL> def load_keywords ( ) : <EOL> arduino_info = st_base . get_arduino_info ( ) <EOL> ide_dir = arduino_info . get_ide_dir ( ) <EOL> keywords = ide_dir . get_keywords ( ) <EOL> for root in arduino_info . get_root_dirs ( ) : <EOL> libraries = root . get_libraries ( ) <EOL> for library in libraries : <EOL> keywords += library . get_keywords ( ) <EOL> for package in root . get_packages ( ) : <EOL> for platform in package . get_platforms ( ) : <EOL> libraries = platform . get_libraries ( ) <EOL> for library in libraries : <EOL> keywords += library . get_keywords ( ) <EOL> return keywords <EOL> def create_completions ( ) : <EOL> user_path = st_base . get_stino_user_path ( ) <EOL> file_path = os . path . join ( user_path , '<STR_LIT>' ) <EOL> completions_file = pyarduino . base . json_file . JSONFile ( file_path ) <EOL> cpp_keywords = [ '<STR_LIT>' , '<STR_LIT:error>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> cpp_keywords += [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> keywords = load_keywords ( ) <EOL> keyword_ids = [ k . get_id ( ) for k in keywords ] <EOL> keyword_ids += cpp_keywords <EOL> completions_dict = { '<STR_LIT>' : '<STR_LIT>' } <EOL> completions_dict [ '<STR_LIT>' ] = keyword_ids <EOL> completions_file . set_data ( completions_dict ) <EOL> def create_syntax_file ( ) : <EOL> keywords = load_keywords ( ) <EOL> LITERAL1s = [ k . get_id ( ) for k in keywords if k . get_type ( ) == '<STR_LIT>' ] <EOL> KEYWORD1s = [ k . get_id ( ) for k in keywords if k . get_type ( ) == '<STR_LIT>' ] <EOL> KEYWORD2s = [ k . get_id ( ) for k in keywords if k . get_type ( ) == '<STR_LIT>' ] <EOL> KEYWORD3s = [ k . get_id ( ) for k in keywords if k . get_type ( ) == '<STR_LIT>' ] <EOL> LITERAL1_text = '<STR_LIT:|>' . join ( LITERAL1s ) <EOL> KEYWORD1_text = '<STR_LIT:|>' . join ( KEYWORD1s ) <EOL> KEYWORD2_text = '<STR_LIT:|>' . join ( KEYWORD2s ) <EOL> KEYWORD3_text = '<STR_LIT:|>' . join ( KEYWORD3s ) <EOL> preset_path = st_base . get_preset_path ( ) <EOL> file_path = os . path . join ( preset_path , '<STR_LIT>' ) <EOL> template_file = pyarduino . base . abs_file . File ( file_path ) <EOL> text = template_file . read ( ) <EOL> text = text . replace ( '<STR_LIT>' , LITERAL1_text ) <EOL> text = text . replace ( '<STR_LIT>' , KEYWORD1_text ) <EOL> text = text . replace ( '<STR_LIT>' , KEYWORD2_text ) <EOL> text = text . replace ( '<STR_LIT>' , KEYWORD3_text ) <EOL> user_path = st_base . get_stino_user_path ( ) <EOL> file_path = os . path . join ( user_path , '<STR_LIT>' ) <EOL> syntax_file = pyarduino . base . abs_file . File ( file_path ) <EOL> syntax_file . write ( text ) <EOL> def create_sub_menus ( ) : <EOL> arduino_info = st_base . get_arduino_info ( ) <EOL> st_menu . create_sketchbook_menu ( arduino_info ) <EOL> st_menu . create_examples_menu ( arduino_info ) <EOL> st_menu . create_libraries_menu ( arduino_info ) <EOL> st_menu . create_boards_menu ( arduino_info ) <EOL> st_menu . create_board_options_menu ( arduino_info ) <EOL> st_menu . create_programmers_menu ( arduino_info ) <EOL> st_menu . create_serials_menu ( ) <EOL> st_menu . create_languages_menu ( ) <EOL> def create_menus ( ) : <EOL> st_menu . create_main_menu ( ) <EOL> settings = st_base . get_settings ( ) <EOL> show_arduino_menu = settings . get ( '<STR_LIT>' , True ) <EOL> if show_arduino_menu : <EOL> st_menu . create_arduino_menu ( ) <EOL> create_sub_menus ( ) <EOL> else : <EOL> user_menu_path = st_base . get_user_menu_path ( ) <EOL> if os . path . isdir ( user_menu_path ) : <EOL> shutil . rmtree ( user_menu_path ) <EOL> def update_menu ( ) : <EOL> arduino_info = st_base . get_arduino_info ( ) <EOL> arduino_info . reload ( ) <EOL> arduino_info . update ( ) <EOL> i18n = st_base . get_i18n ( ) <EOL> i18n . load ( ) <EOL> create_menus ( ) <EOL> create_completions ( ) <EOL> create_syntax_file ( ) <EOL> def create_sketch ( sketch_name ) : <EOL> arduino_info = st_base . get_arduino_info ( ) <EOL> sketchbook_dir = arduino_info . get_sketchbook_dir ( ) <EOL> sketchbook_path = sketchbook_dir . get_path ( ) <EOL> sketch_path = os . path . join ( sketchbook_path , sketch_name ) <EOL> index = <NUM_LIT:0> <EOL> org_name = sketch_name <EOL> while os . path . exists ( sketch_path ) : <EOL> sketch_name = '<STR_LIT>' % ( org_name , index ) <EOL> sketch_path = os . path . join ( sketchbook_path , sketch_name ) <EOL> index += <NUM_LIT:1> <EOL> os . makedirs ( sketch_path ) <EOL> settings = st_base . get_settings ( ) <EOL> bare_gcc = settings . get ( '<STR_LIT>' , False ) <EOL> if bare_gcc : <EOL> ext = '<STR_LIT>' <EOL> else : <EOL> ext = '<STR_LIT>' <EOL> template_file_name = '<STR_LIT>' + ext <EOL> preset_path = st_base . get_preset_path ( ) <EOL> template_file_path = os . path . join ( preset_path , template_file_name ) <EOL> template_file = pyarduino . base . abs_file . File ( template_file_path ) <EOL> src_code = template_file . read ( ) <EOL> src_file_name = sketch_name + ext <EOL> src_file_path = os . path . join ( sketch_path , src_file_name ) <EOL> src_file = pyarduino . base . abs_file . File ( src_file_path ) <EOL> src_code = src_code . replace ( '<STR_LIT>' , src_file_name ) <EOL> src_file . write ( src_code ) <EOL> arduino_info . reload ( ) <EOL> arduino_info . update ( ) <EOL> st_menu . create_sketchbook_menu ( arduino_info ) <EOL> return sketch_path <EOL> def new_sketch ( window , sketch_name ) : <EOL> sketch_path = create_sketch ( sketch_name ) <EOL> open_sketch ( window , sketch_path ) <EOL> def open_sketch ( window , sketch_path ) : <EOL> project = pyarduino . arduino_project . Project ( sketch_path ) <EOL> ino_files = project . list_ino_files ( ) <EOL> cpp_files = project . list_cpp_files ( ) <EOL> h_files = project . list_h_files ( ) <EOL> files = ino_files + cpp_files + h_files <EOL> views = [ ] <EOL> for f in files : <EOL> view = window . open_file ( f . get_path ( ) ) <EOL> views . append ( view ) <EOL> if views : <EOL> window . focus_view ( views [ <NUM_LIT:0> ] ) <EOL> project_params = window . project_data ( ) <EOL> if project_params is None : <EOL> project_params = { } <EOL> folders = project_params . setdefault ( '<STR_LIT>' , [ ] ) <EOL> folders . append ( { '<STR_LIT>' : True , '<STR_LIT:path>' : sketch_path } ) <EOL> project_params [ '<STR_LIT>' ] = folders <EOL> window . set_project_data ( project_params ) <EOL> def import_library ( view , edit , library_path ) : <EOL> arduino_info = st_base . get_arduino_info ( ) <EOL> target_arch = arduino_info . get_target_board_info ( ) . get_target_arch ( ) <EOL> library = pyarduino . arduino_library . Library ( library_path ) <EOL> h_files = library . list_h_files ( target_arch ) <EOL> region = sublime . Region ( <NUM_LIT:0> , view . size ( ) ) <EOL> src_text = view . substr ( region ) <EOL> headers = pyarduino . arduino_src . list_headers_from_src ( src_text ) <EOL> h_files = [ f for f in h_files if not f . get_name ( ) in headers ] <EOL> includes = [ '<STR_LIT>' % f . get_name ( ) for f in h_files ] <EOL> text = '<STR_LIT:\n>' . join ( includes ) <EOL> if text : <EOL> text += '<STR_LIT:\n>' <EOL> view . insert ( edit , <NUM_LIT:0> , text ) <EOL> def handle_sketch ( view , func , using_programmer = False ) : <EOL> window = view . window ( ) <EOL> views = window . views ( ) <EOL> if view not in views : <EOL> view = window . active_view ( ) <EOL> if view . file_name ( ) is None : <EOL> tmp_path = pyarduino . base . sys_path . get_tmp_path ( ) <EOL> tmp_path = os . path . join ( tmp_path , '<STR_LIT>' ) <EOL> name = str ( time . time ( ) ) . split ( '<STR_LIT:.>' ) [ <NUM_LIT:1> ] <EOL> sketch_path = os . path . join ( tmp_path , name ) <EOL> os . makedirs ( sketch_path ) <EOL> settings = st_base . get_settings ( ) <EOL> bare_gcc = settings . get ( '<STR_LIT>' , False ) <EOL> if bare_gcc : <EOL> ext = '<STR_LIT>' <EOL> else : <EOL> ext = '<STR_LIT>' <EOL> src_file_name = name + ext <EOL> src_file_path = os . path . join ( sketch_path , src_file_name ) <EOL> region = sublime . Region ( <NUM_LIT:0> , view . size ( ) ) <EOL> text = view . substr ( region ) <EOL> src_file = pyarduino . base . abs_file . File ( src_file_path ) <EOL> src_file . write ( text ) <EOL> view . set_scratch ( True ) <EOL> window = view . window ( ) <EOL> window . run_command ( '<STR_LIT>' ) <EOL> view = window . open_file ( src_file_path ) <EOL> if view . is_dirty ( ) : <EOL> view . run_command ( '<STR_LIT>' ) <EOL> file_path = view . file_name ( ) <EOL> sketch_path = os . path . dirname ( file_path ) <EOL> func ( view , sketch_path , using_programmer ) <EOL> def build_sketch ( view , sketch_path , using_programmer = False ) : <EOL> window = view . window ( ) <EOL> console_name = '<STR_LIT>' + sketch_path + '<STR_LIT:|>' + str ( time . time ( ) ) <EOL> console = st_console . Console ( window , name = console_name ) <EOL> compiler = pyarduino . arduino_compiler . Compiler ( sketch_path , console ) <EOL> compiler . build ( ) <EOL> def upload_sketch ( view , sketch_path , using_programmer ) : <EOL> window = view . window ( ) <EOL> console_name = '<STR_LIT>' + sketch_path + '<STR_LIT:|>' + str ( time . time ( ) ) <EOL> console = st_console . Console ( window , name = console_name ) <EOL> uploader = pyarduino . arduino_uploader . Uploader ( sketch_path , console ) <EOL> uploader . upload ( using_programmer ) <EOL> def burn_bootloader ( window ) : <EOL> console_name = '<STR_LIT>' + str ( time . time ( ) ) <EOL> console = st_console . Console ( window , name = console_name ) <EOL> bootloader = pyarduino . arduino_bootloader . Bootloader ( console ) <EOL> bootloader . burn ( ) <EOL> def change_board ( window , board_id ) : <EOL> arduino_info = st_base . get_arduino_info ( ) <EOL> arduino_info . change_board ( board_id ) <EOL> st_menu . create_board_options_menu ( arduino_info ) <EOL> view = window . active_view ( ) <EOL> set_status ( view ) <EOL> def change_sub_board ( window , option_index , sub_board_id ) : <EOL> arduino_info = st_base . get_arduino_info ( ) <EOL> arduino_info . change_sub_board ( option_index , sub_board_id ) <EOL> view = window . active_view ( ) <EOL> set_status ( view ) <EOL> def change_programmer ( programmer_id ) : <EOL> arduino_info = st_base . get_arduino_info ( ) <EOL> arduino_info . change_programmer ( programmer_id ) <EOL> def archive_sketch ( window , sketch_path ) : <EOL> sketch_name = os . path . basename ( sketch_path ) <EOL> console = st_console . Console ( window , str ( time . time ( ) ) ) <EOL> message_queue = pyarduino . base . message_queue . MessageQueue ( console ) <EOL> message_queue . put ( '<STR_LIT>' , sketch_name ) <EOL> zip_file_name = sketch_name + '<STR_LIT>' <EOL> document_path = pyarduino . base . sys_path . get_document_path ( ) <EOL> zip_file_path = os . path . join ( document_path , zip_file_name ) <EOL> os . chdir ( sketch_path ) <EOL> sketch_dir = pyarduino . base . abs_file . Dir ( sketch_path ) <EOL> files = sketch_dir . list_files ( ) <EOL> file_names = [ f . get_name ( ) for f in files ] <EOL> try : <EOL> opened_zipfile = zipfile . ZipFile ( zip_file_path , <EOL> '<STR_LIT:w>' , zipfile . ZIP_DEFLATED ) <EOL> except IOError : <EOL> text = '<STR_LIT>' <EOL> text += "<STR_LIT>" <EOL> message_queue . put ( text ) <EOL> else : <EOL> for file_name in file_names : <EOL> opened_zipfile . write ( file_name ) <EOL> opened_zipfile . close ( ) <EOL> message_queue . put ( '<STR_LIT>' , zip_file_path ) <EOL> message_queue . print_screen ( one_time = True ) <EOL> def get_url ( url ) : <EOL> arduino_info = st_base . get_arduino_info ( ) <EOL> ide_dir = arduino_info . get_ide_dir ( ) <EOL> ide_path = ide_dir . get_path ( ) <EOL> file_name = url + '<STR_LIT>' <EOL> reference_folder = os . path . join ( ide_path , '<STR_LIT>' ) <EOL> reference_file = os . path . join ( reference_folder , file_name ) <EOL> if os . path . isfile ( reference_file ) : <EOL> reference_file = reference_file . replace ( os . path . sep , '<STR_LIT:/>' ) <EOL> url = '<STR_LIT>' + reference_file <EOL> else : <EOL> url = '<STR_LIT>' <EOL> return url <EOL> def find_in_ref ( view ) : <EOL> arduino_info = st_base . get_arduino_info ( ) <EOL> ide_dir = arduino_info . get_ide_dir ( ) <EOL> id_keyword_dict = ide_dir . get_id_keyword_dict ( ) <EOL> ref_list = [ ] <EOL> selected_text = get_selected_text_from_view ( view ) <EOL> words = get_word_list_from_text ( selected_text ) <EOL> for word in words : <EOL> if word in id_keyword_dict : <EOL> keyword = id_keyword_dict . get ( word ) <EOL> ref = keyword . get_ref ( ) <EOL> if ref and not ref in ref_list : <EOL> ref_list . append ( ref ) <EOL> for ref in ref_list : <EOL> url = get_url ( ref ) <EOL> sublime . run_command ( '<STR_LIT>' , { '<STR_LIT:url>' : url } ) <EOL> def get_selected_text_from_view ( view ) : <EOL> selected_text = '<STR_LIT>' <EOL> region_list = view . sel ( ) <EOL> for region in region_list : <EOL> selected_region = view . word ( region ) <EOL> selected_text += view . substr ( selected_region ) <EOL> selected_text += '<STR_LIT:\n>' <EOL> return selected_text <EOL> def get_word_list_from_text ( text ) : <EOL> pattern_text = r'<STR_LIT>' <EOL> word_list = re . findall ( pattern_text , text ) <EOL> return word_list <EOL> def is_arduino_ide_path ( dir_path ) : <EOL> path = pyarduino . arduino_root . update_ide_path ( dir_path ) <EOL> return pyarduino . arduino_root . is_arduino_ide_path ( path ) <EOL> def set_arduino_ide_path ( window , dir_path ) : <EOL> if is_arduino_ide_path ( dir_path ) : <EOL> arduino_info = st_base . get_arduino_info ( ) <EOL> arduino_info . change_ide_path ( dir_path ) <EOL> ide_dir = arduino_info . get_ide_dir ( ) <EOL> version_name = ide_dir . get_version_name ( ) <EOL> text = '<STR_LIT>' <EOL> console = st_console . Console ( window , str ( time . time ( ) ) ) <EOL> message_queue = pyarduino . base . message_queue . MessageQueue ( console ) <EOL> message_queue . put ( text , version_name , dir_path ) <EOL> message_queue . print_screen ( one_time = True ) <EOL> create_menus ( ) <EOL> view = window . active_view ( ) <EOL> set_status ( view ) <EOL> return <NUM_LIT:0> <EOL> else : <EOL> return <NUM_LIT:1> <EOL> def set_sketchbook_path ( window , dir_path ) : <EOL> arduino_info = st_base . get_arduino_info ( ) <EOL> arduino_info . change_sketchbook_path ( dir_path ) <EOL> text = '<STR_LIT>' <EOL> console = st_console . Console ( window , str ( time . time ( ) ) ) <EOL> message_queue = pyarduino . base . message_queue . MessageQueue ( console ) <EOL> message_queue . put ( text , dir_path ) <EOL> message_queue . print_screen ( one_time = True ) <EOL> create_menus ( ) <EOL> return <NUM_LIT:0> <EOL> def set_build_path ( window , dir_path ) : <EOL> settings = st_base . get_settings ( ) <EOL> settings . set ( '<STR_LIT>' , dir_path ) <EOL> text = '<STR_LIT>' <EOL> console = st_console . Console ( window , str ( time . time ( ) ) ) <EOL> message_queue = pyarduino . base . message_queue . MessageQueue ( console ) <EOL> message_queue . put ( text , dir_path ) <EOL> message_queue . print_screen ( one_time = True ) <EOL> return <NUM_LIT:0> <EOL> def select_arduino_dir ( window ) : <EOL> select_dir ( window , func = set_arduino_ide_path , <EOL> condition_func = is_arduino_ide_path ) <EOL> def change_sketchbook_dir ( window ) : <EOL> select_dir ( window , func = set_sketchbook_path , is_user = True ) <EOL> def change_build_dir ( window ) : <EOL> select_dir ( window , func = set_build_path , is_user = True ) <EOL> def select_dir ( window , index = - <NUM_LIT:2> , level = <NUM_LIT:0> , paths = None , <EOL> func = None , condition_func = None , is_user = False ) : <EOL> if index == - <NUM_LIT:1> : <EOL> return '<STR_LIT>' <EOL> if level > <NUM_LIT:0> and index == <NUM_LIT:0> : <EOL> sel_path = paths [ <NUM_LIT:0> ] . split ( '<STR_LIT:(>' ) [ <NUM_LIT:1> ] [ : - <NUM_LIT:1> ] <EOL> if func : <EOL> return_code = func ( window , sel_path ) <EOL> if return_code == <NUM_LIT:0> : <EOL> return <EOL> else : <EOL> return <EOL> else : <EOL> if index == <NUM_LIT:1> : <EOL> level -= <NUM_LIT:1> <EOL> elif index > <NUM_LIT:1> : <EOL> level += <NUM_LIT:1> <EOL> if level <= <NUM_LIT:0> : <EOL> level = <NUM_LIT:0> <EOL> dir_path = '<STR_LIT:.>' <EOL> parent_path = '<STR_LIT:..>' <EOL> if is_user : <EOL> paths = pyarduino . base . sys_path . list_user_root_path ( ) <EOL> else : <EOL> paths = pyarduino . base . sys_path . list_os_root_path ( ) <EOL> else : <EOL> sel_path = paths [ index ] <EOL> if sel_path == pyarduino . base . sys_path . ROOT_PATH : <EOL> sel_path = '<STR_LIT:/>' <EOL> dir_path = os . path . abspath ( sel_path ) <EOL> if condition_func and condition_func ( dir_path ) : <EOL> func ( window , dir_path ) <EOL> return <EOL> parent_path = os . path . join ( dir_path , '<STR_LIT:..>' ) <EOL> cur_dir = pyarduino . base . abs_file . Dir ( dir_path ) <EOL> sub_dirs = cur_dir . list_dirs ( ) <EOL> paths = [ d . get_path ( ) for d in sub_dirs ] <EOL> paths . insert ( <NUM_LIT:0> , parent_path ) <EOL> paths . insert ( <NUM_LIT:0> , '<STR_LIT>' % dir_path ) <EOL> sublime . set_timeout ( lambda : window . show_quick_panel ( <EOL> paths , lambda index : select_dir ( window , index , level , paths , <EOL> func , condition_func , is_user ) ) , <NUM_LIT:5> ) <EOL> def update_serial_info ( ) : <EOL> st_menu . create_serials_menu ( ) <EOL> window = sublime . active_window ( ) <EOL> view = window . active_view ( ) <EOL> set_status ( view ) <EOL> def get_serial_listener ( ) : <EOL> serial_listener = pyarduino . base . serial_listener . SerialListener ( <EOL> func = update_serial_info ) <EOL> return serial_listener <EOL> def toggle_serial_monitor ( window ) : <EOL> monitor_module = pyarduino . base . serial_monitor <EOL> serial_monitor = None <EOL> settings = st_base . get_settings ( ) <EOL> serial_port = settings . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> serial_ports = pyarduino . base . serial_port . list_serial_ports ( ) <EOL> if serial_port in serial_ports : <EOL> if serial_port in monitor_module . serials_in_use : <EOL> serial_monitor = monitor_module . serial_monitor_dict . get ( <EOL> serial_port , None ) <EOL> if not serial_monitor : <EOL> monitor_view = st_console . MonitorView ( window , serial_port ) <EOL> serial_monitor = pyarduino . base . serial_monitor . SerialMonitor ( <EOL> serial_port , monitor_view ) <EOL> if not serial_monitor . is_running ( ) : <EOL> serial_monitor . start ( ) <EOL> if not serial_port in monitor_module . serials_in_use : <EOL> monitor_module . serials_in_use . append ( serial_port ) <EOL> monitor_module . serial_monitor_dict [ serial_port ] = serial_monitor <EOL> else : <EOL> serial_monitor . stop ( ) <EOL> monitor_module . serials_in_use . remove ( serial_port ) <EOL> def send_serial_message ( text ) : <EOL> monitor_module = pyarduino . base . serial_monitor <EOL> settings = st_base . get_settings ( ) <EOL> serial_port = settings . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> if serial_port in monitor_module . serials_in_use : <EOL> serial_monitor = monitor_module . serial_monitor_dict . get ( <EOL> serial_port , None ) <EOL> if serial_monitor and serial_monitor . is_running ( ) : <EOL> serial_monitor . send ( text ) <EOL> def set_status ( view ) : <EOL> infos = [ ] <EOL> exts = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:c>' , '<STR_LIT>' ] <EOL> file_name = view . file_name ( ) <EOL> if file_name and file_name . split ( '<STR_LIT:.>' ) [ - <NUM_LIT:1> ] in exts : <EOL> arduino_info = st_base . get_arduino_info ( ) <EOL> version_name = arduino_info . get_ide_dir ( ) . get_version_name ( ) <EOL> version_text = '<STR_LIT>' % version_name <EOL> infos . append ( version_text ) <EOL> target_board_info = arduino_info . get_target_board_info ( ) <EOL> target_board = target_board_info . get_target_board ( ) <EOL> if target_board : <EOL> target_board_caption = target_board . get_caption ( ) <EOL> infos . append ( target_board_caption ) <EOL> if target_board . has_options ( ) : <EOL> target_sub_boards = target_board_info . get_target_sub_boards ( ) <EOL> for index , target_sub_board in enumerate ( target_sub_boards ) : <EOL> caption_text = target_sub_board . get_caption ( ) <EOL> if index == <NUM_LIT:0> : <EOL> caption_text = '<STR_LIT:[>' + caption_text <EOL> if index == len ( target_sub_boards ) - <NUM_LIT:1> : <EOL> caption_text += '<STR_LIT:]>' <EOL> infos . append ( caption_text ) <EOL> else : <EOL> target_board_caption = '<STR_LIT>' <EOL> infos . append ( target_board_caption ) <EOL> settings = st_base . get_settings ( ) <EOL> target_serial_port = settings . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> serial_ports = pyarduino . base . serial_port . list_serial_ports ( ) <EOL> if not target_serial_port in serial_ports : <EOL> target_serial_port = '<STR_LIT>' <EOL> serial_text = '<STR_LIT>' % target_serial_port <EOL> infos . append ( serial_text ) <EOL> text = '<STR_LIT:U+002CU+0020>' . join ( infos ) <EOL> view . set_status ( '<STR_LIT>' , text ) <EOL> def show_items_panel ( window , item_type ) : <EOL> sublime . set_timeout ( lambda : window . show_quick_panel ( [ '<STR_LIT:1>' , '<STR_LIT:2>' ] , ppp ) ) <EOL> def ppp ( index ) : <EOL> print ( index ) </s>
