<s> import sublime <EOL> import os <EOL> import re <EOL> import threading <EOL> from FuzzyFilePath . common . verbose import verbose <EOL> from FuzzyFilePath . common . config import config <EOL> """<STR_LIT>""" <EOL> ID = "<STR_LIT>" <EOL> def posix ( path ) : <EOL> return path . replace ( "<STR_LIT:\\>" , "<STR_LIT:/>" ) <EOL> class FileCacheWorker ( threading . Thread ) : <EOL> def __init__ ( self , exclude_folders , extensions , folder ) : <EOL> threading . Thread . __init__ ( self ) <EOL> self . exclude_folders = exclude_folders <EOL> self . extensions = extensions <EOL> self . folder = folder <EOL> self . files = None <EOL> def run ( self ) : <EOL> verbose ( ID , "<STR_LIT>" , self . folder ) <EOL> self . files = self . read ( self . folder ) <EOL> verbose ( ID , len ( self . files ) , "<STR_LIT>" ) <EOL> def read ( self , folder , base = None ) : <EOL> """<STR_LIT>""" <EOL> folder_cache = { } <EOL> base = base if base is not None else folder <EOL> for test in self . exclude_folders : <EOL> if re . search ( test , folder ) is not None : <EOL> verbose ( ID , "<STR_LIT>" + folder ) <EOL> return folder_cache <EOL> for ressource in os . listdir ( folder ) : <EOL> current_path = os . path . join ( folder , ressource ) <EOL> if ( os . path . isfile ( current_path ) ) : <EOL> relative_path = os . path . relpath ( current_path , base ) <EOL> filename , extension = os . path . splitext ( relative_path ) <EOL> extension = extension [ <NUM_LIT:1> : ] <EOL> relative_path = re . sub ( "<STR_LIT>" , config [ "<STR_LIT>" ] , posix ( relative_path ) ) <EOL> if extension in self . extensions : <EOL> folder_cache [ relative_path ] = [ <EOL> re . sub ( "<STR_LIT>" , config [ "<STR_LIT>" ] , posix ( filename ) ) , <EOL> extension , <EOL> posix ( filename ) + "<STR_LIT:\t>" + extension <EOL> ] <EOL> elif ( not ressource . startswith ( '<STR_LIT:.>' ) and os . path . isdir ( current_path ) ) : <EOL> folder_cache . update ( self . read ( current_path , base ) ) <EOL> return folder_cache </s>
