<s> from os import strerror as _strerror <EOL> from sys import platform as _platform <EOL> _DEFAULT = "<STR_LIT>" <EOL> _DIALOG = "<STR_LIT>" <EOL> _GENERAL = "<STR_LIT>" <EOL> _ERROR = "<STR_LIT:error>" <EOL> _messages = { <EOL> _DEFAULT : { <EOL> _DIALOG : { <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> _GENERAL : { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> _ERROR : { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT:default>" : "<STR_LIT>" <EOL> } <EOL> } , <EOL> "<STR_LIT:win32>" : { <EOL> _ERROR : { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } <EOL> } <EOL> } <EOL> def get ( group , key , * args ) : <EOL> try : <EOL> msg = _messages [ _platform ] [ group ] [ key ] <EOL> except KeyError : <EOL> msg = _messages [ _DEFAULT ] [ group ] [ key ] <EOL> return str . format ( msg , * args ) <EOL> def error ( error_key , * args ) : <EOL> if isinstance ( error_key , int ) : <EOL> msg = _errno ( error_key , args ) <EOL> elif isinstance ( error_key , str ) : <EOL> msg = _error ( error_key , args ) <EOL> return msg <EOL> def _errno ( error_code , args ) : <EOL> try : <EOL> msg = _strerror ( error_code ) <EOL> except ValueError : <EOL> msg = get ( _ERROR , "<STR_LIT:default>" , * args ) <EOL> return str . format ( msg + "<STR_LIT>" , error_code ) <EOL> def _error ( error_key , args ) : <EOL> try : <EOL> msg = get ( _ERROR , error_key , * args ) <EOL> except KeyError : <EOL> msg = get ( _ERROR , "<STR_LIT:default>" , * args ) <EOL> return msg <EOL> def dialog ( key , * args ) : <EOL> return get ( _DIALOG , key , * args ) <EOL> def message ( key , * args ) : <EOL> return get ( _GENERAL , key , * args ) </s>
