def publish_user_items(portal, username, usercontentpath, old_hostname, new_hostname, new_port, specified_groups, id_mapping_file, grps_on_disk):
    ''' Publish all items for current user '''
    # Returns list of dictionaries of new items as well as a list of the
    # original item ids
    newitems, old_source_ids = [], []
    existing_portal_ids = []
    
    print "\n" + sectionBreak
    print "Publishing items for user '" + username + "'...\n"
    
    # Load 'id mapping' file if specified. Since this supports overwrite
    # capability, let's also create a list of all current item ids to verify that item
    # actually exists.
    id_mapping = None
    if id_mapping_file:
        filefolder = os.path.dirname(id_mapping_file)
        filename = os.path.basename(id_mapping_file)
        os.chdir(filefolder)
        id_mapping = json.load(open(filename))
        
        # Create list of existing portal items
        existing_portal_items = portal.search()
        for existing_portal_item in existing_portal_items:
            existing_portal_ids.append(existing_portal_item['id'])
        

    item_dirs = os.listdir(os.path.join(usercontentpath,"items"))
    
    n = 1
    for item_dir in item_dirs:
        overwrite_id = None
        do_load_item = False
        foldername = None
        
        print "\n\tPublishing item {} ({}/{})...".format(item_dir, n, len(item_dirs))
        
        if id_mapping:
            overwrite_id = id_mapping.get(item_dir)['id']
            if overwrite_id:
                print "\t   -Item referenced in id mapping file. Checking if item exists in portal..."
                if existing_portal_ids in overwrite_id:
                    print "\t   -Item exists in portal. Will update item."
                else:
                    overwrite_id = None
                    print "*** WARNING: item referenced in id mapping file does NOT exist in portal. Will add new item instead of updating."
        
        
        # Determine if item should be loaded base on specified group parameters
        if not specified_groups:
            do_load_item = True
        else:
            os.chdir(os.path.join(usercontentpath,"items", item_dir))
            sharing_info = json.load(open('sharing.json'))
            item_groups = sharing_info.get('groups')
            for item_group in item_groups:
                grp_on_disk = grps_on_disk.get(item_group)
                if grp_on_disk:
                    for specified_group in specified_groups:
                        if specified_group == grp_on_disk:
                            do_load_item = True

            if not do_load_item:
                print "\t   -Skipping item. Item groups do not match user specified group criteria."       
        
        
        # Add/Update item
        if do_load_item:
            
            try:
                item, old_source_id = load_item(portal, os.path.join(usercontentpath,"items", item_dir), overwrite_id)
                newitems.append(item)
                old_source_ids.append(old_source_id)         
    
                # Reassign item to target owner and folder
                if os.path.exists(os.path.join(usercontentpath, "folders.json")):
                    os.chdir(usercontentpath)
                    foldersinfo = json.load(open('folders.json'))
                    foldername = publish_get_folder_name_for_item(item, foldersinfo)
                
                portal.reassign_item(item['id'], username, foldername)
                
            except Exception as err:
                print 'ERROR: Exception on adding/updating item: {}'.format(item_dir)
                
        n = n + 1

    return newitems, old_source_ids
dataset/ETHPy150Open Esri/ops-server-config/Publish/Portal/PortalContentPost.py/publish_user_items/swapped operands of `in`