def tags_exist(find_tags, tags_to_search):
    '''Determines if specific "OpsServer" values exist in list of tags'''
    found = False
    
    DEBUG = False
    
    # Create list of possible "OpsServer" type tag prefixes; i.e. in case someone didn't
    # specify the correct prefix.
    ops_type_flags = ["opsserver", "opsservers", "opserver", "opservers", "opssrver", "opssrvr"]
    
    # Convert find_tags to lower case and remove and leading/trailing spaces
    find_tags_mod = [element.lower().strip().encode("ascii") for element in list(find_tags)]
    
    # Convert tags_to_search to lower case and remove and leading/trailing spaces
    tags_to_search_mod = [element.lower().strip().encode("ascii") for element in list(tags_to_search)]
    
    if DEBUG:
        print "In tags_exist function: "
        print "\tfind_tags_mod: " + str(find_tags_mod)
        print "\ttags_to_search_mod: " + str(tags_to_search_mod)
        print "\tops_type_flags: " + str(ops_type_flags)
    
    # Loop through tags to search and look for the find tags
    for search in tags_to_search_mod:
        search = search.replace(" ","")
        
        if DEBUG:
            print "\tsearch: " + search
            
        if search.find(":") > -1:
            
            if DEBUG:
                print "\tI'm in the find : if statement"
                
            element1 = search.split(":")[0]
            element2 = search.split(":")[1]
            
            if DEBUG:
                print "\t\telement1: " + element1
                print "\t\telement2: " + element2
                
            if element1 in ops_type_flags:
                if element2 in find_tags_mod:
                    found = True
                    
    if DEBUG:
        print "\tfound: " + str(found)
        
    return found
dataset/ETHPy150Open Esri/ops-server-config/Publish/Portal/PortalContentPost.py/tags_exist/original