'Check snmp community args'

def check_snmp_community_args(self, **kwargs):

    module = kwargs['module']
    result = dict()
    need_cfg = False
    result['community_info'] = []
    state = module.params['state']
    community_name = module.params['community_name']
    access_right = module.params['access_right']
    acl_number = module.params['acl_number']
    community_mib_view = module.params['community_mib_view']
    if (community_name and access_right):
        if ((len(community_name) > 32) or (len(community_name) == 0)):
            module.fail_json(msg=('Error:    The    len    of    community_name    %s    is    out    of    [1    -    32].' % community_name))
        if acl_number:
            if acl_number.isdigit():
                if ((int(acl_number) > 2999) or (int(acl_number) < 2000)):
                    module.fail_json(msg=('Error:    The    value    of    acl_number    %s    is    out    of    [2000    -    2999].' % acl_number))
            elif ((not acl_number[0].isalpha()) or (len(acl_number) > 32) or (len(acl_number) < 1)):
                module.fail_json(msg=('Error:    The    len    of    acl_number    %s    is    out    of    [1    -    32]    or    is    invalid.' % acl_number))
        if community_mib_view:
            if ((len(community_mib_view) > 32) or (len(community_mib_view) == 0)):
                module.fail_json(msg=('Error:    The    len    of    community_mib_view    %s    is    out    of    [1    -    32].' % community_mib_view))
        conf_str = CE_GET_SNMP_COMMUNITY_HEADER
        if acl_number:
            conf_str += '<aclNumber></aclNumber>'
        if community_mib_view:
            conf_str += '<mibViewName></mibViewName>'
        conf_str += CE_GET_SNMP_COMMUNITY_TAIL
        recv_xml = self.netconf_get_config(module=module, conf_str=conf_str)
        if ('<data/>' in recv_xml):
            if (state == 'present'):
                need_cfg = True
        else:
            xml_str = recv_xml.replace('\r', '').replace('\n', '').replace('xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"', '').replace('xmlns="http://www.huawei.com/netconf/vrp"', '')
            root = ElementTree.fromstring(xml_str)
            community_info = root.findall('data/snmp/communitys/community')
            if community_info:
                for tmp in community_info:
                    tmp_dict = dict()
                    for site in tmp:
                        if (site.tag in ['communityName', 'accessRight', 'aclNumber', 'mibViewName']):
                            tmp_dict[site.tag] = site.text
                    result['community_info'].append(tmp_dict)
            if result['community_info']:
                for tmp in result['community_info']:
                    if ('communityName' in tmp.keys()):
                        need_cfg = True
                    if ('accessRight' in tmp.keys()):
                        if (state == 'present'):
                            if (tmp['accessRight'] != access_right):
                                need_cfg = True
                        elif (tmp['accessRight'] == access_right):
                            need_cfg = True
                    if acl_number:
                        if ('aclNumber' in tmp.keys()):
                            if (state == 'present'):
                                if (tmp['aclNumber'] != acl_number):
                                    need_cfg = True
                            elif (tmp['aclNumber'] == acl_number):
                                need_cfg = True
                    if community_mib_view:
                        if ('mibViewName' in tmp.keys()):
                            if (state == 'present'):
                                if (tmp['mibViewName'] != community_mib_view):
                                    need_cfg = True
                            elif (tmp['mibViewName'] == community_mib_view):
                                need_cfg = True
    result['need_cfg'] = need_cfg
    return result
