<s> """<STR_LIT>""" <EOL> import logging <EOL> import sys <EOL> import docopt <EOL> import imap_cli <EOL> from imap_cli import config <EOL> from imap_cli import const <EOL> log = logging . getLogger ( '<STR_LIT>' ) <EOL> def flag ( imap_account , message_set , flags , unset = False ) : <EOL> if message_set is None or len ( message_set ) == <NUM_LIT:0> : <EOL> log . error ( '<STR_LIT>' ) <EOL> request_message_set = '<STR_LIT:U+002C>' . join ( str ( mail_id ) for mail_id in message_set ) <EOL> status , result = imap_account . uid ( <EOL> u'<STR_LIT>' , <EOL> request_message_set , <EOL> u'<STR_LIT>' if unset is False else '<STR_LIT>' , <EOL> u'<STR_LIT>' . format ( u'<STR_LIT:U+0020>' . join ( flags ) ) , <EOL> ) <EOL> if status == const . STATUS_OK : <EOL> log . debug ( '<STR_LIT>' . format ( flags , result ) ) <EOL> else : <EOL> log . error ( '<STR_LIT>' . format ( flags , result ) ) <EOL> def main ( ) : <EOL> args = docopt . docopt ( '<STR_LIT:\n>' . join ( __doc__ . split ( '<STR_LIT:\n>' ) [ <NUM_LIT:2> : ] ) , <EOL> version = const . VERSION ) <EOL> logging . basicConfig ( <EOL> level = logging . DEBUG if args [ '<STR_LIT>' ] else logging . INFO , <EOL> stream = sys . stdout , <EOL> ) <EOL> conf = config . new_context_from_file ( args [ '<STR_LIT>' ] , section = '<STR_LIT>' ) <EOL> if conf is None : <EOL> return <NUM_LIT:1> <EOL> try : <EOL> imap_account = imap_cli . connect ( ** conf ) <EOL> imap_cli . change_dir ( imap_account , <EOL> args [ '<STR_LIT>' ] or const . DEFAULT_DIRECTORY , <EOL> read_only = False ) <EOL> flag ( imap_account , [ args [ '<STR_LIT>' ] ] , args [ '<STR_LIT>' ] , <EOL> unset = args [ '<STR_LIT>' ] ) <EOL> imap_cli . disconnect ( imap_account ) <EOL> except KeyboardInterrupt : <EOL> log . info ( '<STR_LIT>' ) <EOL> return <NUM_LIT:0> <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> sys . exit ( main ( ) ) </s>
