<s> import inspect <EOL> from robotide . lib . robot . utils import NormalizedDict <EOL> class _RunKeywordRegister : <EOL> def __init__ ( self ) : <EOL> self . _libs = { } <EOL> def register_run_keyword ( self , libname , keyword , args_to_process = None ) : <EOL> if args_to_process is None : <EOL> args_to_process = self . _get_args_from_method ( keyword ) <EOL> keyword = keyword . __name__ <EOL> if libname not in self . _libs : <EOL> self . _libs [ libname ] = NormalizedDict ( ignore = [ '<STR_LIT:_>' ] ) <EOL> self . _libs [ libname ] [ keyword ] = int ( args_to_process ) <EOL> def get_args_to_process ( self , libname , kwname ) : <EOL> if libname in self . _libs and kwname in self . _libs [ libname ] : <EOL> return self . _libs [ libname ] [ kwname ] <EOL> return - <NUM_LIT:1> <EOL> def is_run_keyword ( self , libname , kwname ) : <EOL> return self . get_args_to_process ( libname , kwname ) >= <NUM_LIT:0> <EOL> def _get_args_from_method ( self , method ) : <EOL> if inspect . ismethod ( method ) : <EOL> return method . im_func . func_code . co_argcount - <NUM_LIT:1> <EOL> elif inspect . isfunction ( method ) : <EOL> return method . func_code . co_argcount <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> RUN_KW_REGISTER = _RunKeywordRegister ( ) </s>
