def extract_groups_from_user_info(portal, userinfo, extractpath):
    # Function created 5/21/2013 to replace "extract_groups" function.
    # Because the password is not the same as the user name, we can't
    # login as the individual user to extract all the groups that
    # are owned by a user (i.e. public and private). So to work around
    # this fact, we are extracting the groups from the user info object,
    # which do contain both public and private groups.
    
    grouppath = os.path.join(extractpath, "groups")
    if not os.path.exists(grouppath):
        os.makedirs(grouppath)
    
    # userinfo.json file contains the all the groups that the user
    # belongs to; so extract only those groups which are owned by the user.
    groups = []
    allgroups = userinfo["groups"]
    for x in allgroups:
        if x["owner"] == userinfo["username"]:
            groups.append(x)
        
    if len(groups) == 0:
        print "\n- Groups: No groups."
    else:
        print "\n- Groups:"
        for group in groups:
            groupidpath = os.path.join(grouppath, group["id"])
            os.makedirs(groupidpath)
            os.chdir(groupidpath)
            if group:
                thumbfile = portal.group_thumbnaild(group["id"],groupidpath)
                group = portal.group(group["id"])
                print "... group '" + str(group['title']) + "' to " + str(group['id'])
                #MF users = portal.group_users(group["id"])
                users = portal.group_members(group["id"])
                
                if thumbfile:
                    thumbfile = os.path.basename(thumbfile)
                group["thumbfile"] = thumbfile
                json.dump(group, open('group.json','w'))
                json.dump(users, open('group_users.json','w'))
Gets tokens from a text in English
dataset/ETHPy150Open Esri/ops-server-config/Publish/Portal/PortalContentExtract.py/extract_groups_from_user_info--crossover with--dataset/ETHPy150Open alfredolainez/deep-nlp/language.py/tokenize_document