<s> import sys <EOL> import six <EOL> from . base import EmailTransport <EOL> class GenericFileMailbox ( EmailTransport ) : <EOL> _variant = None <EOL> _path = None <EOL> def __init__ ( self , path ) : <EOL> super ( GenericFileMailbox , self ) . __init__ ( ) <EOL> if six . PY2 : <EOL> self . _path = path . encode ( <EOL> sys . getfilesystemencoding ( ) <EOL> ) <EOL> else : <EOL> self . _path = path <EOL> def get_instance ( self ) : <EOL> return self . _variant ( self . _path ) <EOL> def get_message ( self , condition = None ) : <EOL> repository = self . get_instance ( ) <EOL> repository . lock ( ) <EOL> for key , message in repository . items ( ) : <EOL> if condition and not condition ( message ) : <EOL> continue <EOL> repository . remove ( key ) <EOL> yield message <EOL> repository . unlock ( ) </s>
