def __init__(self, gens, args, flags=None, strict=False):
    dict.__init__(self)
    if (gens and args.get('gens', ())):
        raise OptionError("both '*gens' and keyword argument 'gens' supplied")
    elif gens:
        args = dict(args)
        args['gens'] = gens
    defaults = args.pop('defaults', {})

    def preprocess_options(args):
        for (option, value) in args.items():
            try:
                cls = self.__options__[option]
            except KeyError:
                raise OptionError(("'%s' is not a valid option" % option))
            if issubclass(cls, Flag):
                if ((flags is None) or (option not in flags)):
                    if strict:
                        raise OptionError(("'%s' flag is not allowed in this context" % option))
            if (value is not None):
                self[option] = cls.preprocess(value)
    preprocess_options(args)
    for (key, value) in dict(defaults).items():
        if (key in self):
            del defaults[key]
        else:
            for option in self.keys():
                cls = self.__options__[option]
                if (key in cls.excludes):
                    del defaults[key]
                    break
    preprocess_options(defaults)
    for option in self.keys():
        cls = self.__options__[option]
        for require_option in cls.requires:
            if (self.get(require_option) is None):
                raise OptionError(("'%s' option is only allowed together with '%s'" % (option, require_option)))
        for exclude_option in cls.excludes:
            if (self.get(exclude_option) is not None):
                raise OptionError(("'%s' option is not allowed together with '%s'" % (option, exclude_option)))
    for option in self.__order__:
        self.__options__[option].postprocess(self)
def __init__(self, gens, args, flags=None, strict=False):
    dict.__init__(self)
    if (gens and args.get('gens', ())):
        raise OptionError("both '*gens' and keyword argument 'gens' supplied")
    elif gens:
        args = dict(args)
        args['gens'] = gens
    defaults = args.pop('defaults', {})

    def preprocess_options(args):
        for (option, value) in args.items():
            try:
                cls = self.__options__[option]
            except KeyError:
                raise OptionError(("'%s' is not a valid option" % option))
            if issubclass(cls, Flag):
                if ((flags is None) or (option not in flags)):
                    if strict:
                        raise OptionError(("'%s' flag is not allowed in this context" % option))
            if (value is not None):
                self[option] = cls.preprocess(value)
    preprocess_options(args)
    for (key, value) in dict(defaults).items():
        if (key in self):
            del defaults[key]
        else:
            for option in self.keys():
                cls = self.__options__[option]
                if (key in cls.excludes):
                    del defaults[key]
                    break
    preprocess_options(defaults)
    for option in self.keys():
        cls = self.__options__[option]
        for require_option in cls.requires:
            if (self.get(require_option) is None):
                raise OptionError(("'%s' option is only allowed together with '%s'" % (option, require_option)))
        for exclude_option in cls.excludes:
            if (self.get(exclude_option) is not None):
                raise OptionError(("'%s' option is not allowed together with '%s'" % (option, exclude_option)))
    for option in self.__order__:
        self.__options__[option].postprocess(self)