<s> import os <EOL> import abc <EOL> import six <EOL> __all__ = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> @ six . add_metaclass ( abc . ABCMeta ) <EOL> class FileWriter ( object ) : <EOL> @ abc . abstractmethod <EOL> def write ( self , data , file_path , replace = False ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class TextFileWriter ( FileWriter ) : <EOL> def write_text ( self , text_data , file_path , replace = False , compressed = False ) : <EOL> if compressed : <EOL> return Exception ( '<STR_LIT>' ) <EOL> self . write ( text_data , file_path , replace = replace ) <EOL> def write ( self , data , file_path , replace = False ) : <EOL> if os . path . exists ( file_path ) and not replace : <EOL> raise Exception ( '<STR_LIT>' % file_path ) <EOL> with open ( file_path , '<STR_LIT:w>' ) as f : <EOL> f . write ( data ) </s>
