def requires(resource, msg=None):
<EOL>if sys._getframe().f_back.f_globals.get("<STR_LIT>") == "<STR_LIT:__main__>":<EOL><INDENT>return<EOL><DEDENT>if not is_resource_enabled(resource):<EOL><INDENT>if msg is None:<EOL><INDENT>msg = "<STR_LIT>" % resource<EOL><DEDENT>raise ResourceDenied(msg)<EOL><DEDENT>
Raise ResourceDenied if the specified resource is not available.

    If the caller's module is __main__ then automatically return True.  The
    possibility of False being returned occurs when regrtest.py is executing.