<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> from . import base <EOL> from . import arduino_sketchbook <EOL> from . import arduino_params_file <EOL> from . import arduino_keyword <EOL> from . import arduino_src <EOL> class LibrarySet ( base . abs_file . Dir ) : <EOL> def __init__ ( self , parent_id , path ) : <EOL> super ( LibrarySet , self ) . __init__ ( path ) <EOL> self . id = parent_id <EOL> self . library_ids = [ ] <EOL> self . libraries = [ ] <EOL> self . id_library_dict = { } <EOL> self . load_libraries ( ) <EOL> def get_library_ids ( self ) : <EOL> return self . library_ids <EOL> def get_libraries ( self ) : <EOL> return self . libraries <EOL> def get_library ( self , library_id ) : <EOL> return self . id_library_dict . get ( library_id , None ) <EOL> def load_libraries ( self ) : <EOL> sub_dirs = self . list_dirs ( ) <EOL> self . libraries = [ Library ( d . path ) for d in sub_dirs ] <EOL> self . libraries = [ lib for lib in self . libraries if lib . is_library ( ) ] <EOL> self . library_ids = [ lib . name for lib in self . libraries ] <EOL> self . id_library_dict = dict ( zip ( self . library_ids , self . libraries ) ) <EOL> class Library ( base . abs_file . Dir ) : <EOL> def __init__ ( self , path ) : <EOL> super ( Library , self ) . __init__ ( path ) <EOL> self . src_path = os . path . join ( self . path , '<STR_LIT:src>' ) <EOL> if not os . path . isdir ( self . src_path ) : <EOL> self . src_path = self . path <EOL> self . src_dir = base . abs_file . Dir ( self . src_path ) <EOL> examples_path = os . path . join ( self . path , '<STR_LIT>' ) <EOL> self . example_set = arduino_sketchbook . Sketchbook ( examples_path ) <EOL> self . example_set . name = self . name <EOL> self . property_dict = { } <EOL> self . load_properties ( ) <EOL> self . load_keywords ( ) <EOL> self . arch = self . property_dict . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> if '<STR_LIT:U+002C>' in self . arch : <EOL> self . arch = '<STR_LIT:*>' <EOL> if not self . arch : <EOL> self . arch = '<STR_LIT:*>' <EOL> def get_arch ( self ) : <EOL> return self . arch <EOL> def get_examples ( self ) : <EOL> return self . example_set <EOL> def get_property_dict ( self ) : <EOL> return self . property_dict <EOL> def get_property ( self , property_id ) : <EOL> return self . property_dict . get ( property_id , None ) <EOL> def get_keywords ( self ) : <EOL> return self . keywords_file . get_keywords ( ) <EOL> def get_keyword_ids ( self ) : <EOL> return self . keywords_file . get_keyword_ids ( ) <EOL> def get_id_keyword_dict ( self ) : <EOL> return self . keywords_file . get_id_keyword_dict ( ) <EOL> def load_keywords ( self ) : <EOL> keywords_file_path = os . path . join ( self . path , '<STR_LIT>' ) <EOL> self . keywords_file = arduino_keyword . KeywordsFile ( keywords_file_path ) <EOL> def load_properties ( self ) : <EOL> properties_file_path = os . path . join ( self . path , '<STR_LIT>' ) <EOL> properties_file = arduino_params_file . ParamsFile ( properties_file_path ) <EOL> self . property_dict = properties_file . get_params ( ) <EOL> def list_src_dirs ( self , target_arch = '<STR_LIT>' , with_util = True ) : <EOL> src_dirs = [ self . src_dir ] <EOL> arch_path = os . path . join ( self . src_path , target_arch ) <EOL> if os . path . isdir ( arch_path ) : <EOL> arch_dir = base . abs_file . Dir ( arch_path ) <EOL> src_dirs . append ( arch_dir ) <EOL> if with_util : <EOL> utility_dirs = [ ] <EOL> for src_dir in src_dirs : <EOL> utility_path = os . path . join ( src_dir . get_path ( ) , '<STR_LIT>' ) <EOL> if os . path . isdir ( utility_path ) : <EOL> utility_dir = base . abs_file . Dir ( utility_path ) <EOL> utility_dirs . append ( utility_dir ) <EOL> src_dirs += utility_dirs <EOL> return src_dirs <EOL> def list_files ( self , EXTS , target_arch = '<STR_LIT>' , with_util = True ) : <EOL> files = [ ] <EOL> src_dirs = self . list_src_dirs ( target_arch , with_util ) <EOL> for src_dir in src_dirs : <EOL> files += src_dir . list_files_of_extensions ( EXTS ) <EOL> return files <EOL> def list_h_files ( self , target_arch = '<STR_LIT>' ) : <EOL> return self . list_files ( arduino_src . H_EXTS , target_arch , False ) <EOL> def list_cpp_files ( self , target_arch = '<STR_LIT>' ) : <EOL> return self . list_files ( arduino_src . CPP_EXTS , target_arch ) <EOL> def is_library ( self ) : <EOL> h_files = self . list_h_files ( ) <EOL> return bool ( h_files ) </s>
