def flags(name,
          use=None,
          accept_keywords=None,
          env=None,
          license=None,
          properties=None,
          unmask=False,
          mask=False):
    '''
    Enforce the given flags on the given package or ``DEPEND`` atom.

    .. warning::

        In most cases, the affected package(s) need to be rebuilt in
        order to apply the changes.

    name
        The name of the package or its DEPEND atom
    use
        A list of ``USE`` flags
    accept_keywords
        A list of keywords to accept. ``~ARCH`` means current host arch, and will
        be translated into a line without keywords
    env
        A list of environment files
    license
        A list of accepted licenses
    properties
        A list of additional properties
    unmask
        A boolean to unmask the package
    mask
        A boolean to mask the package
    '''
    ret = {'changes': {},
           'comment': '',
           'name': name,
           'result': True}

    if use:
        result = _flags_helper('use', name, use, __opts__['test'])
        if result['result']:
            ret['changes']['use'] = result['changes']
        elif result['result'] is False:
            ret['result'] = False
            ret['comment'] = result['comment']
            return ret

    if accept_keywords:
        result = _flags_helper('accept_keywords', name, accept_keywords, __opts__['test'])
        if result['result']:
            ret['changes']['accept_keywords'] = result['changes']
        elif result['result'] is False:
            ret['result'] = False
            ret['comment'] = result['comment']
            return ret

    if env:
        result = _flags_helper('env', name, env, __opts__['test'])
        if result['result']:
            ret['changes']['env'] = result['changes']
        elif result['result'] is False:
            ret['result'] = False
            ret['comment'] = result['comment']
            return ret

    if license:
        result = _flags_helper('license', name, license, __opts__['test'])
        if result['result']:
            ret['changes']['license'] = result['changes']
        elif result['result'] is False:
            ret['result'] = False
            ret['comment'] = result['comment']
            return ret

    if properties:
        result = _flags_helper('properties', name, properties, __opts__['test'])
        if result['result']:
            ret['changes']['properties'] = result['changes']
        elif result['result'] is False:
            ret['result'] = False
            ret['comment'] = result['comment']
            return ret

    if mask:
        result = _mask_helper('mask', name, __opts__['test'])
        if result['result']:
            ret['changes']['mask'] = 'masked'
        elif result['result'] is False:
            ret['result'] = False
            ret['comment'] = result['comment']
            return ret

    if unmask:
        result = _mask_helper('unmask', name, __opts__['test'])
        if result['result']:
            ret['changes']['unmask'] = 'unmasked'
        elif result['result'] is False:
            ret['result'] = False
            ret['comment'] = result['comment']
            return ret

    if __opts__['test'] and not ret['result']:
        ret['result'] = None

    return ret
Enforce the given flags on the given package or ``DEPEND`` atom.

    .. warning::

        In most cases, the affected package(s) need to be rebuilt in
        order to apply the changes.

    name
        The name of the package or its DEPEND atom
    use
        A list of ``USE`` flags
    accept_keywords
        A list of keywords to accept. ``~ARCH`` means current host arch, and will
        be translated into a line without keywords
    env
        A list of environment files
    license
        A list of accepted licenses
    properties
        A list of additional properties
    unmask
        A boolean to unmask the package
    mask
        A boolean to mask the package