def process_services(services, enterprise):
    'Converts services to a format Couchbase understands'
    sep = ','
    if (services.find(sep) < 0):
        sep = ';'
    svc_set = set([w.strip() for w in services.split(sep)])
    svc_candidate = ['data', 'index', 'query', 'fts', 'eventing', 'analytics', 'backup']
    for svc in svc_set:
        if (svc not in svc_candidate):
            return (None, [f'`{svc}` is not a valid service'])
        if ((not enterprise) and (svc in ['eventing', 'analytics', 'backup'])):
            return (None, [f'{svc} service is only available on Enterprise Edition'])
    if (not enterprise):
        ce_svc_30 = set(['data'])
        ce_svc_40 = set(['data', 'index', 'query'])
        ce_svc_45 = set(['data', 'index', 'query', 'fts'])
        if (svc_set not in [ce_svc_30, ce_svc_40, ce_svc_45]):
            return (None, [f"Invalid service configuration. Community Edition only supports nodes with the following combinations of services: '{''.join(ce_svc_30)}', '{','.join(ce_svc_40)}' or '{','.join(ce_svc_45)}'"])
    services = ','.join(svc_set)
    for (old, new) in [[';', ','], ['data', 'kv'], ['query', 'n1ql'], ['analytics', 'cbas']]:
        services = services.replace(old, new)
    return (services, None)
Converts services to a format Couchbase understands
def process_services(services, enterprise):
    
    sep = ','
    if (services.find(sep) < 0):
        sep = ';'
    svc_set = set([w.strip() for w in services.split(sep)])
    svc_candidate = ['data', 'index', 'query', 'fts', 'eventing', 'analytics', 'backup']
    for svc in svc_set:
        if (svc not in svc_candidate):
            return (None, [f'`{svc}` is not a valid service'])
        if ((not enterprise) and (svc in ['eventing', 'analytics', 'backup'])):
            return (None, [f'{svc} service is only available on Enterprise Edition'])
    if (not enterprise):
        ce_svc_30 = set(['data'])
        ce_svc_40 = set(['data', 'index', 'query'])
        ce_svc_45 = set(['data', 'index', 'query', 'fts'])
        if (svc_set not in [ce_svc_30, ce_svc_40, ce_svc_45]):
            return (None, [f"Invalid service configuration. Community Edition only supports nodes with the following combinations of services: '{.join(ce_svc_30)}', '{','.join(ce_svc_40)}' or '{','.join(ce_svc_45)}'"])
    services = ','.join(svc_set)
    for (old, new) in [[';', ','], ['data', 'kv'], ['query', 'n1ql'], ['analytics', 'cbas']]:
        services = services.replace(old, new)
    return (services, None)