def allowed_flags(args, flags):
    "\n    Allow specified flags to be used in the given context.\n\n    Examples\n    ========\n\n    >>> from sympy.polys.polyoptions import allowed_flags\n    >>> from sympy.polys.domains import ZZ\n\n    >>> allowed_flags({'domain': ZZ}, [])\n\n    >>> allowed_flags({'domain': ZZ, 'frac': True}, [])\n    Traceback (most recent call last):\n    ...\n    FlagError: 'frac' flag is not allowed in this context\n\n    >>> allowed_flags({'domain': ZZ, 'frac': True}, ['frac'])\n\n    "
    flags = set(flags)
    for arg in args.keys():
        try:
            if (Options.__options__[arg].is_Flag and (not (arg in flags))):
                raise FlagError(("'%s' flag is not allowed in this context" % arg))
        except KeyError:
            raise OptionError(("'%s' is not a valid option" % arg))
Allow specified flags to be used in the given context.

Examples
========

>>> from sympy.polys.polyoptions import allowed_flags
>>> from sympy.polys.domains import ZZ

>>> allowed_flags({'domain': ZZ}, [])

>>> allowed_flags({'domain': ZZ, 'frac': True}, [])
Traceback (most recent call last):
...
FlagError: 'frac' flag is not allowed in this context

>>> allowed_flags({'domain': ZZ, 'frac': True}, ['frac'])
def allowed_flags(args, flags):
    "\n    Allow specified flags to be used in the given context.\n\n    Examples\n    ========\n\n    >>> from sympy.polys.polyoptions import allowed_flags\n    >>> from sympy.polys.domains import ZZ\n\n    >>> allowed_flags({'domain': ZZ}, [])\n\n    >>> allowed_flags({'domain': ZZ, 'frac': True}, [])\n    Traceback (most recent call last):\n    ...\n    FlagError: 'frac' flag is not allowed in this context\n\n    >>> allowed_flags({'domain': ZZ, 'frac': True}, ['frac'])\n\n    "
    flags = set(flags)
    for arg in args.keys():
        try:
            if (Options.__options__[arg].is_Flag and (not (arg in flags))):
                raise FlagError(("'%s' flag is not allowed in this context" % arg))
        except KeyError:
            raise OptionError(("'%s' is not a valid option" % arg))