<s> """<STR_LIT>""" <EOL> import abc <EOL> import shlex <EOL> def SplitIntoComponents ( str_in ) : <EOL> """<STR_LIT>""" <EOL> if str_in . startswith ( ( "<STR_LIT>" , "<STR_LIT:'>" ) ) : <EOL> return shlex . split ( str_in ) <EOL> else : <EOL> components = str_in . split ( "<STR_LIT:U+0020>" , <NUM_LIT:1> ) <EOL> if len ( components ) > <NUM_LIT:1> : <EOL> return [ components [ <NUM_LIT:0> ] ] + SplitIntoComponents ( components [ <NUM_LIT:1> ] ) <EOL> else : <EOL> return components <EOL> class Extractor ( object ) : <EOL> """<STR_LIT>""" <EOL> __metaclass__ = abc . ABCMeta <EOL> @ abc . abstractmethod <EOL> def Extract ( self , components ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> class PostProcessor ( object ) : <EOL> """<STR_LIT>""" <EOL> __metaclass__ = abc . ABCMeta <EOL> @ abc . abstractmethod <EOL> def Process ( self , path ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> class Detector ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , extractors = None , post_processors = None ) : <EOL> """<STR_LIT>""" <EOL> self . extractors = extractors or [ ] <EOL> self . post_processors = post_processors or [ ] <EOL> def Detect ( self , str_in ) : <EOL> """<STR_LIT>""" <EOL> components = SplitIntoComponents ( str_in ) <EOL> extracted_paths = set ( ) <EOL> for extractor in self . extractors : <EOL> extracted_paths . update ( extractor . Extract ( components ) ) <EOL> results = set ( extracted_paths ) <EOL> for post_processor in self . post_processors : <EOL> processed_results = set ( ) <EOL> for result in results : <EOL> processed_results . update ( post_processor . Process ( result ) ) <EOL> results = processed_results <EOL> return results </s>
