<s> from abc import ABCMeta , abstractmethod <EOL> from depot . _compat import with_metaclass <EOL> from depot . manager import DepotManager <EOL> class FileFilter ( with_metaclass ( ABCMeta , object ) ) : <EOL> """<STR_LIT>""" <EOL> @ abstractmethod <EOL> def on_save ( self , uploaded_file ) : <EOL> """<STR_LIT>""" <EOL> return <EOL> class DepotFileInfo ( with_metaclass ( ABCMeta , dict ) ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , content , depot_name = None ) : <EOL> super ( DepotFileInfo , self ) . __init__ ( ) <EOL> self . _thaw ( ) <EOL> if isinstance ( content , dict ) : <EOL> object . __setattr__ ( self , '<STR_LIT>' , None ) <EOL> self . update ( content ) <EOL> else : <EOL> object . __setattr__ ( self , '<STR_LIT>' , content ) <EOL> if depot_name is None : <EOL> depot_name = DepotManager . get_default ( ) <EOL> depot_name = DepotManager . resolve_alias ( depot_name ) <EOL> if not depot_name : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> self [ '<STR_LIT>' ] = depot_name <EOL> self [ '<STR_LIT>' ] = [ ] <EOL> self . process_content ( content ) <EOL> self . _freeze ( ) <EOL> @ abstractmethod <EOL> def process_content ( self , content , filename = None , content_type = None ) : <EOL> """<STR_LIT>""" <EOL> return <EOL> def __getitem__ ( self , key ) : <EOL> return dict . __getitem__ ( self , key ) <EOL> def __getattr__ ( self , name ) : <EOL> try : <EOL> return self [ name ] <EOL> except KeyError : <EOL> raise AttributeError ( name ) <EOL> def __setitem__ ( self , key , value ) : <EOL> if object . __getattribute__ ( self , '<STR_LIT>' ) : <EOL> raise TypeError ( '<STR_LIT>' ) <EOL> return dict . __setitem__ ( self , key , value ) <EOL> __setattr__ = __setitem__ <EOL> def __delattr__ ( self , name ) : <EOL> if object . __getattribute__ ( self , '<STR_LIT>' ) : <EOL> raise TypeError ( '<STR_LIT>' ) <EOL> try : <EOL> del self [ name ] <EOL> except KeyError : <EOL> raise AttributeError ( name ) <EOL> def __delitem__ ( self , key ) : <EOL> if object . __getattribute__ ( self , '<STR_LIT>' ) : <EOL> raise TypeError ( '<STR_LIT>' ) <EOL> dict . __delitem__ ( self , key ) <EOL> def _apply_filters ( self , filters ) : <EOL> if self . original_content is not None : <EOL> self . _thaw ( ) <EOL> for filt in filters : <EOL> filt . on_save ( self ) <EOL> self . _freeze ( ) <EOL> def _freeze ( self ) : <EOL> object . __setattr__ ( self , '<STR_LIT>' , True ) <EOL> def _thaw ( self ) : <EOL> object . __setattr__ ( self , '<STR_LIT>' , False ) </s>
