<s> """<STR_LIT>""" <EOL> from asyncflux . util import asyncflux_coroutine <EOL> class User ( object ) : <EOL> IS_ADMIN = False <EOL> READ_FROM = '<STR_LIT>' <EOL> WRITE_TO = '<STR_LIT>' <EOL> def __init__ ( self , database , name , is_admin = None , read_from = None , <EOL> write_to = None ) : <EOL> self . __database = database <EOL> self . __client = database . client <EOL> self . __name = name <EOL> self . __is_admin = is_admin or self . IS_ADMIN <EOL> self . __read_from = read_from or self . READ_FROM <EOL> self . __write_to = write_to or self . WRITE_TO <EOL> @ property <EOL> def database ( self ) : <EOL> return self . __database <EOL> @ property <EOL> def name ( self ) : <EOL> return self . __name <EOL> @ property <EOL> def is_admin ( self ) : <EOL> return self . __is_admin <EOL> @ property <EOL> def write_to ( self ) : <EOL> return self . __write_to <EOL> @ property <EOL> def read_from ( self ) : <EOL> return self . __read_from <EOL> def __update_attributes ( self , is_admin = None , read_from = None , <EOL> write_to = None ) : <EOL> if is_admin : <EOL> self . __is_admin = is_admin <EOL> if read_from : <EOL> self . __read_from = read_from <EOL> if write_to : <EOL> self . __write_to = write_to <EOL> @ asyncflux_coroutine <EOL> def update ( self , new_password = None , is_admin = None , read_from = None , <EOL> write_to = None ) : <EOL> yield self . database . update_user ( self . name , new_password = new_password , <EOL> is_admin = is_admin , read_from = read_from , <EOL> write_to = write_to ) <EOL> self . __update_attributes ( is_admin = is_admin , read_from = read_from , <EOL> write_to = write_to ) <EOL> @ asyncflux_coroutine <EOL> def change_password ( self , new_password ) : <EOL> yield self . database . change_user_password ( self . name , new_password ) <EOL> @ asyncflux_coroutine <EOL> def change_privileges ( self , is_admin , read_from = None , write_to = None ) : <EOL> yield self . database . change_user_privileges ( self . name , is_admin , <EOL> read_from = read_from , <EOL> write_to = write_to ) <EOL> self . __update_attributes ( is_admin = is_admin , read_from = read_from , <EOL> write_to = write_to ) <EOL> @ asyncflux_coroutine <EOL> def change_permissions ( self , read_from , write_to ) : <EOL> yield self . database . change_user_permissions ( self . name , read_from , <EOL> write_to ) <EOL> self . __update_attributes ( read_from = read_from , write_to = write_to ) <EOL> @ asyncflux_coroutine <EOL> def delete ( self ) : <EOL> yield self . database . delete_user ( self . name ) <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % ( self . database , self . name ) </s>
